From 399da4ecef7cece7f8174fbe7346ebf91cb92125 Mon Sep 17 00:00:00 2001 From: akwritescode <63263190+akwritescode@users.noreply.github.com> Date: Wed, 12 Jan 2022 17:05:06 -0500 Subject: [PATCH] deployed prod abis (#38) --- .../hardhat/contracts/core/Controller.sol | 4 +- .../hardhat/deploy/01_deploy_uniswapv3.ts | 26 +- packages/hardhat/deploy/03_deploy_pools.ts | 12 +- .../hardhat/deploy/04_deploy_controller.ts | 22 +- .../deployments/mainnet/ABDKMath64x64.json | 26 +- .../deployments/mainnet/Controller.json | 92 +++--- .../hardhat/deployments/mainnet/Oracle.json | 28 +- .../deployments/mainnet/ShortHelper.json | 58 ++-- .../deployments/mainnet/ShortPowerPerp.json | 32 +- .../mainnet/SqrtPriceMathPartial.json | 142 +++++++++ .../deployments/mainnet/TickMathExternal.json | 120 ++++++++ .../deployments/mainnet/WPowerPerp.json | 30 +- .../d97d3d4b09e0d70518330d405a7dd9ff.json | 290 ++++++++++++++++++ 13 files changed, 720 insertions(+), 162 deletions(-) create mode 100644 packages/hardhat/deployments/mainnet/SqrtPriceMathPartial.json create mode 100644 packages/hardhat/deployments/mainnet/TickMathExternal.json create mode 100644 packages/hardhat/deployments/mainnet/solcInputs/d97d3d4b09e0d70518330d405a7dd9ff.json diff --git a/packages/hardhat/contracts/core/Controller.sol b/packages/hardhat/contracts/core/Controller.sol index 2e5a0da7a..f4755503f 100644 --- a/packages/hardhat/contracts/core/Controller.sol +++ b/packages/hardhat/contracts/core/Controller.sol @@ -72,7 +72,7 @@ contract Controller is Ownable, ReentrancyGuard, IERC721Receiver { //80% of index uint256 internal constant LOWER_MARK_RATIO = 8e17; - //125% of index + //140% of index uint256 internal constant UPPER_MARK_RATIO = 140e16; // 10% uint256 internal constant LIQUIDATION_BOUNTY = 1e17; @@ -476,7 +476,7 @@ contract Controller is Ownable, ReentrancyGuard, IERC721Receiver { return 0; } - // add back the bounty amount, liquidators only get reward from liquidation + // add back the bounty amount, liquidators onlly get reward from liquidation cachedVault.addEthCollateral(bounty); // if the vault is still not safe after saving, liquidate it diff --git a/packages/hardhat/deploy/01_deploy_uniswapv3.ts b/packages/hardhat/deploy/01_deploy_uniswapv3.ts index c6d455c77..1776b177d 100644 --- a/packages/hardhat/deploy/01_deploy_uniswapv3.ts +++ b/packages/hardhat/deploy/01_deploy_uniswapv3.ts @@ -29,17 +29,17 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { console.log(`Start deploying with ${deployer}`) - const {deploy} = deployments; + const { deploy } = deployments; if (hasUniswapDeployments(network.name)) { console.log(`Already have Uniswap Deployment on network ${network.name}. Skipping this step. 🍹\n`) } else { console.log(`\nDeploying whole Uniswap 🦄 on network ${network.name} again...`) - - + + // get WETH9 const weth9 = await getWETH(ethers, deployer, network.name) - + // Deploy Uniswap Factory await deploy("UniswapV3Factory", { from: deployer, @@ -51,7 +51,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { }); console.log(`UniswapV3Factory Deployed 🍹`) const uniswapFactory = await ethers.getContract("UniswapV3Factory", deployer); - + await deploy("SwapRouter", { from: deployer, log: true, @@ -62,10 +62,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { args: [uniswapFactory.address, weth9.address] }); console.log(`SwapRouter Deployed 🍍`) - + // tokenDescriptor is only used to query tokenURI() on NFT. Don't need that in our deployment const tokenDescriptorAddress = ethers.constants.AddressZero - + await deploy("NonfungiblePositionManager", { from: deployer, log: true, @@ -75,14 +75,18 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { }, args: [uniswapFactory.address, weth9.address, tokenDescriptorAddress] }); - - console.log(`NonfungiblePositionManager Deployed 🥑\n`) + + console.log(`NonfungiblePositionManager Deployed 🥑\n`) } // deploy quoter separately. const { uniswapFactory } = await getUniswapDeployments(ethers, deployer, network.name) const weth = await getWETH(ethers, deployer, network.name) - + + if (network.name === "mainnet") { + return + } + await deploy("Quoter", { from: deployer, log: true, @@ -93,7 +97,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { args: [uniswapFactory.address, weth.address] }); - console.log(`Quoter Deployed 🥦\n`) + console.log(`Quoter Deployed 🥦\n`) } export default func; \ No newline at end of file diff --git a/packages/hardhat/deploy/03_deploy_pools.ts b/packages/hardhat/deploy/03_deploy_pools.ts index 129ae2963..4dc0a5ef6 100644 --- a/packages/hardhat/deploy/03_deploy_pools.ts +++ b/packages/hardhat/deploy/03_deploy_pools.ts @@ -10,21 +10,21 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { deployer } = await getNamedAccounts(); const { positionManager, uniswapFactory } = await getUniswapDeployments(ethers, deployer, network.name) - + // Get Tokens const weth9 = await getWETH(ethers, deployer, network.name) const usdc = await getUSDC(ethers, deployer, network.name); // Create ETH/SQUEETH Pool with positionManager const squeeth = await ethers.getContract("WPowerPerp", deployer); - + // update this number to initial price we want to start the pool with. - - const squeethPriceInEth = 3350 / oracleScaleFactor.toNumber(); + + const squeethPriceInEth = 3290 / oracleScaleFactor.toNumber(); const squeethWethPool = await createUniPool(squeethPriceInEth, weth9, squeeth, positionManager, uniswapFactory) - const tx1 = await squeethWethPool.increaseObservationCardinalityNext(128) + const tx1 = await squeethWethPool.increaseObservationCardinalityNext(128) await ethers.provider.waitForTransaction(tx1.hash, 1) - + console.log(`SQU/ETH Pool created 🐑. Address: ${squeethWethPool.address}`) if (network.name === "mainnet") { diff --git a/packages/hardhat/deploy/04_deploy_controller.ts b/packages/hardhat/deploy/04_deploy_controller.ts index 7119c4ae6..67a06b3a1 100644 --- a/packages/hardhat/deploy/04_deploy_controller.ts +++ b/packages/hardhat/deploy/04_deploy_controller.ts @@ -1,5 +1,5 @@ -import {HardhatRuntimeEnvironment} from 'hardhat/types'; -import {DeployFunction} from 'hardhat-deploy/types'; +import { HardhatRuntimeEnvironment } from 'hardhat/types'; +import { DeployFunction } from 'hardhat-deploy/types'; import { getPoolAddress } from '../test/setup' import { getUniswapDeployments, getUSDC, getWETH } from '../tasks/utils' @@ -15,7 +15,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const oracle = await ethers.getContract("Oracle", deployer); const shortSqueeth = await ethers.getContract("ShortPowerPerp", deployer); const wsqueeth = await ethers.getContract("WPowerPerp", deployer); - + const weth9 = await getWETH(ethers, deployer, network.name) const usdc = await getUSDC(ethers, deployer, network.name) @@ -26,17 +26,17 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const squeethEthPool = await getPoolAddress(weth9, wsqueeth, uniswapFactory) // deploy abdk library - await deploy("ABDKMath64x64", { from: deployer, log: true}) + await deploy("ABDKMath64x64", { from: deployer, log: true }) const abdk = await ethers.getContract("ABDKMath64x64", deployer) - await deploy("TickMathExternal", { from: deployer, log: true}) + await deploy("TickMathExternal", { from: deployer, log: true }) const tickMathExternal = await ethers.getContract("TickMathExternal", deployer) - await deploy("SqrtPriceMathPartial", { from: deployer, log: true}) + await deploy("SqrtPriceMathPartial", { from: deployer, log: true }) const sqrtPriceMathPartial = await ethers.getContract("SqrtPriceMathPartial", deployer) // deploy controller - await deploy("Controller", { from: deployer, log: true, libraries: {ABDKMath64x64: abdk.address, SqrtPriceMathPartial: sqrtPriceMathPartial.address, TickMathExternal: tickMathExternal.address}, args:[oracle.address, shortSqueeth.address, wsqueeth.address, weth9.address, usdc.address, ethUSDCPool, squeethEthPool, positionManager.address, feeTier]}); + await deploy("Controller", { from: deployer, log: true, libraries: { ABDKMath64x64: abdk.address, SqrtPriceMathPartial: sqrtPriceMathPartial.address, TickMathExternal: tickMathExternal.address }, args: [oracle.address, shortSqueeth.address, wsqueeth.address, weth9.address, usdc.address, ethUSDCPool, squeethEthPool, positionManager.address, feeTier] }); const controller = await ethers.getContract("Controller", deployer); try { @@ -46,7 +46,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { } catch (error) { console.log(`Squeeth already init or wrong deployer address.`) } - + try { const tx = await shortSqueeth.init(controller.address, { from: deployer }); await ethers.provider.waitForTransaction(tx.hash, 1) @@ -55,18 +55,18 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { console.log(`ShortPowerPerp already init or wrong deployer address.`) } - const multisig = "0x609FFF64429e2A275a879e5C50e415cec842c629" + const alsig = "0x0144571202B48d8B3EEE3A95E4140B7144F8b72F" if (network.name === "mainnet") { try { - const tx = await controller.transferOwnership(multisig, { from: deployer }); + const tx = await controller.transferOwnership(alsig, { from: deployer }); await ethers.provider.waitForTransaction(tx.hash, 1) console.log(`Ownership transferred! 🥭`); } catch (error) { console.log(`Ownership transfer failed`) } } - + } export default func; \ No newline at end of file diff --git a/packages/hardhat/deployments/mainnet/ABDKMath64x64.json b/packages/hardhat/deployments/mainnet/ABDKMath64x64.json index 8f1c9c362..76a6beca2 100644 --- a/packages/hardhat/deployments/mainnet/ABDKMath64x64.json +++ b/packages/hardhat/deployments/mainnet/ABDKMath64x64.json @@ -1,5 +1,5 @@ { - "address": "0xB0069E6586F70003342309B9289e07035cC41400", + "address": "0x21A8D15322C257Abd2b22a56eDde758398be0F32", "abi": [ { "inputs": [ @@ -64,27 +64,27 @@ "type": "function" } ], - "transactionHash": "0xe9724044e3990f12a72a1d068b46013f46f870674becb47ccb975219fa2fec6b", + "transactionHash": "0x86f31b501dd7bb2b50f0734c402ecb3b42082a668cea1aa7d1b6cbc27b760e61", "receipt": { "to": null, - "from": "0x80010e7575b24f47097598474502F0fd0aDbF3a8", - "contractAddress": "0xB0069E6586F70003342309B9289e07035cC41400", - "transactionIndex": 41, + "from": "0xa3cB04d8BD927EEC8826BD77b7C71abE3d29c081", + "contractAddress": "0x21A8D15322C257Abd2b22a56eDde758398be0F32", + "transactionIndex": 126, "gasUsed": "941465", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x2ab3649dc0a43bd17ea2416369f39da50b84a12fff0223121061659a8b2ca2ee", - "transactionHash": "0xe9724044e3990f12a72a1d068b46013f46f870674becb47ccb975219fa2fec6b", + "blockHash": "0x738261ad46f621f353d1fd86ae62362fb4805c8599c51d1767164370e9156bef", + "transactionHash": "0x86f31b501dd7bb2b50f0734c402ecb3b42082a668cea1aa7d1b6cbc27b760e61", "logs": [], - "blockNumber": 13977496, - "cumulativeGasUsed": "3922222", + "blockNumber": 13982526, + "cumulativeGasUsed": "9014540", "status": 1, "byzantium": true }, "args": [], - "solcInputHash": "56b4ec4ab07157f3d2fb7e1de805d93e", - "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"y\",\"type\":\"uint256\"}],\"name\":\"divu\",\"outputs\":[{\"internalType\":\"int128\",\"name\":\"\",\"type\":\"int128\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int128\",\"name\":\"x\",\"type\":\"int128\"}],\"name\":\"exp_2\",\"outputs\":[{\"internalType\":\"int128\",\"name\":\"\",\"type\":\"int128\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int128\",\"name\":\"x\",\"type\":\"int128\"}],\"name\":\"log_2\",\"outputs\":[{\"internalType\":\"int128\",\"name\":\"\",\"type\":\"int128\"}],\"stateMutability\":\"pure\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"divu(uint256,uint256)\":{\"params\":{\"x\":\"unsigned 256-bit integer number\",\"y\":\"unsigned 256-bit integer number\"},\"returns\":{\"_0\":\"signed 64.64-bit fixed point number\"}},\"exp_2(int128)\":{\"params\":{\"x\":\"signed 64.64-bit fixed point number\"},\"returns\":{\"_0\":\"signed 64.64-bit fixed point number\"}},\"log_2(int128)\":{\"params\":{\"x\":\"signed 64.64-bit fixed point number\"},\"returns\":{\"_0\":\"signed 64.64-bit fixed point number\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"divu(uint256,uint256)\":{\"notice\":\"Calculate x / y rounding towards zero, where x and y are unsigned 256-bit integer numbers. Revert on overflow or when y is zero.\"},\"exp_2(int128)\":{\"notice\":\"Calculate binary exponent of x. Revert on overflow.\"},\"log_2(int128)\":{\"notice\":\"Calculate binary logarithm of x. Revert if x <= 0.\"}},\"notice\":\"Smart contract library of mathematical functions operating with signed 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is basically a simple fraction whose numerator is signed 128-bit integer and denominator is 2^64. As long as denominator is always the same, there is no need to store it, thus in Solidity signed 64.64-bit fixed point numbers are represented by int128 type holding only the numerator. Commit used - 16d7e1dd8628dfa2f88d5dadab731df7ada70bdd Copied from - https://github.com/abdk-consulting/abdk-libraries-solidity/tree/v2.4 Changes - some function visibility switched to public, solidity version set to 0.7.x Changes (cont) - revert strings added solidity version set to ^0.7.0\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/libs/ABDKMath64x64.sol\":\"ABDKMath64x64\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":850},\"remappings\":[]},\"sources\":{\"contracts/libs/ABDKMath64x64.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-4-Clause\\n/*\\n * ABDK Math 64.64 Smart Contract Library. Copyright \\u00a9 2019 by ABDK Consulting.\\n * Author: Mikhail Vladimirov \\n * Copyright (c) 2019, ABDK Consulting\\n *\\n * All rights reserved.\\n *\\n * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\\n *\\n * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\\n * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\\n * All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by ABDK Consulting.\\n * Neither the name of ABDK Consulting nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\\n * THIS SOFTWARE IS PROVIDED BY ABDK CONSULTING ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\\n * IN NO EVENT SHALL ABDK CONSULTING BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\\n */\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * Smart contract library of mathematical functions operating with signed\\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\\n * basically a simple fraction whose numerator is signed 128-bit integer and\\n * denominator is 2^64. As long as denominator is always the same, there is no\\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\\n * represented by int128 type holding only the numerator.\\n *\\n * Commit used - 16d7e1dd8628dfa2f88d5dadab731df7ada70bdd\\n * Copied from - https://github.com/abdk-consulting/abdk-libraries-solidity/tree/v2.4\\n * Changes - some function visibility switched to public, solidity version set to 0.7.x\\n * Changes (cont) - revert strings added\\n * solidity version set to ^0.7.0\\n */\\nlibrary ABDKMath64x64 {\\n /*\\n * Minimum value signed 64.64-bit fixed point number may have.\\n * Minimum value signed 64.64-bit fixed point number may have.\\n * Minimum value signed 64.64-bit fixed point number may have.\\n * -2^127\\n */\\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\\n\\n /*\\n * Maximum value signed 64.64-bit fixed point number may have.\\n * Maximum value signed 64.64-bit fixed point number may have.\\n * Maximum value signed 64.64-bit fixed point number may have.\\n * 2^127-1\\n */\\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\\n\\n /**\\n * Calculate x * y rounding down. Revert on overflow.\\n *\\n * @param x signed 64.64-bit fixed point number\\n * @param y signed 64.64-bit fixed point number\\n * @return signed 64.64-bit fixed point number\\n */\\n function mul(int128 x, int128 y) internal pure returns (int128) {\\n int256 result = (int256(x) * y) >> 64;\\n require(result >= MIN_64x64 && result <= MAX_64x64, \\\"MUL-OVUF\\\");\\n return int128(result);\\n }\\n\\n /**\\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\\n * and y is unsigned 256-bit integer number. Revert on overflow.\\n *\\n * @param x signed 64.64 fixed point number\\n * @param y unsigned 256-bit integer number\\n * @return unsigned 256-bit integer number\\n */\\n function mulu(int128 x, uint256 y) internal pure returns (uint256) {\\n if (y == 0) return 0;\\n\\n require(x >= 0, \\\"MULU-X0\\\");\\n\\n uint256 lo = (uint256(x) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\\n uint256 hi = uint256(x) * (y >> 128);\\n\\n require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, \\\"MULU-OF1\\\");\\n hi <<= 64;\\n\\n require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo, \\\"MULU-OF2\\\");\\n return hi + lo;\\n }\\n\\n /**\\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\\n * integer numbers. Revert on overflow or when y is zero.\\n *\\n * @param x unsigned 256-bit integer number\\n * @param y unsigned 256-bit integer number\\n * @return signed 64.64-bit fixed point number\\n */\\n function divu(uint256 x, uint256 y) public pure returns (int128) {\\n require(y != 0, \\\"DIVU-INF\\\");\\n uint128 result = divuu(x, y);\\n require(result <= uint128(MAX_64x64), \\\"DIVU-OF\\\");\\n return int128(result);\\n }\\n\\n /**\\n * Calculate binary logarithm of x. Revert if x <= 0.\\n *\\n * @param x signed 64.64-bit fixed point number\\n * @return signed 64.64-bit fixed point number\\n */\\n function log_2(int128 x) public pure returns (int128) {\\n require(x > 0, \\\"LOG_2-X0\\\");\\n\\n int256 msb = 0;\\n int256 xc = x;\\n if (xc >= 0x10000000000000000) {\\n xc >>= 64;\\n msb += 64;\\n }\\n if (xc >= 0x100000000) {\\n xc >>= 32;\\n msb += 32;\\n }\\n if (xc >= 0x10000) {\\n xc >>= 16;\\n msb += 16;\\n }\\n if (xc >= 0x100) {\\n xc >>= 8;\\n msb += 8;\\n }\\n if (xc >= 0x10) {\\n xc >>= 4;\\n msb += 4;\\n }\\n if (xc >= 0x4) {\\n xc >>= 2;\\n msb += 2;\\n }\\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\\n\\n int256 result = (msb - 64) << 64;\\n uint256 ux = uint256(x) << uint256(127 - msb);\\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\\n ux *= ux;\\n uint256 b = ux >> 255;\\n ux >>= 127 + b;\\n result += bit * int256(b);\\n }\\n\\n return int128(result);\\n }\\n\\n /**\\n * Calculate binary exponent of x. Revert on overflow.\\n *\\n * @param x signed 64.64-bit fixed point number\\n * @return signed 64.64-bit fixed point number\\n */\\n function exp_2(int128 x) public pure returns (int128) {\\n require(x < 0x400000000000000000, \\\"EXP_2-OF\\\"); // Overflow\\n\\n if (x < -0x400000000000000000) return 0; // Underflow\\n\\n uint256 result = 0x80000000000000000000000000000000;\\n\\n if (x & 0x8000000000000000 > 0) result = (result * 0x16A09E667F3BCC908B2FB1366EA957D3E) >> 128;\\n if (x & 0x4000000000000000 > 0) result = (result * 0x1306FE0A31B7152DE8D5A46305C85EDEC) >> 128;\\n if (x & 0x2000000000000000 > 0) result = (result * 0x1172B83C7D517ADCDF7C8C50EB14A791F) >> 128;\\n if (x & 0x1000000000000000 > 0) result = (result * 0x10B5586CF9890F6298B92B71842A98363) >> 128;\\n if (x & 0x800000000000000 > 0) result = (result * 0x1059B0D31585743AE7C548EB68CA417FD) >> 128;\\n if (x & 0x400000000000000 > 0) result = (result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8) >> 128;\\n if (x & 0x200000000000000 > 0) result = (result * 0x10163DA9FB33356D84A66AE336DCDFA3F) >> 128;\\n if (x & 0x100000000000000 > 0) result = (result * 0x100B1AFA5ABCBED6129AB13EC11DC9543) >> 128;\\n if (x & 0x80000000000000 > 0) result = (result * 0x10058C86DA1C09EA1FF19D294CF2F679B) >> 128;\\n if (x & 0x40000000000000 > 0) result = (result * 0x1002C605E2E8CEC506D21BFC89A23A00F) >> 128;\\n if (x & 0x20000000000000 > 0) result = (result * 0x100162F3904051FA128BCA9C55C31E5DF) >> 128;\\n if (x & 0x10000000000000 > 0) result = (result * 0x1000B175EFFDC76BA38E31671CA939725) >> 128;\\n if (x & 0x8000000000000 > 0) result = (result * 0x100058BA01FB9F96D6CACD4B180917C3D) >> 128;\\n if (x & 0x4000000000000 > 0) result = (result * 0x10002C5CC37DA9491D0985C348C68E7B3) >> 128;\\n if (x & 0x2000000000000 > 0) result = (result * 0x1000162E525EE054754457D5995292026) >> 128;\\n if (x & 0x1000000000000 > 0) result = (result * 0x10000B17255775C040618BF4A4ADE83FC) >> 128;\\n if (x & 0x800000000000 > 0) result = (result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB) >> 128;\\n if (x & 0x400000000000 > 0) result = (result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9) >> 128;\\n if (x & 0x200000000000 > 0) result = (result * 0x10000162E43F4F831060E02D839A9D16D) >> 128;\\n if (x & 0x100000000000 > 0) result = (result * 0x100000B1721BCFC99D9F890EA06911763) >> 128;\\n if (x & 0x80000000000 > 0) result = (result * 0x10000058B90CF1E6D97F9CA14DBCC1628) >> 128;\\n if (x & 0x40000000000 > 0) result = (result * 0x1000002C5C863B73F016468F6BAC5CA2B) >> 128;\\n if (x & 0x20000000000 > 0) result = (result * 0x100000162E430E5A18F6119E3C02282A5) >> 128;\\n if (x & 0x10000000000 > 0) result = (result * 0x1000000B1721835514B86E6D96EFD1BFE) >> 128;\\n if (x & 0x8000000000 > 0) result = (result * 0x100000058B90C0B48C6BE5DF846C5B2EF) >> 128;\\n if (x & 0x4000000000 > 0) result = (result * 0x10000002C5C8601CC6B9E94213C72737A) >> 128;\\n if (x & 0x2000000000 > 0) result = (result * 0x1000000162E42FFF037DF38AA2B219F06) >> 128;\\n if (x & 0x1000000000 > 0) result = (result * 0x10000000B17217FBA9C739AA5819F44F9) >> 128;\\n if (x & 0x800000000 > 0) result = (result * 0x1000000058B90BFCDEE5ACD3C1CEDC823) >> 128;\\n if (x & 0x400000000 > 0) result = (result * 0x100000002C5C85FE31F35A6A30DA1BE50) >> 128;\\n if (x & 0x200000000 > 0) result = (result * 0x10000000162E42FF0999CE3541B9FFFCF) >> 128;\\n if (x & 0x100000000 > 0) result = (result * 0x100000000B17217F80F4EF5AADDA45554) >> 128;\\n if (x & 0x80000000 > 0) result = (result * 0x10000000058B90BFBF8479BD5A81B51AD) >> 128;\\n if (x & 0x40000000 > 0) result = (result * 0x1000000002C5C85FDF84BD62AE30A74CC) >> 128;\\n if (x & 0x20000000 > 0) result = (result * 0x100000000162E42FEFB2FED257559BDAA) >> 128;\\n if (x & 0x10000000 > 0) result = (result * 0x1000000000B17217F7D5A7716BBA4A9AE) >> 128;\\n if (x & 0x8000000 > 0) result = (result * 0x100000000058B90BFBE9DDBAC5E109CCE) >> 128;\\n if (x & 0x4000000 > 0) result = (result * 0x10000000002C5C85FDF4B15DE6F17EB0D) >> 128;\\n if (x & 0x2000000 > 0) result = (result * 0x1000000000162E42FEFA494F1478FDE05) >> 128;\\n if (x & 0x1000000 > 0) result = (result * 0x10000000000B17217F7D20CF927C8E94C) >> 128;\\n if (x & 0x800000 > 0) result = (result * 0x1000000000058B90BFBE8F71CB4E4B33D) >> 128;\\n if (x & 0x400000 > 0) result = (result * 0x100000000002C5C85FDF477B662B26945) >> 128;\\n if (x & 0x200000 > 0) result = (result * 0x10000000000162E42FEFA3AE53369388C) >> 128;\\n if (x & 0x100000 > 0) result = (result * 0x100000000000B17217F7D1D351A389D40) >> 128;\\n if (x & 0x80000 > 0) result = (result * 0x10000000000058B90BFBE8E8B2D3D4EDE) >> 128;\\n if (x & 0x40000 > 0) result = (result * 0x1000000000002C5C85FDF4741BEA6E77E) >> 128;\\n if (x & 0x20000 > 0) result = (result * 0x100000000000162E42FEFA39FE95583C2) >> 128;\\n if (x & 0x10000 > 0) result = (result * 0x1000000000000B17217F7D1CFB72B45E1) >> 128;\\n if (x & 0x8000 > 0) result = (result * 0x100000000000058B90BFBE8E7CC35C3F0) >> 128;\\n if (x & 0x4000 > 0) result = (result * 0x10000000000002C5C85FDF473E242EA38) >> 128;\\n if (x & 0x2000 > 0) result = (result * 0x1000000000000162E42FEFA39F02B772C) >> 128;\\n if (x & 0x1000 > 0) result = (result * 0x10000000000000B17217F7D1CF7D83C1A) >> 128;\\n if (x & 0x800 > 0) result = (result * 0x1000000000000058B90BFBE8E7BDCBE2E) >> 128;\\n if (x & 0x400 > 0) result = (result * 0x100000000000002C5C85FDF473DEA871F) >> 128;\\n if (x & 0x200 > 0) result = (result * 0x10000000000000162E42FEFA39EF44D91) >> 128;\\n if (x & 0x100 > 0) result = (result * 0x100000000000000B17217F7D1CF79E949) >> 128;\\n if (x & 0x80 > 0) result = (result * 0x10000000000000058B90BFBE8E7BCE544) >> 128;\\n if (x & 0x40 > 0) result = (result * 0x1000000000000002C5C85FDF473DE6ECA) >> 128;\\n if (x & 0x20 > 0) result = (result * 0x100000000000000162E42FEFA39EF366F) >> 128;\\n if (x & 0x10 > 0) result = (result * 0x1000000000000000B17217F7D1CF79AFA) >> 128;\\n if (x & 0x8 > 0) result = (result * 0x100000000000000058B90BFBE8E7BCD6D) >> 128;\\n if (x & 0x4 > 0) result = (result * 0x10000000000000002C5C85FDF473DE6B2) >> 128;\\n if (x & 0x2 > 0) result = (result * 0x1000000000000000162E42FEFA39EF358) >> 128;\\n if (x & 0x1 > 0) result = (result * 0x10000000000000000B17217F7D1CF79AB) >> 128;\\n\\n result >>= uint256(63 - (x >> 64));\\n require(result <= uint256(MAX_64x64));\\n\\n return int128(result);\\n }\\n\\n /**\\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\\n * integer numbers. Revert on overflow or when y is zero.\\n *\\n * @param x unsigned 256-bit integer number\\n * @param y unsigned 256-bit integer number\\n * @return unsigned 64.64-bit fixed point number\\n */\\n function divuu(uint256 x, uint256 y) private pure returns (uint128) {\\n require(y != 0);\\n\\n uint256 result;\\n\\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) result = (x << 64) / y;\\n else {\\n uint256 msb = 192;\\n uint256 xc = x >> 192;\\n if (xc >= 0x100000000) {\\n xc >>= 32;\\n msb += 32;\\n }\\n if (xc >= 0x10000) {\\n xc >>= 16;\\n msb += 16;\\n }\\n if (xc >= 0x100) {\\n xc >>= 8;\\n msb += 8;\\n }\\n if (xc >= 0x10) {\\n xc >>= 4;\\n msb += 4;\\n }\\n if (xc >= 0x4) {\\n xc >>= 2;\\n msb += 2;\\n }\\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\\n\\n result = (x << (255 - msb)) / (((y - 1) >> (msb - 191)) + 1);\\n require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, \\\"DIVUU-OF1\\\");\\n\\n uint256 hi = result * (y >> 128);\\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\\n\\n uint256 xh = x >> 192;\\n uint256 xl = x << 64;\\n\\n if (xl < lo) xh -= 1;\\n xl -= lo; // We rely on overflow behavior here\\n lo = hi << 128;\\n if (xl < lo) xh -= 1;\\n xl -= lo; // We rely on overflow behavior here\\n\\n assert(xh == hi >> 128);\\n\\n result += xl / y;\\n }\\n\\n require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, \\\"DIVUU-OF2\\\");\\n return uint128(result);\\n }\\n}\\n\",\"keccak256\":\"0x56efa7c16e4fffb37ad80af15bd042d9f92532a4553d6b12915e3fa21609ad66\",\"license\":\"BSD-4-Clause\"}},\"version\":1}", - "bytecode": "0x611035610026600b82828239805160001a60731461001957fe5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361061004b5760003560e01c80632cbbdee514610050578063fc193cf214610087578063fc505d37146100a7575b600080fd5b6100706004803603602081101561006657600080fd5b5035600f0b6100ca565b60408051600f9290920b8252519081900360200190f35b6100706004803603602081101561009d57600080fd5b5035600f0b6101f8565b610070600480360360408110156100bd57600080fd5b5080359060200135610d19565b60008082600f0b13610123576040805162461bcd60e51b815260206004820152600860248201527f4c4f475f322d5830000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000600f83900b680100000000000000008112610142576040918201911d5b6401000000008112610156576020918201911d5b620100008112610168576010918201911d5b6101008112610179576008918201911d5b60108112610189576004918201911d5b60048112610199576002918201911d5b600281126101a8576001820191505b603f19820160401b600f85900b607f8490031b6780000000000000005b60008113156101eb5790800260ff81901c8281029390930192607f011c9060011d6101c5565b509093505050505b919050565b60006840000000000000000082600f0b1261025a576040805162461bcd60e51b815260206004820152600860248201527f4558505f322d4f46000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b683fffffffffffffffff1982600f0b1215610277575060006101f3565b6f8000000000000000000000000000000060006780000000000000008416600f0b13156102b55770016a09e667f3bcc908b2fb1366ea957d3e0260801c5b60008367400000000000000016600f0b13156102e2577001306fe0a31b7152de8d5a46305c85edec0260801c5b60008367200000000000000016600f0b131561030f577001172b83c7d517adcdf7c8c50eb14a791f0260801c5b60008367100000000000000016600f0b131561033c5770010b5586cf9890f6298b92b71842a983630260801c5b60008367080000000000000016600f0b1315610369577001059b0d31585743ae7c548eb68ca417fd0260801c5b60008367040000000000000016600f0b131561039657700102c9a3e778060ee6f7caca4f7a29bde80260801c5b60008367020000000000000016600f0b13156103c35770010163da9fb33356d84a66ae336dcdfa3f0260801c5b60008367010000000000000016600f0b13156103f057700100b1afa5abcbed6129ab13ec11dc95430260801c5b600083668000000000000016600f0b131561041c5770010058c86da1c09ea1ff19d294cf2f679b0260801c5b600083664000000000000016600f0b1315610448577001002c605e2e8cec506d21bfc89a23a00f0260801c5b600083662000000000000016600f0b131561047457700100162f3904051fa128bca9c55c31e5df0260801c5b600083661000000000000016600f0b13156104a0577001000b175effdc76ba38e31671ca9397250260801c5b600083660800000000000016600f0b13156104cc57700100058ba01fb9f96d6cacd4b180917c3d0260801c5b600083660400000000000016600f0b13156104f85770010002c5cc37da9491d0985c348c68e7b30260801c5b600083660200000000000016600f0b1315610524577001000162e525ee054754457d59952920260260801c5b600083660100000000000016600f0b13156105505770010000b17255775c040618bf4a4ade83fc0260801c5b6000836580000000000016600f0b131561057b577001000058b91b5bc9ae2eed81e9b7d4cfab0260801c5b6000836540000000000016600f0b13156105a657700100002c5c89d5ec6ca4d7c8acc017b7c90260801c5b6000836520000000000016600f0b13156105d15770010000162e43f4f831060e02d839a9d16d0260801c5b6000836510000000000016600f0b13156105fc57700100000b1721bcfc99d9f890ea069117630260801c5b6000836508000000000016600f0b13156106275770010000058b90cf1e6d97f9ca14dbcc16280260801c5b6000836504000000000016600f0b1315610652577001000002c5c863b73f016468f6bac5ca2b0260801c5b6000836502000000000016600f0b131561067d57700100000162e430e5a18f6119e3c02282a50260801c5b6000836501000000000016600f0b13156106a8577001000000b1721835514b86e6d96efd1bfe0260801c5b60008364800000000016600f0b13156106d257700100000058b90c0b48c6be5df846c5b2ef0260801c5b60008364400000000016600f0b13156106fc5770010000002c5c8601cc6b9e94213c72737a0260801c5b60008364200000000016600f0b1315610726577001000000162e42fff037df38aa2b219f060260801c5b60008364100000000016600f0b13156107505770010000000b17217fba9c739aa5819f44f90260801c5b60008364080000000016600f0b131561077a577001000000058b90bfcdee5acd3c1cedc8230260801c5b60008364040000000016600f0b13156107a457700100000002c5c85fe31f35a6a30da1be500260801c5b60008364020000000016600f0b13156107ce5770010000000162e42ff0999ce3541b9fffcf0260801c5b60008364010000000016600f0b13156107f857700100000000b17217f80f4ef5aadda455540260801c5b600083638000000016600f0b13156108215770010000000058b90bfbf8479bd5a81b51ad0260801c5b600083634000000016600f0b131561084a577001000000002c5c85fdf84bd62ae30a74cc0260801c5b600083632000000016600f0b131561087357700100000000162e42fefb2fed257559bdaa0260801c5b600083631000000016600f0b131561089c577001000000000b17217f7d5a7716bba4a9ae0260801c5b600083630800000016600f0b13156108c557700100000000058b90bfbe9ddbac5e109cce0260801c5b600083630400000016600f0b13156108ee5770010000000002c5c85fdf4b15de6f17eb0d0260801c5b600083630200000016600f0b1315610917577001000000000162e42fefa494f1478fde050260801c5b600083630100000016600f0b13156109405770010000000000b17217f7d20cf927c8e94c0260801c5b6000836280000016600f0b1315610968577001000000000058b90bfbe8f71cb4e4b33d0260801c5b6000836240000016600f0b131561099057700100000000002c5c85fdf477b662b269450260801c5b6000836220000016600f0b13156109b85770010000000000162e42fefa3ae53369388c0260801c5b6000836210000016600f0b13156109e057700100000000000b17217f7d1d351a389d400260801c5b6000836208000016600f0b1315610a085770010000000000058b90bfbe8e8b2d3d4ede0260801c5b6000836204000016600f0b1315610a30577001000000000002c5c85fdf4741bea6e77e0260801c5b6000836202000016600f0b1315610a5857700100000000000162e42fefa39fe95583c20260801c5b6000836201000016600f0b1315610a80577001000000000000b17217f7d1cfb72b45e10260801c5b60008361800016600f0b1315610aa757700100000000000058b90bfbe8e7cc35c3f00260801c5b60008361400016600f0b1315610ace5770010000000000002c5c85fdf473e242ea380260801c5b60008361200016600f0b1315610af5577001000000000000162e42fefa39f02b772c0260801c5b60008361100016600f0b1315610b1c5770010000000000000b17217f7d1cf7d83c1a0260801c5b60008361080016600f0b1315610b43577001000000000000058b90bfbe8e7bdcbe2e0260801c5b60008361040016600f0b1315610b6a57700100000000000002c5c85fdf473dea871f0260801c5b60008361020016600f0b1315610b915770010000000000000162e42fefa39ef44d910260801c5b60008361010016600f0b1315610bb857700100000000000000b17217f7d1cf79e9490260801c5b600083608016600f0b1315610bde5770010000000000000058b90bfbe8e7bce5440260801c5b600083604016600f0b1315610c04577001000000000000002c5c85fdf473de6eca0260801c5b600083602016600f0b1315610c2a57700100000000000000162e42fefa39ef366f0260801c5b600083601016600f0b1315610c50577001000000000000000b17217f7d1cf79afa0260801c5b600083600816600f0b1315610c7657700100000000000000058b90bfbe8e7bcd6d0260801c5b600083600416600f0b1315610c9c5770010000000000000002c5c85fdf473de6b20260801c5b600083600216600f0b1315610cc2577001000000000000000162e42fefa39ef3580260801c5b600083600116600f0b1315610ce85770010000000000000000b17217f7d1cf79ab0260801c5b600f83810b60401d603f03900b1c6f7fffffffffffffffffffffffffffffff811115610d1357600080fd5b92915050565b600081610d6d576040805162461bcd60e51b815260206004820152600860248201527f444956552d494e46000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000610d798484610df9565b90506f7fffffffffffffffffffffffffffffff6fffffffffffffffffffffffffffffffff82161115610df2576040805162461bcd60e51b815260206004820152600760248201527f444956552d4f4600000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b9392505050565b600081610e0557600080fd5b600077ffffffffffffffffffffffffffffffffffffffffffffffff8411610e3b5782604085901b81610e3357fe5b049050610f9a565b60c084811c6401000000008110610e54576020918201911c5b620100008110610e66576010918201911c5b6101008110610e77576008918201911c5b60108110610e87576004918201911c5b60048110610e97576002918201911c5b60028110610ea6576001820191505b60bf820360018603901c6001018260ff0387901b81610ec157fe5b0492506fffffffffffffffffffffffffffffffff831115610f29576040805162461bcd60e51b815260206004820152600960248201527f44495655552d4f46310000000000000000000000000000000000000000000000604482015290519081900360640190fd5b608085901c83026fffffffffffffffffffffffffffffffff8616840260c088901c604089901b82811015610f5e576001820391505b608084901b92900382811015610f75576001820391505b829003608084901c8214610f8557fe5b888181610f8e57fe5b04870196505050505050505b6fffffffffffffffffffffffffffffffff811115610df2576040805162461bcd60e51b815260206004820152600960248201527f44495655552d4f46320000000000000000000000000000000000000000000000604482015290519081900360640190fdfea26469706673582212207eda39a8a75c3d5e11c7d20b92a9c16d846bc90d6a1c114f1db5d0d681b164c364736f6c63430007060033", - "deployedBytecode": "0x730000000000000000000000000000000000000000301460806040526004361061004b5760003560e01c80632cbbdee514610050578063fc193cf214610087578063fc505d37146100a7575b600080fd5b6100706004803603602081101561006657600080fd5b5035600f0b6100ca565b60408051600f9290920b8252519081900360200190f35b6100706004803603602081101561009d57600080fd5b5035600f0b6101f8565b610070600480360360408110156100bd57600080fd5b5080359060200135610d19565b60008082600f0b13610123576040805162461bcd60e51b815260206004820152600860248201527f4c4f475f322d5830000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000600f83900b680100000000000000008112610142576040918201911d5b6401000000008112610156576020918201911d5b620100008112610168576010918201911d5b6101008112610179576008918201911d5b60108112610189576004918201911d5b60048112610199576002918201911d5b600281126101a8576001820191505b603f19820160401b600f85900b607f8490031b6780000000000000005b60008113156101eb5790800260ff81901c8281029390930192607f011c9060011d6101c5565b509093505050505b919050565b60006840000000000000000082600f0b1261025a576040805162461bcd60e51b815260206004820152600860248201527f4558505f322d4f46000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b683fffffffffffffffff1982600f0b1215610277575060006101f3565b6f8000000000000000000000000000000060006780000000000000008416600f0b13156102b55770016a09e667f3bcc908b2fb1366ea957d3e0260801c5b60008367400000000000000016600f0b13156102e2577001306fe0a31b7152de8d5a46305c85edec0260801c5b60008367200000000000000016600f0b131561030f577001172b83c7d517adcdf7c8c50eb14a791f0260801c5b60008367100000000000000016600f0b131561033c5770010b5586cf9890f6298b92b71842a983630260801c5b60008367080000000000000016600f0b1315610369577001059b0d31585743ae7c548eb68ca417fd0260801c5b60008367040000000000000016600f0b131561039657700102c9a3e778060ee6f7caca4f7a29bde80260801c5b60008367020000000000000016600f0b13156103c35770010163da9fb33356d84a66ae336dcdfa3f0260801c5b60008367010000000000000016600f0b13156103f057700100b1afa5abcbed6129ab13ec11dc95430260801c5b600083668000000000000016600f0b131561041c5770010058c86da1c09ea1ff19d294cf2f679b0260801c5b600083664000000000000016600f0b1315610448577001002c605e2e8cec506d21bfc89a23a00f0260801c5b600083662000000000000016600f0b131561047457700100162f3904051fa128bca9c55c31e5df0260801c5b600083661000000000000016600f0b13156104a0577001000b175effdc76ba38e31671ca9397250260801c5b600083660800000000000016600f0b13156104cc57700100058ba01fb9f96d6cacd4b180917c3d0260801c5b600083660400000000000016600f0b13156104f85770010002c5cc37da9491d0985c348c68e7b30260801c5b600083660200000000000016600f0b1315610524577001000162e525ee054754457d59952920260260801c5b600083660100000000000016600f0b13156105505770010000b17255775c040618bf4a4ade83fc0260801c5b6000836580000000000016600f0b131561057b577001000058b91b5bc9ae2eed81e9b7d4cfab0260801c5b6000836540000000000016600f0b13156105a657700100002c5c89d5ec6ca4d7c8acc017b7c90260801c5b6000836520000000000016600f0b13156105d15770010000162e43f4f831060e02d839a9d16d0260801c5b6000836510000000000016600f0b13156105fc57700100000b1721bcfc99d9f890ea069117630260801c5b6000836508000000000016600f0b13156106275770010000058b90cf1e6d97f9ca14dbcc16280260801c5b6000836504000000000016600f0b1315610652577001000002c5c863b73f016468f6bac5ca2b0260801c5b6000836502000000000016600f0b131561067d57700100000162e430e5a18f6119e3c02282a50260801c5b6000836501000000000016600f0b13156106a8577001000000b1721835514b86e6d96efd1bfe0260801c5b60008364800000000016600f0b13156106d257700100000058b90c0b48c6be5df846c5b2ef0260801c5b60008364400000000016600f0b13156106fc5770010000002c5c8601cc6b9e94213c72737a0260801c5b60008364200000000016600f0b1315610726577001000000162e42fff037df38aa2b219f060260801c5b60008364100000000016600f0b13156107505770010000000b17217fba9c739aa5819f44f90260801c5b60008364080000000016600f0b131561077a577001000000058b90bfcdee5acd3c1cedc8230260801c5b60008364040000000016600f0b13156107a457700100000002c5c85fe31f35a6a30da1be500260801c5b60008364020000000016600f0b13156107ce5770010000000162e42ff0999ce3541b9fffcf0260801c5b60008364010000000016600f0b13156107f857700100000000b17217f80f4ef5aadda455540260801c5b600083638000000016600f0b13156108215770010000000058b90bfbf8479bd5a81b51ad0260801c5b600083634000000016600f0b131561084a577001000000002c5c85fdf84bd62ae30a74cc0260801c5b600083632000000016600f0b131561087357700100000000162e42fefb2fed257559bdaa0260801c5b600083631000000016600f0b131561089c577001000000000b17217f7d5a7716bba4a9ae0260801c5b600083630800000016600f0b13156108c557700100000000058b90bfbe9ddbac5e109cce0260801c5b600083630400000016600f0b13156108ee5770010000000002c5c85fdf4b15de6f17eb0d0260801c5b600083630200000016600f0b1315610917577001000000000162e42fefa494f1478fde050260801c5b600083630100000016600f0b13156109405770010000000000b17217f7d20cf927c8e94c0260801c5b6000836280000016600f0b1315610968577001000000000058b90bfbe8f71cb4e4b33d0260801c5b6000836240000016600f0b131561099057700100000000002c5c85fdf477b662b269450260801c5b6000836220000016600f0b13156109b85770010000000000162e42fefa3ae53369388c0260801c5b6000836210000016600f0b13156109e057700100000000000b17217f7d1d351a389d400260801c5b6000836208000016600f0b1315610a085770010000000000058b90bfbe8e8b2d3d4ede0260801c5b6000836204000016600f0b1315610a30577001000000000002c5c85fdf4741bea6e77e0260801c5b6000836202000016600f0b1315610a5857700100000000000162e42fefa39fe95583c20260801c5b6000836201000016600f0b1315610a80577001000000000000b17217f7d1cfb72b45e10260801c5b60008361800016600f0b1315610aa757700100000000000058b90bfbe8e7cc35c3f00260801c5b60008361400016600f0b1315610ace5770010000000000002c5c85fdf473e242ea380260801c5b60008361200016600f0b1315610af5577001000000000000162e42fefa39f02b772c0260801c5b60008361100016600f0b1315610b1c5770010000000000000b17217f7d1cf7d83c1a0260801c5b60008361080016600f0b1315610b43577001000000000000058b90bfbe8e7bdcbe2e0260801c5b60008361040016600f0b1315610b6a57700100000000000002c5c85fdf473dea871f0260801c5b60008361020016600f0b1315610b915770010000000000000162e42fefa39ef44d910260801c5b60008361010016600f0b1315610bb857700100000000000000b17217f7d1cf79e9490260801c5b600083608016600f0b1315610bde5770010000000000000058b90bfbe8e7bce5440260801c5b600083604016600f0b1315610c04577001000000000000002c5c85fdf473de6eca0260801c5b600083602016600f0b1315610c2a57700100000000000000162e42fefa39ef366f0260801c5b600083601016600f0b1315610c50577001000000000000000b17217f7d1cf79afa0260801c5b600083600816600f0b1315610c7657700100000000000000058b90bfbe8e7bcd6d0260801c5b600083600416600f0b1315610c9c5770010000000000000002c5c85fdf473de6b20260801c5b600083600216600f0b1315610cc2577001000000000000000162e42fefa39ef3580260801c5b600083600116600f0b1315610ce85770010000000000000000b17217f7d1cf79ab0260801c5b600f83810b60401d603f03900b1c6f7fffffffffffffffffffffffffffffff811115610d1357600080fd5b92915050565b600081610d6d576040805162461bcd60e51b815260206004820152600860248201527f444956552d494e46000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000610d798484610df9565b90506f7fffffffffffffffffffffffffffffff6fffffffffffffffffffffffffffffffff82161115610df2576040805162461bcd60e51b815260206004820152600760248201527f444956552d4f4600000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b9392505050565b600081610e0557600080fd5b600077ffffffffffffffffffffffffffffffffffffffffffffffff8411610e3b5782604085901b81610e3357fe5b049050610f9a565b60c084811c6401000000008110610e54576020918201911c5b620100008110610e66576010918201911c5b6101008110610e77576008918201911c5b60108110610e87576004918201911c5b60048110610e97576002918201911c5b60028110610ea6576001820191505b60bf820360018603901c6001018260ff0387901b81610ec157fe5b0492506fffffffffffffffffffffffffffffffff831115610f29576040805162461bcd60e51b815260206004820152600960248201527f44495655552d4f46310000000000000000000000000000000000000000000000604482015290519081900360640190fd5b608085901c83026fffffffffffffffffffffffffffffffff8616840260c088901c604089901b82811015610f5e576001820391505b608084901b92900382811015610f75576001820391505b829003608084901c8214610f8557fe5b888181610f8e57fe5b04870196505050505050505b6fffffffffffffffffffffffffffffffff811115610df2576040805162461bcd60e51b815260206004820152600960248201527f44495655552d4f46320000000000000000000000000000000000000000000000604482015290519081900360640190fdfea26469706673582212207eda39a8a75c3d5e11c7d20b92a9c16d846bc90d6a1c114f1db5d0d681b164c364736f6c63430007060033", + "solcInputHash": "d97d3d4b09e0d70518330d405a7dd9ff", + "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"x\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"y\",\"type\":\"uint256\"}],\"name\":\"divu\",\"outputs\":[{\"internalType\":\"int128\",\"name\":\"\",\"type\":\"int128\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int128\",\"name\":\"x\",\"type\":\"int128\"}],\"name\":\"exp_2\",\"outputs\":[{\"internalType\":\"int128\",\"name\":\"\",\"type\":\"int128\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int128\",\"name\":\"x\",\"type\":\"int128\"}],\"name\":\"log_2\",\"outputs\":[{\"internalType\":\"int128\",\"name\":\"\",\"type\":\"int128\"}],\"stateMutability\":\"pure\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"divu(uint256,uint256)\":{\"params\":{\"x\":\"unsigned 256-bit integer number\",\"y\":\"unsigned 256-bit integer number\"},\"returns\":{\"_0\":\"signed 64.64-bit fixed point number\"}},\"exp_2(int128)\":{\"params\":{\"x\":\"signed 64.64-bit fixed point number\"},\"returns\":{\"_0\":\"signed 64.64-bit fixed point number\"}},\"log_2(int128)\":{\"params\":{\"x\":\"signed 64.64-bit fixed point number\"},\"returns\":{\"_0\":\"signed 64.64-bit fixed point number\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"divu(uint256,uint256)\":{\"notice\":\"Calculate x / y rounding towards zero, where x and y are unsigned 256-bit integer numbers. Revert on overflow or when y is zero.\"},\"exp_2(int128)\":{\"notice\":\"Calculate binary exponent of x. Revert on overflow.\"},\"log_2(int128)\":{\"notice\":\"Calculate binary logarithm of x. Revert if x <= 0.\"}},\"notice\":\"Smart contract library of mathematical functions operating with signed 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is basically a simple fraction whose numerator is signed 128-bit integer and denominator is 2^64. As long as denominator is always the same, there is no need to store it, thus in Solidity signed 64.64-bit fixed point numbers are represented by int128 type holding only the numerator. Commit used - 16d7e1dd8628dfa2f88d5dadab731df7ada70bdd Copied from - https://github.com/abdk-consulting/abdk-libraries-solidity/tree/v2.4 Changes - some function visibility switched to public, solidity version set to 0.7.x Changes (cont) - revert strings added solidity version set to ^0.7.0\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/libs/ABDKMath64x64.sol\":\"ABDKMath64x64\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":825},\"remappings\":[]},\"sources\":{\"contracts/libs/ABDKMath64x64.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-4-Clause\\n/*\\n * ABDK Math 64.64 Smart Contract Library. Copyright \\u00a9 2019 by ABDK Consulting.\\n * Author: Mikhail Vladimirov \\n * Copyright (c) 2019, ABDK Consulting\\n *\\n * All rights reserved.\\n *\\n * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\\n *\\n * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\\n * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\\n * All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by ABDK Consulting.\\n * Neither the name of ABDK Consulting nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\\n * THIS SOFTWARE IS PROVIDED BY ABDK CONSULTING ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\\n * IN NO EVENT SHALL ABDK CONSULTING BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\\n */\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * Smart contract library of mathematical functions operating with signed\\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\\n * basically a simple fraction whose numerator is signed 128-bit integer and\\n * denominator is 2^64. As long as denominator is always the same, there is no\\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\\n * represented by int128 type holding only the numerator.\\n *\\n * Commit used - 16d7e1dd8628dfa2f88d5dadab731df7ada70bdd\\n * Copied from - https://github.com/abdk-consulting/abdk-libraries-solidity/tree/v2.4\\n * Changes - some function visibility switched to public, solidity version set to 0.7.x\\n * Changes (cont) - revert strings added\\n * solidity version set to ^0.7.0\\n */\\nlibrary ABDKMath64x64 {\\n /*\\n * Minimum value signed 64.64-bit fixed point number may have.\\n * Minimum value signed 64.64-bit fixed point number may have.\\n * Minimum value signed 64.64-bit fixed point number may have.\\n * -2^127\\n */\\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\\n\\n /*\\n * Maximum value signed 64.64-bit fixed point number may have.\\n * Maximum value signed 64.64-bit fixed point number may have.\\n * Maximum value signed 64.64-bit fixed point number may have.\\n * 2^127-1\\n */\\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\\n\\n /**\\n * Calculate x * y rounding down. Revert on overflow.\\n *\\n * @param x signed 64.64-bit fixed point number\\n * @param y signed 64.64-bit fixed point number\\n * @return signed 64.64-bit fixed point number\\n */\\n function mul(int128 x, int128 y) internal pure returns (int128) {\\n int256 result = (int256(x) * y) >> 64;\\n require(result >= MIN_64x64 && result <= MAX_64x64, \\\"MUL-OVUF\\\");\\n return int128(result);\\n }\\n\\n /**\\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\\n * and y is unsigned 256-bit integer number. Revert on overflow.\\n *\\n * @param x signed 64.64 fixed point number\\n * @param y unsigned 256-bit integer number\\n * @return unsigned 256-bit integer number\\n */\\n function mulu(int128 x, uint256 y) internal pure returns (uint256) {\\n if (y == 0) return 0;\\n\\n require(x >= 0, \\\"MULU-X0\\\");\\n\\n uint256 lo = (uint256(x) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\\n uint256 hi = uint256(x) * (y >> 128);\\n\\n require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, \\\"MULU-OF1\\\");\\n hi <<= 64;\\n\\n require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo, \\\"MULU-OF2\\\");\\n return hi + lo;\\n }\\n\\n /**\\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\\n * integer numbers. Revert on overflow or when y is zero.\\n *\\n * @param x unsigned 256-bit integer number\\n * @param y unsigned 256-bit integer number\\n * @return signed 64.64-bit fixed point number\\n */\\n function divu(uint256 x, uint256 y) public pure returns (int128) {\\n require(y != 0, \\\"DIVU-INF\\\");\\n uint128 result = divuu(x, y);\\n require(result <= uint128(MAX_64x64), \\\"DIVU-OF\\\");\\n return int128(result);\\n }\\n\\n /**\\n * Calculate binary logarithm of x. Revert if x <= 0.\\n *\\n * @param x signed 64.64-bit fixed point number\\n * @return signed 64.64-bit fixed point number\\n */\\n function log_2(int128 x) public pure returns (int128) {\\n require(x > 0, \\\"LOG_2-X0\\\");\\n\\n int256 msb = 0;\\n int256 xc = x;\\n if (xc >= 0x10000000000000000) {\\n xc >>= 64;\\n msb += 64;\\n }\\n if (xc >= 0x100000000) {\\n xc >>= 32;\\n msb += 32;\\n }\\n if (xc >= 0x10000) {\\n xc >>= 16;\\n msb += 16;\\n }\\n if (xc >= 0x100) {\\n xc >>= 8;\\n msb += 8;\\n }\\n if (xc >= 0x10) {\\n xc >>= 4;\\n msb += 4;\\n }\\n if (xc >= 0x4) {\\n xc >>= 2;\\n msb += 2;\\n }\\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\\n\\n int256 result = (msb - 64) << 64;\\n uint256 ux = uint256(x) << uint256(127 - msb);\\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\\n ux *= ux;\\n uint256 b = ux >> 255;\\n ux >>= 127 + b;\\n result += bit * int256(b);\\n }\\n\\n return int128(result);\\n }\\n\\n /**\\n * Calculate binary exponent of x. Revert on overflow.\\n *\\n * @param x signed 64.64-bit fixed point number\\n * @return signed 64.64-bit fixed point number\\n */\\n function exp_2(int128 x) public pure returns (int128) {\\n require(x < 0x400000000000000000, \\\"EXP_2-OF\\\"); // Overflow\\n\\n if (x < -0x400000000000000000) return 0; // Underflow\\n\\n uint256 result = 0x80000000000000000000000000000000;\\n\\n if (x & 0x8000000000000000 > 0) result = (result * 0x16A09E667F3BCC908B2FB1366EA957D3E) >> 128;\\n if (x & 0x4000000000000000 > 0) result = (result * 0x1306FE0A31B7152DE8D5A46305C85EDEC) >> 128;\\n if (x & 0x2000000000000000 > 0) result = (result * 0x1172B83C7D517ADCDF7C8C50EB14A791F) >> 128;\\n if (x & 0x1000000000000000 > 0) result = (result * 0x10B5586CF9890F6298B92B71842A98363) >> 128;\\n if (x & 0x800000000000000 > 0) result = (result * 0x1059B0D31585743AE7C548EB68CA417FD) >> 128;\\n if (x & 0x400000000000000 > 0) result = (result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8) >> 128;\\n if (x & 0x200000000000000 > 0) result = (result * 0x10163DA9FB33356D84A66AE336DCDFA3F) >> 128;\\n if (x & 0x100000000000000 > 0) result = (result * 0x100B1AFA5ABCBED6129AB13EC11DC9543) >> 128;\\n if (x & 0x80000000000000 > 0) result = (result * 0x10058C86DA1C09EA1FF19D294CF2F679B) >> 128;\\n if (x & 0x40000000000000 > 0) result = (result * 0x1002C605E2E8CEC506D21BFC89A23A00F) >> 128;\\n if (x & 0x20000000000000 > 0) result = (result * 0x100162F3904051FA128BCA9C55C31E5DF) >> 128;\\n if (x & 0x10000000000000 > 0) result = (result * 0x1000B175EFFDC76BA38E31671CA939725) >> 128;\\n if (x & 0x8000000000000 > 0) result = (result * 0x100058BA01FB9F96D6CACD4B180917C3D) >> 128;\\n if (x & 0x4000000000000 > 0) result = (result * 0x10002C5CC37DA9491D0985C348C68E7B3) >> 128;\\n if (x & 0x2000000000000 > 0) result = (result * 0x1000162E525EE054754457D5995292026) >> 128;\\n if (x & 0x1000000000000 > 0) result = (result * 0x10000B17255775C040618BF4A4ADE83FC) >> 128;\\n if (x & 0x800000000000 > 0) result = (result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB) >> 128;\\n if (x & 0x400000000000 > 0) result = (result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9) >> 128;\\n if (x & 0x200000000000 > 0) result = (result * 0x10000162E43F4F831060E02D839A9D16D) >> 128;\\n if (x & 0x100000000000 > 0) result = (result * 0x100000B1721BCFC99D9F890EA06911763) >> 128;\\n if (x & 0x80000000000 > 0) result = (result * 0x10000058B90CF1E6D97F9CA14DBCC1628) >> 128;\\n if (x & 0x40000000000 > 0) result = (result * 0x1000002C5C863B73F016468F6BAC5CA2B) >> 128;\\n if (x & 0x20000000000 > 0) result = (result * 0x100000162E430E5A18F6119E3C02282A5) >> 128;\\n if (x & 0x10000000000 > 0) result = (result * 0x1000000B1721835514B86E6D96EFD1BFE) >> 128;\\n if (x & 0x8000000000 > 0) result = (result * 0x100000058B90C0B48C6BE5DF846C5B2EF) >> 128;\\n if (x & 0x4000000000 > 0) result = (result * 0x10000002C5C8601CC6B9E94213C72737A) >> 128;\\n if (x & 0x2000000000 > 0) result = (result * 0x1000000162E42FFF037DF38AA2B219F06) >> 128;\\n if (x & 0x1000000000 > 0) result = (result * 0x10000000B17217FBA9C739AA5819F44F9) >> 128;\\n if (x & 0x800000000 > 0) result = (result * 0x1000000058B90BFCDEE5ACD3C1CEDC823) >> 128;\\n if (x & 0x400000000 > 0) result = (result * 0x100000002C5C85FE31F35A6A30DA1BE50) >> 128;\\n if (x & 0x200000000 > 0) result = (result * 0x10000000162E42FF0999CE3541B9FFFCF) >> 128;\\n if (x & 0x100000000 > 0) result = (result * 0x100000000B17217F80F4EF5AADDA45554) >> 128;\\n if (x & 0x80000000 > 0) result = (result * 0x10000000058B90BFBF8479BD5A81B51AD) >> 128;\\n if (x & 0x40000000 > 0) result = (result * 0x1000000002C5C85FDF84BD62AE30A74CC) >> 128;\\n if (x & 0x20000000 > 0) result = (result * 0x100000000162E42FEFB2FED257559BDAA) >> 128;\\n if (x & 0x10000000 > 0) result = (result * 0x1000000000B17217F7D5A7716BBA4A9AE) >> 128;\\n if (x & 0x8000000 > 0) result = (result * 0x100000000058B90BFBE9DDBAC5E109CCE) >> 128;\\n if (x & 0x4000000 > 0) result = (result * 0x10000000002C5C85FDF4B15DE6F17EB0D) >> 128;\\n if (x & 0x2000000 > 0) result = (result * 0x1000000000162E42FEFA494F1478FDE05) >> 128;\\n if (x & 0x1000000 > 0) result = (result * 0x10000000000B17217F7D20CF927C8E94C) >> 128;\\n if (x & 0x800000 > 0) result = (result * 0x1000000000058B90BFBE8F71CB4E4B33D) >> 128;\\n if (x & 0x400000 > 0) result = (result * 0x100000000002C5C85FDF477B662B26945) >> 128;\\n if (x & 0x200000 > 0) result = (result * 0x10000000000162E42FEFA3AE53369388C) >> 128;\\n if (x & 0x100000 > 0) result = (result * 0x100000000000B17217F7D1D351A389D40) >> 128;\\n if (x & 0x80000 > 0) result = (result * 0x10000000000058B90BFBE8E8B2D3D4EDE) >> 128;\\n if (x & 0x40000 > 0) result = (result * 0x1000000000002C5C85FDF4741BEA6E77E) >> 128;\\n if (x & 0x20000 > 0) result = (result * 0x100000000000162E42FEFA39FE95583C2) >> 128;\\n if (x & 0x10000 > 0) result = (result * 0x1000000000000B17217F7D1CFB72B45E1) >> 128;\\n if (x & 0x8000 > 0) result = (result * 0x100000000000058B90BFBE8E7CC35C3F0) >> 128;\\n if (x & 0x4000 > 0) result = (result * 0x10000000000002C5C85FDF473E242EA38) >> 128;\\n if (x & 0x2000 > 0) result = (result * 0x1000000000000162E42FEFA39F02B772C) >> 128;\\n if (x & 0x1000 > 0) result = (result * 0x10000000000000B17217F7D1CF7D83C1A) >> 128;\\n if (x & 0x800 > 0) result = (result * 0x1000000000000058B90BFBE8E7BDCBE2E) >> 128;\\n if (x & 0x400 > 0) result = (result * 0x100000000000002C5C85FDF473DEA871F) >> 128;\\n if (x & 0x200 > 0) result = (result * 0x10000000000000162E42FEFA39EF44D91) >> 128;\\n if (x & 0x100 > 0) result = (result * 0x100000000000000B17217F7D1CF79E949) >> 128;\\n if (x & 0x80 > 0) result = (result * 0x10000000000000058B90BFBE8E7BCE544) >> 128;\\n if (x & 0x40 > 0) result = (result * 0x1000000000000002C5C85FDF473DE6ECA) >> 128;\\n if (x & 0x20 > 0) result = (result * 0x100000000000000162E42FEFA39EF366F) >> 128;\\n if (x & 0x10 > 0) result = (result * 0x1000000000000000B17217F7D1CF79AFA) >> 128;\\n if (x & 0x8 > 0) result = (result * 0x100000000000000058B90BFBE8E7BCD6D) >> 128;\\n if (x & 0x4 > 0) result = (result * 0x10000000000000002C5C85FDF473DE6B2) >> 128;\\n if (x & 0x2 > 0) result = (result * 0x1000000000000000162E42FEFA39EF358) >> 128;\\n if (x & 0x1 > 0) result = (result * 0x10000000000000000B17217F7D1CF79AB) >> 128;\\n\\n result >>= uint256(63 - (x >> 64));\\n require(result <= uint256(MAX_64x64));\\n\\n return int128(result);\\n }\\n\\n /**\\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\\n * integer numbers. Revert on overflow or when y is zero.\\n *\\n * @param x unsigned 256-bit integer number\\n * @param y unsigned 256-bit integer number\\n * @return unsigned 64.64-bit fixed point number\\n */\\n function divuu(uint256 x, uint256 y) private pure returns (uint128) {\\n require(y != 0);\\n\\n uint256 result;\\n\\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) result = (x << 64) / y;\\n else {\\n uint256 msb = 192;\\n uint256 xc = x >> 192;\\n if (xc >= 0x100000000) {\\n xc >>= 32;\\n msb += 32;\\n }\\n if (xc >= 0x10000) {\\n xc >>= 16;\\n msb += 16;\\n }\\n if (xc >= 0x100) {\\n xc >>= 8;\\n msb += 8;\\n }\\n if (xc >= 0x10) {\\n xc >>= 4;\\n msb += 4;\\n }\\n if (xc >= 0x4) {\\n xc >>= 2;\\n msb += 2;\\n }\\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\\n\\n result = (x << (255 - msb)) / (((y - 1) >> (msb - 191)) + 1);\\n require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, \\\"DIVUU-OF1\\\");\\n\\n uint256 hi = result * (y >> 128);\\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\\n\\n uint256 xh = x >> 192;\\n uint256 xl = x << 64;\\n\\n if (xl < lo) xh -= 1;\\n xl -= lo; // We rely on overflow behavior here\\n lo = hi << 128;\\n if (xl < lo) xh -= 1;\\n xl -= lo; // We rely on overflow behavior here\\n\\n assert(xh == hi >> 128);\\n\\n result += xl / y;\\n }\\n\\n require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, \\\"DIVUU-OF2\\\");\\n return uint128(result);\\n }\\n}\\n\",\"keccak256\":\"0x56efa7c16e4fffb37ad80af15bd042d9f92532a4553d6b12915e3fa21609ad66\",\"license\":\"BSD-4-Clause\"}},\"version\":1}", + "bytecode": "0x611035610026600b82828239805160001a60731461001957fe5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361061004b5760003560e01c80632cbbdee514610050578063fc193cf214610087578063fc505d37146100a7575b600080fd5b6100706004803603602081101561006657600080fd5b5035600f0b6100ca565b60408051600f9290920b8252519081900360200190f35b6100706004803603602081101561009d57600080fd5b5035600f0b6101f8565b610070600480360360408110156100bd57600080fd5b5080359060200135610d19565b60008082600f0b13610123576040805162461bcd60e51b815260206004820152600860248201527f4c4f475f322d5830000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000600f83900b680100000000000000008112610142576040918201911d5b6401000000008112610156576020918201911d5b620100008112610168576010918201911d5b6101008112610179576008918201911d5b60108112610189576004918201911d5b60048112610199576002918201911d5b600281126101a8576001820191505b603f19820160401b600f85900b607f8490031b6780000000000000005b60008113156101eb5790800260ff81901c8281029390930192607f011c9060011d6101c5565b509093505050505b919050565b60006840000000000000000082600f0b1261025a576040805162461bcd60e51b815260206004820152600860248201527f4558505f322d4f46000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b683fffffffffffffffff1982600f0b1215610277575060006101f3565b6f8000000000000000000000000000000060006780000000000000008416600f0b13156102b55770016a09e667f3bcc908b2fb1366ea957d3e0260801c5b60008367400000000000000016600f0b13156102e2577001306fe0a31b7152de8d5a46305c85edec0260801c5b60008367200000000000000016600f0b131561030f577001172b83c7d517adcdf7c8c50eb14a791f0260801c5b60008367100000000000000016600f0b131561033c5770010b5586cf9890f6298b92b71842a983630260801c5b60008367080000000000000016600f0b1315610369577001059b0d31585743ae7c548eb68ca417fd0260801c5b60008367040000000000000016600f0b131561039657700102c9a3e778060ee6f7caca4f7a29bde80260801c5b60008367020000000000000016600f0b13156103c35770010163da9fb33356d84a66ae336dcdfa3f0260801c5b60008367010000000000000016600f0b13156103f057700100b1afa5abcbed6129ab13ec11dc95430260801c5b600083668000000000000016600f0b131561041c5770010058c86da1c09ea1ff19d294cf2f679b0260801c5b600083664000000000000016600f0b1315610448577001002c605e2e8cec506d21bfc89a23a00f0260801c5b600083662000000000000016600f0b131561047457700100162f3904051fa128bca9c55c31e5df0260801c5b600083661000000000000016600f0b13156104a0577001000b175effdc76ba38e31671ca9397250260801c5b600083660800000000000016600f0b13156104cc57700100058ba01fb9f96d6cacd4b180917c3d0260801c5b600083660400000000000016600f0b13156104f85770010002c5cc37da9491d0985c348c68e7b30260801c5b600083660200000000000016600f0b1315610524577001000162e525ee054754457d59952920260260801c5b600083660100000000000016600f0b13156105505770010000b17255775c040618bf4a4ade83fc0260801c5b6000836580000000000016600f0b131561057b577001000058b91b5bc9ae2eed81e9b7d4cfab0260801c5b6000836540000000000016600f0b13156105a657700100002c5c89d5ec6ca4d7c8acc017b7c90260801c5b6000836520000000000016600f0b13156105d15770010000162e43f4f831060e02d839a9d16d0260801c5b6000836510000000000016600f0b13156105fc57700100000b1721bcfc99d9f890ea069117630260801c5b6000836508000000000016600f0b13156106275770010000058b90cf1e6d97f9ca14dbcc16280260801c5b6000836504000000000016600f0b1315610652577001000002c5c863b73f016468f6bac5ca2b0260801c5b6000836502000000000016600f0b131561067d57700100000162e430e5a18f6119e3c02282a50260801c5b6000836501000000000016600f0b13156106a8577001000000b1721835514b86e6d96efd1bfe0260801c5b60008364800000000016600f0b13156106d257700100000058b90c0b48c6be5df846c5b2ef0260801c5b60008364400000000016600f0b13156106fc5770010000002c5c8601cc6b9e94213c72737a0260801c5b60008364200000000016600f0b1315610726577001000000162e42fff037df38aa2b219f060260801c5b60008364100000000016600f0b13156107505770010000000b17217fba9c739aa5819f44f90260801c5b60008364080000000016600f0b131561077a577001000000058b90bfcdee5acd3c1cedc8230260801c5b60008364040000000016600f0b13156107a457700100000002c5c85fe31f35a6a30da1be500260801c5b60008364020000000016600f0b13156107ce5770010000000162e42ff0999ce3541b9fffcf0260801c5b60008364010000000016600f0b13156107f857700100000000b17217f80f4ef5aadda455540260801c5b600083638000000016600f0b13156108215770010000000058b90bfbf8479bd5a81b51ad0260801c5b600083634000000016600f0b131561084a577001000000002c5c85fdf84bd62ae30a74cc0260801c5b600083632000000016600f0b131561087357700100000000162e42fefb2fed257559bdaa0260801c5b600083631000000016600f0b131561089c577001000000000b17217f7d5a7716bba4a9ae0260801c5b600083630800000016600f0b13156108c557700100000000058b90bfbe9ddbac5e109cce0260801c5b600083630400000016600f0b13156108ee5770010000000002c5c85fdf4b15de6f17eb0d0260801c5b600083630200000016600f0b1315610917577001000000000162e42fefa494f1478fde050260801c5b600083630100000016600f0b13156109405770010000000000b17217f7d20cf927c8e94c0260801c5b6000836280000016600f0b1315610968577001000000000058b90bfbe8f71cb4e4b33d0260801c5b6000836240000016600f0b131561099057700100000000002c5c85fdf477b662b269450260801c5b6000836220000016600f0b13156109b85770010000000000162e42fefa3ae53369388c0260801c5b6000836210000016600f0b13156109e057700100000000000b17217f7d1d351a389d400260801c5b6000836208000016600f0b1315610a085770010000000000058b90bfbe8e8b2d3d4ede0260801c5b6000836204000016600f0b1315610a30577001000000000002c5c85fdf4741bea6e77e0260801c5b6000836202000016600f0b1315610a5857700100000000000162e42fefa39fe95583c20260801c5b6000836201000016600f0b1315610a80577001000000000000b17217f7d1cfb72b45e10260801c5b60008361800016600f0b1315610aa757700100000000000058b90bfbe8e7cc35c3f00260801c5b60008361400016600f0b1315610ace5770010000000000002c5c85fdf473e242ea380260801c5b60008361200016600f0b1315610af5577001000000000000162e42fefa39f02b772c0260801c5b60008361100016600f0b1315610b1c5770010000000000000b17217f7d1cf7d83c1a0260801c5b60008361080016600f0b1315610b43577001000000000000058b90bfbe8e7bdcbe2e0260801c5b60008361040016600f0b1315610b6a57700100000000000002c5c85fdf473dea871f0260801c5b60008361020016600f0b1315610b915770010000000000000162e42fefa39ef44d910260801c5b60008361010016600f0b1315610bb857700100000000000000b17217f7d1cf79e9490260801c5b600083608016600f0b1315610bde5770010000000000000058b90bfbe8e7bce5440260801c5b600083604016600f0b1315610c04577001000000000000002c5c85fdf473de6eca0260801c5b600083602016600f0b1315610c2a57700100000000000000162e42fefa39ef366f0260801c5b600083601016600f0b1315610c50577001000000000000000b17217f7d1cf79afa0260801c5b600083600816600f0b1315610c7657700100000000000000058b90bfbe8e7bcd6d0260801c5b600083600416600f0b1315610c9c5770010000000000000002c5c85fdf473de6b20260801c5b600083600216600f0b1315610cc2577001000000000000000162e42fefa39ef3580260801c5b600083600116600f0b1315610ce85770010000000000000000b17217f7d1cf79ab0260801c5b600f83810b60401d603f03900b1c6f7fffffffffffffffffffffffffffffff811115610d1357600080fd5b92915050565b600081610d6d576040805162461bcd60e51b815260206004820152600860248201527f444956552d494e46000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000610d798484610df9565b90506f7fffffffffffffffffffffffffffffff6fffffffffffffffffffffffffffffffff82161115610df2576040805162461bcd60e51b815260206004820152600760248201527f444956552d4f4600000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b9392505050565b600081610e0557600080fd5b600077ffffffffffffffffffffffffffffffffffffffffffffffff8411610e3b5782604085901b81610e3357fe5b049050610f9a565b60c084811c6401000000008110610e54576020918201911c5b620100008110610e66576010918201911c5b6101008110610e77576008918201911c5b60108110610e87576004918201911c5b60048110610e97576002918201911c5b60028110610ea6576001820191505b60bf820360018603901c6001018260ff0387901b81610ec157fe5b0492506fffffffffffffffffffffffffffffffff831115610f29576040805162461bcd60e51b815260206004820152600960248201527f44495655552d4f46310000000000000000000000000000000000000000000000604482015290519081900360640190fd5b608085901c83026fffffffffffffffffffffffffffffffff8616840260c088901c604089901b82811015610f5e576001820391505b608084901b92900382811015610f75576001820391505b829003608084901c8214610f8557fe5b888181610f8e57fe5b04870196505050505050505b6fffffffffffffffffffffffffffffffff811115610df2576040805162461bcd60e51b815260206004820152600960248201527f44495655552d4f46320000000000000000000000000000000000000000000000604482015290519081900360640190fdfea264697066735822122040574cb227dea1d1a5db4fb4ab0552095e5133a47a8b45993e447ebd0471743a64736f6c63430007060033", + "deployedBytecode": "0x730000000000000000000000000000000000000000301460806040526004361061004b5760003560e01c80632cbbdee514610050578063fc193cf214610087578063fc505d37146100a7575b600080fd5b6100706004803603602081101561006657600080fd5b5035600f0b6100ca565b60408051600f9290920b8252519081900360200190f35b6100706004803603602081101561009d57600080fd5b5035600f0b6101f8565b610070600480360360408110156100bd57600080fd5b5080359060200135610d19565b60008082600f0b13610123576040805162461bcd60e51b815260206004820152600860248201527f4c4f475f322d5830000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000600f83900b680100000000000000008112610142576040918201911d5b6401000000008112610156576020918201911d5b620100008112610168576010918201911d5b6101008112610179576008918201911d5b60108112610189576004918201911d5b60048112610199576002918201911d5b600281126101a8576001820191505b603f19820160401b600f85900b607f8490031b6780000000000000005b60008113156101eb5790800260ff81901c8281029390930192607f011c9060011d6101c5565b509093505050505b919050565b60006840000000000000000082600f0b1261025a576040805162461bcd60e51b815260206004820152600860248201527f4558505f322d4f46000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b683fffffffffffffffff1982600f0b1215610277575060006101f3565b6f8000000000000000000000000000000060006780000000000000008416600f0b13156102b55770016a09e667f3bcc908b2fb1366ea957d3e0260801c5b60008367400000000000000016600f0b13156102e2577001306fe0a31b7152de8d5a46305c85edec0260801c5b60008367200000000000000016600f0b131561030f577001172b83c7d517adcdf7c8c50eb14a791f0260801c5b60008367100000000000000016600f0b131561033c5770010b5586cf9890f6298b92b71842a983630260801c5b60008367080000000000000016600f0b1315610369577001059b0d31585743ae7c548eb68ca417fd0260801c5b60008367040000000000000016600f0b131561039657700102c9a3e778060ee6f7caca4f7a29bde80260801c5b60008367020000000000000016600f0b13156103c35770010163da9fb33356d84a66ae336dcdfa3f0260801c5b60008367010000000000000016600f0b13156103f057700100b1afa5abcbed6129ab13ec11dc95430260801c5b600083668000000000000016600f0b131561041c5770010058c86da1c09ea1ff19d294cf2f679b0260801c5b600083664000000000000016600f0b1315610448577001002c605e2e8cec506d21bfc89a23a00f0260801c5b600083662000000000000016600f0b131561047457700100162f3904051fa128bca9c55c31e5df0260801c5b600083661000000000000016600f0b13156104a0577001000b175effdc76ba38e31671ca9397250260801c5b600083660800000000000016600f0b13156104cc57700100058ba01fb9f96d6cacd4b180917c3d0260801c5b600083660400000000000016600f0b13156104f85770010002c5cc37da9491d0985c348c68e7b30260801c5b600083660200000000000016600f0b1315610524577001000162e525ee054754457d59952920260260801c5b600083660100000000000016600f0b13156105505770010000b17255775c040618bf4a4ade83fc0260801c5b6000836580000000000016600f0b131561057b577001000058b91b5bc9ae2eed81e9b7d4cfab0260801c5b6000836540000000000016600f0b13156105a657700100002c5c89d5ec6ca4d7c8acc017b7c90260801c5b6000836520000000000016600f0b13156105d15770010000162e43f4f831060e02d839a9d16d0260801c5b6000836510000000000016600f0b13156105fc57700100000b1721bcfc99d9f890ea069117630260801c5b6000836508000000000016600f0b13156106275770010000058b90cf1e6d97f9ca14dbcc16280260801c5b6000836504000000000016600f0b1315610652577001000002c5c863b73f016468f6bac5ca2b0260801c5b6000836502000000000016600f0b131561067d57700100000162e430e5a18f6119e3c02282a50260801c5b6000836501000000000016600f0b13156106a8577001000000b1721835514b86e6d96efd1bfe0260801c5b60008364800000000016600f0b13156106d257700100000058b90c0b48c6be5df846c5b2ef0260801c5b60008364400000000016600f0b13156106fc5770010000002c5c8601cc6b9e94213c72737a0260801c5b60008364200000000016600f0b1315610726577001000000162e42fff037df38aa2b219f060260801c5b60008364100000000016600f0b13156107505770010000000b17217fba9c739aa5819f44f90260801c5b60008364080000000016600f0b131561077a577001000000058b90bfcdee5acd3c1cedc8230260801c5b60008364040000000016600f0b13156107a457700100000002c5c85fe31f35a6a30da1be500260801c5b60008364020000000016600f0b13156107ce5770010000000162e42ff0999ce3541b9fffcf0260801c5b60008364010000000016600f0b13156107f857700100000000b17217f80f4ef5aadda455540260801c5b600083638000000016600f0b13156108215770010000000058b90bfbf8479bd5a81b51ad0260801c5b600083634000000016600f0b131561084a577001000000002c5c85fdf84bd62ae30a74cc0260801c5b600083632000000016600f0b131561087357700100000000162e42fefb2fed257559bdaa0260801c5b600083631000000016600f0b131561089c577001000000000b17217f7d5a7716bba4a9ae0260801c5b600083630800000016600f0b13156108c557700100000000058b90bfbe9ddbac5e109cce0260801c5b600083630400000016600f0b13156108ee5770010000000002c5c85fdf4b15de6f17eb0d0260801c5b600083630200000016600f0b1315610917577001000000000162e42fefa494f1478fde050260801c5b600083630100000016600f0b13156109405770010000000000b17217f7d20cf927c8e94c0260801c5b6000836280000016600f0b1315610968577001000000000058b90bfbe8f71cb4e4b33d0260801c5b6000836240000016600f0b131561099057700100000000002c5c85fdf477b662b269450260801c5b6000836220000016600f0b13156109b85770010000000000162e42fefa3ae53369388c0260801c5b6000836210000016600f0b13156109e057700100000000000b17217f7d1d351a389d400260801c5b6000836208000016600f0b1315610a085770010000000000058b90bfbe8e8b2d3d4ede0260801c5b6000836204000016600f0b1315610a30577001000000000002c5c85fdf4741bea6e77e0260801c5b6000836202000016600f0b1315610a5857700100000000000162e42fefa39fe95583c20260801c5b6000836201000016600f0b1315610a80577001000000000000b17217f7d1cfb72b45e10260801c5b60008361800016600f0b1315610aa757700100000000000058b90bfbe8e7cc35c3f00260801c5b60008361400016600f0b1315610ace5770010000000000002c5c85fdf473e242ea380260801c5b60008361200016600f0b1315610af5577001000000000000162e42fefa39f02b772c0260801c5b60008361100016600f0b1315610b1c5770010000000000000b17217f7d1cf7d83c1a0260801c5b60008361080016600f0b1315610b43577001000000000000058b90bfbe8e7bdcbe2e0260801c5b60008361040016600f0b1315610b6a57700100000000000002c5c85fdf473dea871f0260801c5b60008361020016600f0b1315610b915770010000000000000162e42fefa39ef44d910260801c5b60008361010016600f0b1315610bb857700100000000000000b17217f7d1cf79e9490260801c5b600083608016600f0b1315610bde5770010000000000000058b90bfbe8e7bce5440260801c5b600083604016600f0b1315610c04577001000000000000002c5c85fdf473de6eca0260801c5b600083602016600f0b1315610c2a57700100000000000000162e42fefa39ef366f0260801c5b600083601016600f0b1315610c50577001000000000000000b17217f7d1cf79afa0260801c5b600083600816600f0b1315610c7657700100000000000000058b90bfbe8e7bcd6d0260801c5b600083600416600f0b1315610c9c5770010000000000000002c5c85fdf473de6b20260801c5b600083600216600f0b1315610cc2577001000000000000000162e42fefa39ef3580260801c5b600083600116600f0b1315610ce85770010000000000000000b17217f7d1cf79ab0260801c5b600f83810b60401d603f03900b1c6f7fffffffffffffffffffffffffffffff811115610d1357600080fd5b92915050565b600081610d6d576040805162461bcd60e51b815260206004820152600860248201527f444956552d494e46000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000610d798484610df9565b90506f7fffffffffffffffffffffffffffffff6fffffffffffffffffffffffffffffffff82161115610df2576040805162461bcd60e51b815260206004820152600760248201527f444956552d4f4600000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b9392505050565b600081610e0557600080fd5b600077ffffffffffffffffffffffffffffffffffffffffffffffff8411610e3b5782604085901b81610e3357fe5b049050610f9a565b60c084811c6401000000008110610e54576020918201911c5b620100008110610e66576010918201911c5b6101008110610e77576008918201911c5b60108110610e87576004918201911c5b60048110610e97576002918201911c5b60028110610ea6576001820191505b60bf820360018603901c6001018260ff0387901b81610ec157fe5b0492506fffffffffffffffffffffffffffffffff831115610f29576040805162461bcd60e51b815260206004820152600960248201527f44495655552d4f46310000000000000000000000000000000000000000000000604482015290519081900360640190fd5b608085901c83026fffffffffffffffffffffffffffffffff8616840260c088901c604089901b82811015610f5e576001820391505b608084901b92900382811015610f75576001820391505b829003608084901c8214610f8557fe5b888181610f8e57fe5b04870196505050505050505b6fffffffffffffffffffffffffffffffff811115610df2576040805162461bcd60e51b815260206004820152600960248201527f44495655552d4f46320000000000000000000000000000000000000000000000604482015290519081900360640190fdfea264697066735822122040574cb227dea1d1a5db4fb4ab0552095e5133a47a8b45993e447ebd0471743a64736f6c63430007060033", "devdoc": { "kind": "dev", "methods": { diff --git a/packages/hardhat/deployments/mainnet/Controller.json b/packages/hardhat/deployments/mainnet/Controller.json index 1d90109e6..e6934bb11 100644 --- a/packages/hardhat/deployments/mainnet/Controller.json +++ b/packages/hardhat/deployments/mainnet/Controller.json @@ -1,5 +1,5 @@ { - "address": "0x0344f8706947321FA87881D3DaD0EB1b8C65E732", + "address": "0x64187ae08781B09368e6253F9E94951243A493D5", "abi": [ { "inputs": [ @@ -1303,54 +1303,56 @@ "type": "receive" } ], - "transactionHash": "0x9d47e92664cf4f860e532d9fdd20781108e4d0bef9855d22c3da47bad1b886a8", + "transactionHash": "0xf1cccfa9f3dd36b322876b4430d9689e796090396669357e73f45f44e5b32985", "receipt": { "to": null, - "from": "0x80010e7575b24f47097598474502F0fd0aDbF3a8", - "contractAddress": "0x0344f8706947321FA87881D3DaD0EB1b8C65E732", - "transactionIndex": 50, - "gasUsed": "5442488", - "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000008000000000000000000000000000000000000400000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000200000000000000020000000000000000000000000010000800000000000000000000000000000000000", - "blockHash": "0x442b110e938a2b2acefeeed9c764a4c1b74c2da0ddfd40d5c0d594ff03c0cbc1", - "transactionHash": "0x9d47e92664cf4f860e532d9fdd20781108e4d0bef9855d22c3da47bad1b886a8", + "from": "0xa3cB04d8BD927EEC8826BD77b7C71abE3d29c081", + "contractAddress": "0x64187ae08781B09368e6253F9E94951243A493D5", + "transactionIndex": 24, + "gasUsed": "5402942", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000010000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000022000000000000000000800000000000000000000000000000000400000000100000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x841ddd8a2f726f44b1c1fc82c948be33954e108c31863cacc918f150d88b43df", + "transactionHash": "0xf1cccfa9f3dd36b322876b4430d9689e796090396669357e73f45f44e5b32985", "logs": [ { - "transactionIndex": 50, - "blockNumber": 13977497, - "transactionHash": "0x9d47e92664cf4f860e532d9fdd20781108e4d0bef9855d22c3da47bad1b886a8", - "address": "0x0344f8706947321FA87881D3DaD0EB1b8C65E732", + "transactionIndex": 24, + "blockNumber": 13982541, + "transactionHash": "0xf1cccfa9f3dd36b322876b4430d9689e796090396669357e73f45f44e5b32985", + "address": "0x64187ae08781B09368e6253F9E94951243A493D5", "topics": [ "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x00000000000000000000000080010e7575b24f47097598474502f0fd0adbf3a8" + "0x000000000000000000000000a3cb04d8bd927eec8826bd77b7c71abe3d29c081" ], "data": "0x", - "logIndex": 55, - "blockHash": "0x442b110e938a2b2acefeeed9c764a4c1b74c2da0ddfd40d5c0d594ff03c0cbc1" + "logIndex": 23, + "blockHash": "0x841ddd8a2f726f44b1c1fc82c948be33954e108c31863cacc918f150d88b43df" } ], - "blockNumber": 13977497, - "cumulativeGasUsed": "8140872", + "blockNumber": 13982541, + "cumulativeGasUsed": "6855366", "status": 1, "byzantium": true }, "args": [ - "0xF3822177e77319528a82cad3AC5aa55c4B3792f3", - "0x4757F744ec0CF2e3500Dc655F55100C943a59cbb", - "0x4a49c7aC69de6cf23da5872b7A7c7D2f2D48fC87", + "0x65D66c76447ccB45dAf1e8044e918fA786A483A1", + "0xa653e22A963ff0026292Cc8B67941c0ba7863a38", + "0xf1B99e3E573A1a9C5E6B2Ce818b617F0E664E86B", "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8", - "0x79941Aa39Eb093596c88ff43cEC0470Fa680b461", + "0x82c427AdFDf2d245Ec51D8046b41c4ee87F0d29C", "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", 3000 ], - "solcInputHash": "56b4ec4ab07157f3d2fb7e1de805d93e", - "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_oracle\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_shortPowerPerp\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_wPowerPerp\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_weth\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_quoteCurrency\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_ethQuoteCurrencyPool\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_wPowerPerpPool\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_uniPositionManager\",\"type\":\"address\"},{\"internalType\":\"uint24\",\"name\":\"_feeTier\",\"type\":\"uint24\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"}],\"name\":\"BurnShort\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"DepositCollateral\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"DepositUniPositionToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newFee\",\"type\":\"uint256\"}],\"name\":\"FeeRateUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldFeeRecipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newFeeRecipient\",\"type\":\"address\"}],\"name\":\"FeeRecipientUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"debtAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralPaid\",\"type\":\"uint256\"}],\"name\":\"Liquidate\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"}],\"name\":\"MintShort\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldNormFactor\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newNormFactor\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lastModificationTimestamp\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"NormalizationFactorUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"}],\"name\":\"OpenVault\",\"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\":\"pausesLeft\",\"type\":\"uint256\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wPowerPerpAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"payoutAmount\",\"type\":\"uint256\"}],\"name\":\"RedeemLong\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vauldId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralAmount\",\"type\":\"uint256\"}],\"name\":\"RedeemShort\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"ethRedeemed\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wPowerPerpRedeemed\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wPowerPerpBurned\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wPowerPerpExcess\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bounty\",\"type\":\"uint256\"}],\"name\":\"ReduceDebt\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"indexForSettlement\",\"type\":\"uint256\"}],\"name\":\"Shutdown\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"unpauser\",\"type\":\"address\"}],\"name\":\"UnPaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"UpdateOperator\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"WithdrawCollateral\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"WithdrawUniPositionToken\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"FUNDING_PERIOD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TWAP_PERIOD\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"applyFunding\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_powerPerpAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_withdrawAmount\",\"type\":\"uint256\"}],\"name\":\"burnPowerPerpAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_wPowerPerpAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_withdrawAmount\",\"type\":\"uint256\"}],\"name\":\"burnWPowerPerpAmount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"}],\"name\":\"deposit\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_uniTokenId\",\"type\":\"uint256\"}],\"name\":\"depositUniPositionToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"donate\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ethQuoteCurrencyPool\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeRecipient\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeTier\",\"outputs\":[{\"internalType\":\"uint24\",\"name\":\"\",\"type\":\"uint24\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_period\",\"type\":\"uint32\"}],\"name\":\"getDenormalizedMark\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_period\",\"type\":\"uint32\"}],\"name\":\"getDenormalizedMarkForFunding\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getExpectedNormalizationFactor\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_period\",\"type\":\"uint32\"}],\"name\":\"getIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_period\",\"type\":\"uint32\"}],\"name\":\"getUnscaledIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"indexForSettlement\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isShutDown\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isSystemPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"}],\"name\":\"isVaultSafe\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastFundingUpdateTimestamp\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastPauseTime\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maxDebtAmount\",\"type\":\"uint256\"}],\"name\":\"liquidate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_powerPerpAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_uniTokenId\",\"type\":\"uint256\"}],\"name\":\"mintPowerPerpAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_wPowerPerpAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_uniTokenId\",\"type\":\"uint256\"}],\"name\":\"mintWPowerPerpAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"normalizationFactor\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC721Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"oracle\",\"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\":\"pause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pausesLeft\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"quoteCurrency\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_wPerpAmount\",\"type\":\"uint256\"}],\"name\":\"redeemLong\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"}],\"name\":\"redeemShort\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"}],\"name\":\"reduceDebt\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"}],\"name\":\"reduceDebtShutdown\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_newFeeRate\",\"type\":\"uint256\"}],\"name\":\"setFeeRate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_newFeeRecipient\",\"type\":\"address\"}],\"name\":\"setFeeRecipient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"shortPowerPerp\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"shutDown\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unPauseAnyone\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unPauseOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_operator\",\"type\":\"address\"}],\"name\":\"updateOperator\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"vaults\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"NftCollateralId\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"collateralAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint128\",\"name\":\"shortAmount\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wPowerPerp\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wPowerPerpPool\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"weth\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"}],\"name\":\"withdrawUniPositionToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"burnPowerPerpAmount(uint256,uint256,uint256)\":{\"params\":{\"_powerPerpAmount\":\"amount of powerPerp to burn\",\"_vaultId\":\"id of the vault\",\"_withdrawAmount\":\"amount of eth to withdraw\"},\"returns\":{\"_0\":\"amount of wPowerPerp burned\"}},\"burnWPowerPerpAmount(uint256,uint256,uint256)\":{\"params\":{\"_vaultId\":\"id of the vault\",\"_wPowerPerpAmount\":\"amount of wPowerPerp to burn\",\"_withdrawAmount\":\"amount of eth to withdraw\"}},\"constructor\":{\"params\":{\"_ethQuoteCurrencyPool\":\"uniswap v3 pool for weth / quoteCurrency\",\"_oracle\":\"oracle address\",\"_quoteCurrency\":\"quoteCurrency address\",\"_shortPowerPerp\":\"ERC721 token address representing the short position\",\"_uniPositionManager\":\"uniswap v3 position manager address\",\"_wPowerPerp\":\"ERC20 token address representing the long position\",\"_wPowerPerpPool\":\"uniswap v3 pool for wPowerPerp / weth\",\"_weth\":\"weth address\"}},\"deposit(uint256)\":{\"details\":\"deposit collateral into a vault\",\"params\":{\"_vaultId\":\"id of the vault\"}},\"depositUniPositionToken(uint256,uint256)\":{\"params\":{\"_uniTokenId\":\"uniswap position token id\",\"_vaultId\":\"id of the vault\"}},\"getDenormalizedMark(uint32)\":{\"params\":{\"_period\":\"period of time for the twap in seconds\"},\"returns\":{\"_0\":\"mark price denominated in $USD, scaled by 1e18\"}},\"getDenormalizedMarkForFunding(uint32)\":{\"details\":\"this is the mark that would be used to calculate a new normalization factor if funding was calculated now\",\"params\":{\"_period\":\"period which you want to calculate twap with\"},\"returns\":{\"_0\":\"mark price denominated in $USD, scaled by 1e18\"}},\"getExpectedNormalizationFactor()\":{\"details\":\"can be used for on-chain and off-chain calculations\"},\"getIndex(uint32)\":{\"details\":\"the index price is scaled down by INDEX_SCALE in the associated PowerXBase librarythis is the index price used when calculating funding and for collateralization\",\"params\":{\"_period\":\"period which you want to calculate twap with\"},\"returns\":{\"_0\":\"index price denominated in $USD, scaled by 1e18\"}},\"getUnscaledIndex(uint32)\":{\"details\":\"this is the mark that would be be used for future funding after a new normalization factor is applied\",\"params\":{\"_period\":\"period which you want to calculate twap with\"},\"returns\":{\"_0\":\"index price denominated in $USD, scaled by 1e18\"}},\"isVaultSafe(uint256)\":{\"details\":\"return if the vault is properly collateralized\",\"params\":{\"_vaultId\":\"id of the vault\"},\"returns\":{\"_0\":\"true if the vault is properly collateralized\"}},\"liquidate(uint256,uint256)\":{\"details\":\"liquidator can get back (wPowerPerp burned) * (index price) * (normalizationFactor) * 110% in collateralnormally can only liquidate 50% of a vault's debtif a vault is under dust limit after a liquidation can fully liquidatewill attempt to reduceDebt first, and can earn a bounty if sucessful\",\"params\":{\"_maxDebtAmount\":\"max amount of wPowerPerpetual to repay\",\"_vaultId\":\"vault to liquidate\"},\"returns\":{\"_0\":\"amount of wPowerPerp repaid\"}},\"mintPowerPerpAmount(uint256,uint256,uint256)\":{\"params\":{\"_powerPerpAmount\":\"amount of powerPerp to mint\",\"_uniTokenId\":\"uniswap v3 position token id (additional collateral)\",\"_vaultId\":\"vault to mint wPowerPerp in\"},\"returns\":{\"_0\":\"vaultId\",\"_1\":\"amount of wPowerPerp minted\"}},\"mintWPowerPerpAmount(uint256,uint256,uint256)\":{\"params\":{\"_uniTokenId\":\"uniswap v3 position token id (additional collateral)\",\"_vaultId\":\"vault to mint wPowerPerp in\",\"_wPowerPerpAmount\":\"amount of wPowerPerp to mint\"},\"returns\":{\"_0\":\"vaultId\"}},\"onERC721Received(address,address,uint256,bytes)\":{\"details\":\"accept erc721 from safeTransferFrom and safeMint after callback\",\"returns\":{\"_0\":\"returns received selector\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pause()\":{\"details\":\"can only be called for 365 days since the contract was launched or 4 times\"},\"redeemLong(uint256)\":{\"params\":{\"_wPerpAmount\":\"amount of wPowerPerp to burn\"}},\"redeemShort(uint256)\":{\"details\":\"short position is redeemed by valuing the debt at the (settlement index value) * normalizationFactor\",\"params\":{\"_vaultId\":\"vault id\"}},\"reduceDebt(uint256)\":{\"details\":\"the caller won't get any bounty. this is expected to be used by vault owner\",\"params\":{\"_vaultId\":\"target vault\"}},\"reduceDebtShutdown(uint256)\":{\"details\":\"the caller won't get any bounty. this is expected to be used for insolvent vaults in shutdown\",\"params\":{\"_vaultId\":\"vault containing uniswap v3 position to liquidate\"}},\"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.\"},\"setFeeRate(uint256)\":{\"details\":\"this function cannot be called if the feeRecipient is still un-set\",\"params\":{\"_newFeeRate\":\"new fee rate in basis points. can't be higher than 1%\"}},\"setFeeRecipient(address)\":{\"details\":\"this should be a contract handling insurance\",\"params\":{\"_newFeeRecipient\":\"new fee recipient\"}},\"shutDown()\":{\"details\":\"this bypasses the check on number of pauses or time based checks, but is irreversible and enables emergency settlement\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"unPauseAnyone()\":{\"details\":\"anyone can unpause the contract after 24 hours\"},\"unPauseOwner()\":{\"details\":\"owner can unpause at any time\"},\"updateOperator(uint256,address)\":{\"details\":\"can be revoke by setting address to 0\",\"params\":{\"_operator\":\"new operator address\",\"_vaultId\":\"id of the vault\"}},\"withdraw(uint256,uint256)\":{\"params\":{\"_amount\":\"amount of eth to withdraw\",\"_vaultId\":\"id of the vault\"}},\"withdrawUniPositionToken(uint256)\":{\"params\":{\"_vaultId\":\"id of the vault\"}}},\"stateVariables\":{\"ONE\":{\"details\":\"basic unit used for calculation\"},\"PAUSE_TIME_LIMIT\":{\"details\":\"system can only be paused for 182 days from deployment\"},\"feeRate\":{\"details\":\"fee rate in basis point. feeRate of 1 = 0.01%\"},\"indexForSettlement\":{\"details\":\"the settlement price for each wPowerPerp for settlement\"},\"vaults\":{\"details\":\"vault data storage\"},\"wPowerPerpPool\":{\"details\":\"address of the powerPerp/weth pool\"}},\"version\":1},\"userdoc\":{\"events\":{\"OpenVault(address,uint256)\":{\"notice\":\"Events\"}},\"kind\":\"user\",\"methods\":{\"applyFunding()\":{\"notice\":\"update the normalization factor as a way to pay funding\"},\"burnPowerPerpAmount(uint256,uint256,uint256)\":{\"notice\":\"burn powerPerp and remove collateral from a vault\"},\"burnWPowerPerpAmount(uint256,uint256,uint256)\":{\"notice\":\"burn wPowerPerp and remove collateral from a vault\"},\"constructor\":{\"notice\":\"constructor\"},\"depositUniPositionToken(uint256,uint256)\":{\"notice\":\"deposit uniswap position token into a vault to increase collateral ratio\"},\"donate()\":{\"notice\":\"add eth into a contract. used in case contract has insufficient eth to pay for settlement transactions\"},\"getDenormalizedMark(uint32)\":{\"notice\":\"get the expected mark price of powerPerp after funding has been applied\"},\"getDenormalizedMarkForFunding(uint32)\":{\"notice\":\"get the mark price of powerPerp before funding has been applied\"},\"getExpectedNormalizationFactor()\":{\"notice\":\"returns the expected normalization factor, if the funding is paid right now\"},\"getIndex(uint32)\":{\"notice\":\"get the index price of the powerPerp, scaled down\"},\"getUnscaledIndex(uint32)\":{\"notice\":\"the unscaled index of the power perp in USD, scaled by 18 decimals\"},\"liquidate(uint256,uint256)\":{\"notice\":\"if a vault is under the 150% collateral ratio, anyone can liquidate the vault by burning wPowerPerp\"},\"mintPowerPerpAmount(uint256,uint256,uint256)\":{\"notice\":\"deposit collateral and mint wPowerPerp (non-rebasing) for specified powerPerp (rebasing) amount\"},\"mintWPowerPerpAmount(uint256,uint256,uint256)\":{\"notice\":\"deposit collateral and mint wPowerPerp\"},\"pause()\":{\"notice\":\"pause the system for up to 24 hours after which any one can unpause\"},\"redeemLong(uint256)\":{\"notice\":\"redeem wPowerPerp for (settlement index value) * normalizationFactor when the system is shutdown\"},\"redeemShort(uint256)\":{\"notice\":\"redeem short position when the system is shutdown\"},\"reduceDebt(uint256)\":{\"notice\":\"withdraw assets from uniswap v3 position, reducing debt and increasing collateral in the vault\"},\"reduceDebtShutdown(uint256)\":{\"notice\":\"after the system is shutdown, insolvent vaults need to be have their uniswap v3 token assets withdrawn by forceif a vault has a uniswap v3 position in it, anyone can call to withdraw uniswap v3 token assets, reducing debt and increasing collateral in the vault\"},\"setFeeRate(uint256)\":{\"notice\":\"set the fee rate when user mints\"},\"setFeeRecipient(address)\":{\"notice\":\"set the recipient who will receive the fee\"},\"shutDown()\":{\"notice\":\"shutting down the system allows all long wPowerPerp to be settled at index * normalizationFactorshort positions can be redeemed for vault collateral minus value of debtpause (if not paused) and then immediately shutdown the system, can be called when paused already\"},\"unPauseAnyone()\":{\"notice\":\"unpause the contract\"},\"unPauseOwner()\":{\"notice\":\"unpause the contract\"},\"updateOperator(uint256,address)\":{\"notice\":\"authorize an address to modify the vault\"},\"withdraw(uint256,uint256)\":{\"notice\":\"withdraw collateral from a vault\"},\"withdrawUniPositionToken(uint256)\":{\"notice\":\"withdraw uniswap v3 position token from a vault\"}},\"notice\":\"Error C0: Paused C1: Not paused C2: Shutdown C3: Not shutdown C4: Invalid oracle address C5: Invalid shortPowerPerp address C6: Invalid wPowerPerp address C7: Invalid weth address C8: Invalid quote currency address C9: Invalid eth:quoteCurrency pool address C10: Invalid wPowerPerp:eth pool address C11: Invalid Uniswap position manager C12: Can not liquidate safe vault C13: Invalid address C14: Set fee recipient first C15: Fee too high C16: Paused too many times C17: Pause time limit exceeded C18: Not enough paused time has passed C19: Cannot receive eth C20: Not allowed C21: Need full liquidation C22: Dust vault left C23: Invalid nft C24: Invalid state C25: 0 liquidity Uniswap position token C26: Wrong fee tier for NFT deposit\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/core/Controller.sol\":\"Controller\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":850},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor () {\\n address msgSender = _msgSender();\\n _owner = msgSender;\\n emit OwnershipTransferred(address(0), msgSender);\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n emit OwnershipTransferred(_owner, address(0));\\n _owner = address(0);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n emit OwnershipTransferred(_owner, newOwner);\\n _owner = newOwner;\\n }\\n}\\n\",\"keccak256\":\"0x549c5343ad9f7e3f38aa4c4761854403502574bbc15b822db2ce892ff9b79da7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd2f30fad5b24c4120f96dbac83aacdb7993ee610a9092bc23c44463da292bf8d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0xe22a1fc7400ae196eba2ad1562d0386462b00a6363b742d55a2fd2021a58586f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0xbd74f587ab9b9711801baf667db1426e4a03fd2d7f15af33e0e0d0394e7cef76\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"../../introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\\n}\\n\",\"keccak256\":\"0xb11597841d47f7a773bca63ca323c76f804cb5d944788de0327db5526319dc82\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Enumerable is IERC721 {\\n\\n /**\\n * @dev Returns the total amount of tokens stored by the contract.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\\n */\\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);\\n\\n /**\\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\\n * Use along with {totalSupply} to enumerate all tokens.\\n */\\n function tokenByIndex(uint256 index) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x2789dfea2d73182683d637db5729201f6730dae6113030a94c828f8688f38f2f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Metadata is IERC721 {\\n\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0xc82c7d1d732081d9bd23f1555ebdf8f3bc1738bc42c2bfc4b9aa7564d9fa3573\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\\n */\\n function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0x05604ffcf69e416b8a42728bb0e4fd75170d8fac70bf1a284afeb4752a9bc52f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf89f005a3d98f7768cdee2583707db0ac725cf567d455751af32ee68132f3db3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/*\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with GSN meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x8d3cb350f04ff49cfb10aef08d87f19dcbaecc8027b0bed12f3275cd12f38cf0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor () {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and make it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0x1153f6dd334c01566417b8c551122450542a2b75a2bbb379d59a8c320ed6da28\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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;\\n}\\n\",\"keccak256\":\"0x0ba8a9b95a956a4050749c0158e928398c447c91469682ca8a7cc7e77a7fe032\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/FullMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.4.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 // 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;\\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 /// @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 result = mulDiv(a, b, denominator);\\n if (mulmod(a, b, denominator) > 0) {\\n require(result < type(uint256).max);\\n result++;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe511530871deaef86692cea9adb6076d26d7b47fd4815ce51af52af981026057\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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\":\"0x86715eb960f18e01ac94e3bba4614ed51a887fa3c5bd1c43bf80aa98e019cf2d\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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\":\"0x4c12bf820c0b011f5490a209960ca34dd8af34660ef9e01de0438393d15e3fd8\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/SqrtPriceMath.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity >=0.5.0;\\n\\nimport './LowGasSafeMath.sol';\\nimport './SafeCast.sol';\\n\\nimport './FullMath.sol';\\nimport './UnsafeMath.sol';\\nimport './FixedPoint96.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 if (add) {\\n uint256 product;\\n if ((product = amount * sqrtPX96) / amount == sqrtPX96) {\\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 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 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 (\\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 (\\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\\n require(sqrtRatioAX96 > 0);\\n\\n return\\n roundUp\\n ? UnsafeMath.divRoundingUp(\\n FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96),\\n sqrtRatioAX96\\n )\\n : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96;\\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\":\"0x4f69701d331d364b69a1cda77cd7b983a0079d36ae0e06b0bb1d64ae56c3705e\",\"license\":\"BUSL-1.1\"},\"@uniswap/v3-core/contracts/libraries/TickMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.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 uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\\n require(absTick <= uint256(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 /// @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 // 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\",\"keccak256\":\"0x1f864a2bf61ba05f3173eaf2e3f94c5e1da4bec0554757527b6d1ef1fe439e4e\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/UnsafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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\":\"0x5f36d7d16348d8c37fe64fda932018d6e5e8acecd054f0f97d32db62d20c6c88\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IERC721Permit.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\n\\nimport '@openzeppelin/contracts/token/ERC721/IERC721.sol';\\n\\n/// @title ERC721 with permit\\n/// @notice Extension to ERC721 that includes a permit function for signature based approvals\\ninterface IERC721Permit is IERC721 {\\n /// @notice The permit typehash used in the permit signature\\n /// @return The typehash for the permit\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n\\n /// @notice The domain separator used in the permit signature\\n /// @return The domain seperator used in encoding of permit signature\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Approve of a specific token ID for spending by spender via signature\\n /// @param spender The account that is being approved\\n /// @param tokenId The ID of the token that is being approved for spending\\n /// @param deadline The deadline timestamp by which the call must be mined for the approve to work\\n /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`\\n /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`\\n /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`\\n function permit(\\n address spender,\\n uint256 tokenId,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable;\\n}\\n\",\"keccak256\":\"0x9e3c2a4ee65ddf95b2dfcb0815784eea3a295707e6f8b83e4c4f0f8fe2e3a1d4\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\nimport '@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol';\\nimport '@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol';\\n\\nimport './IPoolInitializer.sol';\\nimport './IERC721Permit.sol';\\nimport './IPeripheryPayments.sol';\\nimport './IPeripheryImmutableState.sol';\\nimport '../libraries/PoolAddress.sol';\\n\\n/// @title Non-fungible token for positions\\n/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred\\n/// and authorized.\\ninterface INonfungiblePositionManager is\\n IPoolInitializer,\\n IPeripheryPayments,\\n IPeripheryImmutableState,\\n IERC721Metadata,\\n IERC721Enumerable,\\n IERC721Permit\\n{\\n /// @notice Emitted when liquidity is increased for a position NFT\\n /// @dev Also emitted when a token is minted\\n /// @param tokenId The ID of the token for which liquidity was increased\\n /// @param liquidity The amount by which liquidity for the NFT position was increased\\n /// @param amount0 The amount of token0 that was paid for the increase in liquidity\\n /// @param amount1 The amount of token1 that was paid for the increase in liquidity\\n event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\\n /// @notice Emitted when liquidity is decreased for a position NFT\\n /// @param tokenId The ID of the token for which liquidity was decreased\\n /// @param liquidity The amount by which liquidity for the NFT position was decreased\\n /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity\\n /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity\\n event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\\n /// @notice Emitted when tokens are collected for a position NFT\\n /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior\\n /// @param tokenId The ID of the token for which underlying tokens were collected\\n /// @param recipient The address of the account that received the collected tokens\\n /// @param amount0 The amount of token0 owed to the position that was collected\\n /// @param amount1 The amount of token1 owed to the position that was collected\\n event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);\\n\\n /// @notice Returns the position information associated with a given token ID.\\n /// @dev Throws if the token ID is not valid.\\n /// @param tokenId The ID of the token that represents the position\\n /// @return nonce The nonce for permits\\n /// @return operator The address that is approved for spending\\n /// @return token0 The address of the token0 for a specific pool\\n /// @return token1 The address of the token1 for a specific pool\\n /// @return fee The fee associated with the pool\\n /// @return tickLower The lower end of the tick range for the position\\n /// @return tickUpper The higher end of the tick range for the position\\n /// @return liquidity The liquidity of the position\\n /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position\\n /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position\\n /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation\\n /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation\\n function positions(uint256 tokenId)\\n external\\n view\\n returns (\\n uint96 nonce,\\n address operator,\\n address token0,\\n address token1,\\n uint24 fee,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n uint256 feeGrowthInside0LastX128,\\n uint256 feeGrowthInside1LastX128,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n );\\n\\n struct MintParams {\\n address token0;\\n address token1;\\n uint24 fee;\\n int24 tickLower;\\n int24 tickUpper;\\n uint256 amount0Desired;\\n uint256 amount1Desired;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n address recipient;\\n uint256 deadline;\\n }\\n\\n /// @notice Creates a new position wrapped in a NFT\\n /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized\\n /// a method does not exist, i.e. the pool is assumed to be initialized.\\n /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata\\n /// @return tokenId The ID of the token that represents the minted position\\n /// @return liquidity The amount of liquidity for this position\\n /// @return amount0 The amount of token0\\n /// @return amount1 The amount of token1\\n function mint(MintParams calldata params)\\n external\\n payable\\n returns (\\n uint256 tokenId,\\n uint128 liquidity,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n struct IncreaseLiquidityParams {\\n uint256 tokenId;\\n uint256 amount0Desired;\\n uint256 amount1Desired;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n uint256 deadline;\\n }\\n\\n /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`\\n /// @param params tokenId The ID of the token for which liquidity is being increased,\\n /// amount0Desired The desired amount of token0 to be spent,\\n /// amount1Desired The desired amount of token1 to be spent,\\n /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,\\n /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,\\n /// deadline The time by which the transaction must be included to effect the change\\n /// @return liquidity The new liquidity amount as a result of the increase\\n /// @return amount0 The amount of token0 to acheive resulting liquidity\\n /// @return amount1 The amount of token1 to acheive resulting liquidity\\n function increaseLiquidity(IncreaseLiquidityParams calldata params)\\n external\\n payable\\n returns (\\n uint128 liquidity,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n struct DecreaseLiquidityParams {\\n uint256 tokenId;\\n uint128 liquidity;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n uint256 deadline;\\n }\\n\\n /// @notice Decreases the amount of liquidity in a position and accounts it to the position\\n /// @param params tokenId The ID of the token for which liquidity is being decreased,\\n /// amount The amount by which liquidity will be decreased,\\n /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,\\n /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,\\n /// deadline The time by which the transaction must be included to effect the change\\n /// @return amount0 The amount of token0 accounted to the position's tokens owed\\n /// @return amount1 The amount of token1 accounted to the position's tokens owed\\n function decreaseLiquidity(DecreaseLiquidityParams calldata params)\\n external\\n payable\\n returns (uint256 amount0, uint256 amount1);\\n\\n struct CollectParams {\\n uint256 tokenId;\\n address recipient;\\n uint128 amount0Max;\\n uint128 amount1Max;\\n }\\n\\n /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient\\n /// @param params tokenId The ID of the NFT for which tokens are being collected,\\n /// recipient The account that should receive the tokens,\\n /// amount0Max The maximum amount of token0 to collect,\\n /// amount1Max The maximum amount of token1 to collect\\n /// @return amount0 The amount of fees collected in token0\\n /// @return amount1 The amount of fees collected in token1\\n function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens\\n /// must be collected first.\\n /// @param tokenId The ID of the token that is being burned\\n function burn(uint256 tokenId) external payable;\\n}\\n\",\"keccak256\":\"0xe1dadc73e60bf05d0b4e0f05bd2847c5783e833cc10352c14763360b13495ee1\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPeripheryImmutableState.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Immutable state\\n/// @notice Functions that return immutable state of the router\\ninterface IPeripheryImmutableState {\\n /// @return Returns the address of the Uniswap V3 factory\\n function factory() external view returns (address);\\n\\n /// @return Returns the address of WETH9\\n function WETH9() external view returns (address);\\n}\\n\",\"keccak256\":\"0x7affcfeb5127c0925a71d6a65345e117c33537523aeca7bc98085ead8452519d\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPeripheryPayments.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\n\\n/// @title Periphery Payments\\n/// @notice Functions to ease deposits and withdrawals of ETH\\ninterface IPeripheryPayments {\\n /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.\\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.\\n /// @param amountMinimum The minimum amount of WETH9 to unwrap\\n /// @param recipient The address receiving ETH\\n function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;\\n\\n /// @notice Refunds any ETH balance held by this contract to the `msg.sender`\\n /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps\\n /// that use ether for the input amount\\n function refundETH() external payable;\\n\\n /// @notice Transfers the full amount of a token held by this contract to recipient\\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users\\n /// @param token The contract address of the token which will be transferred to `recipient`\\n /// @param amountMinimum The minimum amount of token required for a transfer\\n /// @param recipient The destination address of the token\\n function sweepToken(\\n address token,\\n uint256 amountMinimum,\\n address recipient\\n ) external payable;\\n}\\n\",\"keccak256\":\"0xb547e10f1e69bed03621a62b73a503e260643066c6b4054867a4d1fef47eb274\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPoolInitializer.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\n/// @title Creates and initializes V3 Pools\\n/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that\\n/// require the pool to exist.\\ninterface IPoolInitializer {\\n /// @notice Creates a new pool if it does not exist, then initializes if not initialized\\n /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool\\n /// @param token0 The contract address of token0 of the pool\\n /// @param token1 The contract address of token1 of the pool\\n /// @param fee The fee amount of the v3 pool for the specified token pair\\n /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value\\n /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary\\n function createAndInitializePoolIfNecessary(\\n address token0,\\n address token1,\\n uint24 fee,\\n uint160 sqrtPriceX96\\n ) external payable returns (address pool);\\n}\\n\",\"keccak256\":\"0x9d7695e8d94c22cc5fcced602017aabb988de89981ea7bee29ea629d5328a862\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee\\nlibrary PoolAddress {\\n bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;\\n\\n /// @notice The identifying key of the pool\\n struct PoolKey {\\n address token0;\\n address token1;\\n uint24 fee;\\n }\\n\\n /// @notice Returns PoolKey: the ordered tokens with the matched fee levels\\n /// @param tokenA The first token of a pool, unsorted\\n /// @param tokenB The second token of a pool, unsorted\\n /// @param fee The fee level of the pool\\n /// @return Poolkey The pool details with ordered token0 and token1 assignments\\n function getPoolKey(\\n address tokenA,\\n address tokenB,\\n uint24 fee\\n ) internal pure returns (PoolKey memory) {\\n if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);\\n return PoolKey({token0: tokenA, token1: tokenB, fee: fee});\\n }\\n\\n /// @notice Deterministically computes the pool address given the factory and PoolKey\\n /// @param factory The Uniswap V3 factory contract address\\n /// @param key The PoolKey\\n /// @return pool The contract address of the V3 pool\\n function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {\\n require(key.token0 < key.token1);\\n pool = address(\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n hex'ff',\\n factory,\\n keccak256(abi.encode(key.token0, key.token1, key.fee)),\\n POOL_INIT_CODE_HASH\\n )\\n )\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x5edd84eb8ba7c12fd8cb6cffe52e1e9f3f6464514ee5f539c2283826209035a2\",\"license\":\"GPL-2.0-or-later\"},\"contracts/core/Controller.sol\":{\"content\":\"//SPDX-License-Identifier: BUSL-1.1\\n\\npragma solidity =0.7.6;\\npragma abicoder v2;\\n\\n// interface\\nimport {IERC721} from \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\nimport {INonfungiblePositionManager} from \\\"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\\\";\\nimport {IWETH9} from \\\"../interfaces/IWETH9.sol\\\";\\nimport {IWPowerPerp} from \\\"../interfaces/IWPowerPerp.sol\\\";\\nimport {IShortPowerPerp} from \\\"../interfaces/IShortPowerPerp.sol\\\";\\nimport {IOracle} from \\\"../interfaces/IOracle.sol\\\";\\nimport {IERC721Receiver} from \\\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\\\";\\n\\n//contract\\nimport {Ownable} from \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport {ReentrancyGuard} from \\\"@openzeppelin/contracts/utils/ReentrancyGuard.sol\\\";\\n\\n//lib\\nimport {SafeMath} from \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport {Address} from \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport {ABDKMath64x64} from \\\"../libs/ABDKMath64x64.sol\\\";\\nimport {VaultLib} from \\\"../libs/VaultLib.sol\\\";\\nimport {Uint256Casting} from \\\"../libs/Uint256Casting.sol\\\";\\nimport {Power2Base} from \\\"../libs/Power2Base.sol\\\";\\n\\n/**\\n *\\n * Error\\n * C0: Paused\\n * C1: Not paused\\n * C2: Shutdown\\n * C3: Not shutdown\\n * C4: Invalid oracle address\\n * C5: Invalid shortPowerPerp address\\n * C6: Invalid wPowerPerp address\\n * C7: Invalid weth address\\n * C8: Invalid quote currency address\\n * C9: Invalid eth:quoteCurrency pool address\\n * C10: Invalid wPowerPerp:eth pool address\\n * C11: Invalid Uniswap position manager\\n * C12: Can not liquidate safe vault\\n * C13: Invalid address\\n * C14: Set fee recipient first\\n * C15: Fee too high\\n * C16: Paused too many times\\n * C17: Pause time limit exceeded\\n * C18: Not enough paused time has passed\\n * C19: Cannot receive eth\\n * C20: Not allowed\\n * C21: Need full liquidation\\n * C22: Dust vault left\\n * C23: Invalid nft\\n * C24: Invalid state\\n * C25: 0 liquidity Uniswap position token\\n * C26: Wrong fee tier for NFT deposit\\n */\\ncontract Controller is Ownable, ReentrancyGuard, IERC721Receiver {\\n using SafeMath for uint256;\\n using Uint256Casting for uint256;\\n using ABDKMath64x64 for int128;\\n using VaultLib for VaultLib.Vault;\\n using Address for address payable;\\n\\n uint256 internal constant MIN_COLLATERAL = 6.9 ether;\\n /// @dev system can only be paused for 182 days from deployment\\n uint256 internal constant PAUSE_TIME_LIMIT = 182 days;\\n\\n uint256 public constant FUNDING_PERIOD = 420 hours;\\n uint24 public immutable feeTier;\\n uint32 public constant TWAP_PERIOD = 420 seconds;\\n\\n //80% of index\\n uint256 internal constant LOWER_MARK_RATIO = 8e17;\\n //125% of index\\n uint256 internal constant UPPER_MARK_RATIO = 140e16;\\n // 10%\\n uint256 internal constant LIQUIDATION_BOUNTY = 1e17;\\n // 2%\\n uint256 internal constant REDUCE_DEBT_BOUNTY = 2e16;\\n\\n /// @dev basic unit used for calculation\\n uint256 private constant ONE = 1e18;\\n\\n address public immutable weth;\\n address public immutable quoteCurrency;\\n address public immutable ethQuoteCurrencyPool;\\n /// @dev address of the powerPerp/weth pool\\n address public immutable wPowerPerpPool;\\n address internal immutable uniswapPositionManager;\\n address public immutable shortPowerPerp;\\n address public immutable wPowerPerp;\\n address public immutable oracle;\\n address public feeRecipient;\\n\\n uint256 internal immutable deployTimestamp;\\n /// @dev fee rate in basis point. feeRate of 1 = 0.01%\\n uint256 public feeRate;\\n /// @dev the settlement price for each wPowerPerp for settlement\\n uint256 public indexForSettlement;\\n\\n uint256 public pausesLeft = 4;\\n uint256 public lastPauseTime;\\n\\n // these 2 parameters are always updated together. Use uint128 to batch read and write.\\n uint128 public normalizationFactor;\\n uint128 public lastFundingUpdateTimestamp;\\n\\n bool internal immutable isWethToken0;\\n bool public isShutDown;\\n bool public isSystemPaused;\\n\\n /// @dev vault data storage\\n mapping(uint256 => VaultLib.Vault) public vaults;\\n\\n /// Events\\n event OpenVault(address sender, uint256 vaultId);\\n event DepositCollateral(address sender, uint256 vaultId, uint256 amount);\\n event DepositUniPositionToken(address sender, uint256 vaultId, uint256 tokenId);\\n event WithdrawCollateral(address sender, uint256 vaultId, uint256 amount);\\n event WithdrawUniPositionToken(address sender, uint256 vaultId, uint256 tokenId);\\n event MintShort(address sender, uint256 amount, uint256 vaultId);\\n event BurnShort(address sender, uint256 amount, uint256 vaultId);\\n event ReduceDebt(\\n address sender,\\n uint256 vaultId,\\n uint256 ethRedeemed,\\n uint256 wPowerPerpRedeemed,\\n uint256 wPowerPerpBurned,\\n uint256 wPowerPerpExcess,\\n uint256 bounty\\n );\\n event UpdateOperator(address sender, uint256 vaultId, address operator);\\n event FeeRateUpdated(uint256 oldFee, uint256 newFee);\\n event FeeRecipientUpdated(address oldFeeRecipient, address newFeeRecipient);\\n event Liquidate(address liquidator, uint256 vaultId, uint256 debtAmount, uint256 collateralPaid);\\n event NormalizationFactorUpdated(\\n uint256 oldNormFactor,\\n uint256 newNormFactor,\\n uint256 lastModificationTimestamp,\\n uint256 timestamp\\n );\\n event Paused(uint256 pausesLeft);\\n event UnPaused(address unpauser);\\n event Shutdown(uint256 indexForSettlement);\\n event RedeemLong(address sender, uint256 wPowerPerpAmount, uint256 payoutAmount);\\n event RedeemShort(address sender, uint256 vauldId, uint256 collateralAmount);\\n\\n modifier notPaused() {\\n require(!isSystemPaused, \\\"C0\\\");\\n _;\\n }\\n\\n modifier isPaused() {\\n require(isSystemPaused, \\\"C1\\\");\\n _;\\n }\\n\\n modifier notShutdown() {\\n require(!isShutDown, \\\"C2\\\");\\n _;\\n }\\n\\n modifier isShutdown() {\\n require(isShutDown, \\\"C3\\\");\\n _;\\n }\\n\\n /**\\n * @notice constructor\\n * @param _oracle oracle address\\n * @param _shortPowerPerp ERC721 token address representing the short position\\n * @param _wPowerPerp ERC20 token address representing the long position\\n * @param _weth weth address\\n * @param _quoteCurrency quoteCurrency address\\n * @param _ethQuoteCurrencyPool uniswap v3 pool for weth / quoteCurrency\\n * @param _wPowerPerpPool uniswap v3 pool for wPowerPerp / weth\\n * @param _uniPositionManager uniswap v3 position manager address\\n */\\n constructor(\\n address _oracle,\\n address _shortPowerPerp,\\n address _wPowerPerp,\\n address _weth,\\n address _quoteCurrency,\\n address _ethQuoteCurrencyPool,\\n address _wPowerPerpPool,\\n address _uniPositionManager,\\n uint24 _feeTier\\n ) {\\n require(_oracle != address(0), \\\"C4\\\");\\n require(_shortPowerPerp != address(0), \\\"C5\\\");\\n require(_wPowerPerp != address(0), \\\"C6\\\");\\n require(_weth != address(0), \\\"C7\\\");\\n require(_quoteCurrency != address(0), \\\"C8\\\");\\n require(_ethQuoteCurrencyPool != address(0), \\\"C9\\\");\\n require(_wPowerPerpPool != address(0), \\\"C10\\\");\\n require(_uniPositionManager != address(0), \\\"C11\\\");\\n\\n oracle = _oracle;\\n shortPowerPerp = _shortPowerPerp;\\n wPowerPerp = _wPowerPerp;\\n weth = _weth;\\n quoteCurrency = _quoteCurrency;\\n ethQuoteCurrencyPool = _ethQuoteCurrencyPool;\\n wPowerPerpPool = _wPowerPerpPool;\\n uniswapPositionManager = _uniPositionManager;\\n feeTier = _feeTier;\\n isWethToken0 = _weth < _wPowerPerp;\\n\\n normalizationFactor = 1e18;\\n deployTimestamp = block.timestamp;\\n lastFundingUpdateTimestamp = block.timestamp.toUint128();\\n }\\n\\n /**\\n * ======================\\n * | External Functions |\\n * ======================\\n */\\n\\n /**\\n * @notice returns the expected normalization factor, if the funding is paid right now\\n * @dev can be used for on-chain and off-chain calculations\\n */\\n function getExpectedNormalizationFactor() external view returns (uint256) {\\n return _getNewNormalizationFactor();\\n }\\n\\n /**\\n * @notice get the index price of the powerPerp, scaled down\\n * @dev the index price is scaled down by INDEX_SCALE in the associated PowerXBase library\\n * @dev this is the index price used when calculating funding and for collateralization\\n * @param _period period which you want to calculate twap with\\n * @return index price denominated in $USD, scaled by 1e18\\n */\\n function getIndex(uint32 _period) external view returns (uint256) {\\n return Power2Base._getIndex(_period, oracle, ethQuoteCurrencyPool, weth, quoteCurrency);\\n }\\n\\n /**\\n * @notice the unscaled index of the power perp in USD, scaled by 18 decimals\\n * @dev this is the mark that would be be used for future funding after a new normalization factor is applied\\n * @param _period period which you want to calculate twap with\\n * @return index price denominated in $USD, scaled by 1e18\\n */\\n function getUnscaledIndex(uint32 _period) external view returns (uint256) {\\n return Power2Base._getUnscaledIndex(_period, oracle, ethQuoteCurrencyPool, weth, quoteCurrency);\\n }\\n\\n /**\\n * @notice get the expected mark price of powerPerp after funding has been applied\\n * @param _period period of time for the twap in seconds\\n * @return mark price denominated in $USD, scaled by 1e18\\n */\\n function getDenormalizedMark(uint32 _period) external view returns (uint256) {\\n return\\n Power2Base._getDenormalizedMark(\\n _period,\\n oracle,\\n wPowerPerpPool,\\n ethQuoteCurrencyPool,\\n weth,\\n quoteCurrency,\\n wPowerPerp,\\n _getNewNormalizationFactor()\\n );\\n }\\n\\n /**\\n * @notice get the mark price of powerPerp before funding has been applied\\n * @dev this is the mark that would be used to calculate a new normalization factor if funding was calculated now\\n * @param _period period which you want to calculate twap with\\n * @return mark price denominated in $USD, scaled by 1e18\\n */\\n function getDenormalizedMarkForFunding(uint32 _period) external view returns (uint256) {\\n return\\n Power2Base._getDenormalizedMark(\\n _period,\\n oracle,\\n wPowerPerpPool,\\n ethQuoteCurrencyPool,\\n weth,\\n quoteCurrency,\\n wPowerPerp,\\n normalizationFactor\\n );\\n }\\n\\n /**\\n * @dev return if the vault is properly collateralized\\n * @param _vaultId id of the vault\\n * @return true if the vault is properly collateralized\\n */\\n function isVaultSafe(uint256 _vaultId) external view returns (bool) {\\n VaultLib.Vault memory vault = vaults[_vaultId];\\n uint256 expectedNormalizationFactor = _getNewNormalizationFactor();\\n return _isVaultSafe(vault, expectedNormalizationFactor);\\n }\\n\\n /**\\n * @notice deposit collateral and mint wPowerPerp (non-rebasing) for specified powerPerp (rebasing) amount\\n * @param _vaultId vault to mint wPowerPerp in\\n * @param _powerPerpAmount amount of powerPerp to mint\\n * @param _uniTokenId uniswap v3 position token id (additional collateral)\\n * @return vaultId\\n * @return amount of wPowerPerp minted\\n */\\n function mintPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _powerPerpAmount,\\n uint256 _uniTokenId\\n ) external payable notPaused nonReentrant returns (uint256, uint256) {\\n return _openDepositMint(msg.sender, _vaultId, _powerPerpAmount, msg.value, _uniTokenId, false);\\n }\\n\\n /**\\n * @notice deposit collateral and mint wPowerPerp\\n * @param _vaultId vault to mint wPowerPerp in\\n * @param _wPowerPerpAmount amount of wPowerPerp to mint\\n * @param _uniTokenId uniswap v3 position token id (additional collateral)\\n * @return vaultId\\n */\\n function mintWPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _uniTokenId\\n ) external payable notPaused nonReentrant returns (uint256) {\\n (uint256 vaultId, ) = _openDepositMint(msg.sender, _vaultId, _wPowerPerpAmount, msg.value, _uniTokenId, true);\\n return vaultId;\\n }\\n\\n /**\\n * @dev deposit collateral into a vault\\n * @param _vaultId id of the vault\\n */\\n function deposit(uint256 _vaultId) external payable notPaused nonReentrant {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n\\n _applyFunding();\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n _addEthCollateral(cachedVault, _vaultId, msg.value);\\n\\n _writeVault(_vaultId, cachedVault);\\n }\\n\\n /**\\n * @notice deposit uniswap position token into a vault to increase collateral ratio\\n * @param _vaultId id of the vault\\n * @param _uniTokenId uniswap position token id\\n */\\n function depositUniPositionToken(uint256 _vaultId, uint256 _uniTokenId) external notPaused nonReentrant {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n\\n _applyFunding();\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n\\n _depositUniPositionToken(cachedVault, msg.sender, _vaultId, _uniTokenId);\\n _writeVault(_vaultId, cachedVault);\\n }\\n\\n /**\\n * @notice withdraw collateral from a vault\\n * @param _vaultId id of the vault\\n * @param _amount amount of eth to withdraw\\n */\\n function withdraw(uint256 _vaultId, uint256 _amount) external notPaused nonReentrant {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n\\n uint256 cachedNormFactor = _applyFunding();\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n\\n _withdrawCollateral(cachedVault, _vaultId, _amount);\\n _checkVault(cachedVault, cachedNormFactor);\\n _writeVault(_vaultId, cachedVault);\\n payable(msg.sender).sendValue(_amount);\\n }\\n\\n /**\\n * @notice withdraw uniswap v3 position token from a vault\\n * @param _vaultId id of the vault\\n */\\n function withdrawUniPositionToken(uint256 _vaultId) external notPaused nonReentrant {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n\\n uint256 cachedNormFactor = _applyFunding();\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n _withdrawUniPositionToken(cachedVault, msg.sender, _vaultId);\\n _checkVault(cachedVault, cachedNormFactor);\\n _writeVault(_vaultId, cachedVault);\\n }\\n\\n /**\\n * @notice burn wPowerPerp and remove collateral from a vault\\n * @param _vaultId id of the vault\\n * @param _wPowerPerpAmount amount of wPowerPerp to burn\\n * @param _withdrawAmount amount of eth to withdraw\\n */\\n function burnWPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _withdrawAmount\\n ) external notPaused nonReentrant {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n\\n _burnAndWithdraw(msg.sender, _vaultId, _wPowerPerpAmount, _withdrawAmount, true);\\n }\\n\\n /**\\n * @notice burn powerPerp and remove collateral from a vault\\n * @param _vaultId id of the vault\\n * @param _powerPerpAmount amount of powerPerp to burn\\n * @param _withdrawAmount amount of eth to withdraw\\n * @return amount of wPowerPerp burned\\n */\\n function burnPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _powerPerpAmount,\\n uint256 _withdrawAmount\\n ) external notPaused nonReentrant returns (uint256) {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n\\n return _burnAndWithdraw(msg.sender, _vaultId, _powerPerpAmount, _withdrawAmount, false);\\n }\\n\\n /**\\n * @notice after the system is shutdown, insolvent vaults need to be have their uniswap v3 token assets withdrawn by force\\n * @notice if a vault has a uniswap v3 position in it, anyone can call to withdraw uniswap v3 token assets, reducing debt and increasing collateral in the vault\\n * @dev the caller won't get any bounty. this is expected to be used for insolvent vaults in shutdown\\n * @param _vaultId vault containing uniswap v3 position to liquidate\\n */\\n function reduceDebtShutdown(uint256 _vaultId) external isShutdown nonReentrant {\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n _reduceDebt(cachedVault, IShortPowerPerp(shortPowerPerp).ownerOf(_vaultId), _vaultId, false);\\n _writeVault(_vaultId, cachedVault);\\n }\\n\\n /**\\n * @notice withdraw assets from uniswap v3 position, reducing debt and increasing collateral in the vault\\n * @dev the caller won't get any bounty. this is expected to be used by vault owner\\n * @param _vaultId target vault\\n */\\n function reduceDebt(uint256 _vaultId) external notPaused nonReentrant {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n\\n _reduceDebt(cachedVault, IShortPowerPerp(shortPowerPerp).ownerOf(_vaultId), _vaultId, false);\\n\\n _writeVault(_vaultId, cachedVault);\\n }\\n\\n /**\\n * @notice if a vault is under the 150% collateral ratio, anyone can liquidate the vault by burning wPowerPerp\\n * @dev liquidator can get back (wPowerPerp burned) * (index price) * (normalizationFactor) * 110% in collateral\\n * @dev normally can only liquidate 50% of a vault's debt\\n * @dev if a vault is under dust limit after a liquidation can fully liquidate\\n * @dev will attempt to reduceDebt first, and can earn a bounty if sucessful\\n * @param _vaultId vault to liquidate\\n * @param _maxDebtAmount max amount of wPowerPerpetual to repay\\n * @return amount of wPowerPerp repaid\\n */\\n function liquidate(uint256 _vaultId, uint256 _maxDebtAmount) external notPaused nonReentrant returns (uint256) {\\n uint256 cachedNormFactor = _applyFunding();\\n\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n\\n require(!_isVaultSafe(cachedVault, cachedNormFactor), \\\"C12\\\");\\n\\n // try to save target vault before liquidation by reducing debt\\n uint256 bounty = _reduceDebt(cachedVault, IShortPowerPerp(shortPowerPerp).ownerOf(_vaultId), _vaultId, true);\\n\\n // if vault is safe after saving, pay bounty and return early\\n if (_isVaultSafe(cachedVault, cachedNormFactor)) {\\n _writeVault(_vaultId, cachedVault);\\n payable(msg.sender).sendValue(bounty);\\n return 0;\\n }\\n\\n // add back the bounty amount, liquidators onlly get reward from liquidation\\n cachedVault.addEthCollateral(bounty);\\n\\n // if the vault is still not safe after saving, liquidate it\\n (uint256 debtAmount, uint256 collateralPaid) = _liquidate(\\n cachedVault,\\n _maxDebtAmount,\\n cachedNormFactor,\\n msg.sender\\n );\\n\\n emit Liquidate(msg.sender, _vaultId, debtAmount, collateralPaid);\\n\\n _writeVault(_vaultId, cachedVault);\\n\\n // pay the liquidator\\n payable(msg.sender).sendValue(collateralPaid);\\n\\n return debtAmount;\\n }\\n\\n /**\\n * @notice authorize an address to modify the vault\\n * @dev can be revoke by setting address to 0\\n * @param _vaultId id of the vault\\n * @param _operator new operator address\\n */\\n function updateOperator(uint256 _vaultId, address _operator) external {\\n require(\\n (shortPowerPerp == msg.sender) || (IShortPowerPerp(shortPowerPerp).ownerOf(_vaultId) == msg.sender),\\n \\\"C20\\\"\\n );\\n vaults[_vaultId].operator = _operator;\\n emit UpdateOperator(msg.sender, _vaultId, _operator);\\n }\\n\\n /**\\n * @notice set the recipient who will receive the fee\\n * @dev this should be a contract handling insurance\\n * @param _newFeeRecipient new fee recipient\\n */\\n function setFeeRecipient(address _newFeeRecipient) external onlyOwner {\\n require(_newFeeRecipient != address(0), \\\"C13\\\");\\n emit FeeRecipientUpdated(feeRecipient, _newFeeRecipient);\\n feeRecipient = _newFeeRecipient;\\n }\\n\\n /**\\n * @notice set the fee rate when user mints\\n * @dev this function cannot be called if the feeRecipient is still un-set\\n * @param _newFeeRate new fee rate in basis points. can't be higher than 1%\\n */\\n function setFeeRate(uint256 _newFeeRate) external onlyOwner {\\n require(feeRecipient != address(0), \\\"C14\\\");\\n require(_newFeeRate <= 100, \\\"C15\\\");\\n emit FeeRateUpdated(feeRate, _newFeeRate);\\n feeRate = _newFeeRate;\\n }\\n\\n /**\\n * @notice shutting down the system allows all long wPowerPerp to be settled at index * normalizationFactor\\n * @notice short positions can be redeemed for vault collateral minus value of debt\\n * @notice pause (if not paused) and then immediately shutdown the system, can be called when paused already\\n * @dev this bypasses the check on number of pauses or time based checks, but is irreversible and enables emergency settlement\\n */\\n function shutDown() external onlyOwner notShutdown {\\n isSystemPaused = true;\\n isShutDown = true;\\n indexForSettlement = Power2Base._getScaledTwap(\\n oracle,\\n ethQuoteCurrencyPool,\\n weth,\\n quoteCurrency,\\n TWAP_PERIOD,\\n false\\n );\\n emit Shutdown(indexForSettlement);\\n }\\n\\n /**\\n * @notice pause the system for up to 24 hours after which any one can unpause\\n * @dev can only be called for 365 days since the contract was launched or 4 times\\n */\\n function pause() external onlyOwner notShutdown notPaused {\\n require(pausesLeft > 0, \\\"C16\\\");\\n uint256 timeSinceDeploy = block.timestamp.sub(deployTimestamp);\\n require(timeSinceDeploy < PAUSE_TIME_LIMIT, \\\"C17\\\");\\n isSystemPaused = true;\\n pausesLeft -= 1;\\n lastPauseTime = block.timestamp;\\n\\n emit Paused(pausesLeft);\\n }\\n\\n /**\\n * @notice unpause the contract\\n * @dev anyone can unpause the contract after 24 hours\\n */\\n function unPauseAnyone() external isPaused notShutdown {\\n require(block.timestamp > (lastPauseTime + 1 days), \\\"C18\\\");\\n isSystemPaused = false;\\n emit UnPaused(msg.sender);\\n }\\n\\n /**\\n * @notice unpause the contract\\n * @dev owner can unpause at any time\\n */\\n function unPauseOwner() external onlyOwner isPaused notShutdown {\\n isSystemPaused = false;\\n emit UnPaused(msg.sender);\\n }\\n\\n /**\\n * @notice redeem wPowerPerp for (settlement index value) * normalizationFactor when the system is shutdown\\n * @param _wPerpAmount amount of wPowerPerp to burn\\n */\\n function redeemLong(uint256 _wPerpAmount) external isShutdown nonReentrant {\\n IWPowerPerp(wPowerPerp).burn(msg.sender, _wPerpAmount);\\n\\n uint256 longValue = Power2Base._getLongSettlementValue(_wPerpAmount, indexForSettlement, normalizationFactor);\\n payable(msg.sender).sendValue(longValue);\\n\\n emit RedeemLong(msg.sender, _wPerpAmount, longValue);\\n }\\n\\n /**\\n * @notice redeem short position when the system is shutdown\\n * @dev short position is redeemed by valuing the debt at the (settlement index value) * normalizationFactor\\n * @param _vaultId vault id\\n */\\n function redeemShort(uint256 _vaultId) external isShutdown nonReentrant {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n uint256 cachedNormFactor = normalizationFactor;\\n\\n _reduceDebt(cachedVault, msg.sender, _vaultId, false);\\n\\n uint256 debt = Power2Base._getLongSettlementValue(\\n cachedVault.shortAmount,\\n indexForSettlement,\\n cachedNormFactor\\n );\\n // if the debt is more than collateral, this line will revert\\n uint256 excess = uint256(cachedVault.collateralAmount).sub(debt);\\n\\n // reset the vault but don't burn the nft, just because people may want to keep it\\n cachedVault.shortAmount = 0;\\n cachedVault.collateralAmount = 0;\\n _writeVault(_vaultId, cachedVault);\\n\\n payable(msg.sender).sendValue(excess);\\n\\n emit RedeemShort(msg.sender, _vaultId, excess);\\n }\\n\\n /**\\n * @notice update the normalization factor as a way to pay funding\\n */\\n function applyFunding() external notPaused {\\n _applyFunding();\\n }\\n\\n /**\\n * @notice add eth into a contract. used in case contract has insufficient eth to pay for settlement transactions\\n */\\n function donate() external payable isShutdown {}\\n\\n /**\\n * @notice fallback function to accept eth\\n */\\n receive() external payable {\\n require(msg.sender == weth, \\\"C19\\\");\\n }\\n\\n /**\\n * @dev accept erc721 from safeTransferFrom and safeMint after callback\\n * @return returns received selector\\n */\\n function onERC721Received(\\n address,\\n address,\\n uint256,\\n bytes memory\\n ) public virtual override returns (bytes4) {\\n return this.onERC721Received.selector;\\n }\\n\\n /*\\n * ======================\\n * | Internal Functions |\\n * ======================\\n */\\n\\n /**\\n * @notice check if an address can modify a vault\\n * @param _vaultId the id of the vault to check if can be modified by _account\\n * @param _account the address to check if can modify the vault\\n */\\n function _checkCanModifyVault(uint256 _vaultId, address _account) internal view {\\n require(\\n IShortPowerPerp(shortPowerPerp).ownerOf(_vaultId) == _account || vaults[_vaultId].operator == _account,\\n \\\"C20\\\"\\n );\\n }\\n\\n /**\\n * @notice wrapper function which opens a vault, adds collateral and mints wPowerPerp\\n * @param _account account to receive wPowerPerp\\n * @param _vaultId id of the vault\\n * @param _mintAmount amount to mint\\n * @param _depositAmount amount of eth as collateral\\n * @param _uniTokenId id of uniswap v3 position token\\n * @param _isWAmount if the input amount is a wPowerPerp amount (as opposed to rebasing powerPerp)\\n * @return the vaultId that was acted on or for a new vault the newly created vaultId\\n * @return the minted wPowerPerp amount\\n */\\n function _openDepositMint(\\n address _account,\\n uint256 _vaultId,\\n uint256 _mintAmount,\\n uint256 _depositAmount,\\n uint256 _uniTokenId,\\n bool _isWAmount\\n ) internal returns (uint256, uint256) {\\n uint256 cachedNormFactor = _applyFunding();\\n uint256 depositAmountWithFee = _depositAmount;\\n uint256 wPowerPerpAmount = _isWAmount ? _mintAmount : _mintAmount.mul(ONE).div(cachedNormFactor);\\n uint256 feeAmount;\\n VaultLib.Vault memory cachedVault;\\n\\n // load vault or create new a new one\\n if (_vaultId == 0) {\\n (_vaultId, cachedVault) = _openVault(_account);\\n } else {\\n // make sure we're not accessing an unexistent vault.\\n _checkCanModifyVault(_vaultId, msg.sender);\\n cachedVault = vaults[_vaultId];\\n }\\n\\n if (wPowerPerpAmount > 0) {\\n (feeAmount, depositAmountWithFee) = _getFee(cachedVault, wPowerPerpAmount, _depositAmount);\\n _mintWPowerPerp(cachedVault, _account, _vaultId, wPowerPerpAmount);\\n }\\n if (_depositAmount > 0) _addEthCollateral(cachedVault, _vaultId, depositAmountWithFee);\\n if (_uniTokenId != 0) _depositUniPositionToken(cachedVault, _account, _vaultId, _uniTokenId);\\n\\n _checkVault(cachedVault, cachedNormFactor);\\n _writeVault(_vaultId, cachedVault);\\n\\n // pay insurance fee\\n if (feeAmount > 0) payable(feeRecipient).sendValue(feeAmount);\\n\\n return (_vaultId, wPowerPerpAmount);\\n }\\n\\n /**\\n * @notice wrapper function to burn wPowerPerp and redeem collateral\\n * @param _account who should receive collateral\\n * @param _vaultId id of the vault\\n * @param _burnAmount amount of wPowerPerp to burn\\n * @param _withdrawAmount amount of eth collateral to withdraw\\n * @param _isWAmount true if the amount is wPowerPerp (as opposed to rebasing powerPerp)\\n * @return total burned wPowerPower amount\\n */\\n function _burnAndWithdraw(\\n address _account,\\n uint256 _vaultId,\\n uint256 _burnAmount,\\n uint256 _withdrawAmount,\\n bool _isWAmount\\n ) internal returns (uint256) {\\n uint256 cachedNormFactor = _applyFunding();\\n uint256 wBurnAmount = _isWAmount ? _burnAmount : _burnAmount.mul(ONE).div(cachedNormFactor);\\n\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n if (wBurnAmount > 0) _burnWPowerPerp(cachedVault, _account, _vaultId, wBurnAmount);\\n if (_withdrawAmount > 0) _withdrawCollateral(cachedVault, _vaultId, _withdrawAmount);\\n _checkVault(cachedVault, cachedNormFactor);\\n _writeVault(_vaultId, cachedVault);\\n\\n if (_withdrawAmount > 0) payable(msg.sender).sendValue(_withdrawAmount);\\n\\n return wBurnAmount;\\n }\\n\\n /**\\n * @notice open a new vault\\n * @dev create a new vault and bind it with a new short vault id\\n * @param _recipient owner of new vault\\n * @return id of the new vault\\n * @return new in-memory vault\\n */\\n function _openVault(address _recipient) internal returns (uint256, VaultLib.Vault memory) {\\n uint256 vaultId = IShortPowerPerp(shortPowerPerp).mintNFT(_recipient);\\n\\n VaultLib.Vault memory vault = VaultLib.Vault({\\n NftCollateralId: 0,\\n collateralAmount: 0,\\n shortAmount: 0,\\n operator: address(0)\\n });\\n emit OpenVault(msg.sender, vaultId);\\n return (vaultId, vault);\\n }\\n\\n /**\\n * @notice deposit uniswap v3 position token into a vault\\n * @dev this function will update the vault memory in-place\\n * @param _vault the Vault memory to update\\n * @param _account account to transfer the uniswap v3 position from\\n * @param _vaultId id of the vault\\n * @param _uniTokenId uniswap position token id\\n */\\n function _depositUniPositionToken(\\n VaultLib.Vault memory _vault,\\n address _account,\\n uint256 _vaultId,\\n uint256 _uniTokenId\\n ) internal {\\n //get tokens for uniswap NFT\\n (, , address token0, address token1, uint24 fee, , , uint128 liquidity, , , , ) = INonfungiblePositionManager(\\n uniswapPositionManager\\n ).positions(_uniTokenId);\\n\\n // require that liquidity is above 0\\n require(liquidity > 0, \\\"C25\\\");\\n // accept NFTs from only the wPowerPerp pool\\n require(fee == feeTier, \\\"C26\\\");\\n // check token0 and token1\\n require((token0 == wPowerPerp && token1 == weth) || (token1 == wPowerPerp && token0 == weth), \\\"C23\\\");\\n\\n _vault.addUniNftCollateral(_uniTokenId);\\n INonfungiblePositionManager(uniswapPositionManager).safeTransferFrom(_account, address(this), _uniTokenId);\\n emit DepositUniPositionToken(msg.sender, _vaultId, _uniTokenId);\\n }\\n\\n /**\\n * @notice add eth collateral into a vault\\n * @dev this function will update the vault memory in-place\\n * @param _vault the Vault memory to update.\\n * @param _vaultId id of the vault\\n * @param _amount amount of eth adding to the vault\\n */\\n function _addEthCollateral(\\n VaultLib.Vault memory _vault,\\n uint256 _vaultId,\\n uint256 _amount\\n ) internal {\\n _vault.addEthCollateral(_amount);\\n emit DepositCollateral(msg.sender, _vaultId, _amount);\\n }\\n\\n /**\\n * @notice remove uniswap v3 position token from the vault\\n * @dev this function will update the vault memory in-place\\n * @param _vault the Vault memory to update\\n * @param _account where to send the uni position token to\\n * @param _vaultId id of the vault\\n */\\n function _withdrawUniPositionToken(\\n VaultLib.Vault memory _vault,\\n address _account,\\n uint256 _vaultId\\n ) internal {\\n uint256 tokenId = _vault.NftCollateralId;\\n _vault.removeUniNftCollateral();\\n INonfungiblePositionManager(uniswapPositionManager).safeTransferFrom(address(this), _account, tokenId);\\n emit WithdrawUniPositionToken(msg.sender, _vaultId, tokenId);\\n }\\n\\n /**\\n * @notice remove eth collateral from the vault\\n * @dev this function will update the vault memory in-place\\n * @param _vault the Vault memory to update\\n * @param _vaultId id of the vault\\n * @param _amount amount of eth to withdraw\\n */\\n function _withdrawCollateral(\\n VaultLib.Vault memory _vault,\\n uint256 _vaultId,\\n uint256 _amount\\n ) internal {\\n _vault.removeEthCollateral(_amount);\\n\\n emit WithdrawCollateral(msg.sender, _vaultId, _amount);\\n }\\n\\n /**\\n * @notice mint wPowerPerp (ERC20) to an account\\n * @dev this function will update the vault memory in-place\\n * @param _vault the Vault memory to update\\n * @param _account account to receive wPowerPerp\\n * @param _vaultId id of the vault\\n * @param _wPowerPerpAmount wPowerPerp amount to mint\\n */\\n function _mintWPowerPerp(\\n VaultLib.Vault memory _vault,\\n address _account,\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount\\n ) internal {\\n _vault.addShort(_wPowerPerpAmount);\\n IWPowerPerp(wPowerPerp).mint(_account, _wPowerPerpAmount);\\n\\n emit MintShort(msg.sender, _wPowerPerpAmount, _vaultId);\\n }\\n\\n /**\\n * @notice burn wPowerPerp (ERC20) from an account\\n * @dev this function will update the vault memory in-place\\n * @param _vault the Vault memory to update\\n * @param _account account burning the wPowerPerp\\n * @param _vaultId id of the vault\\n * @param _wPowerPerpAmount wPowerPerp amount to burn\\n */\\n function _burnWPowerPerp(\\n VaultLib.Vault memory _vault,\\n address _account,\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount\\n ) internal {\\n _vault.removeShort(_wPowerPerpAmount);\\n IWPowerPerp(wPowerPerp).burn(_account, _wPowerPerpAmount);\\n\\n emit BurnShort(msg.sender, _wPowerPerpAmount, _vaultId);\\n }\\n\\n /**\\n * @notice liquidate a vault, pay the liquidator\\n * @dev liquidator can only liquidate at most 1/2 of the vault in 1 transaction\\n * @dev this function will update the vault memory in-place\\n * @param _vault the Vault memory to update\\n * @param _maxWPowerPerpAmount maximum debt amount liquidator is willing to repay\\n * @param _normalizationFactor current normalization factor\\n * @param _liquidator liquidator address to receive eth\\n * @return debtAmount amount of wPowerPerp repaid (burn from the vault)\\n * @return collateralToPay amount of collateral paid to liquidator\\n */\\n function _liquidate(\\n VaultLib.Vault memory _vault,\\n uint256 _maxWPowerPerpAmount,\\n uint256 _normalizationFactor,\\n address _liquidator\\n ) internal returns (uint256, uint256) {\\n (uint256 liquidateAmount, uint256 collateralToPay) = _getLiquidationResult(\\n _maxWPowerPerpAmount,\\n uint256(_vault.shortAmount),\\n uint256(_vault.collateralAmount)\\n );\\n\\n // if the liquidator didn't specify enough wPowerPerp to burn, revert.\\n require(_maxWPowerPerpAmount >= liquidateAmount, \\\"C21\\\");\\n\\n IWPowerPerp(wPowerPerp).burn(_liquidator, liquidateAmount);\\n _vault.removeShort(liquidateAmount);\\n _vault.removeEthCollateral(collateralToPay);\\n\\n (, bool isDust) = _getVaultStatus(_vault, _normalizationFactor);\\n require(!isDust, \\\"C22\\\");\\n\\n return (liquidateAmount, collateralToPay);\\n }\\n\\n /**\\n * @notice redeem uniswap v3 position in a vault for its constituent eth and wPowerPerp\\n * @notice this will increase vault collateral by the amount of eth, and decrease debt by the amount of wPowerPerp\\n * @dev will be executed before liquidation if there's an NFT in the vault\\n * @dev pays a 2% bounty to the liquidator if called by liquidate()\\n * @dev will update the vault memory in-place\\n * @param _vault the Vault memory to update\\n * @param _owner account to send any excess\\n * @param _vaultId id of the vault to reduce debt on\\n * @param _payBounty true if paying caller 2% bounty\\n * @return bounty amount of bounty paid for liquidator\\n */\\n function _reduceDebt(\\n VaultLib.Vault memory _vault,\\n address _owner,\\n uint256 _vaultId,\\n bool _payBounty\\n ) internal returns (uint256) {\\n uint256 nftId = _vault.NftCollateralId;\\n if (nftId == 0) return 0;\\n\\n (uint256 withdrawnEthAmount, uint256 withdrawnWPowerPerpAmount) = _redeemUniToken(nftId);\\n\\n // change weth back to eth\\n if (withdrawnEthAmount > 0) IWETH9(weth).withdraw(withdrawnEthAmount);\\n\\n (uint256 burnAmount, uint256 excess, uint256 bounty) = _getReduceDebtResultInVault(\\n _vault,\\n withdrawnEthAmount,\\n withdrawnWPowerPerpAmount,\\n _payBounty\\n );\\n\\n if (excess > 0) IWPowerPerp(wPowerPerp).transfer(_owner, excess);\\n if (burnAmount > 0) IWPowerPerp(wPowerPerp).burn(address(this), burnAmount);\\n\\n emit ReduceDebt(\\n msg.sender,\\n _vaultId,\\n withdrawnEthAmount,\\n withdrawnWPowerPerpAmount,\\n burnAmount,\\n excess,\\n bounty\\n );\\n\\n return bounty;\\n }\\n\\n /**\\n * @notice pay fee recipient\\n * @dev pay in eth from either the vault or the deposit amount\\n * @param _vault the Vault memory to update\\n * @param _wPowerPerpAmount the amount of wPowerPerpAmount minting\\n * @param _depositAmount the amount of eth depositing or withdrawing\\n * @return the amount of actual deposited eth into the vault, this is less than the original amount if a fee was taken\\n */\\n function _getFee(\\n VaultLib.Vault memory _vault,\\n uint256 _wPowerPerpAmount,\\n uint256 _depositAmount\\n ) internal view returns (uint256, uint256) {\\n uint256 cachedFeeRate = feeRate;\\n if (cachedFeeRate == 0) return (uint256(0), _depositAmount);\\n uint256 depositAmountAfterFee;\\n uint256 ethEquivalentMinted = Power2Base._getDebtValueInEth(\\n _wPowerPerpAmount,\\n oracle,\\n wPowerPerpPool,\\n wPowerPerp,\\n weth\\n );\\n uint256 feeAmount = ethEquivalentMinted.mul(cachedFeeRate).div(10000);\\n\\n // if fee can be paid from deposited collateral, pay from _depositAmount\\n if (_depositAmount > feeAmount) {\\n depositAmountAfterFee = _depositAmount.sub(feeAmount);\\n // if not, adjust the vault to pay from the vault collateral\\n } else {\\n _vault.removeEthCollateral(feeAmount);\\n depositAmountAfterFee = _depositAmount;\\n }\\n //return the fee and deposit amount, which has only been reduced by a fee if it is paid out of the deposit amount\\n return (feeAmount, depositAmountAfterFee);\\n }\\n\\n /**\\n * @notice write vault to storage\\n * @dev writes to vaults mapping\\n */\\n function _writeVault(uint256 _vaultId, VaultLib.Vault memory _vault) private {\\n vaults[_vaultId] = _vault;\\n }\\n\\n /**\\n * @dev redeem a uni position token and get back wPowerPerp and eth\\n * @param _uniTokenId uniswap v3 position token id\\n * @return wethAmount amount of weth withdrawn from uniswap\\n * @return wPowerPerpAmount amount of wPowerPerp withdrawn from uniswap\\n */\\n function _redeemUniToken(uint256 _uniTokenId) internal returns (uint256, uint256) {\\n INonfungiblePositionManager positionManager = INonfungiblePositionManager(uniswapPositionManager);\\n\\n (, , uint128 liquidity, , ) = VaultLib._getUniswapPositionInfo(uniswapPositionManager, _uniTokenId);\\n\\n // prepare parameters to withdraw liquidity from uniswap v3 position manager\\n INonfungiblePositionManager.DecreaseLiquidityParams memory decreaseParams = INonfungiblePositionManager\\n .DecreaseLiquidityParams({\\n tokenId: _uniTokenId,\\n liquidity: liquidity,\\n amount0Min: 0,\\n amount1Min: 0,\\n deadline: block.timestamp\\n });\\n\\n positionManager.decreaseLiquidity(decreaseParams);\\n\\n // withdraw max amount of weth and wPowerPerp from uniswap\\n INonfungiblePositionManager.CollectParams memory collectParams = INonfungiblePositionManager.CollectParams({\\n tokenId: _uniTokenId,\\n recipient: address(this),\\n amount0Max: uint128(-1),\\n amount1Max: uint128(-1)\\n });\\n\\n (uint256 collectedToken0, uint256 collectedToken1) = positionManager.collect(collectParams);\\n\\n return isWethToken0 ? (collectedToken0, collectedToken1) : (collectedToken1, collectedToken0);\\n }\\n\\n /**\\n * @notice update the normalization factor as a way to pay in-kind funding\\n * @dev the normalization factor scales amount of debt that must be repaid, effecting an interest rate paid between long and short positions\\n * @return new normalization factor\\n **/\\n function _applyFunding() internal returns (uint256) {\\n // only update the norm factor once per block\\n if (lastFundingUpdateTimestamp == block.timestamp) return normalizationFactor;\\n\\n uint256 newNormalizationFactor = _getNewNormalizationFactor();\\n\\n emit NormalizationFactorUpdated(\\n normalizationFactor,\\n newNormalizationFactor,\\n lastFundingUpdateTimestamp,\\n block.timestamp\\n );\\n\\n // the following will be batch into 1 SSTORE because of type uint128\\n normalizationFactor = newNormalizationFactor.toUint128();\\n lastFundingUpdateTimestamp = block.timestamp.toUint128();\\n\\n return newNormalizationFactor;\\n }\\n\\n /**\\n * @dev calculate new normalization factor base on the current timestamp\\n * @return new normalization factor if funding happens in the current block\\n */\\n function _getNewNormalizationFactor() internal view returns (uint256) {\\n uint32 period = block.timestamp.sub(lastFundingUpdateTimestamp).toUint32();\\n\\n if (period == 0) {\\n return normalizationFactor;\\n }\\n\\n // make sure we use the same period for mark and index\\n uint32 periodForOracle = _getConsistentPeriodForOracle(period);\\n\\n // avoid reading normalizationFactor from storage multiple times\\n uint256 cacheNormFactor = normalizationFactor;\\n\\n uint256 mark = Power2Base._getDenormalizedMark(\\n periodForOracle,\\n oracle,\\n wPowerPerpPool,\\n ethQuoteCurrencyPool,\\n weth,\\n quoteCurrency,\\n wPowerPerp,\\n cacheNormFactor\\n );\\n uint256 index = Power2Base._getIndex(periodForOracle, oracle, ethQuoteCurrencyPool, weth, quoteCurrency);\\n\\n //the fraction of the funding period. used to compound the funding rate\\n int128 rFunding = ABDKMath64x64.divu(period, FUNDING_PERIOD);\\n\\n // floor mark to be at least LOWER_MARK_RATIO of index\\n uint256 lowerBound = index.mul(LOWER_MARK_RATIO).div(ONE);\\n if (mark < lowerBound) {\\n mark = lowerBound;\\n } else {\\n // cap mark to be at most UPPER_MARK_RATIO of index\\n uint256 upperBound = index.mul(UPPER_MARK_RATIO).div(ONE);\\n if (mark > upperBound) mark = upperBound;\\n }\\n\\n // normFactor(new) = multiplier * normFactor(old)\\n // multiplier = (index/mark)^rFunding\\n // x^r = n^(log_n(x) * r)\\n // multiplier = 2^( log2(index/mark) * rFunding )\\n\\n int128 base = ABDKMath64x64.divu(index, mark);\\n int128 logTerm = ABDKMath64x64.log_2(base).mul(rFunding);\\n int128 multiplier = logTerm.exp_2();\\n return multiplier.mulu(cacheNormFactor);\\n }\\n\\n /**\\n * @notice check if vault has enough collateral and is not a dust vault\\n * @dev revert if vault has insufficient collateral or is a dust vault\\n * @param _vault the Vault memory to update\\n * @param _normalizationFactor normalization factor\\n */\\n function _checkVault(VaultLib.Vault memory _vault, uint256 _normalizationFactor) internal view {\\n (bool isSafe, bool isDust) = _getVaultStatus(_vault, _normalizationFactor);\\n require(isSafe, \\\"C24\\\");\\n require(!isDust, \\\"C22\\\");\\n }\\n\\n /**\\n * @notice check that the vault has enough collateral\\n * @param _vault in-memory vault\\n * @param _normalizationFactor normalization factor\\n * @return true if the vault is properly collateralized\\n */\\n function _isVaultSafe(VaultLib.Vault memory _vault, uint256 _normalizationFactor) internal view returns (bool) {\\n (bool isSafe, ) = _getVaultStatus(_vault, _normalizationFactor);\\n return isSafe;\\n }\\n\\n /**\\n * @notice return if the vault is properly collateralized and if it is a dust vault\\n * @param _vault the Vault memory to update\\n * @param _normalizationFactor normalization factor\\n * @return true if the vault is safe\\n * @return true if the vault is a dust vault\\n */\\n function _getVaultStatus(VaultLib.Vault memory _vault, uint256 _normalizationFactor)\\n internal\\n view\\n returns (bool, bool)\\n {\\n uint256 scaledEthPrice = Power2Base._getScaledTwap(\\n oracle,\\n ethQuoteCurrencyPool,\\n weth,\\n quoteCurrency,\\n TWAP_PERIOD,\\n true // do not call more than maximum period so it does not revert\\n );\\n return\\n VaultLib.getVaultStatus(\\n _vault,\\n uniswapPositionManager,\\n _normalizationFactor,\\n scaledEthPrice,\\n MIN_COLLATERAL,\\n IOracle(oracle).getTimeWeightedAverageTickSafe(wPowerPerpPool, TWAP_PERIOD),\\n isWethToken0\\n );\\n }\\n\\n /**\\n * @notice get the expected excess, burnAmount and bounty if Uniswap position token got burned\\n * @dev this function will update the vault memory in-place\\n * @return burnAmount amount of wPowerPerp that should be burned\\n * @return wPowerPerpExcess amount of wPowerPerp that should be send to the vault owner\\n * @return bounty amount of bounty should be paid out to caller\\n */\\n function _getReduceDebtResultInVault(\\n VaultLib.Vault memory _vault,\\n uint256 nftEthAmount,\\n uint256 nftWPowerperpAmount,\\n bool _payBounty\\n )\\n internal\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256\\n )\\n {\\n uint256 bounty;\\n if (_payBounty) bounty = _getReduceDebtBounty(nftEthAmount, nftWPowerperpAmount);\\n\\n uint256 burnAmount = nftWPowerperpAmount;\\n uint256 wPowerPerpExcess;\\n\\n if (nftWPowerperpAmount > _vault.shortAmount) {\\n wPowerPerpExcess = nftWPowerperpAmount.sub(_vault.shortAmount);\\n burnAmount = _vault.shortAmount;\\n }\\n\\n _vault.removeShort(burnAmount);\\n _vault.removeUniNftCollateral();\\n _vault.addEthCollateral(nftEthAmount);\\n _vault.removeEthCollateral(bounty);\\n\\n return (burnAmount, wPowerPerpExcess, bounty);\\n }\\n\\n /**\\n * @notice get how much bounty you can get by helping a vault reducing the debt.\\n * @dev bounty is 2% of the total value of the position token\\n * @param _ethWithdrawn amount of eth withdrawn from uniswap by redeeming the position token\\n * @param _wPowerPerpReduced amount of wPowerPerp withdrawn from uniswap by redeeming the position token\\n */\\n function _getReduceDebtBounty(uint256 _ethWithdrawn, uint256 _wPowerPerpReduced) internal view returns (uint256) {\\n return\\n Power2Base\\n ._getDebtValueInEth(_wPowerPerpReduced, oracle, wPowerPerpPool, wPowerPerp, weth)\\n .add(_ethWithdrawn)\\n .mul(REDUCE_DEBT_BOUNTY)\\n .div(ONE);\\n }\\n\\n /**\\n * @notice get the expected wPowerPerp needed to liquidate a vault.\\n * @dev a liquidator cannot liquidate more than half of a vault, unless only liquidating half of the debt will make the vault a \\\"dust vault\\\"\\n * @dev a liquidator cannot take out more collateral than the vault holds\\n * @param _maxWPowerPerpAmount the max amount of wPowerPerp willing to pay\\n * @param _vaultShortAmount the amount of short in the vault\\n * @param _maxWPowerPerpAmount the amount of collateral in the vault\\n * @return finalLiquidateAmount the amount that should be liquidated. This amount can be higher than _maxWPowerPerpAmount, which should be checked\\n * @return collateralToPay final amount of collateral paying out to the liquidator\\n */\\n function _getLiquidationResult(\\n uint256 _maxWPowerPerpAmount,\\n uint256 _vaultShortAmount,\\n uint256 _vaultCollateralAmount\\n ) internal view returns (uint256, uint256) {\\n // try limiting liquidation amount to half of the vault debt\\n (uint256 finalLiquidateAmount, uint256 collateralToPay) = _getSingleLiquidationAmount(\\n _maxWPowerPerpAmount,\\n _vaultShortAmount.div(2)\\n );\\n\\n if (_vaultCollateralAmount > collateralToPay) {\\n if (_vaultCollateralAmount.sub(collateralToPay) < MIN_COLLATERAL) {\\n // the vault is left with dust after liquidation, allow liquidating full vault\\n // calculate the new liquidation amount and collateral again based on the new limit\\n (finalLiquidateAmount, collateralToPay) = _getSingleLiquidationAmount(\\n _maxWPowerPerpAmount,\\n _vaultShortAmount\\n );\\n }\\n }\\n\\n // check if final collateral to pay is greater than vault amount.\\n // if so the system only pays out the amount the vault has, which may not be profitable\\n if (collateralToPay > _vaultCollateralAmount) {\\n // force liquidator to pay full debt amount\\n finalLiquidateAmount = _vaultShortAmount;\\n collateralToPay = _vaultCollateralAmount;\\n }\\n\\n return (finalLiquidateAmount, collateralToPay);\\n }\\n\\n /**\\n * @notice determine how much wPowerPerp to liquidate, and how much collateral to return\\n * @param _maxInputWAmount maximum wPowerPerp amount liquidator is willing to repay\\n * @param _maxLiquidatableWAmount maximum wPowerPerp amount a liquidator is allowed to repay\\n * @return finalWAmountToLiquidate amount of wPowerPerp the liquidator will burn\\n * @return collateralToPay total collateral the liquidator will get\\n */\\n function _getSingleLiquidationAmount(uint256 _maxInputWAmount, uint256 _maxLiquidatableWAmount)\\n internal\\n view\\n returns (uint256, uint256)\\n {\\n uint256 finalWAmountToLiquidate = _maxInputWAmount > _maxLiquidatableWAmount\\n ? _maxLiquidatableWAmount\\n : _maxInputWAmount;\\n\\n uint256 collateralToPay = Power2Base._getDebtValueInEth(\\n finalWAmountToLiquidate,\\n oracle,\\n wPowerPerpPool,\\n wPowerPerp,\\n weth\\n );\\n\\n // add 10% bonus for liquidators\\n collateralToPay = collateralToPay.add(collateralToPay.mul(LIQUIDATION_BOUNTY).div(ONE));\\n\\n return (finalWAmountToLiquidate, collateralToPay);\\n }\\n\\n /**\\n * @notice get a period can be used to request a twap for 2 uniswap v3 pools\\n * @dev if the period is greater than min(max_pool_1, max_pool_2), return min(max_pool_1, max_pool_2)\\n * @param _period max period that we intend to use\\n * @return fair period not greator than _period to be used for both pools.\\n */\\n function _getConsistentPeriodForOracle(uint32 _period) internal view returns (uint32) {\\n uint32 maxPeriodPool1 = IOracle(oracle).getMaxPeriod(ethQuoteCurrencyPool);\\n uint32 maxPeriodPool2 = IOracle(oracle).getMaxPeriod(wPowerPerpPool);\\n\\n uint32 maxSafePeriod = maxPeriodPool1 > maxPeriodPool2 ? maxPeriodPool2 : maxPeriodPool1;\\n return _period > maxSafePeriod ? maxSafePeriod : _period;\\n }\\n}\\n\",\"keccak256\":\"0xe8124d746e61cf09306b8f3df7afeeb41df84fda4b0d620b257dabd9fbfd94e8\",\"license\":\"BUSL-1.1\"},\"contracts/interfaces/IOracle.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\ninterface IOracle {\\n function getHistoricalTwap(\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _period,\\n uint32 _periodToHistoricPrice\\n ) external view returns (uint256);\\n\\n function getTwap(\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _period,\\n bool _checkPeriod\\n ) external view returns (uint256);\\n\\n function getMaxPeriod(address _pool) external view returns (uint32);\\n\\n function getTimeWeightedAverageTickSafe(address _pool, uint32 _period)\\n external\\n view\\n returns (int24 timeWeightedAverageTick);\\n}\\n\",\"keccak256\":\"0xe4ca0166858146d6aa98ec5d76e432c121299757b9eef14c32990d981d6e81ed\",\"license\":\"MIT\"},\"contracts/interfaces/IShortPowerPerp.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\nimport {IERC721} from \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\n\\ninterface IShortPowerPerp is IERC721 {\\n function nextId() external view returns (uint256);\\n\\n function mintNFT(address recipient) external returns (uint256 _newId);\\n}\\n\",\"keccak256\":\"0xf2d2cb2decac32a199e63f0d5141e46a6e989620944ec5f0144e5aebd0c7989e\",\"license\":\"MIT\"},\"contracts/interfaces/IWETH9.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IWETH9 is IERC20 {\\n function deposit() external payable;\\n\\n function withdraw(uint256 wad) external;\\n}\\n\",\"keccak256\":\"0x8a9a4512f1fc29b14dcf97ca149f263f28de43191a3ee31336f2389e3f2f5f8e\",\"license\":\"MIT\"},\"contracts/interfaces/IWPowerPerp.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IWPowerPerp is IERC20 {\\n function mint(address _account, uint256 _amount) external;\\n\\n function burn(address _account, uint256 _amount) external;\\n}\\n\",\"keccak256\":\"0x873a337fcb47b96ed0714dbc2edbf1d200f529752efb7beb18109c9e6a9d7271\",\"license\":\"MIT\"},\"contracts/libs/ABDKMath64x64.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-4-Clause\\n/*\\n * ABDK Math 64.64 Smart Contract Library. Copyright \\u00a9 2019 by ABDK Consulting.\\n * Author: Mikhail Vladimirov \\n * Copyright (c) 2019, ABDK Consulting\\n *\\n * All rights reserved.\\n *\\n * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\\n *\\n * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\\n * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\\n * All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by ABDK Consulting.\\n * Neither the name of ABDK Consulting nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\\n * THIS SOFTWARE IS PROVIDED BY ABDK CONSULTING ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\\n * IN NO EVENT SHALL ABDK CONSULTING BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\\n */\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * Smart contract library of mathematical functions operating with signed\\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\\n * basically a simple fraction whose numerator is signed 128-bit integer and\\n * denominator is 2^64. As long as denominator is always the same, there is no\\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\\n * represented by int128 type holding only the numerator.\\n *\\n * Commit used - 16d7e1dd8628dfa2f88d5dadab731df7ada70bdd\\n * Copied from - https://github.com/abdk-consulting/abdk-libraries-solidity/tree/v2.4\\n * Changes - some function visibility switched to public, solidity version set to 0.7.x\\n * Changes (cont) - revert strings added\\n * solidity version set to ^0.7.0\\n */\\nlibrary ABDKMath64x64 {\\n /*\\n * Minimum value signed 64.64-bit fixed point number may have.\\n * Minimum value signed 64.64-bit fixed point number may have.\\n * Minimum value signed 64.64-bit fixed point number may have.\\n * -2^127\\n */\\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\\n\\n /*\\n * Maximum value signed 64.64-bit fixed point number may have.\\n * Maximum value signed 64.64-bit fixed point number may have.\\n * Maximum value signed 64.64-bit fixed point number may have.\\n * 2^127-1\\n */\\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\\n\\n /**\\n * Calculate x * y rounding down. Revert on overflow.\\n *\\n * @param x signed 64.64-bit fixed point number\\n * @param y signed 64.64-bit fixed point number\\n * @return signed 64.64-bit fixed point number\\n */\\n function mul(int128 x, int128 y) internal pure returns (int128) {\\n int256 result = (int256(x) * y) >> 64;\\n require(result >= MIN_64x64 && result <= MAX_64x64, \\\"MUL-OVUF\\\");\\n return int128(result);\\n }\\n\\n /**\\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\\n * and y is unsigned 256-bit integer number. Revert on overflow.\\n *\\n * @param x signed 64.64 fixed point number\\n * @param y unsigned 256-bit integer number\\n * @return unsigned 256-bit integer number\\n */\\n function mulu(int128 x, uint256 y) internal pure returns (uint256) {\\n if (y == 0) return 0;\\n\\n require(x >= 0, \\\"MULU-X0\\\");\\n\\n uint256 lo = (uint256(x) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\\n uint256 hi = uint256(x) * (y >> 128);\\n\\n require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, \\\"MULU-OF1\\\");\\n hi <<= 64;\\n\\n require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo, \\\"MULU-OF2\\\");\\n return hi + lo;\\n }\\n\\n /**\\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\\n * integer numbers. Revert on overflow or when y is zero.\\n *\\n * @param x unsigned 256-bit integer number\\n * @param y unsigned 256-bit integer number\\n * @return signed 64.64-bit fixed point number\\n */\\n function divu(uint256 x, uint256 y) public pure returns (int128) {\\n require(y != 0, \\\"DIVU-INF\\\");\\n uint128 result = divuu(x, y);\\n require(result <= uint128(MAX_64x64), \\\"DIVU-OF\\\");\\n return int128(result);\\n }\\n\\n /**\\n * Calculate binary logarithm of x. Revert if x <= 0.\\n *\\n * @param x signed 64.64-bit fixed point number\\n * @return signed 64.64-bit fixed point number\\n */\\n function log_2(int128 x) public pure returns (int128) {\\n require(x > 0, \\\"LOG_2-X0\\\");\\n\\n int256 msb = 0;\\n int256 xc = x;\\n if (xc >= 0x10000000000000000) {\\n xc >>= 64;\\n msb += 64;\\n }\\n if (xc >= 0x100000000) {\\n xc >>= 32;\\n msb += 32;\\n }\\n if (xc >= 0x10000) {\\n xc >>= 16;\\n msb += 16;\\n }\\n if (xc >= 0x100) {\\n xc >>= 8;\\n msb += 8;\\n }\\n if (xc >= 0x10) {\\n xc >>= 4;\\n msb += 4;\\n }\\n if (xc >= 0x4) {\\n xc >>= 2;\\n msb += 2;\\n }\\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\\n\\n int256 result = (msb - 64) << 64;\\n uint256 ux = uint256(x) << uint256(127 - msb);\\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\\n ux *= ux;\\n uint256 b = ux >> 255;\\n ux >>= 127 + b;\\n result += bit * int256(b);\\n }\\n\\n return int128(result);\\n }\\n\\n /**\\n * Calculate binary exponent of x. Revert on overflow.\\n *\\n * @param x signed 64.64-bit fixed point number\\n * @return signed 64.64-bit fixed point number\\n */\\n function exp_2(int128 x) public pure returns (int128) {\\n require(x < 0x400000000000000000, \\\"EXP_2-OF\\\"); // Overflow\\n\\n if (x < -0x400000000000000000) return 0; // Underflow\\n\\n uint256 result = 0x80000000000000000000000000000000;\\n\\n if (x & 0x8000000000000000 > 0) result = (result * 0x16A09E667F3BCC908B2FB1366EA957D3E) >> 128;\\n if (x & 0x4000000000000000 > 0) result = (result * 0x1306FE0A31B7152DE8D5A46305C85EDEC) >> 128;\\n if (x & 0x2000000000000000 > 0) result = (result * 0x1172B83C7D517ADCDF7C8C50EB14A791F) >> 128;\\n if (x & 0x1000000000000000 > 0) result = (result * 0x10B5586CF9890F6298B92B71842A98363) >> 128;\\n if (x & 0x800000000000000 > 0) result = (result * 0x1059B0D31585743AE7C548EB68CA417FD) >> 128;\\n if (x & 0x400000000000000 > 0) result = (result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8) >> 128;\\n if (x & 0x200000000000000 > 0) result = (result * 0x10163DA9FB33356D84A66AE336DCDFA3F) >> 128;\\n if (x & 0x100000000000000 > 0) result = (result * 0x100B1AFA5ABCBED6129AB13EC11DC9543) >> 128;\\n if (x & 0x80000000000000 > 0) result = (result * 0x10058C86DA1C09EA1FF19D294CF2F679B) >> 128;\\n if (x & 0x40000000000000 > 0) result = (result * 0x1002C605E2E8CEC506D21BFC89A23A00F) >> 128;\\n if (x & 0x20000000000000 > 0) result = (result * 0x100162F3904051FA128BCA9C55C31E5DF) >> 128;\\n if (x & 0x10000000000000 > 0) result = (result * 0x1000B175EFFDC76BA38E31671CA939725) >> 128;\\n if (x & 0x8000000000000 > 0) result = (result * 0x100058BA01FB9F96D6CACD4B180917C3D) >> 128;\\n if (x & 0x4000000000000 > 0) result = (result * 0x10002C5CC37DA9491D0985C348C68E7B3) >> 128;\\n if (x & 0x2000000000000 > 0) result = (result * 0x1000162E525EE054754457D5995292026) >> 128;\\n if (x & 0x1000000000000 > 0) result = (result * 0x10000B17255775C040618BF4A4ADE83FC) >> 128;\\n if (x & 0x800000000000 > 0) result = (result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB) >> 128;\\n if (x & 0x400000000000 > 0) result = (result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9) >> 128;\\n if (x & 0x200000000000 > 0) result = (result * 0x10000162E43F4F831060E02D839A9D16D) >> 128;\\n if (x & 0x100000000000 > 0) result = (result * 0x100000B1721BCFC99D9F890EA06911763) >> 128;\\n if (x & 0x80000000000 > 0) result = (result * 0x10000058B90CF1E6D97F9CA14DBCC1628) >> 128;\\n if (x & 0x40000000000 > 0) result = (result * 0x1000002C5C863B73F016468F6BAC5CA2B) >> 128;\\n if (x & 0x20000000000 > 0) result = (result * 0x100000162E430E5A18F6119E3C02282A5) >> 128;\\n if (x & 0x10000000000 > 0) result = (result * 0x1000000B1721835514B86E6D96EFD1BFE) >> 128;\\n if (x & 0x8000000000 > 0) result = (result * 0x100000058B90C0B48C6BE5DF846C5B2EF) >> 128;\\n if (x & 0x4000000000 > 0) result = (result * 0x10000002C5C8601CC6B9E94213C72737A) >> 128;\\n if (x & 0x2000000000 > 0) result = (result * 0x1000000162E42FFF037DF38AA2B219F06) >> 128;\\n if (x & 0x1000000000 > 0) result = (result * 0x10000000B17217FBA9C739AA5819F44F9) >> 128;\\n if (x & 0x800000000 > 0) result = (result * 0x1000000058B90BFCDEE5ACD3C1CEDC823) >> 128;\\n if (x & 0x400000000 > 0) result = (result * 0x100000002C5C85FE31F35A6A30DA1BE50) >> 128;\\n if (x & 0x200000000 > 0) result = (result * 0x10000000162E42FF0999CE3541B9FFFCF) >> 128;\\n if (x & 0x100000000 > 0) result = (result * 0x100000000B17217F80F4EF5AADDA45554) >> 128;\\n if (x & 0x80000000 > 0) result = (result * 0x10000000058B90BFBF8479BD5A81B51AD) >> 128;\\n if (x & 0x40000000 > 0) result = (result * 0x1000000002C5C85FDF84BD62AE30A74CC) >> 128;\\n if (x & 0x20000000 > 0) result = (result * 0x100000000162E42FEFB2FED257559BDAA) >> 128;\\n if (x & 0x10000000 > 0) result = (result * 0x1000000000B17217F7D5A7716BBA4A9AE) >> 128;\\n if (x & 0x8000000 > 0) result = (result * 0x100000000058B90BFBE9DDBAC5E109CCE) >> 128;\\n if (x & 0x4000000 > 0) result = (result * 0x10000000002C5C85FDF4B15DE6F17EB0D) >> 128;\\n if (x & 0x2000000 > 0) result = (result * 0x1000000000162E42FEFA494F1478FDE05) >> 128;\\n if (x & 0x1000000 > 0) result = (result * 0x10000000000B17217F7D20CF927C8E94C) >> 128;\\n if (x & 0x800000 > 0) result = (result * 0x1000000000058B90BFBE8F71CB4E4B33D) >> 128;\\n if (x & 0x400000 > 0) result = (result * 0x100000000002C5C85FDF477B662B26945) >> 128;\\n if (x & 0x200000 > 0) result = (result * 0x10000000000162E42FEFA3AE53369388C) >> 128;\\n if (x & 0x100000 > 0) result = (result * 0x100000000000B17217F7D1D351A389D40) >> 128;\\n if (x & 0x80000 > 0) result = (result * 0x10000000000058B90BFBE8E8B2D3D4EDE) >> 128;\\n if (x & 0x40000 > 0) result = (result * 0x1000000000002C5C85FDF4741BEA6E77E) >> 128;\\n if (x & 0x20000 > 0) result = (result * 0x100000000000162E42FEFA39FE95583C2) >> 128;\\n if (x & 0x10000 > 0) result = (result * 0x1000000000000B17217F7D1CFB72B45E1) >> 128;\\n if (x & 0x8000 > 0) result = (result * 0x100000000000058B90BFBE8E7CC35C3F0) >> 128;\\n if (x & 0x4000 > 0) result = (result * 0x10000000000002C5C85FDF473E242EA38) >> 128;\\n if (x & 0x2000 > 0) result = (result * 0x1000000000000162E42FEFA39F02B772C) >> 128;\\n if (x & 0x1000 > 0) result = (result * 0x10000000000000B17217F7D1CF7D83C1A) >> 128;\\n if (x & 0x800 > 0) result = (result * 0x1000000000000058B90BFBE8E7BDCBE2E) >> 128;\\n if (x & 0x400 > 0) result = (result * 0x100000000000002C5C85FDF473DEA871F) >> 128;\\n if (x & 0x200 > 0) result = (result * 0x10000000000000162E42FEFA39EF44D91) >> 128;\\n if (x & 0x100 > 0) result = (result * 0x100000000000000B17217F7D1CF79E949) >> 128;\\n if (x & 0x80 > 0) result = (result * 0x10000000000000058B90BFBE8E7BCE544) >> 128;\\n if (x & 0x40 > 0) result = (result * 0x1000000000000002C5C85FDF473DE6ECA) >> 128;\\n if (x & 0x20 > 0) result = (result * 0x100000000000000162E42FEFA39EF366F) >> 128;\\n if (x & 0x10 > 0) result = (result * 0x1000000000000000B17217F7D1CF79AFA) >> 128;\\n if (x & 0x8 > 0) result = (result * 0x100000000000000058B90BFBE8E7BCD6D) >> 128;\\n if (x & 0x4 > 0) result = (result * 0x10000000000000002C5C85FDF473DE6B2) >> 128;\\n if (x & 0x2 > 0) result = (result * 0x1000000000000000162E42FEFA39EF358) >> 128;\\n if (x & 0x1 > 0) result = (result * 0x10000000000000000B17217F7D1CF79AB) >> 128;\\n\\n result >>= uint256(63 - (x >> 64));\\n require(result <= uint256(MAX_64x64));\\n\\n return int128(result);\\n }\\n\\n /**\\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\\n * integer numbers. Revert on overflow or when y is zero.\\n *\\n * @param x unsigned 256-bit integer number\\n * @param y unsigned 256-bit integer number\\n * @return unsigned 64.64-bit fixed point number\\n */\\n function divuu(uint256 x, uint256 y) private pure returns (uint128) {\\n require(y != 0);\\n\\n uint256 result;\\n\\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) result = (x << 64) / y;\\n else {\\n uint256 msb = 192;\\n uint256 xc = x >> 192;\\n if (xc >= 0x100000000) {\\n xc >>= 32;\\n msb += 32;\\n }\\n if (xc >= 0x10000) {\\n xc >>= 16;\\n msb += 16;\\n }\\n if (xc >= 0x100) {\\n xc >>= 8;\\n msb += 8;\\n }\\n if (xc >= 0x10) {\\n xc >>= 4;\\n msb += 4;\\n }\\n if (xc >= 0x4) {\\n xc >>= 2;\\n msb += 2;\\n }\\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\\n\\n result = (x << (255 - msb)) / (((y - 1) >> (msb - 191)) + 1);\\n require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, \\\"DIVUU-OF1\\\");\\n\\n uint256 hi = result * (y >> 128);\\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\\n\\n uint256 xh = x >> 192;\\n uint256 xl = x << 64;\\n\\n if (xl < lo) xh -= 1;\\n xl -= lo; // We rely on overflow behavior here\\n lo = hi << 128;\\n if (xl < lo) xh -= 1;\\n xl -= lo; // We rely on overflow behavior here\\n\\n assert(xh == hi >> 128);\\n\\n result += xl / y;\\n }\\n\\n require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, \\\"DIVUU-OF2\\\");\\n return uint128(result);\\n }\\n}\\n\",\"keccak256\":\"0x56efa7c16e4fffb37ad80af15bd042d9f92532a4553d6b12915e3fa21609ad66\",\"license\":\"BSD-4-Clause\"},\"contracts/libs/Power2Base.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\n\\npragma solidity =0.7.6;\\n\\n//interface\\nimport {IOracle} from \\\"../interfaces/IOracle.sol\\\";\\n\\n//lib\\nimport {SafeMath} from \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\n\\nlibrary Power2Base {\\n using SafeMath for uint256;\\n\\n uint32 private constant TWAP_PERIOD = 420 seconds;\\n uint256 private constant INDEX_SCALE = 1e4;\\n uint256 private constant ONE = 1e18;\\n uint256 private constant ONE_ONE = 1e36;\\n\\n /**\\n * @notice return the scaled down index of the power perp in USD, scaled by 18 decimals\\n * @param _period period of time for the twap in seconds (cannot be longer than maximum period for the pool)\\n * @param _oracle oracle address\\n * @param _ethQuoteCurrencyPool uniswap v3 pool for weth / quoteCurrency\\n * @param _weth weth address\\n * @param _quoteCurrency quoteCurrency address\\n * @return for squeeth, return ethPrice^2\\n */\\n function _getIndex(\\n uint32 _period,\\n address _oracle,\\n address _ethQuoteCurrencyPool,\\n address _weth,\\n address _quoteCurrency\\n ) internal view returns (uint256) {\\n uint256 ethQuoteCurrencyPrice = _getScaledTwap(\\n _oracle,\\n _ethQuoteCurrencyPool,\\n _weth,\\n _quoteCurrency,\\n _period,\\n false\\n );\\n return ethQuoteCurrencyPrice.mul(ethQuoteCurrencyPrice).div(ONE);\\n }\\n\\n /**\\n * @notice return the unscaled index of the power perp in USD, scaled by 18 decimals\\n * @param _period period of time for the twap in seconds (cannot be longer than maximum period for the pool)\\n * @param _oracle oracle address\\n * @param _ethQuoteCurrencyPool uniswap v3 pool for weth / quoteCurrency\\n * @param _weth weth address\\n * @param _quoteCurrency quoteCurrency address\\n * @return for squeeth, return ethPrice^2\\n */\\n function _getUnscaledIndex(\\n uint32 _period,\\n address _oracle,\\n address _ethQuoteCurrencyPool,\\n address _weth,\\n address _quoteCurrency\\n ) internal view returns (uint256) {\\n uint256 ethQuoteCurrencyPrice = _getTwap(_oracle, _ethQuoteCurrencyPool, _weth, _quoteCurrency, _period, false);\\n return ethQuoteCurrencyPrice.mul(ethQuoteCurrencyPrice).div(ONE);\\n }\\n\\n /**\\n * @notice return the mark price of power perp in quoteCurrency, scaled by 18 decimals\\n * @param _period period of time for the twap in seconds (cannot be longer than maximum period for the pool)\\n * @param _oracle oracle address\\n * @param _wSqueethEthPool uniswap v3 pool for wSqueeth / weth\\n * @param _ethQuoteCurrencyPool uniswap v3 pool for weth / quoteCurrency\\n * @param _weth weth address\\n * @param _quoteCurrency quoteCurrency address\\n * @param _wSqueeth wSqueeth address\\n * @param _normalizationFactor current normalization factor\\n * @return for squeeth, return ethPrice * squeethPriceInEth\\n */\\n function _getDenormalizedMark(\\n uint32 _period,\\n address _oracle,\\n address _wSqueethEthPool,\\n address _ethQuoteCurrencyPool,\\n address _weth,\\n address _quoteCurrency,\\n address _wSqueeth,\\n uint256 _normalizationFactor\\n ) internal view returns (uint256) {\\n uint256 ethQuoteCurrencyPrice = _getScaledTwap(\\n _oracle,\\n _ethQuoteCurrencyPool,\\n _weth,\\n _quoteCurrency,\\n _period,\\n false\\n );\\n uint256 wsqueethEthPrice = _getTwap(_oracle, _wSqueethEthPool, _wSqueeth, _weth, _period, false);\\n\\n return wsqueethEthPrice.mul(ethQuoteCurrencyPrice).div(_normalizationFactor);\\n }\\n\\n /**\\n * @notice get the fair collateral value for a _debtAmount of wSqueeth\\n * @dev the actual amount liquidator can get should have a 10% bonus on top of this value.\\n * @param _debtAmount wSqueeth amount paid by liquidator\\n * @param _oracle oracle address\\n * @param _wSqueethEthPool uniswap v3 pool for wSqueeth / weth\\n * @param _wSqueeth wSqueeth address\\n * @param _weth weth address\\n * @return returns value of debt in ETH\\n */\\n function _getDebtValueInEth(\\n uint256 _debtAmount,\\n address _oracle,\\n address _wSqueethEthPool,\\n address _wSqueeth,\\n address _weth\\n ) internal view returns (uint256) {\\n uint256 wSqueethPrice = _getTwap(_oracle, _wSqueethEthPool, _wSqueeth, _weth, TWAP_PERIOD, false);\\n return _debtAmount.mul(wSqueethPrice).div(ONE);\\n }\\n\\n /**\\n * @notice request twap from our oracle, scaled down by INDEX_SCALE\\n * @param _oracle oracle address\\n * @param _pool uniswap v3 pool address\\n * @param _base base currency. to get eth/usd price, eth is base token\\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\\n * @param _period number of seconds in the past to start calculating time-weighted average.\\n * @param _checkPeriod check that period is not longer than maximum period for the pool to prevent reverts\\n * @return twap price scaled down by INDEX_SCALE\\n */\\n function _getScaledTwap(\\n address _oracle,\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _period,\\n bool _checkPeriod\\n ) internal view returns (uint256) {\\n uint256 twap = _getTwap(_oracle, _pool, _base, _quote, _period, _checkPeriod);\\n return twap.div(INDEX_SCALE);\\n }\\n\\n /**\\n * @notice request twap from our oracle\\n * @dev this will revert if period is > max period for the pool\\n * @param _oracle oracle address\\n * @param _pool uniswap v3 pool address\\n * @param _base base currency. to get eth/quoteCurrency price, eth is base token\\n * @param _quote quote currency. to get eth/quoteCurrency price, quoteCurrency is the quote currency\\n * @param _period number of seconds in the past to start calculating time-weighted average\\n * @param _checkPeriod check that period is not longer than maximum period for the pool to prevent reverts\\n * @return human readable price. scaled by 1e18\\n */\\n function _getTwap(\\n address _oracle,\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _period,\\n bool _checkPeriod\\n ) internal view returns (uint256) {\\n // period reaching this point should be check, otherwise might revert\\n return IOracle(_oracle).getTwap(_pool, _base, _quote, _period, _checkPeriod);\\n }\\n\\n /**\\n * @notice get the index value of wsqueeth in wei, used when system settles\\n * @dev the index of squeeth is ethPrice^2, so each squeeth will need to pay out {ethPrice} eth\\n * @param _wsqueethAmount amount of wsqueeth used in settlement\\n * @param _indexPriceForSettlement index price for settlement\\n * @param _normalizationFactor current normalization factor\\n * @return amount in wei that should be paid to the token holder\\n */\\n function _getLongSettlementValue(\\n uint256 _wsqueethAmount,\\n uint256 _indexPriceForSettlement,\\n uint256 _normalizationFactor\\n ) internal pure returns (uint256) {\\n return _wsqueethAmount.mul(_normalizationFactor).mul(_indexPriceForSettlement).div(ONE_ONE);\\n }\\n}\\n\",\"keccak256\":\"0x1938180c41ec0ee817b841df605b199e15ffbbe94700b640d031b4e4665a89af\",\"license\":\"GPL-2.0-or-later\"},\"contracts/libs/Uint256Casting.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nlibrary Uint256Casting {\\n /**\\n * @notice cast a uint256 to a uint128, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint128\\n */\\n function toUint128(uint256 y) internal pure returns (uint128 z) {\\n require((z = uint128(y)) == y, \\\"OF128\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint96, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint96\\n */\\n function toUint96(uint256 y) internal pure returns (uint96 z) {\\n require((z = uint96(y)) == y, \\\"OF96\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint32, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint32\\n */\\n function toUint32(uint256 y) internal pure returns (uint32 z) {\\n require((z = uint32(y)) == y, \\\"OF32\\\");\\n }\\n}\\n\",\"keccak256\":\"0xcccbe82f8696be398d0d0f5a44988e9bab70e18dd40c9563620cdf160d8bcd7c\",\"license\":\"MIT\"},\"contracts/libs/VaultLib.sol\":{\"content\":\"//SPDX-License-Identifier: BUSL-1.1\\n\\npragma solidity =0.7.6;\\n\\n//interface\\nimport {INonfungiblePositionManager} from \\\"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\\\";\\n\\n//lib\\nimport {SafeMath} from \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/TickMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/SqrtPriceMath.sol\\\";\\nimport {Uint256Casting} from \\\"./Uint256Casting.sol\\\";\\n\\n/**\\n * Error code:\\n * V1: Vault already had nft\\n * V2: Vault has no NFT\\n */\\nlibrary VaultLib {\\n using SafeMath for uint256;\\n using Uint256Casting for uint256;\\n\\n uint256 constant ONE_ONE = 1e36;\\n\\n // the collateralization ratio (CR) is checked with the numerator and denominator separately\\n // a user is safe if - collateral value >= (COLLAT_RATIO_NUMER/COLLAT_RATIO_DENOM)* debt value\\n uint256 public constant CR_NUMERATOR = 3;\\n uint256 public constant CR_DENOMINATOR = 2;\\n\\n struct Vault {\\n // the address that can update the vault\\n address operator;\\n // uniswap position token id deposited into the vault as collateral\\n // 2^32 is 4,294,967,296, which means the vault structure will work with up to 4 billion positions\\n uint32 NftCollateralId;\\n // amount of eth (wei) used in the vault as collateral\\n // 2^96 / 1e18 = 79,228,162,514, which means a vault can store up to 79 billion eth\\n // when we need to do calculations, we always cast this number to uint256 to avoid overflow\\n uint96 collateralAmount;\\n // amount of wPowerPerp minted from the vault\\n uint128 shortAmount;\\n }\\n\\n /**\\n * @notice add eth collateral to a vault\\n * @param _vault in-memory vault\\n * @param _amount amount of eth to add\\n */\\n function addEthCollateral(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.collateralAmount = uint256(_vault.collateralAmount).add(_amount).toUint96();\\n }\\n\\n /**\\n * @notice add uniswap position token collateral to a vault\\n * @param _vault in-memory vault\\n * @param _tokenId uniswap position token id\\n */\\n function addUniNftCollateral(Vault memory _vault, uint256 _tokenId) internal pure {\\n require(_vault.NftCollateralId == 0, \\\"V1\\\");\\n require(_tokenId != 0, \\\"C23\\\");\\n _vault.NftCollateralId = _tokenId.toUint32();\\n }\\n\\n /**\\n * @notice remove eth collateral from a vault\\n * @param _vault in-memory vault\\n * @param _amount amount of eth to remove\\n */\\n function removeEthCollateral(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.collateralAmount = uint256(_vault.collateralAmount).sub(_amount).toUint96();\\n }\\n\\n /**\\n * @notice remove uniswap position token collateral from a vault\\n * @param _vault in-memory vault\\n */\\n function removeUniNftCollateral(Vault memory _vault) internal pure {\\n require(_vault.NftCollateralId != 0, \\\"V2\\\");\\n _vault.NftCollateralId = 0;\\n }\\n\\n /**\\n * @notice add debt to vault\\n * @param _vault in-memory vault\\n * @param _amount amount of debt to add\\n */\\n function addShort(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.shortAmount = uint256(_vault.shortAmount).add(_amount).toUint128();\\n }\\n\\n /**\\n * @notice remove debt from vault\\n * @param _vault in-memory vault\\n * @param _amount amount of debt to remove\\n */\\n function removeShort(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.shortAmount = uint256(_vault.shortAmount).sub(_amount).toUint128();\\n }\\n\\n /**\\n * @notice check if a vault is properly collateralized\\n * @param _vault the vault we want to check\\n * @param _positionManager address of the uniswap position manager\\n * @param _normalizationFactor current _normalizationFactor\\n * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18\\n * @param _minCollateral minimum collateral that needs to be in a vault\\n * @param _wsqueethPoolTick current price tick for wsqueeth pool\\n * @param _isWethToken0 whether weth is token0 in the wsqueeth pool\\n * @return true if the vault is sufficiently collateralized\\n * @return true if the vault is considered as a dust vault\\n */\\n function getVaultStatus(\\n Vault memory _vault,\\n address _positionManager,\\n uint256 _normalizationFactor,\\n uint256 _ethQuoteCurrencyPrice,\\n uint256 _minCollateral,\\n int24 _wsqueethPoolTick,\\n bool _isWethToken0\\n ) internal view returns (bool, bool) {\\n if (_vault.shortAmount == 0) return (true, false);\\n\\n uint256 debtValueInETH = uint256(_vault.shortAmount).mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div(\\n ONE_ONE\\n );\\n uint256 totalCollateral = _getEffectiveCollateral(\\n _vault,\\n _positionManager,\\n _normalizationFactor,\\n _ethQuoteCurrencyPrice,\\n _wsqueethPoolTick,\\n _isWethToken0\\n );\\n\\n bool isDust = totalCollateral < _minCollateral;\\n bool isAboveWater = totalCollateral.mul(CR_DENOMINATOR) >= debtValueInETH.mul(CR_NUMERATOR);\\n return (isAboveWater, isDust);\\n }\\n\\n /**\\n * @notice get the total effective collateral of a vault, which is:\\n * collateral amount + uniswap position token equivelent amount in eth\\n * @param _vault the vault we want to check\\n * @param _positionManager address of the uniswap position manager\\n * @param _normalizationFactor current _normalizationFactor\\n * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18\\n * @param _wsqueethPoolTick current price tick for wsqueeth pool\\n * @param _isWethToken0 whether weth is token0 in the wsqueeth pool\\n * @return the total worth of collateral in the vault\\n */\\n function _getEffectiveCollateral(\\n Vault memory _vault,\\n address _positionManager,\\n uint256 _normalizationFactor,\\n uint256 _ethQuoteCurrencyPrice,\\n int24 _wsqueethPoolTick,\\n bool _isWethToken0\\n ) internal view returns (uint256) {\\n if (_vault.NftCollateralId == 0) return _vault.collateralAmount;\\n\\n // the user has deposited uniswap position token as collateral, see how much eth / wSqueeth the uniswap position token has\\n (uint256 nftEthAmount, uint256 nftWsqueethAmount) = _getUniPositionBalances(\\n _positionManager,\\n _vault.NftCollateralId,\\n _wsqueethPoolTick,\\n _isWethToken0\\n );\\n // convert squeeth amount from uniswap position token as equivalent amount of collateral\\n uint256 wSqueethIndexValueInEth = nftWsqueethAmount.mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div(\\n ONE_ONE\\n );\\n // add eth value from uniswap position token as collateral\\n return nftEthAmount.add(wSqueethIndexValueInEth).add(_vault.collateralAmount);\\n }\\n\\n /**\\n * @notice determine how much eth / wPowerPerp the uniswap position contains\\n * @param _positionManager address of the uniswap position manager\\n * @param _tokenId uniswap position token id\\n * @param _wPowerPerpPoolTick current price tick\\n * @param _isWethToken0 whether weth is token0 in the pool\\n * @return ethAmount the eth amount this LP token contains\\n * @return wPowerPerpAmount the wPowerPerp amount this LP token contains\\n */\\n function _getUniPositionBalances(\\n address _positionManager,\\n uint256 _tokenId,\\n int24 _wPowerPerpPoolTick,\\n bool _isWethToken0\\n ) internal view returns (uint256 ethAmount, uint256 wPowerPerpAmount) {\\n (\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n ) = _getUniswapPositionInfo(_positionManager, _tokenId);\\n (uint256 amount0, uint256 amount1) = _getToken0Token1Balances(\\n tickLower,\\n tickUpper,\\n _wPowerPerpPoolTick,\\n liquidity\\n );\\n\\n return\\n _isWethToken0\\n ? (amount0 + tokensOwed0, amount1 + tokensOwed1)\\n : (amount1 + tokensOwed1, amount0 + tokensOwed0);\\n }\\n\\n /**\\n * @notice get uniswap position token info\\n * @param _positionManager address of the uniswap position position manager\\n * @param _tokenId uniswap position token id\\n * @return tickLower lower tick of the position\\n * @return tickUpper upper tick of the position\\n * @return liquidity raw liquidity amount of the position\\n * @return tokensOwed0 amount of token 0 can be collected as fee\\n * @return tokensOwed1 amount of token 1 can be collected as fee\\n */\\n function _getUniswapPositionInfo(address _positionManager, uint256 _tokenId)\\n internal\\n view\\n returns (\\n int24,\\n int24,\\n uint128,\\n uint128,\\n uint128\\n )\\n {\\n INonfungiblePositionManager positionManager = INonfungiblePositionManager(_positionManager);\\n (\\n ,\\n ,\\n ,\\n ,\\n ,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n ,\\n ,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n ) = positionManager.positions(_tokenId);\\n return (tickLower, tickUpper, liquidity, tokensOwed0, tokensOwed1);\\n }\\n\\n /**\\n * @notice get balances of token0 / token1 in a uniswap position\\n * @dev knowing liquidity, tick range, and current tick gives balances\\n * @param _tickLower address of the uniswap position manager\\n * @param _tickUpper uniswap position token id\\n * @param _tick current price tick used for calculation\\n * @return amount0 the amount of token0 in the uniswap position token\\n * @return amount1 the amount of token1 in the uniswap position token\\n */\\n function _getToken0Token1Balances(\\n int24 _tickLower,\\n int24 _tickUpper,\\n int24 _tick,\\n uint128 _liquidity\\n ) internal pure returns (uint256 amount0, uint256 amount1) {\\n // get the current price and tick from wPowerPerp pool\\n uint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(_tick);\\n\\n // the following line is copied from the _modifyPosition function implemented by Uniswap core\\n // we use the same logic to determine how much token0, token1 equals to given \\\"liquidity\\\"\\n // https://github.com/Uniswap/uniswap-v3-core/blob/b2c5555d696428c40c4b236069b3528b2317f3c1/contracts/UniswapV3Pool.sol#L306\\n\\n // use these 2 functions directly, because liquidity is always positive\\n // getAmount0Delta: https://github.com/Uniswap/uniswap-v3-core/blob/b2c5555d696428c40c4b236069b3528b2317f3c1/contracts/libraries/SqrtPriceMath.sol#L209\\n // getAmount1Delta: https://github.com/Uniswap/uniswap-v3-core/blob/b2c5555d696428c40c4b236069b3528b2317f3c1/contracts/libraries/SqrtPriceMath.sol#L225\\n\\n if (_tick < _tickLower) {\\n amount0 = SqrtPriceMath.getAmount0Delta(\\n TickMath.getSqrtRatioAtTick(_tickLower),\\n TickMath.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n } else if (_tick < _tickUpper) {\\n amount0 = SqrtPriceMath.getAmount0Delta(\\n sqrtPriceX96,\\n TickMath.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n amount1 = SqrtPriceMath.getAmount1Delta(\\n TickMath.getSqrtRatioAtTick(_tickLower),\\n sqrtPriceX96,\\n _liquidity,\\n true\\n );\\n } else {\\n amount1 = SqrtPriceMath.getAmount1Delta(\\n TickMath.getSqrtRatioAtTick(_tickLower),\\n TickMath.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n }\\n }\\n}\\n\",\"keccak256\":\"0x70e0be9051bbd93304ab5c934ab16066b39cedc1cc96d81c6f6f8570c62efdd0\",\"license\":\"BUSL-1.1\"}},\"version\":1}", - "bytecode": "0x6101e060405260046005553480156200001757600080fd5b50604051620066fc380380620066fc8339810160408190526200003a916200032c565b600062000046620002c4565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600180556001600160a01b038916620000c65760405162461bcd60e51b8152600401620000bd9062000462565b60405180910390fd5b6001600160a01b038816620000ef5760405162461bcd60e51b8152600401620000bd90620004b6565b6001600160a01b038716620001185760405162461bcd60e51b8152600401620000bd90620003f0565b6001600160a01b038616620001415760405162461bcd60e51b8152600401620000bd9062000446565b6001600160a01b0385166200016a5760405162461bcd60e51b8152600401620000bd906200049a565b6001600160a01b038416620001935760405162461bcd60e51b8152600401620000bd906200047e565b6001600160a01b038316620001bc5760405162461bcd60e51b8152600401620000bd906200040c565b6001600160a01b038216620001e55760405162461bcd60e51b8152600401620000bd9062000429565b6001600160601b031960608a811b82166101805289811b82166101405288811b82166101605287811b821660a05286811b821660c05285811b821660e05284811b82166101005283901b16610120526001600160e81b031960e882901b166080526001600160a01b038781169087161060f81b6101c052600780546001600160801b031916670de0b6b3a7640000179055426101a0819052620002979062002768620002c8602090811b91909117901c565b600780546001600160801b03928316600160801b02921691909117905550620004d2975050505050505050565b3390565b806001600160801b03811681146200030f576040805162461bcd60e51b815260206004820152600560248201526409e8c6264760db1b604482015290519081900360640190fd5b919050565b80516001600160a01b03811681146200030f57600080fd5b60008060008060008060008060006101208a8c0312156200034b578485fd5b620003568a62000314565b98506200036660208b0162000314565b97506200037660408b0162000314565b96506200038660608b0162000314565b95506200039660808b0162000314565b9450620003a660a08b0162000314565b9350620003b660c08b0162000314565b9250620003c660e08b0162000314565b91506101008a015162ffffff81168114620003df578182fd5b809150509295985092959850929598565b602080825260029082015261219b60f11b604082015260600190565b60208082526003908201526204331360ec1b604082015260600190565b60208082526003908201526243313160e81b604082015260600190565b602080825260029082015261433760f01b604082015260600190565b60208082526002908201526110cd60f21b604082015260600190565b602080825260029082015261433960f01b604082015260600190565b602080825260029082015261086760f31b604082015260600190565b602080825260029082015261433560f01b604082015260600190565b60805160e81c60a05160601c60c05160601c60e05160601c6101005160601c6101205160601c6101405160601c6101605160601c6101805160601c6101a0516101c05160f81c615ffb62000701600039806147385280614a0b5250806115d5525080610af15280610be25280610d535280611412528061175552806124555280612adf5280612bb35280613f28528061413452806141f452806145b852806146785280614e025280614ead525080610df852806114365280611bb252806124fa5280612b845280613625528061369d528061391452806139bc5280613b995280613f6a528061403652806144f65280614e445280614eef525080611a925280611db85280611df9528061200c52806121bf52806127285280612f845280613e165250806133de5280613506528061374a528061464c528061484d525080610d745280611d9452806124765280612b005280613f49528061422352806146a75280614e235280614ece525080610b125280610c035280610d9552806110b7528061177652806124975280612b215280612bd4528061416352806145d9525080610b545280610c455280610dd752806114ca52806117b852806124d95280612b635280612c16528061461b5250806103535280610b335280610c245280610db65280610ed5528061179752806124b85280612b425280612bf5528061366152806136d9528061385e5280613f8b52806145fa5280614e655280614f105250806113da52806135dc5250615ffb6000f3fe6080604052600436106103435760003560e01c80638456cb59116101b0578063b707ab99116100ec578063e74b981b11610095578063f2fde38b1161006f578063f2fde38b146108d0578063f90c3f27146108f0578063fbfc6bc014610905578063ff947525146109255761039b565b8063e74b981b14610888578063ed88c68e146108a8578063ee3189ff146108b05761039b565b8063d296d1f1116100c6578063d296d1f11461083e578063d52725841461085e578063de4a427a146108735761039b565b8063b707ab99146107e9578063c65a391d146107fe578063c9e77ee81461081e5761039b565b806391b8d34a116101595780639d4c9442116101335780639d4c944214610781578063a847e67414610796578063ac6cd5ef146107b6578063b6b55f25146107d65761039b565b806391b8d34a1461072c578063978bbdb91461074c57806397efa942146107615761039b565b80638cd21d7c1161018a5780638cd21d7c146106e25780638da5cb5b1461070257806391b4ded9146107175761039b565b80638456cb591461067d5780638632cb03146106925780638c64ea4a146106b25761039b565b806345596e2e1161027f57806372f5d98a116102285780637dc0d1d0116102025780637dc0d1d0146106295780637f07b1301461063e5780638146b09f1461065357806382564bca146106685761039b565b806372f5d98a146105c35780637691c4ac146105e55780637ca25184146106075761039b565b806363b38ae41161025957806363b38ae414610579578063713d517f1461058e578063715018a6146105ae5761039b565b806345596e2e1461052257806346904840146105425780634be2822c146105575761039b565b806324f5f531116102ec5780633fc8cef3116102c65780633fc8cef3146104ab5780634394318d146104cd578063441a3e70146104ed5780634468c0221461050d5761039b565b806324f5f53114610463578063377a19361461047857806339467918146104985761039b565b806315aded831161031d57806315aded83146104005780631bf7bf6c1461042d578063200f4b8d1461044e5761039b565b806307633669146103a057806310b9e583146103b5578063150b7a02146103ca5761039b565b3661039b57336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146103995760405162461bcd60e51b815260040161039090615d95565b60405180910390fd5b005b600080fd5b3480156103ac57600080fd5b5061039961093a565b3480156103c157600080fd5b50610399610a3d565b3480156103d657600080fd5b506103ea6103e5366004615716565b610bb0565b6040516103f79190615b8d565b60405180910390f35b34801561040c57600080fd5b5061042061041b366004615903565b610bda565b6040516103f79190615ebf565b61044061043b3660046158d8565b610c71565b6040516103f7929190615ec8565b34801561045a57600080fd5b50610399610d08565b34801561046f57600080fd5b50610420610d3b565b34801561048457600080fd5b50610420610493366004615903565b610d4b565b6104206104a63660046158d8565b610e3b565b3480156104b757600080fd5b506104c0610ed3565b6040516103f79190615a15565b3480156104d957600080fd5b506104206104e83660046158d8565b610ef7565b3480156104f957600080fd5b50610399610508366004615894565b610f91565b34801561051957600080fd5b506104c06110b5565b34801561052e57600080fd5b5061039961053d366004615835565b6110d9565b34801561054e57600080fd5b506104c06111d6565b34801561056357600080fd5b5061056c6111e5565b6040516103f79190615e71565b34801561058557600080fd5b506104206111fb565b34801561059a57600080fd5b506103996105a9366004615835565b611201565b3480156105ba57600080fd5b5061039961131a565b3480156105cf57600080fd5b506105d86113d8565b6040516103f79190615eaf565b3480156105f157600080fd5b506105fa6113fc565b6040516103f79190615b82565b34801561061357600080fd5b5061061c61140a565b6040516103f79190615ed6565b34801561063557600080fd5b506104c0611410565b34801561064a57600080fd5b506104c0611434565b34801561065f57600080fd5b50610399611458565b34801561067457600080fd5b506104c06114c8565b34801561068957600080fd5b506103996114ec565b34801561069e57600080fd5b506103996106ad3660046158d8565b611675565b3480156106be57600080fd5b506106d26106cd366004615835565b611700565b6040516103f79493929190615b44565b3480156106ee57600080fd5b506104206106fd366004615903565b61174d565b34801561070e57600080fd5b506104c06117dc565b34801561072357600080fd5b506104206117eb565b34801561073857600080fd5b50610399610747366004615894565b6117f1565b34801561075857600080fd5b506104206118ea565b34801561076d57600080fd5b5061039961077c366004615835565b6118f0565b34801561078d57600080fd5b506104c0611a90565b3480156107a257600080fd5b506105fa6107b1366004615835565b611ab4565b3480156107c257600080fd5b506103996107d1366004615835565b611b2e565b6103996107e4366004615835565b611c88565b3480156107f557600080fd5b506104c0611d92565b34801561080a57600080fd5b50610399610819366004615865565b611db6565b34801561082a57600080fd5b50610399610839366004615835565b611f14565b34801561084a57600080fd5b50610420610859366004615894565b6120a6565b34801561086a57600080fd5b5061056c612311565b34801561087f57600080fd5b50610420612320565b34801561089457600080fd5b506103996108a33660046156de565b612326565b610399612429565b3480156108bc57600080fd5b506104206108cb366004615903565b61244d565b3480156108dc57600080fd5b506103996108eb3660046156de565b612526565b3480156108fc57600080fd5b5061042061263a565b34801561091157600080fd5b50610399610920366004615835565b612641565b34801561093157600080fd5b506105fa61275f565b6109426127c6565b6001600160a01b03166109536117dc565b6001600160a01b0316146109ae576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600854610100900460ff166109d55760405162461bcd60e51b815260040161039090615ce9565b60085460ff16156109f85760405162461bcd60e51b815260040161039090615c1f565b6008805461ff00191690556040517fff2b959f2bcdb44c7ecb4b16dae055431019d7350607125cfc2b74a06632c90e90610a33903390615a15565b60405180910390a1565b610a456127c6565b6001600160a01b0316610a566117dc565b6001600160a01b031614610ab1576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60085460ff1615610ad45760405162461bcd60e51b815260040161039090615c1f565b6008805460ff1961ff001990911661010017166001179055610b7d7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006101a460006127ca565b60048190556040517f574214b195bf5273a95bb4498e35cf1fde0ce327c727a95ec2ab359f7ba4e11a91610a3391615ebf565b7f150b7a02000000000000000000000000000000000000000000000000000000005b949350505050565b6000610c69827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006127f7565b90505b919050565b6008546000908190610100900460ff1615610c9e5760405162461bcd60e51b815260040161039090615d05565b60026001541415610ce4576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b6002600155610cf833868634876000612832565b6001805590969095509350505050565b600854610100900460ff1615610d305760405162461bcd60e51b815260040161039090615d05565b610d38612983565b50565b6000610d45612a71565b90505b90565b6000610c69827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000600760009054906101000a90046001600160801b03166001600160801b0316612f34565b600854600090610100900460ff1615610e665760405162461bcd60e51b815260040161039090615d05565b60026001541415610eac576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b60026001819055506000610ec533868634876001612832565b506001805595945050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600854600090610100900460ff1615610f225760405162461bcd60e51b815260040161039090615d05565b60026001541415610f68576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b6002600155610f778433612f78565b610f8533858585600061306c565b60018055949350505050565b600854610100900460ff1615610fb95760405162461bcd60e51b815260040161039090615d05565b60026001541415610fff576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b600260015561100e8233612f78565b6000611018612983565b600084815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b0316606082015290915061108d81858561315a565b61109781836131a4565b6110a184826131f6565b6110ab33846132c9565b5050600180555050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6110e16127c6565b6001600160a01b03166110f26117dc565b6001600160a01b03161461114d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6002546001600160a01b03166111755760405162461bcd60e51b815260040161039090615bc8565b60648111156111965760405162461bcd60e51b815260040161039090615d21565b7f14914da2bf76024616fbe1859783fcd4dbddcb179b1f3a854949fbf920dcb957600354826040516111c9929190615ec8565b60405180910390a1600355565b6002546001600160a01b031681565b600754600160801b90046001600160801b031681565b60055481565b600854610100900460ff16156112295760405162461bcd60e51b815260040161039090615d05565b6002600154141561126f576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b600260015561127e8133612f78565b6000611288612983565b600083815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b031660608201529091506112fd8133856133b3565b61130781836131a4565b61131183826131f6565b50506001805550565b6113226127c6565b6001600160a01b03166113336117dc565b6001600160a01b03161461138e576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b7f000000000000000000000000000000000000000000000000000000000000000081565b600854610100900460ff1681565b6101a481565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600854610100900460ff1661147f5760405162461bcd60e51b815260040161039090615ce9565b60085460ff16156114a25760405162461bcd60e51b815260040161039090615c1f565b600654620151800142116109f85760405162461bcd60e51b815260040161039090615caf565b7f000000000000000000000000000000000000000000000000000000000000000081565b6114f46127c6565b6001600160a01b03166115056117dc565b6001600160a01b031614611560576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60085460ff16156115835760405162461bcd60e51b815260040161039090615c1f565b600854610100900460ff16156115ab5760405162461bcd60e51b815260040161039090615d05565b6000600554116115cd5760405162461bcd60e51b815260040161039090615c3b565b60006115f9427f000000000000000000000000000000000000000000000000000000000000000061348a565b905062eff100811061161d5760405162461bcd60e51b815260040161039090615db2565b6008805461ff001916610100179055600580546000190190819055426006556040517f32fb7c9891bc4f963c7de9f1186d2a7755c7d6e9f4604dabe1d8bb3027c2f49e9161166a91615ebf565b60405180910390a150565b600854610100900460ff161561169d5760405162461bcd60e51b815260040161039090615d05565b600260015414156116e3576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b60026001556116f28333612f78565b6110ab33848484600161306c565b600960205260009081526040902080546001909101546001600160a01b03821691600160a01b900463ffffffff16906001600160601b03811690600160601b90046001600160801b031684565b6000610c69827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006134ec565b6000546001600160a01b031690565b60065481565b600854610100900460ff16156118195760405162461bcd60e51b815260040161039090615d05565b6002600154141561185f576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b600260015561186e8233612f78565b611876612983565b50600082815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b03166060820152611307813385856134fe565b60035481565b60085460ff166119125760405162461bcd60e51b815260040161039090615dcf565b60026001541415611958576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b60026001556119678133612f78565b6000818152600960209081526040808320815160808101835281546001600160a01b0381168252600160a01b900463ffffffff1693810193909352600101546001600160601b03811691830191909152600160601b90046001600160801b03908116606083015260075491929116906119e5908390339086906137fa565b506000611a0283606001516001600160801b031660045484613a77565b90506000611a268285604001516001600160601b031661348a90919063ffffffff16565b60006060860181905260408601529050611a4085856131f6565b611a4a33826132c9565b7f7dff8cdaec6a8d4d1ad32d3c947ed0f0281c3d6456621ef928defae96ec6cddb338683604051611a7d93929190615a89565b60405180910390a1505060018055505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000818152600960209081526040808320815160808101835281546001600160a01b0381168252600160a01b900463ffffffff1693810193909352600101546001600160601b03811691830191909152600160601b90046001600160801b0316606082015281611b22612a71565b9050610bd28282613aaa565b60085460ff16611b505760405162461bcd60e51b815260040161039090615dcf565b60026001541415611b96576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b6002600155604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac90611be99033908590600401615a4d565b600060405180830381600087803b158015611c0357600080fd5b505af1158015611c17573d6000803e3d6000fd5b505060045460075460009350611c3992508491906001600160801b0316613a77565b9050611c4533826132c9565b7f2131ef4f2f82ca75fe7d2e646ebfa45b6be25e53510c829629c76b641500ec67338383604051611c7893929190615a89565b60405180910390a1505060018055565b600854610100900460ff1615611cb05760405162461bcd60e51b815260040161039090615d05565b60026001541415611cf6576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b6002600155611d058133612f78565b611d0d612983565b50600081815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b03166060820152611d80818334613ac0565b611d8a82826131f6565b505060018055565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316331480611e9157506040516331a9108f60e11b815233907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90611e36908690600401615ebf565b60206040518083038186803b158015611e4e57600080fd5b505afa158015611e62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e8691906156fa565b6001600160a01b0316145b611ead5760405162461bcd60e51b815260040161039090615be5565b6000828152600960205260409081902080546001600160a01b0319166001600160a01b038416179055517f3137fc9cd2e33c34f86e29c24d81f3c75b0bce639d3c4ed0d31eeff1160a7ff590611f0890339085908590615a66565b60405180910390a15050565b600854610100900460ff1615611f3c5760405162461bcd60e51b815260040161039090615d05565b60026001541415611f82576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b6002600155611f918133612f78565b600081815260096020908152604091829020825160808101845281546001600160a01b038082168352600160a01b90910463ffffffff16938201939093526001909101546001600160601b03811682850152600160601b90046001600160801b0316606082015291516331a9108f60e11b815261209b9183917f000000000000000000000000000000000000000000000000000000000000000090911690636352211e90612043908790600401615ebf565b60206040518083038186803b15801561205b57600080fd5b505afa15801561206f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061209391906156fa565b8460006137fa565b50611d8a82826131f6565b600854600090610100900460ff16156120d15760405162461bcd60e51b815260040161039090615d05565b60026001541415612117576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b60026001556000612126612983565b600085815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b0316606082015290915061219a8183613aaa565b156121b75760405162461bcd60e51b815260040161039090615d3e565b6000612261827f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636352211e896040518263ffffffff1660e01b81526004016122099190615ebf565b60206040518083038186803b15801561222157600080fd5b505afa158015612235573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061225991906156fa565b8860016137fa565b905061226d8284613aaa565b156122925761227c86836131f6565b61228633826132c9565b60009350505050612307565b61229c8282613afd565b6000806122ab84888733613b33565b915091507f158ba9ab7bbbd08eeffa4753bad41f4d450e24831d293427308badf3eadd8c76338984846040516122e49493929190615aaa565b60405180910390a16122f688856131f6565b61230033826132c9565b5093505050505b6001805592915050565b6007546001600160801b031681565b60045481565b61232e6127c6565b6001600160a01b031661233f6117dc565b6001600160a01b03161461239a576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166123c05760405162461bcd60e51b815260040161039090615c58565b6002546040517faaebcf1bfa00580e41d966056b48521fa9f202645c86d4ddf28113e617c1b1d3916123ff916001600160a01b03909116908490615b0b565b60405180910390a1600280546001600160a01b0319166001600160a01b0392909216919091179055565b60085460ff1661244b5760405162461bcd60e51b815260040161039090615dcf565b565b6000610c69827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000612521612a71565b612f34565b61252e6127c6565b6001600160a01b031661253f6117dc565b6001600160a01b03161461259a576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166125df5760405162461bcd60e51b8152600401808060200182810382526026815260200180615f456026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6217124081565b60085460ff166126635760405162461bcd60e51b815260040161039090615dcf565b600260015414156126a9576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b60026001908155600082815260096020908152604091829020825160808101845281546001600160a01b038082168352600160a01b90910463ffffffff16938201939093529301546001600160601b03811684840152600160601b90046001600160801b0316606084015290516331a9108f60e11b815261209b9183917f000000000000000000000000000000000000000000000000000000000000000090911690636352211e90612043908790600401615ebf565b60085460ff1681565b806001600160801b0381168114610c6c576040805162461bcd60e51b815260206004820152600560248201527f4f46313238000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b3390565b6000806127db888888888888613c5a565b90506127e981612710613d19565b9150505b9695505050505050565b600080612809868686868b6000613c5a565b9050612827670de0b6b3a76400006128218380613d80565b90613d19565b979650505050505050565b600080600061283f612983565b9050856000856128645761285f836128218b670de0b6b3a7640000613d80565b612866565b885b90506000612872615670565b8b61288a576128808d613dd9565b909c5090506128fd565b6128948c33612f78565b5060008b815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b031660608201525b821561291e5761290e81848c613f05565b9450915061291e818e8e86613ffc565b891561292f5761292f818d86613ac0565b881561294157612941818e8e8c6134fe565b61294b81866131a4565b6129558c826131f6565b811561297157600254612971906001600160a01b0316836132c9565b50999b909a5098505050505050505050565b6007546000906001600160801b03600160801b909104164214156129b357506007546001600160801b0316610d48565b60006129bd612a71565b6007546040519192507f339e53729b0447795ff69e70a74fed98fc7fef6fe94b7521099b32f0f8de482291612a0c916001600160801b03808216928692600160801b9004909116904290615e85565b60405180910390a1612a1d81612768565b600780546fffffffffffffffffffffffffffffffff19166001600160801b0392909216919091179055612a4f42612768565b600780546001600160801b03928316600160801b029216919091179055905090565b6007546000908190612a9d90612a98904290600160801b90046001600160801b031661348a565b6140d2565b905063ffffffff8116612abd5750506007546001600160801b0316610d48565b6000612ac88261412f565b6007549091506001600160801b03166000612ba9837f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000089612f34565b90506000612c3a847f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006134ec565b9050600073B0069E6586F70003342309B9289e07035cC4140063fc505d3787621712406040518363ffffffff1660e01b8152600401612c7a929190615ee7565b60206040518083038186803b158015612c9257600080fd5b505af4158015612ca6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cca91906157fa565b90506000612cec670de0b6b3a764000061282185670b1a2bc2ec500000613d80565b905080841015612cfe57809350612d2e565b6000612d1e670de0b6b3a76400006128218667136dcc951d8c0000613d80565b905080851115612d2c578094505b505b6040517ffc505d3700000000000000000000000000000000000000000000000000000000815260009073B0069E6586F70003342309B9289e07035cC414009063fc505d3790612d839087908990600401615ec8565b60206040518083038186803b158015612d9b57600080fd5b505af4158015612daf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dd391906157fa565b90506000612e6b8473B0069E6586F70003342309B9289e07035cC41400632cbbdee5856040518263ffffffff1660e01b8152600401612e129190615bba565b60206040518083038186803b158015612e2a57600080fd5b505af4158015612e3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e6291906157fa565b600f0b906142f3565b6040517ffc193cf200000000000000000000000000000000000000000000000000000000815290915060009073B0069E6586F70003342309B9289e07035cC414009063fc193cf290612ec590600f86900b90600401615bba565b60206040518083038186803b158015612edd57600080fd5b505af4158015612ef1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f1591906157fa565b9050612f25600f82900b89614384565b9a505050505050505050505090565b600080612f46898888888e60006127ca565b90506000612f598a8a878a8f6000613c5a565b9050612f69846128218385613d80565b9b9a5050505050505050505050565b806001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636352211e846040518263ffffffff1660e01b8152600401612fce9190615ebf565b60206040518083038186803b158015612fe657600080fd5b505afa158015612ffa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061301e91906156fa565b6001600160a01b0316148061304c57506000828152600960205260409020546001600160a01b038281169116145b6130685760405162461bcd60e51b815260040161039090615be5565b5050565b600080613077612983565b905060008361309b576130968261282188670de0b6b3a7640000613d80565b61309d565b855b600088815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b03166060820152909150811561311957613119818a8a856144d5565b851561312a5761312a81898861315a565b61313481846131a4565b61313e88826131f6565b851561314e5761314e33876132c9565b50979650505050505050565b6131648382614592565b7f627a692d5a03ab34732c0d2aa319f3ecdebdc4528f383eabcb25441dc0a70cfb33838360405161319793929190615a89565b60405180910390a1505050565b6000806131b184846145ae565b91509150816131d25760405162461bcd60e51b815260040161039090615d5b565b80156131f05760405162461bcd60e51b815260040161039090615d78565b50505050565b600091825260096020908152604092839020825181549284015163ffffffff16600160a01b027fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff6001600160a01b039092166001600160a01b0319909416939093171691909117815591810151600190920180546060909201516001600160801b0316600160601b027fffffffff00000000000000000000000000000000ffffffffffffffffffffffff6001600160601b039094166bffffffffffffffffffffffff199093169290921792909216179055565b8047101561331e576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114613369576040519150601f19603f3d011682016040523d82523d6000602084013e61336e565b606091505b50509050806133ae5760405162461bcd60e51b815260040180806020018281038252603a815260200180615f6b603a913960400191505060405180910390fd5b505050565b602083015163ffffffff166133c784614768565b604051632142170760e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906342842e0e9061341790309087908690600401615a29565b600060405180830381600087803b15801561343157600080fd5b505af1158015613445573d6000803e3d6000fd5b505050507fe59f38fa1264fc25c9f0185eee136eaf810d90b8e7293b342e4037c68720177a33838360405161347c93929190615a89565b60405180910390a150505050565b6000828211156134e1576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b600080612809868686868b60006127ca565b6000806000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166399fbab88866040518263ffffffff1660e01b81526004016135509190615ebf565b6101806040518083038186803b15801561356957600080fd5b505afa15801561357d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135a1919061593b565b505050509750505095509550955050506000816001600160801b0316116135da5760405162461bcd60e51b815260040161039090615c92565b7f000000000000000000000000000000000000000000000000000000000000000062ffffff168262ffffff16146136235760405162461bcd60e51b815260040161039090615c02565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b031614801561369557507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b0316145b8061370d57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b031614801561370d57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b0316145b6137295760405162461bcd60e51b815260040161039090615c75565b61373388866147b3565b604051632142170760e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906342842e0e90613783908a9030908a90600401615a29565b600060405180830381600087803b15801561379d57600080fd5b505af11580156137b1573d6000803e3d6000fd5b505050507f3917c2f26ce18614e3aedd1289da672ef6563c5c295f49e9b1697ae0ad3155623387876040516137e893929190615a89565b60405180910390a15050505050505050565b602084015160009063ffffffff1680613817576000915050610bd2565b60008061382383614848565b909250905081156138c6576040517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690632e1a7d4d90613893908590600401615ebf565b600060405180830381600087803b1580156138ad57600080fd5b505af11580156138c1573d6000803e3d6000fd5b505050505b60008060006138d78b86868b614a47565b91945092509050811561399f576040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb9061394b908d908690600401615a4d565b602060405180830381600087803b15801561396557600080fd5b505af1158015613979573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061399d91906157da565b505b8215613a2657604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac906139f39030908790600401615a4d565b600060405180830381600087803b158015613a0d57600080fd5b505af1158015613a21573d6000803e3d6000fd5b505050505b7ffd0ae2fd36bd955810ae42615bc5ff277c0d0dfcb930f06c9f1777c0ef0752e3338a8787878787604051613a619796959493929190615ad0565b60405180910390a19a9950505050505050505050565b6000613aa06ec097ce7bc90715b34b9f100000000061282185613a9a8887613d80565b90613d80565b90505b9392505050565b600080613ab784846145ae565b50949350505050565b613aca8382613afd565b7f3ca13b7aab12bad7472691fe558faa6b25e99099824a0070a88bd5aa84be610f33838360405161319793929190615a89565b6040820151613b1e90613b19906001600160601b031683614add565b614b37565b6001600160601b031660409092019190915250565b600080600080613b5e8789606001516001600160801b03168a604001516001600160601b0316614b97565b9150915081871015613b825760405162461bcd60e51b815260040161039090615ccc565b604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac90613bd09088908690600401615a4d565b600060405180830381600087803b158015613bea57600080fd5b505af1158015613bfe573d6000803e3d6000fd5b50505050613c158289614bff90919063ffffffff16565b613c1f8882614592565b6000613c2b89886145ae565b9150508015613c4c5760405162461bcd60e51b815260040161039090615d78565b509097909650945050505050565b604080517fcce79bd50000000000000000000000000000000000000000000000000000000081526001600160a01b0387811660048301528681166024830152858116604483015263ffffffff851660648301528315156084830152915160009289169163cce79bd59160a4808301926020929190829003018186803b158015613ce257600080fd5b505afa158015613cf6573d6000803e3d6000fd5b505050506040513d6020811015613d0c57600080fd5b5051979650505050505050565b6000808211613d6f576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381613d7857fe5b049392505050565b600082613d8f575060006134e6565b82820282848281613d9c57fe5b0414613aa35760405162461bcd60e51b8152600401808060200182810382526021815260200180615fa56021913960400191505060405180910390fd5b6000613de3615670565b6040517f54ba0f270000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906354ba0f2790613e4b908790600401615a15565b602060405180830381600087803b158015613e6557600080fd5b505af1158015613e79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e9d919061584d565b6040805160808101825260008082526020820181905281830181905260608201529051919250907f25ff1e0131762176a9084e92880f880f39d6d0e62134607f37e631efe1bad87190613ef39033908590615a4d565b60405180910390a19092509050915091565b600354600090819080613f1f576000849250925050613ff4565b600080613faf877f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000614c35565b90506000613fc36127106128218487613d80565b905080871115613fde57613fd7878261348a565b9250613fec565b613fe88982614592565b8692505b945090925050505b935093915050565b6140068482614c61565b6040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340c10f199061406d9086908590600401615a4d565b600060405180830381600087803b15801561408757600080fd5b505af115801561409b573d6000803e3d6000fd5b505050507fb19fa182730a088464dad0e9e0badeb470d0d8d937d854f5caf15c6ad1992c3633828460405161347c93929190615a89565b8063ffffffff81168114610c6c576040805162461bcd60e51b8152602060048083019190915260248201527f4f46333200000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663de5a6e227f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b815260040161419e9190615a15565b60206040518083038186803b1580156141b657600080fd5b505afa1580156141ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141ee919061591f565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663de5a6e227f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b815260040161425e9190615a15565b60206040518083038186803b15801561427657600080fd5b505afa15801561428a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142ae919061591f565b905060008163ffffffff168363ffffffff16116142cb57826142cd565b815b90508063ffffffff168563ffffffff16116142e857846142ea565b805b95945050505050565b6000600f83810b9083900b0260401d6f7fffffffffffffffffffffffffffffff19811280159061433357506f7fffffffffffffffffffffffffffffff8113155b613aa3576040805162461bcd60e51b815260206004820152600860248201527f4d554c2d4f565546000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b600081614393575060006134e6565b600083600f0b12156143ec576040805162461bcd60e51b815260206004820152600760248201527f4d554c552d583000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b600f83900b6001600160801b038316810260401c90608084901c0277ffffffffffffffffffffffffffffffffffffffffffffffff811115614474576040805162461bcd60e51b815260206004820152600860248201527f4d554c552d4f4631000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60401b81198111156144cd576040805162461bcd60e51b815260206004820152600860248201527f4d554c552d4f4632000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b019392505050565b6144df8482614bff565b604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac9061452d9086908590600401615a4d565b600060405180830381600087803b15801561454757600080fd5b505af115801561455b573d6000803e3d6000fd5b505050507fea19ffc45b48de6d95594aacff7214dd24595fdb0c60e98c8f0b269058c2f79233828460405161347c93929190615a89565b6040820151613b1e90613b19906001600160601b03168361348a565b60008060006146447f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006101a460016127ca565b905061475c857f00000000000000000000000000000000000000000000000000000000000000008684675fc1b971363200007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316634a0a96eb7f00000000000000000000000000000000000000000000000000000000000000006101a46040518363ffffffff1660e01b81526004016146e6929190615b25565b60206040518083038186803b1580156146fe57600080fd5b505afa158015614712573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614736919061581b565b7f0000000000000000000000000000000000000000000000000000000000000000614c7d565b92509250509250929050565b602081015163ffffffff166147a9576040805162461bcd60e51b81526020600482015260026024820152612b1960f11b604482015290519081900360640190fd5b6000602090910152565b602082015163ffffffff16156147f5576040805162461bcd60e51b8152602060048201526002602482015261563160f01b604482015290519081900360640190fd5b8061482d576040805162461bcd60e51b815260206004820152600360248201526243323360e81b604482015290519081900360640190fd5b614836816140d2565b63ffffffff1660209092019190915250565b6000807f0000000000000000000000000000000000000000000000000000000000000000816148778286614d21565b50506040805160a0810182528981526001600160801b03831660208201526000818301819052606082015242608082015290517f0c49ccbe00000000000000000000000000000000000000000000000000000000815291945092506001600160a01b0385169150630c49ccbe906148f2908490600401615e2e565b6040805180830381600087803b15801561490b57600080fd5b505af115801561491f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061494391906158b5565b5050604080516080810182528781523060208201526001600160801b03818301819052606082015290517ffc6f786500000000000000000000000000000000000000000000000000000000815260009081906001600160a01b0387169063fc6f7865906149b4908690600401615deb565b6040805180830381600087803b1580156149cd57600080fd5b505af11580156149e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a0591906158b5565b915091507f0000000000000000000000000000000000000000000000000000000000000000614a35578082614a38565b81815b97509750505050505050915091565b6000806000808415614a6057614a5d8787614ddf565b90505b606088015186906000906001600160801b0316821115614aa65760608a0151614a939089906001600160801b031661348a565b905089606001516001600160801b031691505b614ab08a83614bff565b614ab98a614768565b614ac38a8a613afd565b614acd8a84614592565b9099909850909650945050505050565b600082820183811015613aa3576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b806001600160601b0381168114610c6c576040805162461bcd60e51b8152602060048083019190915260248201527f4f46393600000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000808080614bb087614bab886002613d19565b614e8f565b9150915080851115614be557675fc1b97136320000614bcf868361348a565b1015614be557614bdf8787614e8f565b90925090505b84811115614bf35750849050835b90969095509350505050565b6060820151614c2090614c1b906001600160801b03168361348a565b612768565b6001600160801b031660609092019190915250565b600080614c49868686866101a46000613c5a565b9050612827670de0b6b3a76400006128218984613d80565b6060820151614c2090614c1b906001600160801b031683614add565b60008088606001516001600160801b031660001415614ca25750600190506000614d15565b6000614cdb6ec097ce7bc90715b34b9f100000000061282189613a9a8c8f606001516001600160801b0316613d8090919063ffffffff16565b90506000614ced8b8b8b8b8a8a614f6b565b90508681106000614cff846003613d80565b614d0a846002613d80565b101595509093505050505b97509795505050505050565b6000806000806000808790506000806000806000856001600160a01b03166399fbab888d6040518263ffffffff1660e01b8152600401808281526020019150506101806040518083038186803b158015614d7a57600080fd5b505afa158015614d8e573d6000803e3d6000fd5b505050506040513d610180811015614da557600080fd5b5060a081015160c082015160e083015161014084015161016090940151929e50909c509a5090985096505050505050509295509295909350565b6000613aa3670de0b6b3a764000061282166470de4df820000613a9a87614e89887f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000614c35565b90614add565b6000806000838511614ea15784614ea3565b835b90506000614f34827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000614c35565b9050614f5e614f57670de0b6b3a76400006128218467016345785d8a0000613d80565b8290614add565b9196919550909350505050565b6000866020015163ffffffff1660001415614f94575060408601516001600160601b03166127ed565b600080614fad888a6020015163ffffffff168787615002565b90925090506000614fd56ec097ce7bc90715b34b9f100000000061282189613a9a868d613d80565b60408b0151909150614ff4906001600160601b0316614e898584614add565b9a9950505050505050505050565b60008060008060008060006150178b8b614d21565b9450945094509450945060008061503087878d88615083565b915091508961505657826001600160801b03168101846001600160801b0316830161506f565b836001600160801b03168201836001600160801b031682015b985098505050505050505094509492505050565b600080600061509185615128565b90508660020b8560020b12156150c5576150be6150ad88615128565b6150b688615128565b86600161545a565b925061511e565b8560020b8560020b12156150fe576150e0816150b688615128565b92506150f76150ee88615128565b8286600161550c565b915061511e565b61511b61510a88615128565b61511388615128565b86600161550c565b91505b5094509492505050565b60008060008360020b1261513f578260020b615147565b8260020b6000035b9050620d89e8811115615185576040805162461bcd60e51b81526020600482015260016024820152601560fa1b604482015290519081900360640190fd5b60006001821661519957600160801b6151ab565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156151df576ffff97272373d413259a46990580e213a0260801c5b60048216156151fe576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b600882161561521d576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b601082161561523c576fffcb9843d60f6159c9db58835c9266440260801c5b602082161561525b576fff973b41fa98c081472e6896dfb254c00260801c5b604082161561527a576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615615299576ffe5dee046a99a2a811c461f1969c30530260801c5b6101008216156152b9576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b6102008216156152d9576ff987a7253ac413176f2b074cf7815e540260801c5b6104008216156152f9576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615615319576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615615339576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615615359576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615615379576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615615399576f31be135f97d08fd981231505542fcfa60260801c5b620100008216156153ba576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b620200008216156153da576e5d6af8dedb81196699c329225ee6040260801c5b620400008216156153f9576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615615416576b048a170391f7dc42444e8fa20260801c5b60008460020b131561543157806000198161542d57fe5b0490505b640100000000810615615445576001615448565b60005b60ff16602082901c0192505050919050565b6000836001600160a01b0316856001600160a01b0316111561547a579293925b7bffffffffffffffffffffffffffffffff000000000000000000000000606084901b166001600160a01b0386860381169087166154b657600080fd5b836154e657866001600160a01b03166154d98383896001600160a01b031661557c565b816154e057fe5b04612827565b6128276154fd8383896001600160a01b031661562b565b886001600160a01b0316615665565b6000836001600160a01b0316856001600160a01b0316111561552c579293925b8161555957615554836001600160801b03168686036001600160a01b0316600160601b61557c565b6142ea565b6142ea836001600160801b03168686036001600160a01b0316600160601b61562b565b60008080600019858709868602925082811090839003039050806155b257600084116155a757600080fd5b508290049050613aa3565b8084116155be57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b600061563884848461557c565b90506000828061564457fe5b8486091115613aa357600019811061565b57600080fd5b6001019392505050565b808204910615150190565b60408051608081018252600080825260208201819052918101829052606081019190915290565b8051610c6c81615efd565b8051600281900b8114610c6c57600080fd5b80516001600160801b0381168114610c6c57600080fd5b805162ffffff81168114610c6c57600080fd5b6000602082840312156156ef578081fd5b8135613aa381615efd565b60006020828403121561570b578081fd5b8151613aa381615efd565b6000806000806080858703121561572b578283fd5b843561573681615efd565b935060208581013561574781615efd565b935060408601359250606086013567ffffffffffffffff8082111561576a578384fd5b818801915088601f83011261577d578384fd5b81358181111561578957fe5b604051601f8201601f19168101850183811182821017156157a657fe5b60405281815283820185018b10156157bc578586fd5b81858501868301379081019093019390935250939692955090935050565b6000602082840312156157eb578081fd5b81518015158114613aa3578182fd5b60006020828403121561580b578081fd5b815180600f0b8114613aa3578182fd5b60006020828403121561582c578081fd5b613aa3826156a2565b600060208284031215615846578081fd5b5035919050565b60006020828403121561585e578081fd5b5051919050565b60008060408385031215615877578182fd5b82359150602083013561588981615efd565b809150509250929050565b600080604083850312156158a6578182fd5b50508035926020909101359150565b600080604083850312156158c7578182fd5b505080516020909101519092909150565b6000806000606084860312156158ec578283fd5b505081359360208301359350604090920135919050565b600060208284031215615914578081fd5b8135613aa381615f12565b600060208284031215615930578081fd5b8151613aa381615f12565b6000806000806000806000806000806000806101808d8f03121561595d57898afd5b8c516001600160601b0381168114615973578a8bfd5b9b5061598160208e01615697565b9a5061598f60408e01615697565b995061599d60608e01615697565b98506159ab60808e016156cb565b97506159b960a08e016156a2565b96506159c760c08e016156a2565b95506159d560e08e016156b4565b94506101008d015193506101208d015192506159f46101408e016156b4565b9150615a036101608e016156b4565b90509295989b509295989b509295989b565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b6001600160a01b039390931683526020830191909152604082015260600190565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b6001600160a01b03979097168752602087019590955260408601939093526060850191909152608084015260a083015260c082015260e00190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b0392909216825263ffffffff16602082015260400190565b6001600160a01b0394909416845263ffffffff9290921660208401526001600160601b031660408301526001600160801b0316606082015260800190565b901515815260200190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b600f9190910b815260200190565b60208082526003908201526210cc4d60ea1b604082015260600190565b60208082526003908201526204332360ec1b604082015260600190565b60208082526003908201526221991b60e91b604082015260600190565b602080825260029082015261219960f11b604082015260600190565b60208082526003908201526221989b60e91b604082015260600190565b60208082526003908201526243313360e81b604082015260600190565b60208082526003908201526243323360e81b604082015260600190565b60208082526003908201526243323560e81b604082015260600190565b60208082526003908201526208662760eb1b604082015260600190565b60208082526003908201526243323160e81b604082015260600190565b602080825260029082015261433160f01b604082015260600190565b602080825260029082015261043360f41b604082015260600190565b60208082526003908201526243313560e81b604082015260600190565b60208082526003908201526221989960e91b604082015260600190565b60208082526003908201526210cc8d60ea1b604082015260600190565b60208082526003908201526221991960e91b604082015260600190565b60208082526003908201526243313960e81b604082015260600190565b60208082526003908201526243313760e81b604082015260600190565b602080825260029082015261433360f01b604082015260600190565b815181526020808301516001600160a01b0316908201526040808301516001600160801b0390811691830191909152606092830151169181019190915260800190565b600060a082019050825182526001600160801b03602084015116602083015260408301516040830152606083015160608301526080830151608083015292915050565b6001600160801b0391909116815260200190565b6001600160801b039485168152602081019390935292166040820152606081019190915260800190565b62ffffff91909116815260200190565b90815260200190565b918252602082015260400190565b63ffffffff91909116815260200190565b63ffffffff929092168252602082015260400190565b6001600160a01b0381168114610d3857600080fd5b63ffffffff81168114610d3857600080fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c004f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a264697066735822122067d14fd1333db15cb72cd2b7553b52b4edf574b5ecc5983c9fbf5527769a740664736f6c63430007060033", - "deployedBytecode": "0x6080604052600436106103435760003560e01c80638456cb59116101b0578063b707ab99116100ec578063e74b981b11610095578063f2fde38b1161006f578063f2fde38b146108d0578063f90c3f27146108f0578063fbfc6bc014610905578063ff947525146109255761039b565b8063e74b981b14610888578063ed88c68e146108a8578063ee3189ff146108b05761039b565b8063d296d1f1116100c6578063d296d1f11461083e578063d52725841461085e578063de4a427a146108735761039b565b8063b707ab99146107e9578063c65a391d146107fe578063c9e77ee81461081e5761039b565b806391b8d34a116101595780639d4c9442116101335780639d4c944214610781578063a847e67414610796578063ac6cd5ef146107b6578063b6b55f25146107d65761039b565b806391b8d34a1461072c578063978bbdb91461074c57806397efa942146107615761039b565b80638cd21d7c1161018a5780638cd21d7c146106e25780638da5cb5b1461070257806391b4ded9146107175761039b565b80638456cb591461067d5780638632cb03146106925780638c64ea4a146106b25761039b565b806345596e2e1161027f57806372f5d98a116102285780637dc0d1d0116102025780637dc0d1d0146106295780637f07b1301461063e5780638146b09f1461065357806382564bca146106685761039b565b806372f5d98a146105c35780637691c4ac146105e55780637ca25184146106075761039b565b806363b38ae41161025957806363b38ae414610579578063713d517f1461058e578063715018a6146105ae5761039b565b806345596e2e1461052257806346904840146105425780634be2822c146105575761039b565b806324f5f531116102ec5780633fc8cef3116102c65780633fc8cef3146104ab5780634394318d146104cd578063441a3e70146104ed5780634468c0221461050d5761039b565b806324f5f53114610463578063377a19361461047857806339467918146104985761039b565b806315aded831161031d57806315aded83146104005780631bf7bf6c1461042d578063200f4b8d1461044e5761039b565b806307633669146103a057806310b9e583146103b5578063150b7a02146103ca5761039b565b3661039b57336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146103995760405162461bcd60e51b815260040161039090615d95565b60405180910390fd5b005b600080fd5b3480156103ac57600080fd5b5061039961093a565b3480156103c157600080fd5b50610399610a3d565b3480156103d657600080fd5b506103ea6103e5366004615716565b610bb0565b6040516103f79190615b8d565b60405180910390f35b34801561040c57600080fd5b5061042061041b366004615903565b610bda565b6040516103f79190615ebf565b61044061043b3660046158d8565b610c71565b6040516103f7929190615ec8565b34801561045a57600080fd5b50610399610d08565b34801561046f57600080fd5b50610420610d3b565b34801561048457600080fd5b50610420610493366004615903565b610d4b565b6104206104a63660046158d8565b610e3b565b3480156104b757600080fd5b506104c0610ed3565b6040516103f79190615a15565b3480156104d957600080fd5b506104206104e83660046158d8565b610ef7565b3480156104f957600080fd5b50610399610508366004615894565b610f91565b34801561051957600080fd5b506104c06110b5565b34801561052e57600080fd5b5061039961053d366004615835565b6110d9565b34801561054e57600080fd5b506104c06111d6565b34801561056357600080fd5b5061056c6111e5565b6040516103f79190615e71565b34801561058557600080fd5b506104206111fb565b34801561059a57600080fd5b506103996105a9366004615835565b611201565b3480156105ba57600080fd5b5061039961131a565b3480156105cf57600080fd5b506105d86113d8565b6040516103f79190615eaf565b3480156105f157600080fd5b506105fa6113fc565b6040516103f79190615b82565b34801561061357600080fd5b5061061c61140a565b6040516103f79190615ed6565b34801561063557600080fd5b506104c0611410565b34801561064a57600080fd5b506104c0611434565b34801561065f57600080fd5b50610399611458565b34801561067457600080fd5b506104c06114c8565b34801561068957600080fd5b506103996114ec565b34801561069e57600080fd5b506103996106ad3660046158d8565b611675565b3480156106be57600080fd5b506106d26106cd366004615835565b611700565b6040516103f79493929190615b44565b3480156106ee57600080fd5b506104206106fd366004615903565b61174d565b34801561070e57600080fd5b506104c06117dc565b34801561072357600080fd5b506104206117eb565b34801561073857600080fd5b50610399610747366004615894565b6117f1565b34801561075857600080fd5b506104206118ea565b34801561076d57600080fd5b5061039961077c366004615835565b6118f0565b34801561078d57600080fd5b506104c0611a90565b3480156107a257600080fd5b506105fa6107b1366004615835565b611ab4565b3480156107c257600080fd5b506103996107d1366004615835565b611b2e565b6103996107e4366004615835565b611c88565b3480156107f557600080fd5b506104c0611d92565b34801561080a57600080fd5b50610399610819366004615865565b611db6565b34801561082a57600080fd5b50610399610839366004615835565b611f14565b34801561084a57600080fd5b50610420610859366004615894565b6120a6565b34801561086a57600080fd5b5061056c612311565b34801561087f57600080fd5b50610420612320565b34801561089457600080fd5b506103996108a33660046156de565b612326565b610399612429565b3480156108bc57600080fd5b506104206108cb366004615903565b61244d565b3480156108dc57600080fd5b506103996108eb3660046156de565b612526565b3480156108fc57600080fd5b5061042061263a565b34801561091157600080fd5b50610399610920366004615835565b612641565b34801561093157600080fd5b506105fa61275f565b6109426127c6565b6001600160a01b03166109536117dc565b6001600160a01b0316146109ae576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600854610100900460ff166109d55760405162461bcd60e51b815260040161039090615ce9565b60085460ff16156109f85760405162461bcd60e51b815260040161039090615c1f565b6008805461ff00191690556040517fff2b959f2bcdb44c7ecb4b16dae055431019d7350607125cfc2b74a06632c90e90610a33903390615a15565b60405180910390a1565b610a456127c6565b6001600160a01b0316610a566117dc565b6001600160a01b031614610ab1576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60085460ff1615610ad45760405162461bcd60e51b815260040161039090615c1f565b6008805460ff1961ff001990911661010017166001179055610b7d7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006101a460006127ca565b60048190556040517f574214b195bf5273a95bb4498e35cf1fde0ce327c727a95ec2ab359f7ba4e11a91610a3391615ebf565b7f150b7a02000000000000000000000000000000000000000000000000000000005b949350505050565b6000610c69827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006127f7565b90505b919050565b6008546000908190610100900460ff1615610c9e5760405162461bcd60e51b815260040161039090615d05565b60026001541415610ce4576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b6002600155610cf833868634876000612832565b6001805590969095509350505050565b600854610100900460ff1615610d305760405162461bcd60e51b815260040161039090615d05565b610d38612983565b50565b6000610d45612a71565b90505b90565b6000610c69827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000600760009054906101000a90046001600160801b03166001600160801b0316612f34565b600854600090610100900460ff1615610e665760405162461bcd60e51b815260040161039090615d05565b60026001541415610eac576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b60026001819055506000610ec533868634876001612832565b506001805595945050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600854600090610100900460ff1615610f225760405162461bcd60e51b815260040161039090615d05565b60026001541415610f68576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b6002600155610f778433612f78565b610f8533858585600061306c565b60018055949350505050565b600854610100900460ff1615610fb95760405162461bcd60e51b815260040161039090615d05565b60026001541415610fff576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b600260015561100e8233612f78565b6000611018612983565b600084815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b0316606082015290915061108d81858561315a565b61109781836131a4565b6110a184826131f6565b6110ab33846132c9565b5050600180555050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6110e16127c6565b6001600160a01b03166110f26117dc565b6001600160a01b03161461114d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6002546001600160a01b03166111755760405162461bcd60e51b815260040161039090615bc8565b60648111156111965760405162461bcd60e51b815260040161039090615d21565b7f14914da2bf76024616fbe1859783fcd4dbddcb179b1f3a854949fbf920dcb957600354826040516111c9929190615ec8565b60405180910390a1600355565b6002546001600160a01b031681565b600754600160801b90046001600160801b031681565b60055481565b600854610100900460ff16156112295760405162461bcd60e51b815260040161039090615d05565b6002600154141561126f576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b600260015561127e8133612f78565b6000611288612983565b600083815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b031660608201529091506112fd8133856133b3565b61130781836131a4565b61131183826131f6565b50506001805550565b6113226127c6565b6001600160a01b03166113336117dc565b6001600160a01b03161461138e576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b7f000000000000000000000000000000000000000000000000000000000000000081565b600854610100900460ff1681565b6101a481565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600854610100900460ff1661147f5760405162461bcd60e51b815260040161039090615ce9565b60085460ff16156114a25760405162461bcd60e51b815260040161039090615c1f565b600654620151800142116109f85760405162461bcd60e51b815260040161039090615caf565b7f000000000000000000000000000000000000000000000000000000000000000081565b6114f46127c6565b6001600160a01b03166115056117dc565b6001600160a01b031614611560576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60085460ff16156115835760405162461bcd60e51b815260040161039090615c1f565b600854610100900460ff16156115ab5760405162461bcd60e51b815260040161039090615d05565b6000600554116115cd5760405162461bcd60e51b815260040161039090615c3b565b60006115f9427f000000000000000000000000000000000000000000000000000000000000000061348a565b905062eff100811061161d5760405162461bcd60e51b815260040161039090615db2565b6008805461ff001916610100179055600580546000190190819055426006556040517f32fb7c9891bc4f963c7de9f1186d2a7755c7d6e9f4604dabe1d8bb3027c2f49e9161166a91615ebf565b60405180910390a150565b600854610100900460ff161561169d5760405162461bcd60e51b815260040161039090615d05565b600260015414156116e3576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b60026001556116f28333612f78565b6110ab33848484600161306c565b600960205260009081526040902080546001909101546001600160a01b03821691600160a01b900463ffffffff16906001600160601b03811690600160601b90046001600160801b031684565b6000610c69827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006134ec565b6000546001600160a01b031690565b60065481565b600854610100900460ff16156118195760405162461bcd60e51b815260040161039090615d05565b6002600154141561185f576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b600260015561186e8233612f78565b611876612983565b50600082815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b03166060820152611307813385856134fe565b60035481565b60085460ff166119125760405162461bcd60e51b815260040161039090615dcf565b60026001541415611958576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b60026001556119678133612f78565b6000818152600960209081526040808320815160808101835281546001600160a01b0381168252600160a01b900463ffffffff1693810193909352600101546001600160601b03811691830191909152600160601b90046001600160801b03908116606083015260075491929116906119e5908390339086906137fa565b506000611a0283606001516001600160801b031660045484613a77565b90506000611a268285604001516001600160601b031661348a90919063ffffffff16565b60006060860181905260408601529050611a4085856131f6565b611a4a33826132c9565b7f7dff8cdaec6a8d4d1ad32d3c947ed0f0281c3d6456621ef928defae96ec6cddb338683604051611a7d93929190615a89565b60405180910390a1505060018055505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000818152600960209081526040808320815160808101835281546001600160a01b0381168252600160a01b900463ffffffff1693810193909352600101546001600160601b03811691830191909152600160601b90046001600160801b0316606082015281611b22612a71565b9050610bd28282613aaa565b60085460ff16611b505760405162461bcd60e51b815260040161039090615dcf565b60026001541415611b96576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b6002600155604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac90611be99033908590600401615a4d565b600060405180830381600087803b158015611c0357600080fd5b505af1158015611c17573d6000803e3d6000fd5b505060045460075460009350611c3992508491906001600160801b0316613a77565b9050611c4533826132c9565b7f2131ef4f2f82ca75fe7d2e646ebfa45b6be25e53510c829629c76b641500ec67338383604051611c7893929190615a89565b60405180910390a1505060018055565b600854610100900460ff1615611cb05760405162461bcd60e51b815260040161039090615d05565b60026001541415611cf6576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b6002600155611d058133612f78565b611d0d612983565b50600081815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b03166060820152611d80818334613ac0565b611d8a82826131f6565b505060018055565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316331480611e9157506040516331a9108f60e11b815233907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90611e36908690600401615ebf565b60206040518083038186803b158015611e4e57600080fd5b505afa158015611e62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e8691906156fa565b6001600160a01b0316145b611ead5760405162461bcd60e51b815260040161039090615be5565b6000828152600960205260409081902080546001600160a01b0319166001600160a01b038416179055517f3137fc9cd2e33c34f86e29c24d81f3c75b0bce639d3c4ed0d31eeff1160a7ff590611f0890339085908590615a66565b60405180910390a15050565b600854610100900460ff1615611f3c5760405162461bcd60e51b815260040161039090615d05565b60026001541415611f82576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b6002600155611f918133612f78565b600081815260096020908152604091829020825160808101845281546001600160a01b038082168352600160a01b90910463ffffffff16938201939093526001909101546001600160601b03811682850152600160601b90046001600160801b0316606082015291516331a9108f60e11b815261209b9183917f000000000000000000000000000000000000000000000000000000000000000090911690636352211e90612043908790600401615ebf565b60206040518083038186803b15801561205b57600080fd5b505afa15801561206f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061209391906156fa565b8460006137fa565b50611d8a82826131f6565b600854600090610100900460ff16156120d15760405162461bcd60e51b815260040161039090615d05565b60026001541415612117576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b60026001556000612126612983565b600085815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b0316606082015290915061219a8183613aaa565b156121b75760405162461bcd60e51b815260040161039090615d3e565b6000612261827f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636352211e896040518263ffffffff1660e01b81526004016122099190615ebf565b60206040518083038186803b15801561222157600080fd5b505afa158015612235573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061225991906156fa565b8860016137fa565b905061226d8284613aaa565b156122925761227c86836131f6565b61228633826132c9565b60009350505050612307565b61229c8282613afd565b6000806122ab84888733613b33565b915091507f158ba9ab7bbbd08eeffa4753bad41f4d450e24831d293427308badf3eadd8c76338984846040516122e49493929190615aaa565b60405180910390a16122f688856131f6565b61230033826132c9565b5093505050505b6001805592915050565b6007546001600160801b031681565b60045481565b61232e6127c6565b6001600160a01b031661233f6117dc565b6001600160a01b03161461239a576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166123c05760405162461bcd60e51b815260040161039090615c58565b6002546040517faaebcf1bfa00580e41d966056b48521fa9f202645c86d4ddf28113e617c1b1d3916123ff916001600160a01b03909116908490615b0b565b60405180910390a1600280546001600160a01b0319166001600160a01b0392909216919091179055565b60085460ff1661244b5760405162461bcd60e51b815260040161039090615dcf565b565b6000610c69827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000612521612a71565b612f34565b61252e6127c6565b6001600160a01b031661253f6117dc565b6001600160a01b03161461259a576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166125df5760405162461bcd60e51b8152600401808060200182810382526026815260200180615f456026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6217124081565b60085460ff166126635760405162461bcd60e51b815260040161039090615dcf565b600260015414156126a9576040805162461bcd60e51b815260206004820152601f6024820152600080516020615f25833981519152604482015290519081900360640190fd5b60026001908155600082815260096020908152604091829020825160808101845281546001600160a01b038082168352600160a01b90910463ffffffff16938201939093529301546001600160601b03811684840152600160601b90046001600160801b0316606084015290516331a9108f60e11b815261209b9183917f000000000000000000000000000000000000000000000000000000000000000090911690636352211e90612043908790600401615ebf565b60085460ff1681565b806001600160801b0381168114610c6c576040805162461bcd60e51b815260206004820152600560248201527f4f46313238000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b3390565b6000806127db888888888888613c5a565b90506127e981612710613d19565b9150505b9695505050505050565b600080612809868686868b6000613c5a565b9050612827670de0b6b3a76400006128218380613d80565b90613d19565b979650505050505050565b600080600061283f612983565b9050856000856128645761285f836128218b670de0b6b3a7640000613d80565b612866565b885b90506000612872615670565b8b61288a576128808d613dd9565b909c5090506128fd565b6128948c33612f78565b5060008b815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b031660608201525b821561291e5761290e81848c613f05565b9450915061291e818e8e86613ffc565b891561292f5761292f818d86613ac0565b881561294157612941818e8e8c6134fe565b61294b81866131a4565b6129558c826131f6565b811561297157600254612971906001600160a01b0316836132c9565b50999b909a5098505050505050505050565b6007546000906001600160801b03600160801b909104164214156129b357506007546001600160801b0316610d48565b60006129bd612a71565b6007546040519192507f339e53729b0447795ff69e70a74fed98fc7fef6fe94b7521099b32f0f8de482291612a0c916001600160801b03808216928692600160801b9004909116904290615e85565b60405180910390a1612a1d81612768565b600780546fffffffffffffffffffffffffffffffff19166001600160801b0392909216919091179055612a4f42612768565b600780546001600160801b03928316600160801b029216919091179055905090565b6007546000908190612a9d90612a98904290600160801b90046001600160801b031661348a565b6140d2565b905063ffffffff8116612abd5750506007546001600160801b0316610d48565b6000612ac88261412f565b6007549091506001600160801b03166000612ba9837f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000089612f34565b90506000612c3a847f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006134ec565b9050600073__$f98cbc68e241c61b30349ba6b91a975736$__63fc505d3787621712406040518363ffffffff1660e01b8152600401612c7a929190615ee7565b60206040518083038186803b158015612c9257600080fd5b505af4158015612ca6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cca91906157fa565b90506000612cec670de0b6b3a764000061282185670b1a2bc2ec500000613d80565b905080841015612cfe57809350612d2e565b6000612d1e670de0b6b3a76400006128218667136dcc951d8c0000613d80565b905080851115612d2c578094505b505b6040517ffc505d3700000000000000000000000000000000000000000000000000000000815260009073__$f98cbc68e241c61b30349ba6b91a975736$__9063fc505d3790612d839087908990600401615ec8565b60206040518083038186803b158015612d9b57600080fd5b505af4158015612daf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dd391906157fa565b90506000612e6b8473__$f98cbc68e241c61b30349ba6b91a975736$__632cbbdee5856040518263ffffffff1660e01b8152600401612e129190615bba565b60206040518083038186803b158015612e2a57600080fd5b505af4158015612e3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e6291906157fa565b600f0b906142f3565b6040517ffc193cf200000000000000000000000000000000000000000000000000000000815290915060009073__$f98cbc68e241c61b30349ba6b91a975736$__9063fc193cf290612ec590600f86900b90600401615bba565b60206040518083038186803b158015612edd57600080fd5b505af4158015612ef1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f1591906157fa565b9050612f25600f82900b89614384565b9a505050505050505050505090565b600080612f46898888888e60006127ca565b90506000612f598a8a878a8f6000613c5a565b9050612f69846128218385613d80565b9b9a5050505050505050505050565b806001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636352211e846040518263ffffffff1660e01b8152600401612fce9190615ebf565b60206040518083038186803b158015612fe657600080fd5b505afa158015612ffa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061301e91906156fa565b6001600160a01b0316148061304c57506000828152600960205260409020546001600160a01b038281169116145b6130685760405162461bcd60e51b815260040161039090615be5565b5050565b600080613077612983565b905060008361309b576130968261282188670de0b6b3a7640000613d80565b61309d565b855b600088815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b03166060820152909150811561311957613119818a8a856144d5565b851561312a5761312a81898861315a565b61313481846131a4565b61313e88826131f6565b851561314e5761314e33876132c9565b50979650505050505050565b6131648382614592565b7f627a692d5a03ab34732c0d2aa319f3ecdebdc4528f383eabcb25441dc0a70cfb33838360405161319793929190615a89565b60405180910390a1505050565b6000806131b184846145ae565b91509150816131d25760405162461bcd60e51b815260040161039090615d5b565b80156131f05760405162461bcd60e51b815260040161039090615d78565b50505050565b600091825260096020908152604092839020825181549284015163ffffffff16600160a01b027fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff6001600160a01b039092166001600160a01b0319909416939093171691909117815591810151600190920180546060909201516001600160801b0316600160601b027fffffffff00000000000000000000000000000000ffffffffffffffffffffffff6001600160601b039094166bffffffffffffffffffffffff199093169290921792909216179055565b8047101561331e576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114613369576040519150601f19603f3d011682016040523d82523d6000602084013e61336e565b606091505b50509050806133ae5760405162461bcd60e51b815260040180806020018281038252603a815260200180615f6b603a913960400191505060405180910390fd5b505050565b602083015163ffffffff166133c784614768565b604051632142170760e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906342842e0e9061341790309087908690600401615a29565b600060405180830381600087803b15801561343157600080fd5b505af1158015613445573d6000803e3d6000fd5b505050507fe59f38fa1264fc25c9f0185eee136eaf810d90b8e7293b342e4037c68720177a33838360405161347c93929190615a89565b60405180910390a150505050565b6000828211156134e1576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b600080612809868686868b60006127ca565b6000806000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166399fbab88866040518263ffffffff1660e01b81526004016135509190615ebf565b6101806040518083038186803b15801561356957600080fd5b505afa15801561357d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135a1919061593b565b505050509750505095509550955050506000816001600160801b0316116135da5760405162461bcd60e51b815260040161039090615c92565b7f000000000000000000000000000000000000000000000000000000000000000062ffffff168262ffffff16146136235760405162461bcd60e51b815260040161039090615c02565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b031614801561369557507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b0316145b8061370d57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b031614801561370d57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b0316145b6137295760405162461bcd60e51b815260040161039090615c75565b61373388866147b3565b604051632142170760e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906342842e0e90613783908a9030908a90600401615a29565b600060405180830381600087803b15801561379d57600080fd5b505af11580156137b1573d6000803e3d6000fd5b505050507f3917c2f26ce18614e3aedd1289da672ef6563c5c295f49e9b1697ae0ad3155623387876040516137e893929190615a89565b60405180910390a15050505050505050565b602084015160009063ffffffff1680613817576000915050610bd2565b60008061382383614848565b909250905081156138c6576040517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690632e1a7d4d90613893908590600401615ebf565b600060405180830381600087803b1580156138ad57600080fd5b505af11580156138c1573d6000803e3d6000fd5b505050505b60008060006138d78b86868b614a47565b91945092509050811561399f576040517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb9061394b908d908690600401615a4d565b602060405180830381600087803b15801561396557600080fd5b505af1158015613979573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061399d91906157da565b505b8215613a2657604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac906139f39030908790600401615a4d565b600060405180830381600087803b158015613a0d57600080fd5b505af1158015613a21573d6000803e3d6000fd5b505050505b7ffd0ae2fd36bd955810ae42615bc5ff277c0d0dfcb930f06c9f1777c0ef0752e3338a8787878787604051613a619796959493929190615ad0565b60405180910390a19a9950505050505050505050565b6000613aa06ec097ce7bc90715b34b9f100000000061282185613a9a8887613d80565b90613d80565b90505b9392505050565b600080613ab784846145ae565b50949350505050565b613aca8382613afd565b7f3ca13b7aab12bad7472691fe558faa6b25e99099824a0070a88bd5aa84be610f33838360405161319793929190615a89565b6040820151613b1e90613b19906001600160601b031683614add565b614b37565b6001600160601b031660409092019190915250565b600080600080613b5e8789606001516001600160801b03168a604001516001600160601b0316614b97565b9150915081871015613b825760405162461bcd60e51b815260040161039090615ccc565b604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac90613bd09088908690600401615a4d565b600060405180830381600087803b158015613bea57600080fd5b505af1158015613bfe573d6000803e3d6000fd5b50505050613c158289614bff90919063ffffffff16565b613c1f8882614592565b6000613c2b89886145ae565b9150508015613c4c5760405162461bcd60e51b815260040161039090615d78565b509097909650945050505050565b604080517fcce79bd50000000000000000000000000000000000000000000000000000000081526001600160a01b0387811660048301528681166024830152858116604483015263ffffffff851660648301528315156084830152915160009289169163cce79bd59160a4808301926020929190829003018186803b158015613ce257600080fd5b505afa158015613cf6573d6000803e3d6000fd5b505050506040513d6020811015613d0c57600080fd5b5051979650505050505050565b6000808211613d6f576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381613d7857fe5b049392505050565b600082613d8f575060006134e6565b82820282848281613d9c57fe5b0414613aa35760405162461bcd60e51b8152600401808060200182810382526021815260200180615fa56021913960400191505060405180910390fd5b6000613de3615670565b6040517f54ba0f270000000000000000000000000000000000000000000000000000000081526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906354ba0f2790613e4b908790600401615a15565b602060405180830381600087803b158015613e6557600080fd5b505af1158015613e79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e9d919061584d565b6040805160808101825260008082526020820181905281830181905260608201529051919250907f25ff1e0131762176a9084e92880f880f39d6d0e62134607f37e631efe1bad87190613ef39033908590615a4d565b60405180910390a19092509050915091565b600354600090819080613f1f576000849250925050613ff4565b600080613faf877f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000614c35565b90506000613fc36127106128218487613d80565b905080871115613fde57613fd7878261348a565b9250613fec565b613fe88982614592565b8692505b945090925050505b935093915050565b6140068482614c61565b6040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340c10f199061406d9086908590600401615a4d565b600060405180830381600087803b15801561408757600080fd5b505af115801561409b573d6000803e3d6000fd5b505050507fb19fa182730a088464dad0e9e0badeb470d0d8d937d854f5caf15c6ad1992c3633828460405161347c93929190615a89565b8063ffffffff81168114610c6c576040805162461bcd60e51b8152602060048083019190915260248201527f4f46333200000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663de5a6e227f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b815260040161419e9190615a15565b60206040518083038186803b1580156141b657600080fd5b505afa1580156141ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141ee919061591f565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663de5a6e227f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b815260040161425e9190615a15565b60206040518083038186803b15801561427657600080fd5b505afa15801561428a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142ae919061591f565b905060008163ffffffff168363ffffffff16116142cb57826142cd565b815b90508063ffffffff168563ffffffff16116142e857846142ea565b805b95945050505050565b6000600f83810b9083900b0260401d6f7fffffffffffffffffffffffffffffff19811280159061433357506f7fffffffffffffffffffffffffffffff8113155b613aa3576040805162461bcd60e51b815260206004820152600860248201527f4d554c2d4f565546000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b600081614393575060006134e6565b600083600f0b12156143ec576040805162461bcd60e51b815260206004820152600760248201527f4d554c552d583000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b600f83900b6001600160801b038316810260401c90608084901c0277ffffffffffffffffffffffffffffffffffffffffffffffff811115614474576040805162461bcd60e51b815260206004820152600860248201527f4d554c552d4f4631000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60401b81198111156144cd576040805162461bcd60e51b815260206004820152600860248201527f4d554c552d4f4632000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b019392505050565b6144df8482614bff565b604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac9061452d9086908590600401615a4d565b600060405180830381600087803b15801561454757600080fd5b505af115801561455b573d6000803e3d6000fd5b505050507fea19ffc45b48de6d95594aacff7214dd24595fdb0c60e98c8f0b269058c2f79233828460405161347c93929190615a89565b6040820151613b1e90613b19906001600160601b03168361348a565b60008060006146447f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006101a460016127ca565b905061475c857f00000000000000000000000000000000000000000000000000000000000000008684675fc1b971363200007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316634a0a96eb7f00000000000000000000000000000000000000000000000000000000000000006101a46040518363ffffffff1660e01b81526004016146e6929190615b25565b60206040518083038186803b1580156146fe57600080fd5b505afa158015614712573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614736919061581b565b7f0000000000000000000000000000000000000000000000000000000000000000614c7d565b92509250509250929050565b602081015163ffffffff166147a9576040805162461bcd60e51b81526020600482015260026024820152612b1960f11b604482015290519081900360640190fd5b6000602090910152565b602082015163ffffffff16156147f5576040805162461bcd60e51b8152602060048201526002602482015261563160f01b604482015290519081900360640190fd5b8061482d576040805162461bcd60e51b815260206004820152600360248201526243323360e81b604482015290519081900360640190fd5b614836816140d2565b63ffffffff1660209092019190915250565b6000807f0000000000000000000000000000000000000000000000000000000000000000816148778286614d21565b50506040805160a0810182528981526001600160801b03831660208201526000818301819052606082015242608082015290517f0c49ccbe00000000000000000000000000000000000000000000000000000000815291945092506001600160a01b0385169150630c49ccbe906148f2908490600401615e2e565b6040805180830381600087803b15801561490b57600080fd5b505af115801561491f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061494391906158b5565b5050604080516080810182528781523060208201526001600160801b03818301819052606082015290517ffc6f786500000000000000000000000000000000000000000000000000000000815260009081906001600160a01b0387169063fc6f7865906149b4908690600401615deb565b6040805180830381600087803b1580156149cd57600080fd5b505af11580156149e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a0591906158b5565b915091507f0000000000000000000000000000000000000000000000000000000000000000614a35578082614a38565b81815b97509750505050505050915091565b6000806000808415614a6057614a5d8787614ddf565b90505b606088015186906000906001600160801b0316821115614aa65760608a0151614a939089906001600160801b031661348a565b905089606001516001600160801b031691505b614ab08a83614bff565b614ab98a614768565b614ac38a8a613afd565b614acd8a84614592565b9099909850909650945050505050565b600082820183811015613aa3576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b806001600160601b0381168114610c6c576040805162461bcd60e51b8152602060048083019190915260248201527f4f46393600000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000808080614bb087614bab886002613d19565b614e8f565b9150915080851115614be557675fc1b97136320000614bcf868361348a565b1015614be557614bdf8787614e8f565b90925090505b84811115614bf35750849050835b90969095509350505050565b6060820151614c2090614c1b906001600160801b03168361348a565b612768565b6001600160801b031660609092019190915250565b600080614c49868686866101a46000613c5a565b9050612827670de0b6b3a76400006128218984613d80565b6060820151614c2090614c1b906001600160801b031683614add565b60008088606001516001600160801b031660001415614ca25750600190506000614d15565b6000614cdb6ec097ce7bc90715b34b9f100000000061282189613a9a8c8f606001516001600160801b0316613d8090919063ffffffff16565b90506000614ced8b8b8b8b8a8a614f6b565b90508681106000614cff846003613d80565b614d0a846002613d80565b101595509093505050505b97509795505050505050565b6000806000806000808790506000806000806000856001600160a01b03166399fbab888d6040518263ffffffff1660e01b8152600401808281526020019150506101806040518083038186803b158015614d7a57600080fd5b505afa158015614d8e573d6000803e3d6000fd5b505050506040513d610180811015614da557600080fd5b5060a081015160c082015160e083015161014084015161016090940151929e50909c509a5090985096505050505050509295509295909350565b6000613aa3670de0b6b3a764000061282166470de4df820000613a9a87614e89887f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000614c35565b90614add565b6000806000838511614ea15784614ea3565b835b90506000614f34827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000614c35565b9050614f5e614f57670de0b6b3a76400006128218467016345785d8a0000613d80565b8290614add565b9196919550909350505050565b6000866020015163ffffffff1660001415614f94575060408601516001600160601b03166127ed565b600080614fad888a6020015163ffffffff168787615002565b90925090506000614fd56ec097ce7bc90715b34b9f100000000061282189613a9a868d613d80565b60408b0151909150614ff4906001600160601b0316614e898584614add565b9a9950505050505050505050565b60008060008060008060006150178b8b614d21565b9450945094509450945060008061503087878d88615083565b915091508961505657826001600160801b03168101846001600160801b0316830161506f565b836001600160801b03168201836001600160801b031682015b985098505050505050505094509492505050565b600080600061509185615128565b90508660020b8560020b12156150c5576150be6150ad88615128565b6150b688615128565b86600161545a565b925061511e565b8560020b8560020b12156150fe576150e0816150b688615128565b92506150f76150ee88615128565b8286600161550c565b915061511e565b61511b61510a88615128565b61511388615128565b86600161550c565b91505b5094509492505050565b60008060008360020b1261513f578260020b615147565b8260020b6000035b9050620d89e8811115615185576040805162461bcd60e51b81526020600482015260016024820152601560fa1b604482015290519081900360640190fd5b60006001821661519957600160801b6151ab565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156151df576ffff97272373d413259a46990580e213a0260801c5b60048216156151fe576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b600882161561521d576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b601082161561523c576fffcb9843d60f6159c9db58835c9266440260801c5b602082161561525b576fff973b41fa98c081472e6896dfb254c00260801c5b604082161561527a576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615615299576ffe5dee046a99a2a811c461f1969c30530260801c5b6101008216156152b9576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b6102008216156152d9576ff987a7253ac413176f2b074cf7815e540260801c5b6104008216156152f9576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615615319576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615615339576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615615359576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615615379576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615615399576f31be135f97d08fd981231505542fcfa60260801c5b620100008216156153ba576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b620200008216156153da576e5d6af8dedb81196699c329225ee6040260801c5b620400008216156153f9576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615615416576b048a170391f7dc42444e8fa20260801c5b60008460020b131561543157806000198161542d57fe5b0490505b640100000000810615615445576001615448565b60005b60ff16602082901c0192505050919050565b6000836001600160a01b0316856001600160a01b0316111561547a579293925b7bffffffffffffffffffffffffffffffff000000000000000000000000606084901b166001600160a01b0386860381169087166154b657600080fd5b836154e657866001600160a01b03166154d98383896001600160a01b031661557c565b816154e057fe5b04612827565b6128276154fd8383896001600160a01b031661562b565b886001600160a01b0316615665565b6000836001600160a01b0316856001600160a01b0316111561552c579293925b8161555957615554836001600160801b03168686036001600160a01b0316600160601b61557c565b6142ea565b6142ea836001600160801b03168686036001600160a01b0316600160601b61562b565b60008080600019858709868602925082811090839003039050806155b257600084116155a757600080fd5b508290049050613aa3565b8084116155be57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b600061563884848461557c565b90506000828061564457fe5b8486091115613aa357600019811061565b57600080fd5b6001019392505050565b808204910615150190565b60408051608081018252600080825260208201819052918101829052606081019190915290565b8051610c6c81615efd565b8051600281900b8114610c6c57600080fd5b80516001600160801b0381168114610c6c57600080fd5b805162ffffff81168114610c6c57600080fd5b6000602082840312156156ef578081fd5b8135613aa381615efd565b60006020828403121561570b578081fd5b8151613aa381615efd565b6000806000806080858703121561572b578283fd5b843561573681615efd565b935060208581013561574781615efd565b935060408601359250606086013567ffffffffffffffff8082111561576a578384fd5b818801915088601f83011261577d578384fd5b81358181111561578957fe5b604051601f8201601f19168101850183811182821017156157a657fe5b60405281815283820185018b10156157bc578586fd5b81858501868301379081019093019390935250939692955090935050565b6000602082840312156157eb578081fd5b81518015158114613aa3578182fd5b60006020828403121561580b578081fd5b815180600f0b8114613aa3578182fd5b60006020828403121561582c578081fd5b613aa3826156a2565b600060208284031215615846578081fd5b5035919050565b60006020828403121561585e578081fd5b5051919050565b60008060408385031215615877578182fd5b82359150602083013561588981615efd565b809150509250929050565b600080604083850312156158a6578182fd5b50508035926020909101359150565b600080604083850312156158c7578182fd5b505080516020909101519092909150565b6000806000606084860312156158ec578283fd5b505081359360208301359350604090920135919050565b600060208284031215615914578081fd5b8135613aa381615f12565b600060208284031215615930578081fd5b8151613aa381615f12565b6000806000806000806000806000806000806101808d8f03121561595d57898afd5b8c516001600160601b0381168114615973578a8bfd5b9b5061598160208e01615697565b9a5061598f60408e01615697565b995061599d60608e01615697565b98506159ab60808e016156cb565b97506159b960a08e016156a2565b96506159c760c08e016156a2565b95506159d560e08e016156b4565b94506101008d015193506101208d015192506159f46101408e016156b4565b9150615a036101608e016156b4565b90509295989b509295989b509295989b565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b6001600160a01b039390931683526020830191909152604082015260600190565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b6001600160a01b03979097168752602087019590955260408601939093526060850191909152608084015260a083015260c082015260e00190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b0392909216825263ffffffff16602082015260400190565b6001600160a01b0394909416845263ffffffff9290921660208401526001600160601b031660408301526001600160801b0316606082015260800190565b901515815260200190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b600f9190910b815260200190565b60208082526003908201526210cc4d60ea1b604082015260600190565b60208082526003908201526204332360ec1b604082015260600190565b60208082526003908201526221991b60e91b604082015260600190565b602080825260029082015261219960f11b604082015260600190565b60208082526003908201526221989b60e91b604082015260600190565b60208082526003908201526243313360e81b604082015260600190565b60208082526003908201526243323360e81b604082015260600190565b60208082526003908201526243323560e81b604082015260600190565b60208082526003908201526208662760eb1b604082015260600190565b60208082526003908201526243323160e81b604082015260600190565b602080825260029082015261433160f01b604082015260600190565b602080825260029082015261043360f41b604082015260600190565b60208082526003908201526243313560e81b604082015260600190565b60208082526003908201526221989960e91b604082015260600190565b60208082526003908201526210cc8d60ea1b604082015260600190565b60208082526003908201526221991960e91b604082015260600190565b60208082526003908201526243313960e81b604082015260600190565b60208082526003908201526243313760e81b604082015260600190565b602080825260029082015261433360f01b604082015260600190565b815181526020808301516001600160a01b0316908201526040808301516001600160801b0390811691830191909152606092830151169181019190915260800190565b600060a082019050825182526001600160801b03602084015116602083015260408301516040830152606083015160608301526080830151608083015292915050565b6001600160801b0391909116815260200190565b6001600160801b039485168152602081019390935292166040820152606081019190915260800190565b62ffffff91909116815260200190565b90815260200190565b918252602082015260400190565b63ffffffff91909116815260200190565b63ffffffff929092168252602082015260400190565b6001600160a01b0381168114610d3857600080fd5b63ffffffff81168114610d3857600080fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c004f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a264697066735822122067d14fd1333db15cb72cd2b7553b52b4edf574b5ecc5983c9fbf5527769a740664736f6c63430007060033", + "solcInputHash": "d97d3d4b09e0d70518330d405a7dd9ff", + "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_oracle\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_shortPowerPerp\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_wPowerPerp\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_weth\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_quoteCurrency\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_ethQuoteCurrencyPool\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_wPowerPerpPool\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_uniPositionManager\",\"type\":\"address\"},{\"internalType\":\"uint24\",\"name\":\"_feeTier\",\"type\":\"uint24\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"}],\"name\":\"BurnShort\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"DepositCollateral\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"DepositUniPositionToken\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newFee\",\"type\":\"uint256\"}],\"name\":\"FeeRateUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldFeeRecipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newFeeRecipient\",\"type\":\"address\"}],\"name\":\"FeeRecipientUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"liquidator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"debtAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralPaid\",\"type\":\"uint256\"}],\"name\":\"Liquidate\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"}],\"name\":\"MintShort\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"oldNormFactor\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newNormFactor\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"lastModificationTimestamp\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"NormalizationFactorUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"}],\"name\":\"OpenVault\",\"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\":\"pausesLeft\",\"type\":\"uint256\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wPowerPerpAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"payoutAmount\",\"type\":\"uint256\"}],\"name\":\"RedeemLong\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vauldId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralAmount\",\"type\":\"uint256\"}],\"name\":\"RedeemShort\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"ethRedeemed\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wPowerPerpRedeemed\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wPowerPerpBurned\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"wPowerPerpExcess\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bounty\",\"type\":\"uint256\"}],\"name\":\"ReduceDebt\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"indexForSettlement\",\"type\":\"uint256\"}],\"name\":\"Shutdown\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"unpauser\",\"type\":\"address\"}],\"name\":\"UnPaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"UpdateOperator\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"WithdrawCollateral\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"vaultId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"WithdrawUniPositionToken\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"FUNDING_PERIOD\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TWAP_PERIOD\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"applyFunding\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_powerPerpAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_withdrawAmount\",\"type\":\"uint256\"}],\"name\":\"burnPowerPerpAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_wPowerPerpAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_withdrawAmount\",\"type\":\"uint256\"}],\"name\":\"burnWPowerPerpAmount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"}],\"name\":\"deposit\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_uniTokenId\",\"type\":\"uint256\"}],\"name\":\"depositUniPositionToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"donate\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ethQuoteCurrencyPool\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeRate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeRecipient\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feeTier\",\"outputs\":[{\"internalType\":\"uint24\",\"name\":\"\",\"type\":\"uint24\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_period\",\"type\":\"uint32\"}],\"name\":\"getDenormalizedMark\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_period\",\"type\":\"uint32\"}],\"name\":\"getDenormalizedMarkForFunding\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getExpectedNormalizationFactor\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_period\",\"type\":\"uint32\"}],\"name\":\"getIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_period\",\"type\":\"uint32\"}],\"name\":\"getUnscaledIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"indexForSettlement\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isShutDown\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isSystemPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"}],\"name\":\"isVaultSafe\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastFundingUpdateTimestamp\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastPauseTime\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maxDebtAmount\",\"type\":\"uint256\"}],\"name\":\"liquidate\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_powerPerpAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_uniTokenId\",\"type\":\"uint256\"}],\"name\":\"mintPowerPerpAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_wPowerPerpAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_uniTokenId\",\"type\":\"uint256\"}],\"name\":\"mintWPowerPerpAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"normalizationFactor\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC721Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"oracle\",\"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\":\"pause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pausesLeft\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"quoteCurrency\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_wPerpAmount\",\"type\":\"uint256\"}],\"name\":\"redeemLong\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"}],\"name\":\"redeemShort\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"}],\"name\":\"reduceDebt\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"}],\"name\":\"reduceDebtShutdown\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_newFeeRate\",\"type\":\"uint256\"}],\"name\":\"setFeeRate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_newFeeRecipient\",\"type\":\"address\"}],\"name\":\"setFeeRecipient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"shortPowerPerp\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"shutDown\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unPauseAnyone\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unPauseOwner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_operator\",\"type\":\"address\"}],\"name\":\"updateOperator\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"vaults\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"NftCollateralId\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"collateralAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint128\",\"name\":\"shortAmount\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wPowerPerp\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wPowerPerpPool\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"weth\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"}],\"name\":\"withdrawUniPositionToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"burnPowerPerpAmount(uint256,uint256,uint256)\":{\"params\":{\"_powerPerpAmount\":\"amount of powerPerp to burn\",\"_vaultId\":\"id of the vault\",\"_withdrawAmount\":\"amount of eth to withdraw\"},\"returns\":{\"_0\":\"amount of wPowerPerp burned\"}},\"burnWPowerPerpAmount(uint256,uint256,uint256)\":{\"params\":{\"_vaultId\":\"id of the vault\",\"_wPowerPerpAmount\":\"amount of wPowerPerp to burn\",\"_withdrawAmount\":\"amount of eth to withdraw\"}},\"constructor\":{\"params\":{\"_ethQuoteCurrencyPool\":\"uniswap v3 pool for weth / quoteCurrency\",\"_oracle\":\"oracle address\",\"_quoteCurrency\":\"quoteCurrency address\",\"_shortPowerPerp\":\"ERC721 token address representing the short position\",\"_uniPositionManager\":\"uniswap v3 position manager address\",\"_wPowerPerp\":\"ERC20 token address representing the long position\",\"_wPowerPerpPool\":\"uniswap v3 pool for wPowerPerp / weth\",\"_weth\":\"weth address\"}},\"deposit(uint256)\":{\"details\":\"deposit collateral into a vault\",\"params\":{\"_vaultId\":\"id of the vault\"}},\"depositUniPositionToken(uint256,uint256)\":{\"params\":{\"_uniTokenId\":\"uniswap position token id\",\"_vaultId\":\"id of the vault\"}},\"getDenormalizedMark(uint32)\":{\"params\":{\"_period\":\"period of time for the twap in seconds\"},\"returns\":{\"_0\":\"mark price denominated in $USD, scaled by 1e18\"}},\"getDenormalizedMarkForFunding(uint32)\":{\"details\":\"this is the mark that would be used to calculate a new normalization factor if funding was calculated now\",\"params\":{\"_period\":\"period which you want to calculate twap with\"},\"returns\":{\"_0\":\"mark price denominated in $USD, scaled by 1e18\"}},\"getExpectedNormalizationFactor()\":{\"details\":\"can be used for on-chain and off-chain calculations\"},\"getIndex(uint32)\":{\"details\":\"the index price is scaled down by INDEX_SCALE in the associated PowerXBase librarythis is the index price used when calculating funding and for collateralization\",\"params\":{\"_period\":\"period which you want to calculate twap with\"},\"returns\":{\"_0\":\"index price denominated in $USD, scaled by 1e18\"}},\"getUnscaledIndex(uint32)\":{\"details\":\"this is the mark that would be be used for future funding after a new normalization factor is applied\",\"params\":{\"_period\":\"period which you want to calculate twap with\"},\"returns\":{\"_0\":\"index price denominated in $USD, scaled by 1e18\"}},\"isVaultSafe(uint256)\":{\"details\":\"return if the vault is properly collateralized\",\"params\":{\"_vaultId\":\"id of the vault\"},\"returns\":{\"_0\":\"true if the vault is properly collateralized\"}},\"liquidate(uint256,uint256)\":{\"details\":\"liquidator can get back (wPowerPerp burned) * (index price) * (normalizationFactor) * 110% in collateralnormally can only liquidate 50% of a vault's debtif a vault is under dust limit after a liquidation can fully liquidatewill attempt to reduceDebt first, and can earn a bounty if sucessful\",\"params\":{\"_maxDebtAmount\":\"max amount of wPowerPerpetual to repay\",\"_vaultId\":\"vault to liquidate\"},\"returns\":{\"_0\":\"amount of wPowerPerp repaid\"}},\"mintPowerPerpAmount(uint256,uint256,uint256)\":{\"params\":{\"_powerPerpAmount\":\"amount of powerPerp to mint\",\"_uniTokenId\":\"uniswap v3 position token id (additional collateral)\",\"_vaultId\":\"vault to mint wPowerPerp in\"},\"returns\":{\"_0\":\"vaultId\",\"_1\":\"amount of wPowerPerp minted\"}},\"mintWPowerPerpAmount(uint256,uint256,uint256)\":{\"params\":{\"_uniTokenId\":\"uniswap v3 position token id (additional collateral)\",\"_vaultId\":\"vault to mint wPowerPerp in\",\"_wPowerPerpAmount\":\"amount of wPowerPerp to mint\"},\"returns\":{\"_0\":\"vaultId\"}},\"onERC721Received(address,address,uint256,bytes)\":{\"details\":\"accept erc721 from safeTransferFrom and safeMint after callback\",\"returns\":{\"_0\":\"returns received selector\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pause()\":{\"details\":\"can only be called for 365 days since the contract was launched or 4 times\"},\"redeemLong(uint256)\":{\"params\":{\"_wPerpAmount\":\"amount of wPowerPerp to burn\"}},\"redeemShort(uint256)\":{\"details\":\"short position is redeemed by valuing the debt at the (settlement index value) * normalizationFactor\",\"params\":{\"_vaultId\":\"vault id\"}},\"reduceDebt(uint256)\":{\"details\":\"the caller won't get any bounty. this is expected to be used by vault owner\",\"params\":{\"_vaultId\":\"target vault\"}},\"reduceDebtShutdown(uint256)\":{\"details\":\"the caller won't get any bounty. this is expected to be used for insolvent vaults in shutdown\",\"params\":{\"_vaultId\":\"vault containing uniswap v3 position to liquidate\"}},\"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.\"},\"setFeeRate(uint256)\":{\"details\":\"this function cannot be called if the feeRecipient is still un-set\",\"params\":{\"_newFeeRate\":\"new fee rate in basis points. can't be higher than 1%\"}},\"setFeeRecipient(address)\":{\"details\":\"this should be a contract handling insurance\",\"params\":{\"_newFeeRecipient\":\"new fee recipient\"}},\"shutDown()\":{\"details\":\"this bypasses the check on number of pauses or time based checks, but is irreversible and enables emergency settlement\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"unPauseAnyone()\":{\"details\":\"anyone can unpause the contract after 24 hours\"},\"unPauseOwner()\":{\"details\":\"owner can unpause at any time\"},\"updateOperator(uint256,address)\":{\"details\":\"can be revoke by setting address to 0\",\"params\":{\"_operator\":\"new operator address\",\"_vaultId\":\"id of the vault\"}},\"withdraw(uint256,uint256)\":{\"params\":{\"_amount\":\"amount of eth to withdraw\",\"_vaultId\":\"id of the vault\"}},\"withdrawUniPositionToken(uint256)\":{\"params\":{\"_vaultId\":\"id of the vault\"}}},\"stateVariables\":{\"ONE\":{\"details\":\"basic unit used for calculation\"},\"PAUSE_TIME_LIMIT\":{\"details\":\"system can only be paused for 182 days from deployment\"},\"feeRate\":{\"details\":\"fee rate in basis point. feeRate of 1 = 0.01%\"},\"indexForSettlement\":{\"details\":\"the settlement price for each wPowerPerp for settlement\"},\"vaults\":{\"details\":\"vault data storage\"},\"wPowerPerpPool\":{\"details\":\"address of the powerPerp/weth pool\"}},\"version\":1},\"userdoc\":{\"events\":{\"OpenVault(address,uint256)\":{\"notice\":\"Events\"}},\"kind\":\"user\",\"methods\":{\"applyFunding()\":{\"notice\":\"update the normalization factor as a way to pay funding\"},\"burnPowerPerpAmount(uint256,uint256,uint256)\":{\"notice\":\"burn powerPerp and remove collateral from a vault\"},\"burnWPowerPerpAmount(uint256,uint256,uint256)\":{\"notice\":\"burn wPowerPerp and remove collateral from a vault\"},\"constructor\":{\"notice\":\"constructor\"},\"depositUniPositionToken(uint256,uint256)\":{\"notice\":\"deposit uniswap position token into a vault to increase collateral ratio\"},\"donate()\":{\"notice\":\"add eth into a contract. used in case contract has insufficient eth to pay for settlement transactions\"},\"getDenormalizedMark(uint32)\":{\"notice\":\"get the expected mark price of powerPerp after funding has been applied\"},\"getDenormalizedMarkForFunding(uint32)\":{\"notice\":\"get the mark price of powerPerp before funding has been applied\"},\"getExpectedNormalizationFactor()\":{\"notice\":\"returns the expected normalization factor, if the funding is paid right now\"},\"getIndex(uint32)\":{\"notice\":\"get the index price of the powerPerp, scaled down\"},\"getUnscaledIndex(uint32)\":{\"notice\":\"the unscaled index of the power perp in USD, scaled by 18 decimals\"},\"liquidate(uint256,uint256)\":{\"notice\":\"if a vault is under the 150% collateral ratio, anyone can liquidate the vault by burning wPowerPerp\"},\"mintPowerPerpAmount(uint256,uint256,uint256)\":{\"notice\":\"deposit collateral and mint wPowerPerp (non-rebasing) for specified powerPerp (rebasing) amount\"},\"mintWPowerPerpAmount(uint256,uint256,uint256)\":{\"notice\":\"deposit collateral and mint wPowerPerp\"},\"pause()\":{\"notice\":\"pause the system for up to 24 hours after which any one can unpause\"},\"redeemLong(uint256)\":{\"notice\":\"redeem wPowerPerp for (settlement index value) * normalizationFactor when the system is shutdown\"},\"redeemShort(uint256)\":{\"notice\":\"redeem short position when the system is shutdown\"},\"reduceDebt(uint256)\":{\"notice\":\"withdraw assets from uniswap v3 position, reducing debt and increasing collateral in the vault\"},\"reduceDebtShutdown(uint256)\":{\"notice\":\"after the system is shutdown, insolvent vaults need to be have their uniswap v3 token assets withdrawn by forceif a vault has a uniswap v3 position in it, anyone can call to withdraw uniswap v3 token assets, reducing debt and increasing collateral in the vault\"},\"setFeeRate(uint256)\":{\"notice\":\"set the fee rate when user mints\"},\"setFeeRecipient(address)\":{\"notice\":\"set the recipient who will receive the fee\"},\"shutDown()\":{\"notice\":\"shutting down the system allows all long wPowerPerp to be settled at index * normalizationFactorshort positions can be redeemed for vault collateral minus value of debtpause (if not paused) and then immediately shutdown the system, can be called when paused already\"},\"unPauseAnyone()\":{\"notice\":\"unpause the contract\"},\"unPauseOwner()\":{\"notice\":\"unpause the contract\"},\"updateOperator(uint256,address)\":{\"notice\":\"authorize an address to modify the vault\"},\"withdraw(uint256,uint256)\":{\"notice\":\"withdraw collateral from a vault\"},\"withdrawUniPositionToken(uint256)\":{\"notice\":\"withdraw uniswap v3 position token from a vault\"}},\"notice\":\"Error C0: Paused C1: Not paused C2: Shutdown C3: Not shutdown C4: Invalid oracle address C5: Invalid shortPowerPerp address C6: Invalid wPowerPerp address C7: Invalid weth address C8: Invalid quote currency address C9: Invalid eth:quoteCurrency pool address C10: Invalid wPowerPerp:eth pool address C11: Invalid Uniswap position manager C12: Can not liquidate safe vault C13: Invalid address C14: Set fee recipient first C15: Fee too high C16: Paused too many times C17: Pause time limit exceeded C18: Not enough paused time has passed C19: Cannot receive eth C20: Not allowed C21: Need full liquidation C22: Dust vault left C23: Invalid nft C24: Invalid state C25: 0 liquidity Uniswap position token C26: Wrong fee tier for NFT deposit\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/core/Controller.sol\":\"Controller\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":825},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor () {\\n address msgSender = _msgSender();\\n _owner = msgSender;\\n emit OwnershipTransferred(address(0), msgSender);\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n emit OwnershipTransferred(_owner, address(0));\\n _owner = address(0);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n emit OwnershipTransferred(_owner, newOwner);\\n _owner = newOwner;\\n }\\n}\\n\",\"keccak256\":\"0x549c5343ad9f7e3f38aa4c4761854403502574bbc15b822db2ce892ff9b79da7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd2f30fad5b24c4120f96dbac83aacdb7993ee610a9092bc23c44463da292bf8d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0xe22a1fc7400ae196eba2ad1562d0386462b00a6363b742d55a2fd2021a58586f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0xbd74f587ab9b9711801baf667db1426e4a03fd2d7f15af33e0e0d0394e7cef76\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"../../introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\\n}\\n\",\"keccak256\":\"0xb11597841d47f7a773bca63ca323c76f804cb5d944788de0327db5526319dc82\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Enumerable is IERC721 {\\n\\n /**\\n * @dev Returns the total amount of tokens stored by the contract.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\\n */\\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);\\n\\n /**\\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\\n * Use along with {totalSupply} to enumerate all tokens.\\n */\\n function tokenByIndex(uint256 index) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x2789dfea2d73182683d637db5729201f6730dae6113030a94c828f8688f38f2f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Metadata is IERC721 {\\n\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0xc82c7d1d732081d9bd23f1555ebdf8f3bc1738bc42c2bfc4b9aa7564d9fa3573\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\\n */\\n function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0x05604ffcf69e416b8a42728bb0e4fd75170d8fac70bf1a284afeb4752a9bc52f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf89f005a3d98f7768cdee2583707db0ac725cf567d455751af32ee68132f3db3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/*\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with GSN meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x8d3cb350f04ff49cfb10aef08d87f19dcbaecc8027b0bed12f3275cd12f38cf0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor () {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and make it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0x1153f6dd334c01566417b8c551122450542a2b75a2bbb379d59a8c320ed6da28\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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;\\n}\\n\",\"keccak256\":\"0x0ba8a9b95a956a4050749c0158e928398c447c91469682ca8a7cc7e77a7fe032\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/FullMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.4.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 // 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;\\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 /// @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 result = mulDiv(a, b, denominator);\\n if (mulmod(a, b, denominator) > 0) {\\n require(result < type(uint256).max);\\n result++;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe511530871deaef86692cea9adb6076d26d7b47fd4815ce51af52af981026057\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/libraries/UnsafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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\":\"0x5f36d7d16348d8c37fe64fda932018d6e5e8acecd054f0f97d32db62d20c6c88\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IERC721Permit.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\n\\nimport '@openzeppelin/contracts/token/ERC721/IERC721.sol';\\n\\n/// @title ERC721 with permit\\n/// @notice Extension to ERC721 that includes a permit function for signature based approvals\\ninterface IERC721Permit is IERC721 {\\n /// @notice The permit typehash used in the permit signature\\n /// @return The typehash for the permit\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n\\n /// @notice The domain separator used in the permit signature\\n /// @return The domain seperator used in encoding of permit signature\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Approve of a specific token ID for spending by spender via signature\\n /// @param spender The account that is being approved\\n /// @param tokenId The ID of the token that is being approved for spending\\n /// @param deadline The deadline timestamp by which the call must be mined for the approve to work\\n /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`\\n /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`\\n /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`\\n function permit(\\n address spender,\\n uint256 tokenId,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable;\\n}\\n\",\"keccak256\":\"0x9e3c2a4ee65ddf95b2dfcb0815784eea3a295707e6f8b83e4c4f0f8fe2e3a1d4\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\nimport '@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol';\\nimport '@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol';\\n\\nimport './IPoolInitializer.sol';\\nimport './IERC721Permit.sol';\\nimport './IPeripheryPayments.sol';\\nimport './IPeripheryImmutableState.sol';\\nimport '../libraries/PoolAddress.sol';\\n\\n/// @title Non-fungible token for positions\\n/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred\\n/// and authorized.\\ninterface INonfungiblePositionManager is\\n IPoolInitializer,\\n IPeripheryPayments,\\n IPeripheryImmutableState,\\n IERC721Metadata,\\n IERC721Enumerable,\\n IERC721Permit\\n{\\n /// @notice Emitted when liquidity is increased for a position NFT\\n /// @dev Also emitted when a token is minted\\n /// @param tokenId The ID of the token for which liquidity was increased\\n /// @param liquidity The amount by which liquidity for the NFT position was increased\\n /// @param amount0 The amount of token0 that was paid for the increase in liquidity\\n /// @param amount1 The amount of token1 that was paid for the increase in liquidity\\n event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\\n /// @notice Emitted when liquidity is decreased for a position NFT\\n /// @param tokenId The ID of the token for which liquidity was decreased\\n /// @param liquidity The amount by which liquidity for the NFT position was decreased\\n /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity\\n /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity\\n event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\\n /// @notice Emitted when tokens are collected for a position NFT\\n /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior\\n /// @param tokenId The ID of the token for which underlying tokens were collected\\n /// @param recipient The address of the account that received the collected tokens\\n /// @param amount0 The amount of token0 owed to the position that was collected\\n /// @param amount1 The amount of token1 owed to the position that was collected\\n event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);\\n\\n /// @notice Returns the position information associated with a given token ID.\\n /// @dev Throws if the token ID is not valid.\\n /// @param tokenId The ID of the token that represents the position\\n /// @return nonce The nonce for permits\\n /// @return operator The address that is approved for spending\\n /// @return token0 The address of the token0 for a specific pool\\n /// @return token1 The address of the token1 for a specific pool\\n /// @return fee The fee associated with the pool\\n /// @return tickLower The lower end of the tick range for the position\\n /// @return tickUpper The higher end of the tick range for the position\\n /// @return liquidity The liquidity of the position\\n /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position\\n /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position\\n /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation\\n /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation\\n function positions(uint256 tokenId)\\n external\\n view\\n returns (\\n uint96 nonce,\\n address operator,\\n address token0,\\n address token1,\\n uint24 fee,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n uint256 feeGrowthInside0LastX128,\\n uint256 feeGrowthInside1LastX128,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n );\\n\\n struct MintParams {\\n address token0;\\n address token1;\\n uint24 fee;\\n int24 tickLower;\\n int24 tickUpper;\\n uint256 amount0Desired;\\n uint256 amount1Desired;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n address recipient;\\n uint256 deadline;\\n }\\n\\n /// @notice Creates a new position wrapped in a NFT\\n /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized\\n /// a method does not exist, i.e. the pool is assumed to be initialized.\\n /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata\\n /// @return tokenId The ID of the token that represents the minted position\\n /// @return liquidity The amount of liquidity for this position\\n /// @return amount0 The amount of token0\\n /// @return amount1 The amount of token1\\n function mint(MintParams calldata params)\\n external\\n payable\\n returns (\\n uint256 tokenId,\\n uint128 liquidity,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n struct IncreaseLiquidityParams {\\n uint256 tokenId;\\n uint256 amount0Desired;\\n uint256 amount1Desired;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n uint256 deadline;\\n }\\n\\n /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`\\n /// @param params tokenId The ID of the token for which liquidity is being increased,\\n /// amount0Desired The desired amount of token0 to be spent,\\n /// amount1Desired The desired amount of token1 to be spent,\\n /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,\\n /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,\\n /// deadline The time by which the transaction must be included to effect the change\\n /// @return liquidity The new liquidity amount as a result of the increase\\n /// @return amount0 The amount of token0 to acheive resulting liquidity\\n /// @return amount1 The amount of token1 to acheive resulting liquidity\\n function increaseLiquidity(IncreaseLiquidityParams calldata params)\\n external\\n payable\\n returns (\\n uint128 liquidity,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n struct DecreaseLiquidityParams {\\n uint256 tokenId;\\n uint128 liquidity;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n uint256 deadline;\\n }\\n\\n /// @notice Decreases the amount of liquidity in a position and accounts it to the position\\n /// @param params tokenId The ID of the token for which liquidity is being decreased,\\n /// amount The amount by which liquidity will be decreased,\\n /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,\\n /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,\\n /// deadline The time by which the transaction must be included to effect the change\\n /// @return amount0 The amount of token0 accounted to the position's tokens owed\\n /// @return amount1 The amount of token1 accounted to the position's tokens owed\\n function decreaseLiquidity(DecreaseLiquidityParams calldata params)\\n external\\n payable\\n returns (uint256 amount0, uint256 amount1);\\n\\n struct CollectParams {\\n uint256 tokenId;\\n address recipient;\\n uint128 amount0Max;\\n uint128 amount1Max;\\n }\\n\\n /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient\\n /// @param params tokenId The ID of the NFT for which tokens are being collected,\\n /// recipient The account that should receive the tokens,\\n /// amount0Max The maximum amount of token0 to collect,\\n /// amount1Max The maximum amount of token1 to collect\\n /// @return amount0 The amount of fees collected in token0\\n /// @return amount1 The amount of fees collected in token1\\n function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens\\n /// must be collected first.\\n /// @param tokenId The ID of the token that is being burned\\n function burn(uint256 tokenId) external payable;\\n}\\n\",\"keccak256\":\"0xe1dadc73e60bf05d0b4e0f05bd2847c5783e833cc10352c14763360b13495ee1\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPeripheryImmutableState.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Immutable state\\n/// @notice Functions that return immutable state of the router\\ninterface IPeripheryImmutableState {\\n /// @return Returns the address of the Uniswap V3 factory\\n function factory() external view returns (address);\\n\\n /// @return Returns the address of WETH9\\n function WETH9() external view returns (address);\\n}\\n\",\"keccak256\":\"0x7affcfeb5127c0925a71d6a65345e117c33537523aeca7bc98085ead8452519d\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPeripheryPayments.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\n\\n/// @title Periphery Payments\\n/// @notice Functions to ease deposits and withdrawals of ETH\\ninterface IPeripheryPayments {\\n /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.\\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.\\n /// @param amountMinimum The minimum amount of WETH9 to unwrap\\n /// @param recipient The address receiving ETH\\n function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;\\n\\n /// @notice Refunds any ETH balance held by this contract to the `msg.sender`\\n /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps\\n /// that use ether for the input amount\\n function refundETH() external payable;\\n\\n /// @notice Transfers the full amount of a token held by this contract to recipient\\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users\\n /// @param token The contract address of the token which will be transferred to `recipient`\\n /// @param amountMinimum The minimum amount of token required for a transfer\\n /// @param recipient The destination address of the token\\n function sweepToken(\\n address token,\\n uint256 amountMinimum,\\n address recipient\\n ) external payable;\\n}\\n\",\"keccak256\":\"0xb547e10f1e69bed03621a62b73a503e260643066c6b4054867a4d1fef47eb274\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPoolInitializer.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\n/// @title Creates and initializes V3 Pools\\n/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that\\n/// require the pool to exist.\\ninterface IPoolInitializer {\\n /// @notice Creates a new pool if it does not exist, then initializes if not initialized\\n /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool\\n /// @param token0 The contract address of token0 of the pool\\n /// @param token1 The contract address of token1 of the pool\\n /// @param fee The fee amount of the v3 pool for the specified token pair\\n /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value\\n /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary\\n function createAndInitializePoolIfNecessary(\\n address token0,\\n address token1,\\n uint24 fee,\\n uint160 sqrtPriceX96\\n ) external payable returns (address pool);\\n}\\n\",\"keccak256\":\"0x9d7695e8d94c22cc5fcced602017aabb988de89981ea7bee29ea629d5328a862\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee\\nlibrary PoolAddress {\\n bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;\\n\\n /// @notice The identifying key of the pool\\n struct PoolKey {\\n address token0;\\n address token1;\\n uint24 fee;\\n }\\n\\n /// @notice Returns PoolKey: the ordered tokens with the matched fee levels\\n /// @param tokenA The first token of a pool, unsorted\\n /// @param tokenB The second token of a pool, unsorted\\n /// @param fee The fee level of the pool\\n /// @return Poolkey The pool details with ordered token0 and token1 assignments\\n function getPoolKey(\\n address tokenA,\\n address tokenB,\\n uint24 fee\\n ) internal pure returns (PoolKey memory) {\\n if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);\\n return PoolKey({token0: tokenA, token1: tokenB, fee: fee});\\n }\\n\\n /// @notice Deterministically computes the pool address given the factory and PoolKey\\n /// @param factory The Uniswap V3 factory contract address\\n /// @param key The PoolKey\\n /// @return pool The contract address of the V3 pool\\n function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {\\n require(key.token0 < key.token1);\\n pool = address(\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n hex'ff',\\n factory,\\n keccak256(abi.encode(key.token0, key.token1, key.fee)),\\n POOL_INIT_CODE_HASH\\n )\\n )\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x5edd84eb8ba7c12fd8cb6cffe52e1e9f3f6464514ee5f539c2283826209035a2\",\"license\":\"GPL-2.0-or-later\"},\"contracts/core/Controller.sol\":{\"content\":\"//SPDX-License-Identifier: BUSL-1.1\\n\\npragma solidity =0.7.6;\\npragma abicoder v2;\\n\\n// interface\\nimport {IERC721} from \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\nimport {INonfungiblePositionManager} from \\\"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\\\";\\nimport {IWETH9} from \\\"../interfaces/IWETH9.sol\\\";\\nimport {IWPowerPerp} from \\\"../interfaces/IWPowerPerp.sol\\\";\\nimport {IShortPowerPerp} from \\\"../interfaces/IShortPowerPerp.sol\\\";\\nimport {IOracle} from \\\"../interfaces/IOracle.sol\\\";\\nimport {IERC721Receiver} from \\\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\\\";\\n\\n//contract\\nimport {Ownable} from \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport {ReentrancyGuard} from \\\"@openzeppelin/contracts/utils/ReentrancyGuard.sol\\\";\\n\\n//lib\\nimport {SafeMath} from \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport {Address} from \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport {ABDKMath64x64} from \\\"../libs/ABDKMath64x64.sol\\\";\\nimport {VaultLib} from \\\"../libs/VaultLib.sol\\\";\\nimport {Uint256Casting} from \\\"../libs/Uint256Casting.sol\\\";\\nimport {Power2Base} from \\\"../libs/Power2Base.sol\\\";\\n\\n/**\\n *\\n * Error\\n * C0: Paused\\n * C1: Not paused\\n * C2: Shutdown\\n * C3: Not shutdown\\n * C4: Invalid oracle address\\n * C5: Invalid shortPowerPerp address\\n * C6: Invalid wPowerPerp address\\n * C7: Invalid weth address\\n * C8: Invalid quote currency address\\n * C9: Invalid eth:quoteCurrency pool address\\n * C10: Invalid wPowerPerp:eth pool address\\n * C11: Invalid Uniswap position manager\\n * C12: Can not liquidate safe vault\\n * C13: Invalid address\\n * C14: Set fee recipient first\\n * C15: Fee too high\\n * C16: Paused too many times\\n * C17: Pause time limit exceeded\\n * C18: Not enough paused time has passed\\n * C19: Cannot receive eth\\n * C20: Not allowed\\n * C21: Need full liquidation\\n * C22: Dust vault left\\n * C23: Invalid nft\\n * C24: Invalid state\\n * C25: 0 liquidity Uniswap position token\\n * C26: Wrong fee tier for NFT deposit\\n */\\ncontract Controller is Ownable, ReentrancyGuard, IERC721Receiver {\\n using SafeMath for uint256;\\n using Uint256Casting for uint256;\\n using ABDKMath64x64 for int128;\\n using VaultLib for VaultLib.Vault;\\n using Address for address payable;\\n\\n uint256 internal constant MIN_COLLATERAL = 6.9 ether;\\n /// @dev system can only be paused for 182 days from deployment\\n uint256 internal constant PAUSE_TIME_LIMIT = 182 days;\\n\\n uint256 public constant FUNDING_PERIOD = 420 hours;\\n uint24 public immutable feeTier;\\n uint32 public constant TWAP_PERIOD = 420 seconds;\\n\\n //80% of index\\n uint256 internal constant LOWER_MARK_RATIO = 8e17;\\n //140% of index\\n uint256 internal constant UPPER_MARK_RATIO = 140e16;\\n // 10%\\n uint256 internal constant LIQUIDATION_BOUNTY = 1e17;\\n // 2%\\n uint256 internal constant REDUCE_DEBT_BOUNTY = 2e16;\\n\\n /// @dev basic unit used for calculation\\n uint256 private constant ONE = 1e18;\\n\\n address public immutable weth;\\n address public immutable quoteCurrency;\\n address public immutable ethQuoteCurrencyPool;\\n /// @dev address of the powerPerp/weth pool\\n address public immutable wPowerPerpPool;\\n address internal immutable uniswapPositionManager;\\n address public immutable shortPowerPerp;\\n address public immutable wPowerPerp;\\n address public immutable oracle;\\n address public feeRecipient;\\n\\n uint256 internal immutable deployTimestamp;\\n /// @dev fee rate in basis point. feeRate of 1 = 0.01%\\n uint256 public feeRate;\\n /// @dev the settlement price for each wPowerPerp for settlement\\n uint256 public indexForSettlement;\\n\\n uint256 public pausesLeft = 4;\\n uint256 public lastPauseTime;\\n\\n // these 2 parameters are always updated together. Use uint128 to batch read and write.\\n uint128 public normalizationFactor;\\n uint128 public lastFundingUpdateTimestamp;\\n\\n bool internal immutable isWethToken0;\\n bool public isShutDown;\\n bool public isSystemPaused;\\n\\n /// @dev vault data storage\\n mapping(uint256 => VaultLib.Vault) public vaults;\\n\\n /// Events\\n event OpenVault(address sender, uint256 vaultId);\\n event DepositCollateral(address sender, uint256 vaultId, uint256 amount);\\n event DepositUniPositionToken(address sender, uint256 vaultId, uint256 tokenId);\\n event WithdrawCollateral(address sender, uint256 vaultId, uint256 amount);\\n event WithdrawUniPositionToken(address sender, uint256 vaultId, uint256 tokenId);\\n event MintShort(address sender, uint256 amount, uint256 vaultId);\\n event BurnShort(address sender, uint256 amount, uint256 vaultId);\\n event ReduceDebt(\\n address sender,\\n uint256 vaultId,\\n uint256 ethRedeemed,\\n uint256 wPowerPerpRedeemed,\\n uint256 wPowerPerpBurned,\\n uint256 wPowerPerpExcess,\\n uint256 bounty\\n );\\n event UpdateOperator(address sender, uint256 vaultId, address operator);\\n event FeeRateUpdated(uint256 oldFee, uint256 newFee);\\n event FeeRecipientUpdated(address oldFeeRecipient, address newFeeRecipient);\\n event Liquidate(address liquidator, uint256 vaultId, uint256 debtAmount, uint256 collateralPaid);\\n event NormalizationFactorUpdated(\\n uint256 oldNormFactor,\\n uint256 newNormFactor,\\n uint256 lastModificationTimestamp,\\n uint256 timestamp\\n );\\n event Paused(uint256 pausesLeft);\\n event UnPaused(address unpauser);\\n event Shutdown(uint256 indexForSettlement);\\n event RedeemLong(address sender, uint256 wPowerPerpAmount, uint256 payoutAmount);\\n event RedeemShort(address sender, uint256 vauldId, uint256 collateralAmount);\\n\\n modifier notPaused() {\\n require(!isSystemPaused, \\\"C0\\\");\\n _;\\n }\\n\\n modifier isPaused() {\\n require(isSystemPaused, \\\"C1\\\");\\n _;\\n }\\n\\n modifier notShutdown() {\\n require(!isShutDown, \\\"C2\\\");\\n _;\\n }\\n\\n modifier isShutdown() {\\n require(isShutDown, \\\"C3\\\");\\n _;\\n }\\n\\n /**\\n * @notice constructor\\n * @param _oracle oracle address\\n * @param _shortPowerPerp ERC721 token address representing the short position\\n * @param _wPowerPerp ERC20 token address representing the long position\\n * @param _weth weth address\\n * @param _quoteCurrency quoteCurrency address\\n * @param _ethQuoteCurrencyPool uniswap v3 pool for weth / quoteCurrency\\n * @param _wPowerPerpPool uniswap v3 pool for wPowerPerp / weth\\n * @param _uniPositionManager uniswap v3 position manager address\\n */\\n constructor(\\n address _oracle,\\n address _shortPowerPerp,\\n address _wPowerPerp,\\n address _weth,\\n address _quoteCurrency,\\n address _ethQuoteCurrencyPool,\\n address _wPowerPerpPool,\\n address _uniPositionManager,\\n uint24 _feeTier\\n ) {\\n require(_oracle != address(0), \\\"C4\\\");\\n require(_shortPowerPerp != address(0), \\\"C5\\\");\\n require(_wPowerPerp != address(0), \\\"C6\\\");\\n require(_weth != address(0), \\\"C7\\\");\\n require(_quoteCurrency != address(0), \\\"C8\\\");\\n require(_ethQuoteCurrencyPool != address(0), \\\"C9\\\");\\n require(_wPowerPerpPool != address(0), \\\"C10\\\");\\n require(_uniPositionManager != address(0), \\\"C11\\\");\\n\\n oracle = _oracle;\\n shortPowerPerp = _shortPowerPerp;\\n wPowerPerp = _wPowerPerp;\\n weth = _weth;\\n quoteCurrency = _quoteCurrency;\\n ethQuoteCurrencyPool = _ethQuoteCurrencyPool;\\n wPowerPerpPool = _wPowerPerpPool;\\n uniswapPositionManager = _uniPositionManager;\\n feeTier = _feeTier;\\n isWethToken0 = _weth < _wPowerPerp;\\n\\n normalizationFactor = 1e18;\\n deployTimestamp = block.timestamp;\\n lastFundingUpdateTimestamp = block.timestamp.toUint128();\\n }\\n\\n /**\\n * ======================\\n * | External Functions |\\n * ======================\\n */\\n\\n /**\\n * @notice returns the expected normalization factor, if the funding is paid right now\\n * @dev can be used for on-chain and off-chain calculations\\n */\\n function getExpectedNormalizationFactor() external view returns (uint256) {\\n return _getNewNormalizationFactor();\\n }\\n\\n /**\\n * @notice get the index price of the powerPerp, scaled down\\n * @dev the index price is scaled down by INDEX_SCALE in the associated PowerXBase library\\n * @dev this is the index price used when calculating funding and for collateralization\\n * @param _period period which you want to calculate twap with\\n * @return index price denominated in $USD, scaled by 1e18\\n */\\n function getIndex(uint32 _period) external view returns (uint256) {\\n return Power2Base._getIndex(_period, oracle, ethQuoteCurrencyPool, weth, quoteCurrency);\\n }\\n\\n /**\\n * @notice the unscaled index of the power perp in USD, scaled by 18 decimals\\n * @dev this is the mark that would be be used for future funding after a new normalization factor is applied\\n * @param _period period which you want to calculate twap with\\n * @return index price denominated in $USD, scaled by 1e18\\n */\\n function getUnscaledIndex(uint32 _period) external view returns (uint256) {\\n return Power2Base._getUnscaledIndex(_period, oracle, ethQuoteCurrencyPool, weth, quoteCurrency);\\n }\\n\\n /**\\n * @notice get the expected mark price of powerPerp after funding has been applied\\n * @param _period period of time for the twap in seconds\\n * @return mark price denominated in $USD, scaled by 1e18\\n */\\n function getDenormalizedMark(uint32 _period) external view returns (uint256) {\\n return\\n Power2Base._getDenormalizedMark(\\n _period,\\n oracle,\\n wPowerPerpPool,\\n ethQuoteCurrencyPool,\\n weth,\\n quoteCurrency,\\n wPowerPerp,\\n _getNewNormalizationFactor()\\n );\\n }\\n\\n /**\\n * @notice get the mark price of powerPerp before funding has been applied\\n * @dev this is the mark that would be used to calculate a new normalization factor if funding was calculated now\\n * @param _period period which you want to calculate twap with\\n * @return mark price denominated in $USD, scaled by 1e18\\n */\\n function getDenormalizedMarkForFunding(uint32 _period) external view returns (uint256) {\\n return\\n Power2Base._getDenormalizedMark(\\n _period,\\n oracle,\\n wPowerPerpPool,\\n ethQuoteCurrencyPool,\\n weth,\\n quoteCurrency,\\n wPowerPerp,\\n normalizationFactor\\n );\\n }\\n\\n /**\\n * @dev return if the vault is properly collateralized\\n * @param _vaultId id of the vault\\n * @return true if the vault is properly collateralized\\n */\\n function isVaultSafe(uint256 _vaultId) external view returns (bool) {\\n VaultLib.Vault memory vault = vaults[_vaultId];\\n uint256 expectedNormalizationFactor = _getNewNormalizationFactor();\\n return _isVaultSafe(vault, expectedNormalizationFactor);\\n }\\n\\n /**\\n * @notice deposit collateral and mint wPowerPerp (non-rebasing) for specified powerPerp (rebasing) amount\\n * @param _vaultId vault to mint wPowerPerp in\\n * @param _powerPerpAmount amount of powerPerp to mint\\n * @param _uniTokenId uniswap v3 position token id (additional collateral)\\n * @return vaultId\\n * @return amount of wPowerPerp minted\\n */\\n function mintPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _powerPerpAmount,\\n uint256 _uniTokenId\\n ) external payable notPaused nonReentrant returns (uint256, uint256) {\\n return _openDepositMint(msg.sender, _vaultId, _powerPerpAmount, msg.value, _uniTokenId, false);\\n }\\n\\n /**\\n * @notice deposit collateral and mint wPowerPerp\\n * @param _vaultId vault to mint wPowerPerp in\\n * @param _wPowerPerpAmount amount of wPowerPerp to mint\\n * @param _uniTokenId uniswap v3 position token id (additional collateral)\\n * @return vaultId\\n */\\n function mintWPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _uniTokenId\\n ) external payable notPaused nonReentrant returns (uint256) {\\n (uint256 vaultId, ) = _openDepositMint(msg.sender, _vaultId, _wPowerPerpAmount, msg.value, _uniTokenId, true);\\n return vaultId;\\n }\\n\\n /**\\n * @dev deposit collateral into a vault\\n * @param _vaultId id of the vault\\n */\\n function deposit(uint256 _vaultId) external payable notPaused nonReentrant {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n\\n _applyFunding();\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n _addEthCollateral(cachedVault, _vaultId, msg.value);\\n\\n _writeVault(_vaultId, cachedVault);\\n }\\n\\n /**\\n * @notice deposit uniswap position token into a vault to increase collateral ratio\\n * @param _vaultId id of the vault\\n * @param _uniTokenId uniswap position token id\\n */\\n function depositUniPositionToken(uint256 _vaultId, uint256 _uniTokenId) external notPaused nonReentrant {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n\\n _applyFunding();\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n\\n _depositUniPositionToken(cachedVault, msg.sender, _vaultId, _uniTokenId);\\n _writeVault(_vaultId, cachedVault);\\n }\\n\\n /**\\n * @notice withdraw collateral from a vault\\n * @param _vaultId id of the vault\\n * @param _amount amount of eth to withdraw\\n */\\n function withdraw(uint256 _vaultId, uint256 _amount) external notPaused nonReentrant {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n\\n uint256 cachedNormFactor = _applyFunding();\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n\\n _withdrawCollateral(cachedVault, _vaultId, _amount);\\n _checkVault(cachedVault, cachedNormFactor);\\n _writeVault(_vaultId, cachedVault);\\n payable(msg.sender).sendValue(_amount);\\n }\\n\\n /**\\n * @notice withdraw uniswap v3 position token from a vault\\n * @param _vaultId id of the vault\\n */\\n function withdrawUniPositionToken(uint256 _vaultId) external notPaused nonReentrant {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n\\n uint256 cachedNormFactor = _applyFunding();\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n _withdrawUniPositionToken(cachedVault, msg.sender, _vaultId);\\n _checkVault(cachedVault, cachedNormFactor);\\n _writeVault(_vaultId, cachedVault);\\n }\\n\\n /**\\n * @notice burn wPowerPerp and remove collateral from a vault\\n * @param _vaultId id of the vault\\n * @param _wPowerPerpAmount amount of wPowerPerp to burn\\n * @param _withdrawAmount amount of eth to withdraw\\n */\\n function burnWPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _withdrawAmount\\n ) external notPaused nonReentrant {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n\\n _burnAndWithdraw(msg.sender, _vaultId, _wPowerPerpAmount, _withdrawAmount, true);\\n }\\n\\n /**\\n * @notice burn powerPerp and remove collateral from a vault\\n * @param _vaultId id of the vault\\n * @param _powerPerpAmount amount of powerPerp to burn\\n * @param _withdrawAmount amount of eth to withdraw\\n * @return amount of wPowerPerp burned\\n */\\n function burnPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _powerPerpAmount,\\n uint256 _withdrawAmount\\n ) external notPaused nonReentrant returns (uint256) {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n\\n return _burnAndWithdraw(msg.sender, _vaultId, _powerPerpAmount, _withdrawAmount, false);\\n }\\n\\n /**\\n * @notice after the system is shutdown, insolvent vaults need to be have their uniswap v3 token assets withdrawn by force\\n * @notice if a vault has a uniswap v3 position in it, anyone can call to withdraw uniswap v3 token assets, reducing debt and increasing collateral in the vault\\n * @dev the caller won't get any bounty. this is expected to be used for insolvent vaults in shutdown\\n * @param _vaultId vault containing uniswap v3 position to liquidate\\n */\\n function reduceDebtShutdown(uint256 _vaultId) external isShutdown nonReentrant {\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n _reduceDebt(cachedVault, IShortPowerPerp(shortPowerPerp).ownerOf(_vaultId), _vaultId, false);\\n _writeVault(_vaultId, cachedVault);\\n }\\n\\n /**\\n * @notice withdraw assets from uniswap v3 position, reducing debt and increasing collateral in the vault\\n * @dev the caller won't get any bounty. this is expected to be used by vault owner\\n * @param _vaultId target vault\\n */\\n function reduceDebt(uint256 _vaultId) external notPaused nonReentrant {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n\\n _reduceDebt(cachedVault, IShortPowerPerp(shortPowerPerp).ownerOf(_vaultId), _vaultId, false);\\n\\n _writeVault(_vaultId, cachedVault);\\n }\\n\\n /**\\n * @notice if a vault is under the 150% collateral ratio, anyone can liquidate the vault by burning wPowerPerp\\n * @dev liquidator can get back (wPowerPerp burned) * (index price) * (normalizationFactor) * 110% in collateral\\n * @dev normally can only liquidate 50% of a vault's debt\\n * @dev if a vault is under dust limit after a liquidation can fully liquidate\\n * @dev will attempt to reduceDebt first, and can earn a bounty if sucessful\\n * @param _vaultId vault to liquidate\\n * @param _maxDebtAmount max amount of wPowerPerpetual to repay\\n * @return amount of wPowerPerp repaid\\n */\\n function liquidate(uint256 _vaultId, uint256 _maxDebtAmount) external notPaused nonReentrant returns (uint256) {\\n uint256 cachedNormFactor = _applyFunding();\\n\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n\\n require(!_isVaultSafe(cachedVault, cachedNormFactor), \\\"C12\\\");\\n\\n // try to save target vault before liquidation by reducing debt\\n uint256 bounty = _reduceDebt(cachedVault, IShortPowerPerp(shortPowerPerp).ownerOf(_vaultId), _vaultId, true);\\n\\n // if vault is safe after saving, pay bounty and return early\\n if (_isVaultSafe(cachedVault, cachedNormFactor)) {\\n _writeVault(_vaultId, cachedVault);\\n payable(msg.sender).sendValue(bounty);\\n return 0;\\n }\\n\\n // add back the bounty amount, liquidators onlly get reward from liquidation\\n cachedVault.addEthCollateral(bounty);\\n\\n // if the vault is still not safe after saving, liquidate it\\n (uint256 debtAmount, uint256 collateralPaid) = _liquidate(\\n cachedVault,\\n _maxDebtAmount,\\n cachedNormFactor,\\n msg.sender\\n );\\n\\n emit Liquidate(msg.sender, _vaultId, debtAmount, collateralPaid);\\n\\n _writeVault(_vaultId, cachedVault);\\n\\n // pay the liquidator\\n payable(msg.sender).sendValue(collateralPaid);\\n\\n return debtAmount;\\n }\\n\\n /**\\n * @notice authorize an address to modify the vault\\n * @dev can be revoke by setting address to 0\\n * @param _vaultId id of the vault\\n * @param _operator new operator address\\n */\\n function updateOperator(uint256 _vaultId, address _operator) external {\\n require(\\n (shortPowerPerp == msg.sender) || (IShortPowerPerp(shortPowerPerp).ownerOf(_vaultId) == msg.sender),\\n \\\"C20\\\"\\n );\\n vaults[_vaultId].operator = _operator;\\n emit UpdateOperator(msg.sender, _vaultId, _operator);\\n }\\n\\n /**\\n * @notice set the recipient who will receive the fee\\n * @dev this should be a contract handling insurance\\n * @param _newFeeRecipient new fee recipient\\n */\\n function setFeeRecipient(address _newFeeRecipient) external onlyOwner {\\n require(_newFeeRecipient != address(0), \\\"C13\\\");\\n emit FeeRecipientUpdated(feeRecipient, _newFeeRecipient);\\n feeRecipient = _newFeeRecipient;\\n }\\n\\n /**\\n * @notice set the fee rate when user mints\\n * @dev this function cannot be called if the feeRecipient is still un-set\\n * @param _newFeeRate new fee rate in basis points. can't be higher than 1%\\n */\\n function setFeeRate(uint256 _newFeeRate) external onlyOwner {\\n require(feeRecipient != address(0), \\\"C14\\\");\\n require(_newFeeRate <= 100, \\\"C15\\\");\\n emit FeeRateUpdated(feeRate, _newFeeRate);\\n feeRate = _newFeeRate;\\n }\\n\\n /**\\n * @notice shutting down the system allows all long wPowerPerp to be settled at index * normalizationFactor\\n * @notice short positions can be redeemed for vault collateral minus value of debt\\n * @notice pause (if not paused) and then immediately shutdown the system, can be called when paused already\\n * @dev this bypasses the check on number of pauses or time based checks, but is irreversible and enables emergency settlement\\n */\\n function shutDown() external onlyOwner notShutdown {\\n isSystemPaused = true;\\n isShutDown = true;\\n indexForSettlement = Power2Base._getScaledTwap(\\n oracle,\\n ethQuoteCurrencyPool,\\n weth,\\n quoteCurrency,\\n TWAP_PERIOD,\\n false\\n );\\n emit Shutdown(indexForSettlement);\\n }\\n\\n /**\\n * @notice pause the system for up to 24 hours after which any one can unpause\\n * @dev can only be called for 365 days since the contract was launched or 4 times\\n */\\n function pause() external onlyOwner notShutdown notPaused {\\n require(pausesLeft > 0, \\\"C16\\\");\\n uint256 timeSinceDeploy = block.timestamp.sub(deployTimestamp);\\n require(timeSinceDeploy < PAUSE_TIME_LIMIT, \\\"C17\\\");\\n isSystemPaused = true;\\n pausesLeft -= 1;\\n lastPauseTime = block.timestamp;\\n\\n emit Paused(pausesLeft);\\n }\\n\\n /**\\n * @notice unpause the contract\\n * @dev anyone can unpause the contract after 24 hours\\n */\\n function unPauseAnyone() external isPaused notShutdown {\\n require(block.timestamp > (lastPauseTime + 1 days), \\\"C18\\\");\\n isSystemPaused = false;\\n emit UnPaused(msg.sender);\\n }\\n\\n /**\\n * @notice unpause the contract\\n * @dev owner can unpause at any time\\n */\\n function unPauseOwner() external onlyOwner isPaused notShutdown {\\n isSystemPaused = false;\\n emit UnPaused(msg.sender);\\n }\\n\\n /**\\n * @notice redeem wPowerPerp for (settlement index value) * normalizationFactor when the system is shutdown\\n * @param _wPerpAmount amount of wPowerPerp to burn\\n */\\n function redeemLong(uint256 _wPerpAmount) external isShutdown nonReentrant {\\n IWPowerPerp(wPowerPerp).burn(msg.sender, _wPerpAmount);\\n\\n uint256 longValue = Power2Base._getLongSettlementValue(_wPerpAmount, indexForSettlement, normalizationFactor);\\n payable(msg.sender).sendValue(longValue);\\n\\n emit RedeemLong(msg.sender, _wPerpAmount, longValue);\\n }\\n\\n /**\\n * @notice redeem short position when the system is shutdown\\n * @dev short position is redeemed by valuing the debt at the (settlement index value) * normalizationFactor\\n * @param _vaultId vault id\\n */\\n function redeemShort(uint256 _vaultId) external isShutdown nonReentrant {\\n _checkCanModifyVault(_vaultId, msg.sender);\\n\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n uint256 cachedNormFactor = normalizationFactor;\\n\\n _reduceDebt(cachedVault, msg.sender, _vaultId, false);\\n\\n uint256 debt = Power2Base._getLongSettlementValue(\\n cachedVault.shortAmount,\\n indexForSettlement,\\n cachedNormFactor\\n );\\n // if the debt is more than collateral, this line will revert\\n uint256 excess = uint256(cachedVault.collateralAmount).sub(debt);\\n\\n // reset the vault but don't burn the nft, just because people may want to keep it\\n cachedVault.shortAmount = 0;\\n cachedVault.collateralAmount = 0;\\n _writeVault(_vaultId, cachedVault);\\n\\n payable(msg.sender).sendValue(excess);\\n\\n emit RedeemShort(msg.sender, _vaultId, excess);\\n }\\n\\n /**\\n * @notice update the normalization factor as a way to pay funding\\n */\\n function applyFunding() external notPaused {\\n _applyFunding();\\n }\\n\\n /**\\n * @notice add eth into a contract. used in case contract has insufficient eth to pay for settlement transactions\\n */\\n function donate() external payable isShutdown {}\\n\\n /**\\n * @notice fallback function to accept eth\\n */\\n receive() external payable {\\n require(msg.sender == weth, \\\"C19\\\");\\n }\\n\\n /**\\n * @dev accept erc721 from safeTransferFrom and safeMint after callback\\n * @return returns received selector\\n */\\n function onERC721Received(\\n address,\\n address,\\n uint256,\\n bytes memory\\n ) public virtual override returns (bytes4) {\\n return this.onERC721Received.selector;\\n }\\n\\n /*\\n * ======================\\n * | Internal Functions |\\n * ======================\\n */\\n\\n /**\\n * @notice check if an address can modify a vault\\n * @param _vaultId the id of the vault to check if can be modified by _account\\n * @param _account the address to check if can modify the vault\\n */\\n function _checkCanModifyVault(uint256 _vaultId, address _account) internal view {\\n require(\\n IShortPowerPerp(shortPowerPerp).ownerOf(_vaultId) == _account || vaults[_vaultId].operator == _account,\\n \\\"C20\\\"\\n );\\n }\\n\\n /**\\n * @notice wrapper function which opens a vault, adds collateral and mints wPowerPerp\\n * @param _account account to receive wPowerPerp\\n * @param _vaultId id of the vault\\n * @param _mintAmount amount to mint\\n * @param _depositAmount amount of eth as collateral\\n * @param _uniTokenId id of uniswap v3 position token\\n * @param _isWAmount if the input amount is a wPowerPerp amount (as opposed to rebasing powerPerp)\\n * @return the vaultId that was acted on or for a new vault the newly created vaultId\\n * @return the minted wPowerPerp amount\\n */\\n function _openDepositMint(\\n address _account,\\n uint256 _vaultId,\\n uint256 _mintAmount,\\n uint256 _depositAmount,\\n uint256 _uniTokenId,\\n bool _isWAmount\\n ) internal returns (uint256, uint256) {\\n uint256 cachedNormFactor = _applyFunding();\\n uint256 depositAmountWithFee = _depositAmount;\\n uint256 wPowerPerpAmount = _isWAmount ? _mintAmount : _mintAmount.mul(ONE).div(cachedNormFactor);\\n uint256 feeAmount;\\n VaultLib.Vault memory cachedVault;\\n\\n // load vault or create new a new one\\n if (_vaultId == 0) {\\n (_vaultId, cachedVault) = _openVault(_account);\\n } else {\\n // make sure we're not accessing an unexistent vault.\\n _checkCanModifyVault(_vaultId, msg.sender);\\n cachedVault = vaults[_vaultId];\\n }\\n\\n if (wPowerPerpAmount > 0) {\\n (feeAmount, depositAmountWithFee) = _getFee(cachedVault, wPowerPerpAmount, _depositAmount);\\n _mintWPowerPerp(cachedVault, _account, _vaultId, wPowerPerpAmount);\\n }\\n if (_depositAmount > 0) _addEthCollateral(cachedVault, _vaultId, depositAmountWithFee);\\n if (_uniTokenId != 0) _depositUniPositionToken(cachedVault, _account, _vaultId, _uniTokenId);\\n\\n _checkVault(cachedVault, cachedNormFactor);\\n _writeVault(_vaultId, cachedVault);\\n\\n // pay insurance fee\\n if (feeAmount > 0) payable(feeRecipient).sendValue(feeAmount);\\n\\n return (_vaultId, wPowerPerpAmount);\\n }\\n\\n /**\\n * @notice wrapper function to burn wPowerPerp and redeem collateral\\n * @param _account who should receive collateral\\n * @param _vaultId id of the vault\\n * @param _burnAmount amount of wPowerPerp to burn\\n * @param _withdrawAmount amount of eth collateral to withdraw\\n * @param _isWAmount true if the amount is wPowerPerp (as opposed to rebasing powerPerp)\\n * @return total burned wPowerPower amount\\n */\\n function _burnAndWithdraw(\\n address _account,\\n uint256 _vaultId,\\n uint256 _burnAmount,\\n uint256 _withdrawAmount,\\n bool _isWAmount\\n ) internal returns (uint256) {\\n uint256 cachedNormFactor = _applyFunding();\\n uint256 wBurnAmount = _isWAmount ? _burnAmount : _burnAmount.mul(ONE).div(cachedNormFactor);\\n\\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\\n if (wBurnAmount > 0) _burnWPowerPerp(cachedVault, _account, _vaultId, wBurnAmount);\\n if (_withdrawAmount > 0) _withdrawCollateral(cachedVault, _vaultId, _withdrawAmount);\\n _checkVault(cachedVault, cachedNormFactor);\\n _writeVault(_vaultId, cachedVault);\\n\\n if (_withdrawAmount > 0) payable(msg.sender).sendValue(_withdrawAmount);\\n\\n return wBurnAmount;\\n }\\n\\n /**\\n * @notice open a new vault\\n * @dev create a new vault and bind it with a new short vault id\\n * @param _recipient owner of new vault\\n * @return id of the new vault\\n * @return new in-memory vault\\n */\\n function _openVault(address _recipient) internal returns (uint256, VaultLib.Vault memory) {\\n uint256 vaultId = IShortPowerPerp(shortPowerPerp).mintNFT(_recipient);\\n\\n VaultLib.Vault memory vault = VaultLib.Vault({\\n NftCollateralId: 0,\\n collateralAmount: 0,\\n shortAmount: 0,\\n operator: address(0)\\n });\\n emit OpenVault(msg.sender, vaultId);\\n return (vaultId, vault);\\n }\\n\\n /**\\n * @notice deposit uniswap v3 position token into a vault\\n * @dev this function will update the vault memory in-place\\n * @param _vault the Vault memory to update\\n * @param _account account to transfer the uniswap v3 position from\\n * @param _vaultId id of the vault\\n * @param _uniTokenId uniswap position token id\\n */\\n function _depositUniPositionToken(\\n VaultLib.Vault memory _vault,\\n address _account,\\n uint256 _vaultId,\\n uint256 _uniTokenId\\n ) internal {\\n //get tokens for uniswap NFT\\n (, , address token0, address token1, uint24 fee, , , uint128 liquidity, , , , ) = INonfungiblePositionManager(\\n uniswapPositionManager\\n ).positions(_uniTokenId);\\n\\n // require that liquidity is above 0\\n require(liquidity > 0, \\\"C25\\\");\\n // accept NFTs from only the wPowerPerp pool\\n require(fee == feeTier, \\\"C26\\\");\\n // check token0 and token1\\n require((token0 == wPowerPerp && token1 == weth) || (token1 == wPowerPerp && token0 == weth), \\\"C23\\\");\\n\\n _vault.addUniNftCollateral(_uniTokenId);\\n INonfungiblePositionManager(uniswapPositionManager).safeTransferFrom(_account, address(this), _uniTokenId);\\n emit DepositUniPositionToken(msg.sender, _vaultId, _uniTokenId);\\n }\\n\\n /**\\n * @notice add eth collateral into a vault\\n * @dev this function will update the vault memory in-place\\n * @param _vault the Vault memory to update.\\n * @param _vaultId id of the vault\\n * @param _amount amount of eth adding to the vault\\n */\\n function _addEthCollateral(\\n VaultLib.Vault memory _vault,\\n uint256 _vaultId,\\n uint256 _amount\\n ) internal {\\n _vault.addEthCollateral(_amount);\\n emit DepositCollateral(msg.sender, _vaultId, _amount);\\n }\\n\\n /**\\n * @notice remove uniswap v3 position token from the vault\\n * @dev this function will update the vault memory in-place\\n * @param _vault the Vault memory to update\\n * @param _account where to send the uni position token to\\n * @param _vaultId id of the vault\\n */\\n function _withdrawUniPositionToken(\\n VaultLib.Vault memory _vault,\\n address _account,\\n uint256 _vaultId\\n ) internal {\\n uint256 tokenId = _vault.NftCollateralId;\\n _vault.removeUniNftCollateral();\\n INonfungiblePositionManager(uniswapPositionManager).safeTransferFrom(address(this), _account, tokenId);\\n emit WithdrawUniPositionToken(msg.sender, _vaultId, tokenId);\\n }\\n\\n /**\\n * @notice remove eth collateral from the vault\\n * @dev this function will update the vault memory in-place\\n * @param _vault the Vault memory to update\\n * @param _vaultId id of the vault\\n * @param _amount amount of eth to withdraw\\n */\\n function _withdrawCollateral(\\n VaultLib.Vault memory _vault,\\n uint256 _vaultId,\\n uint256 _amount\\n ) internal {\\n _vault.removeEthCollateral(_amount);\\n\\n emit WithdrawCollateral(msg.sender, _vaultId, _amount);\\n }\\n\\n /**\\n * @notice mint wPowerPerp (ERC20) to an account\\n * @dev this function will update the vault memory in-place\\n * @param _vault the Vault memory to update\\n * @param _account account to receive wPowerPerp\\n * @param _vaultId id of the vault\\n * @param _wPowerPerpAmount wPowerPerp amount to mint\\n */\\n function _mintWPowerPerp(\\n VaultLib.Vault memory _vault,\\n address _account,\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount\\n ) internal {\\n _vault.addShort(_wPowerPerpAmount);\\n IWPowerPerp(wPowerPerp).mint(_account, _wPowerPerpAmount);\\n\\n emit MintShort(msg.sender, _wPowerPerpAmount, _vaultId);\\n }\\n\\n /**\\n * @notice burn wPowerPerp (ERC20) from an account\\n * @dev this function will update the vault memory in-place\\n * @param _vault the Vault memory to update\\n * @param _account account burning the wPowerPerp\\n * @param _vaultId id of the vault\\n * @param _wPowerPerpAmount wPowerPerp amount to burn\\n */\\n function _burnWPowerPerp(\\n VaultLib.Vault memory _vault,\\n address _account,\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount\\n ) internal {\\n _vault.removeShort(_wPowerPerpAmount);\\n IWPowerPerp(wPowerPerp).burn(_account, _wPowerPerpAmount);\\n\\n emit BurnShort(msg.sender, _wPowerPerpAmount, _vaultId);\\n }\\n\\n /**\\n * @notice liquidate a vault, pay the liquidator\\n * @dev liquidator can only liquidate at most 1/2 of the vault in 1 transaction\\n * @dev this function will update the vault memory in-place\\n * @param _vault the Vault memory to update\\n * @param _maxWPowerPerpAmount maximum debt amount liquidator is willing to repay\\n * @param _normalizationFactor current normalization factor\\n * @param _liquidator liquidator address to receive eth\\n * @return debtAmount amount of wPowerPerp repaid (burn from the vault)\\n * @return collateralToPay amount of collateral paid to liquidator\\n */\\n function _liquidate(\\n VaultLib.Vault memory _vault,\\n uint256 _maxWPowerPerpAmount,\\n uint256 _normalizationFactor,\\n address _liquidator\\n ) internal returns (uint256, uint256) {\\n (uint256 liquidateAmount, uint256 collateralToPay) = _getLiquidationResult(\\n _maxWPowerPerpAmount,\\n uint256(_vault.shortAmount),\\n uint256(_vault.collateralAmount)\\n );\\n\\n // if the liquidator didn't specify enough wPowerPerp to burn, revert.\\n require(_maxWPowerPerpAmount >= liquidateAmount, \\\"C21\\\");\\n\\n IWPowerPerp(wPowerPerp).burn(_liquidator, liquidateAmount);\\n _vault.removeShort(liquidateAmount);\\n _vault.removeEthCollateral(collateralToPay);\\n\\n (, bool isDust) = _getVaultStatus(_vault, _normalizationFactor);\\n require(!isDust, \\\"C22\\\");\\n\\n return (liquidateAmount, collateralToPay);\\n }\\n\\n /**\\n * @notice redeem uniswap v3 position in a vault for its constituent eth and wPowerPerp\\n * @notice this will increase vault collateral by the amount of eth, and decrease debt by the amount of wPowerPerp\\n * @dev will be executed before liquidation if there's an NFT in the vault\\n * @dev pays a 2% bounty to the liquidator if called by liquidate()\\n * @dev will update the vault memory in-place\\n * @param _vault the Vault memory to update\\n * @param _owner account to send any excess\\n * @param _vaultId id of the vault to reduce debt on\\n * @param _payBounty true if paying caller 2% bounty\\n * @return bounty amount of bounty paid for liquidator\\n */\\n function _reduceDebt(\\n VaultLib.Vault memory _vault,\\n address _owner,\\n uint256 _vaultId,\\n bool _payBounty\\n ) internal returns (uint256) {\\n uint256 nftId = _vault.NftCollateralId;\\n if (nftId == 0) return 0;\\n\\n (uint256 withdrawnEthAmount, uint256 withdrawnWPowerPerpAmount) = _redeemUniToken(nftId);\\n\\n // change weth back to eth\\n if (withdrawnEthAmount > 0) IWETH9(weth).withdraw(withdrawnEthAmount);\\n\\n (uint256 burnAmount, uint256 excess, uint256 bounty) = _getReduceDebtResultInVault(\\n _vault,\\n withdrawnEthAmount,\\n withdrawnWPowerPerpAmount,\\n _payBounty\\n );\\n\\n if (excess > 0) IWPowerPerp(wPowerPerp).transfer(_owner, excess);\\n if (burnAmount > 0) IWPowerPerp(wPowerPerp).burn(address(this), burnAmount);\\n\\n emit ReduceDebt(\\n msg.sender,\\n _vaultId,\\n withdrawnEthAmount,\\n withdrawnWPowerPerpAmount,\\n burnAmount,\\n excess,\\n bounty\\n );\\n\\n return bounty;\\n }\\n\\n /**\\n * @notice pay fee recipient\\n * @dev pay in eth from either the vault or the deposit amount\\n * @param _vault the Vault memory to update\\n * @param _wPowerPerpAmount the amount of wPowerPerpAmount minting\\n * @param _depositAmount the amount of eth depositing or withdrawing\\n * @return the amount of actual deposited eth into the vault, this is less than the original amount if a fee was taken\\n */\\n function _getFee(\\n VaultLib.Vault memory _vault,\\n uint256 _wPowerPerpAmount,\\n uint256 _depositAmount\\n ) internal view returns (uint256, uint256) {\\n uint256 cachedFeeRate = feeRate;\\n if (cachedFeeRate == 0) return (uint256(0), _depositAmount);\\n uint256 depositAmountAfterFee;\\n uint256 ethEquivalentMinted = Power2Base._getDebtValueInEth(\\n _wPowerPerpAmount,\\n oracle,\\n wPowerPerpPool,\\n wPowerPerp,\\n weth\\n );\\n uint256 feeAmount = ethEquivalentMinted.mul(cachedFeeRate).div(10000);\\n\\n // if fee can be paid from deposited collateral, pay from _depositAmount\\n if (_depositAmount > feeAmount) {\\n depositAmountAfterFee = _depositAmount.sub(feeAmount);\\n // if not, adjust the vault to pay from the vault collateral\\n } else {\\n _vault.removeEthCollateral(feeAmount);\\n depositAmountAfterFee = _depositAmount;\\n }\\n //return the fee and deposit amount, which has only been reduced by a fee if it is paid out of the deposit amount\\n return (feeAmount, depositAmountAfterFee);\\n }\\n\\n /**\\n * @notice write vault to storage\\n * @dev writes to vaults mapping\\n */\\n function _writeVault(uint256 _vaultId, VaultLib.Vault memory _vault) private {\\n vaults[_vaultId] = _vault;\\n }\\n\\n /**\\n * @dev redeem a uni position token and get back wPowerPerp and eth\\n * @param _uniTokenId uniswap v3 position token id\\n * @return wethAmount amount of weth withdrawn from uniswap\\n * @return wPowerPerpAmount amount of wPowerPerp withdrawn from uniswap\\n */\\n function _redeemUniToken(uint256 _uniTokenId) internal returns (uint256, uint256) {\\n INonfungiblePositionManager positionManager = INonfungiblePositionManager(uniswapPositionManager);\\n\\n (, , uint128 liquidity, , ) = VaultLib._getUniswapPositionInfo(uniswapPositionManager, _uniTokenId);\\n\\n // prepare parameters to withdraw liquidity from uniswap v3 position manager\\n INonfungiblePositionManager.DecreaseLiquidityParams memory decreaseParams = INonfungiblePositionManager\\n .DecreaseLiquidityParams({\\n tokenId: _uniTokenId,\\n liquidity: liquidity,\\n amount0Min: 0,\\n amount1Min: 0,\\n deadline: block.timestamp\\n });\\n\\n positionManager.decreaseLiquidity(decreaseParams);\\n\\n // withdraw max amount of weth and wPowerPerp from uniswap\\n INonfungiblePositionManager.CollectParams memory collectParams = INonfungiblePositionManager.CollectParams({\\n tokenId: _uniTokenId,\\n recipient: address(this),\\n amount0Max: uint128(-1),\\n amount1Max: uint128(-1)\\n });\\n\\n (uint256 collectedToken0, uint256 collectedToken1) = positionManager.collect(collectParams);\\n\\n return isWethToken0 ? (collectedToken0, collectedToken1) : (collectedToken1, collectedToken0);\\n }\\n\\n /**\\n * @notice update the normalization factor as a way to pay in-kind funding\\n * @dev the normalization factor scales amount of debt that must be repaid, effecting an interest rate paid between long and short positions\\n * @return new normalization factor\\n **/\\n function _applyFunding() internal returns (uint256) {\\n // only update the norm factor once per block\\n if (lastFundingUpdateTimestamp == block.timestamp) return normalizationFactor;\\n\\n uint256 newNormalizationFactor = _getNewNormalizationFactor();\\n\\n emit NormalizationFactorUpdated(\\n normalizationFactor,\\n newNormalizationFactor,\\n lastFundingUpdateTimestamp,\\n block.timestamp\\n );\\n\\n // the following will be batch into 1 SSTORE because of type uint128\\n normalizationFactor = newNormalizationFactor.toUint128();\\n lastFundingUpdateTimestamp = block.timestamp.toUint128();\\n\\n return newNormalizationFactor;\\n }\\n\\n /**\\n * @dev calculate new normalization factor base on the current timestamp\\n * @return new normalization factor if funding happens in the current block\\n */\\n function _getNewNormalizationFactor() internal view returns (uint256) {\\n uint32 period = block.timestamp.sub(lastFundingUpdateTimestamp).toUint32();\\n\\n if (period == 0) {\\n return normalizationFactor;\\n }\\n\\n // make sure we use the same period for mark and index\\n uint32 periodForOracle = _getConsistentPeriodForOracle(period);\\n\\n // avoid reading normalizationFactor from storage multiple times\\n uint256 cacheNormFactor = normalizationFactor;\\n\\n uint256 mark = Power2Base._getDenormalizedMark(\\n periodForOracle,\\n oracle,\\n wPowerPerpPool,\\n ethQuoteCurrencyPool,\\n weth,\\n quoteCurrency,\\n wPowerPerp,\\n cacheNormFactor\\n );\\n uint256 index = Power2Base._getIndex(periodForOracle, oracle, ethQuoteCurrencyPool, weth, quoteCurrency);\\n\\n //the fraction of the funding period. used to compound the funding rate\\n int128 rFunding = ABDKMath64x64.divu(period, FUNDING_PERIOD);\\n\\n // floor mark to be at least LOWER_MARK_RATIO of index\\n uint256 lowerBound = index.mul(LOWER_MARK_RATIO).div(ONE);\\n if (mark < lowerBound) {\\n mark = lowerBound;\\n } else {\\n // cap mark to be at most UPPER_MARK_RATIO of index\\n uint256 upperBound = index.mul(UPPER_MARK_RATIO).div(ONE);\\n if (mark > upperBound) mark = upperBound;\\n }\\n\\n // normFactor(new) = multiplier * normFactor(old)\\n // multiplier = (index/mark)^rFunding\\n // x^r = n^(log_n(x) * r)\\n // multiplier = 2^( log2(index/mark) * rFunding )\\n\\n int128 base = ABDKMath64x64.divu(index, mark);\\n int128 logTerm = ABDKMath64x64.log_2(base).mul(rFunding);\\n int128 multiplier = logTerm.exp_2();\\n return multiplier.mulu(cacheNormFactor);\\n }\\n\\n /**\\n * @notice check if vault has enough collateral and is not a dust vault\\n * @dev revert if vault has insufficient collateral or is a dust vault\\n * @param _vault the Vault memory to update\\n * @param _normalizationFactor normalization factor\\n */\\n function _checkVault(VaultLib.Vault memory _vault, uint256 _normalizationFactor) internal view {\\n (bool isSafe, bool isDust) = _getVaultStatus(_vault, _normalizationFactor);\\n require(isSafe, \\\"C24\\\");\\n require(!isDust, \\\"C22\\\");\\n }\\n\\n /**\\n * @notice check that the vault has enough collateral\\n * @param _vault in-memory vault\\n * @param _normalizationFactor normalization factor\\n * @return true if the vault is properly collateralized\\n */\\n function _isVaultSafe(VaultLib.Vault memory _vault, uint256 _normalizationFactor) internal view returns (bool) {\\n (bool isSafe, ) = _getVaultStatus(_vault, _normalizationFactor);\\n return isSafe;\\n }\\n\\n /**\\n * @notice return if the vault is properly collateralized and if it is a dust vault\\n * @param _vault the Vault memory to update\\n * @param _normalizationFactor normalization factor\\n * @return true if the vault is safe\\n * @return true if the vault is a dust vault\\n */\\n function _getVaultStatus(VaultLib.Vault memory _vault, uint256 _normalizationFactor)\\n internal\\n view\\n returns (bool, bool)\\n {\\n uint256 scaledEthPrice = Power2Base._getScaledTwap(\\n oracle,\\n ethQuoteCurrencyPool,\\n weth,\\n quoteCurrency,\\n TWAP_PERIOD,\\n true // do not call more than maximum period so it does not revert\\n );\\n return\\n VaultLib.getVaultStatus(\\n _vault,\\n uniswapPositionManager,\\n _normalizationFactor,\\n scaledEthPrice,\\n MIN_COLLATERAL,\\n IOracle(oracle).getTimeWeightedAverageTickSafe(wPowerPerpPool, TWAP_PERIOD),\\n isWethToken0\\n );\\n }\\n\\n /**\\n * @notice get the expected excess, burnAmount and bounty if Uniswap position token got burned\\n * @dev this function will update the vault memory in-place\\n * @return burnAmount amount of wPowerPerp that should be burned\\n * @return wPowerPerpExcess amount of wPowerPerp that should be send to the vault owner\\n * @return bounty amount of bounty should be paid out to caller\\n */\\n function _getReduceDebtResultInVault(\\n VaultLib.Vault memory _vault,\\n uint256 nftEthAmount,\\n uint256 nftWPowerperpAmount,\\n bool _payBounty\\n )\\n internal\\n view\\n returns (\\n uint256,\\n uint256,\\n uint256\\n )\\n {\\n uint256 bounty;\\n if (_payBounty) bounty = _getReduceDebtBounty(nftEthAmount, nftWPowerperpAmount);\\n\\n uint256 burnAmount = nftWPowerperpAmount;\\n uint256 wPowerPerpExcess;\\n\\n if (nftWPowerperpAmount > _vault.shortAmount) {\\n wPowerPerpExcess = nftWPowerperpAmount.sub(_vault.shortAmount);\\n burnAmount = _vault.shortAmount;\\n }\\n\\n _vault.removeShort(burnAmount);\\n _vault.removeUniNftCollateral();\\n _vault.addEthCollateral(nftEthAmount);\\n _vault.removeEthCollateral(bounty);\\n\\n return (burnAmount, wPowerPerpExcess, bounty);\\n }\\n\\n /**\\n * @notice get how much bounty you can get by helping a vault reducing the debt.\\n * @dev bounty is 2% of the total value of the position token\\n * @param _ethWithdrawn amount of eth withdrawn from uniswap by redeeming the position token\\n * @param _wPowerPerpReduced amount of wPowerPerp withdrawn from uniswap by redeeming the position token\\n */\\n function _getReduceDebtBounty(uint256 _ethWithdrawn, uint256 _wPowerPerpReduced) internal view returns (uint256) {\\n return\\n Power2Base\\n ._getDebtValueInEth(_wPowerPerpReduced, oracle, wPowerPerpPool, wPowerPerp, weth)\\n .add(_ethWithdrawn)\\n .mul(REDUCE_DEBT_BOUNTY)\\n .div(ONE);\\n }\\n\\n /**\\n * @notice get the expected wPowerPerp needed to liquidate a vault.\\n * @dev a liquidator cannot liquidate more than half of a vault, unless only liquidating half of the debt will make the vault a \\\"dust vault\\\"\\n * @dev a liquidator cannot take out more collateral than the vault holds\\n * @param _maxWPowerPerpAmount the max amount of wPowerPerp willing to pay\\n * @param _vaultShortAmount the amount of short in the vault\\n * @param _maxWPowerPerpAmount the amount of collateral in the vault\\n * @return finalLiquidateAmount the amount that should be liquidated. This amount can be higher than _maxWPowerPerpAmount, which should be checked\\n * @return collateralToPay final amount of collateral paying out to the liquidator\\n */\\n function _getLiquidationResult(\\n uint256 _maxWPowerPerpAmount,\\n uint256 _vaultShortAmount,\\n uint256 _vaultCollateralAmount\\n ) internal view returns (uint256, uint256) {\\n // try limiting liquidation amount to half of the vault debt\\n (uint256 finalLiquidateAmount, uint256 collateralToPay) = _getSingleLiquidationAmount(\\n _maxWPowerPerpAmount,\\n _vaultShortAmount.div(2)\\n );\\n\\n if (_vaultCollateralAmount > collateralToPay) {\\n if (_vaultCollateralAmount.sub(collateralToPay) < MIN_COLLATERAL) {\\n // the vault is left with dust after liquidation, allow liquidating full vault\\n // calculate the new liquidation amount and collateral again based on the new limit\\n (finalLiquidateAmount, collateralToPay) = _getSingleLiquidationAmount(\\n _maxWPowerPerpAmount,\\n _vaultShortAmount\\n );\\n }\\n }\\n\\n // check if final collateral to pay is greater than vault amount.\\n // if so the system only pays out the amount the vault has, which may not be profitable\\n if (collateralToPay > _vaultCollateralAmount) {\\n // force liquidator to pay full debt amount\\n finalLiquidateAmount = _vaultShortAmount;\\n collateralToPay = _vaultCollateralAmount;\\n }\\n\\n return (finalLiquidateAmount, collateralToPay);\\n }\\n\\n /**\\n * @notice determine how much wPowerPerp to liquidate, and how much collateral to return\\n * @param _maxInputWAmount maximum wPowerPerp amount liquidator is willing to repay\\n * @param _maxLiquidatableWAmount maximum wPowerPerp amount a liquidator is allowed to repay\\n * @return finalWAmountToLiquidate amount of wPowerPerp the liquidator will burn\\n * @return collateralToPay total collateral the liquidator will get\\n */\\n function _getSingleLiquidationAmount(uint256 _maxInputWAmount, uint256 _maxLiquidatableWAmount)\\n internal\\n view\\n returns (uint256, uint256)\\n {\\n uint256 finalWAmountToLiquidate = _maxInputWAmount > _maxLiquidatableWAmount\\n ? _maxLiquidatableWAmount\\n : _maxInputWAmount;\\n\\n uint256 collateralToPay = Power2Base._getDebtValueInEth(\\n finalWAmountToLiquidate,\\n oracle,\\n wPowerPerpPool,\\n wPowerPerp,\\n weth\\n );\\n\\n // add 10% bonus for liquidators\\n collateralToPay = collateralToPay.add(collateralToPay.mul(LIQUIDATION_BOUNTY).div(ONE));\\n\\n return (finalWAmountToLiquidate, collateralToPay);\\n }\\n\\n /**\\n * @notice get a period can be used to request a twap for 2 uniswap v3 pools\\n * @dev if the period is greater than min(max_pool_1, max_pool_2), return min(max_pool_1, max_pool_2)\\n * @param _period max period that we intend to use\\n * @return fair period not greator than _period to be used for both pools.\\n */\\n function _getConsistentPeriodForOracle(uint32 _period) internal view returns (uint32) {\\n uint32 maxPeriodPool1 = IOracle(oracle).getMaxPeriod(ethQuoteCurrencyPool);\\n uint32 maxPeriodPool2 = IOracle(oracle).getMaxPeriod(wPowerPerpPool);\\n\\n uint32 maxSafePeriod = maxPeriodPool1 > maxPeriodPool2 ? maxPeriodPool2 : maxPeriodPool1;\\n return _period > maxSafePeriod ? maxSafePeriod : _period;\\n }\\n}\\n\",\"keccak256\":\"0xf10380c226b48c8be2aba71df6915ddfe04f2fdf6a6612643816ee351a72bc42\",\"license\":\"BUSL-1.1\"},\"contracts/interfaces/IOracle.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\ninterface IOracle {\\n function getHistoricalTwap(\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _period,\\n uint32 _periodToHistoricPrice\\n ) external view returns (uint256);\\n\\n function getTwap(\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _period,\\n bool _checkPeriod\\n ) external view returns (uint256);\\n\\n function getMaxPeriod(address _pool) external view returns (uint32);\\n\\n function getTimeWeightedAverageTickSafe(address _pool, uint32 _period)\\n external\\n view\\n returns (int24 timeWeightedAverageTick);\\n}\\n\",\"keccak256\":\"0xe4ca0166858146d6aa98ec5d76e432c121299757b9eef14c32990d981d6e81ed\",\"license\":\"MIT\"},\"contracts/interfaces/IShortPowerPerp.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\nimport {IERC721} from \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\n\\ninterface IShortPowerPerp is IERC721 {\\n function nextId() external view returns (uint256);\\n\\n function mintNFT(address recipient) external returns (uint256 _newId);\\n}\\n\",\"keccak256\":\"0xf2d2cb2decac32a199e63f0d5141e46a6e989620944ec5f0144e5aebd0c7989e\",\"license\":\"MIT\"},\"contracts/interfaces/IWETH9.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IWETH9 is IERC20 {\\n function deposit() external payable;\\n\\n function withdraw(uint256 wad) external;\\n}\\n\",\"keccak256\":\"0x8a9a4512f1fc29b14dcf97ca149f263f28de43191a3ee31336f2389e3f2f5f8e\",\"license\":\"MIT\"},\"contracts/interfaces/IWPowerPerp.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IWPowerPerp is IERC20 {\\n function mint(address _account, uint256 _amount) external;\\n\\n function burn(address _account, uint256 _amount) external;\\n}\\n\",\"keccak256\":\"0x873a337fcb47b96ed0714dbc2edbf1d200f529752efb7beb18109c9e6a9d7271\",\"license\":\"MIT\"},\"contracts/libs/ABDKMath64x64.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-4-Clause\\n/*\\n * ABDK Math 64.64 Smart Contract Library. Copyright \\u00a9 2019 by ABDK Consulting.\\n * Author: Mikhail Vladimirov \\n * Copyright (c) 2019, ABDK Consulting\\n *\\n * All rights reserved.\\n *\\n * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\\n *\\n * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\\n * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\\n * All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by ABDK Consulting.\\n * Neither the name of ABDK Consulting nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\\n * THIS SOFTWARE IS PROVIDED BY ABDK CONSULTING ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\\n * IN NO EVENT SHALL ABDK CONSULTING BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\\n */\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * Smart contract library of mathematical functions operating with signed\\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\\n * basically a simple fraction whose numerator is signed 128-bit integer and\\n * denominator is 2^64. As long as denominator is always the same, there is no\\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\\n * represented by int128 type holding only the numerator.\\n *\\n * Commit used - 16d7e1dd8628dfa2f88d5dadab731df7ada70bdd\\n * Copied from - https://github.com/abdk-consulting/abdk-libraries-solidity/tree/v2.4\\n * Changes - some function visibility switched to public, solidity version set to 0.7.x\\n * Changes (cont) - revert strings added\\n * solidity version set to ^0.7.0\\n */\\nlibrary ABDKMath64x64 {\\n /*\\n * Minimum value signed 64.64-bit fixed point number may have.\\n * Minimum value signed 64.64-bit fixed point number may have.\\n * Minimum value signed 64.64-bit fixed point number may have.\\n * -2^127\\n */\\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\\n\\n /*\\n * Maximum value signed 64.64-bit fixed point number may have.\\n * Maximum value signed 64.64-bit fixed point number may have.\\n * Maximum value signed 64.64-bit fixed point number may have.\\n * 2^127-1\\n */\\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\\n\\n /**\\n * Calculate x * y rounding down. Revert on overflow.\\n *\\n * @param x signed 64.64-bit fixed point number\\n * @param y signed 64.64-bit fixed point number\\n * @return signed 64.64-bit fixed point number\\n */\\n function mul(int128 x, int128 y) internal pure returns (int128) {\\n int256 result = (int256(x) * y) >> 64;\\n require(result >= MIN_64x64 && result <= MAX_64x64, \\\"MUL-OVUF\\\");\\n return int128(result);\\n }\\n\\n /**\\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\\n * and y is unsigned 256-bit integer number. Revert on overflow.\\n *\\n * @param x signed 64.64 fixed point number\\n * @param y unsigned 256-bit integer number\\n * @return unsigned 256-bit integer number\\n */\\n function mulu(int128 x, uint256 y) internal pure returns (uint256) {\\n if (y == 0) return 0;\\n\\n require(x >= 0, \\\"MULU-X0\\\");\\n\\n uint256 lo = (uint256(x) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\\n uint256 hi = uint256(x) * (y >> 128);\\n\\n require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, \\\"MULU-OF1\\\");\\n hi <<= 64;\\n\\n require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo, \\\"MULU-OF2\\\");\\n return hi + lo;\\n }\\n\\n /**\\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\\n * integer numbers. Revert on overflow or when y is zero.\\n *\\n * @param x unsigned 256-bit integer number\\n * @param y unsigned 256-bit integer number\\n * @return signed 64.64-bit fixed point number\\n */\\n function divu(uint256 x, uint256 y) public pure returns (int128) {\\n require(y != 0, \\\"DIVU-INF\\\");\\n uint128 result = divuu(x, y);\\n require(result <= uint128(MAX_64x64), \\\"DIVU-OF\\\");\\n return int128(result);\\n }\\n\\n /**\\n * Calculate binary logarithm of x. Revert if x <= 0.\\n *\\n * @param x signed 64.64-bit fixed point number\\n * @return signed 64.64-bit fixed point number\\n */\\n function log_2(int128 x) public pure returns (int128) {\\n require(x > 0, \\\"LOG_2-X0\\\");\\n\\n int256 msb = 0;\\n int256 xc = x;\\n if (xc >= 0x10000000000000000) {\\n xc >>= 64;\\n msb += 64;\\n }\\n if (xc >= 0x100000000) {\\n xc >>= 32;\\n msb += 32;\\n }\\n if (xc >= 0x10000) {\\n xc >>= 16;\\n msb += 16;\\n }\\n if (xc >= 0x100) {\\n xc >>= 8;\\n msb += 8;\\n }\\n if (xc >= 0x10) {\\n xc >>= 4;\\n msb += 4;\\n }\\n if (xc >= 0x4) {\\n xc >>= 2;\\n msb += 2;\\n }\\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\\n\\n int256 result = (msb - 64) << 64;\\n uint256 ux = uint256(x) << uint256(127 - msb);\\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\\n ux *= ux;\\n uint256 b = ux >> 255;\\n ux >>= 127 + b;\\n result += bit * int256(b);\\n }\\n\\n return int128(result);\\n }\\n\\n /**\\n * Calculate binary exponent of x. Revert on overflow.\\n *\\n * @param x signed 64.64-bit fixed point number\\n * @return signed 64.64-bit fixed point number\\n */\\n function exp_2(int128 x) public pure returns (int128) {\\n require(x < 0x400000000000000000, \\\"EXP_2-OF\\\"); // Overflow\\n\\n if (x < -0x400000000000000000) return 0; // Underflow\\n\\n uint256 result = 0x80000000000000000000000000000000;\\n\\n if (x & 0x8000000000000000 > 0) result = (result * 0x16A09E667F3BCC908B2FB1366EA957D3E) >> 128;\\n if (x & 0x4000000000000000 > 0) result = (result * 0x1306FE0A31B7152DE8D5A46305C85EDEC) >> 128;\\n if (x & 0x2000000000000000 > 0) result = (result * 0x1172B83C7D517ADCDF7C8C50EB14A791F) >> 128;\\n if (x & 0x1000000000000000 > 0) result = (result * 0x10B5586CF9890F6298B92B71842A98363) >> 128;\\n if (x & 0x800000000000000 > 0) result = (result * 0x1059B0D31585743AE7C548EB68CA417FD) >> 128;\\n if (x & 0x400000000000000 > 0) result = (result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8) >> 128;\\n if (x & 0x200000000000000 > 0) result = (result * 0x10163DA9FB33356D84A66AE336DCDFA3F) >> 128;\\n if (x & 0x100000000000000 > 0) result = (result * 0x100B1AFA5ABCBED6129AB13EC11DC9543) >> 128;\\n if (x & 0x80000000000000 > 0) result = (result * 0x10058C86DA1C09EA1FF19D294CF2F679B) >> 128;\\n if (x & 0x40000000000000 > 0) result = (result * 0x1002C605E2E8CEC506D21BFC89A23A00F) >> 128;\\n if (x & 0x20000000000000 > 0) result = (result * 0x100162F3904051FA128BCA9C55C31E5DF) >> 128;\\n if (x & 0x10000000000000 > 0) result = (result * 0x1000B175EFFDC76BA38E31671CA939725) >> 128;\\n if (x & 0x8000000000000 > 0) result = (result * 0x100058BA01FB9F96D6CACD4B180917C3D) >> 128;\\n if (x & 0x4000000000000 > 0) result = (result * 0x10002C5CC37DA9491D0985C348C68E7B3) >> 128;\\n if (x & 0x2000000000000 > 0) result = (result * 0x1000162E525EE054754457D5995292026) >> 128;\\n if (x & 0x1000000000000 > 0) result = (result * 0x10000B17255775C040618BF4A4ADE83FC) >> 128;\\n if (x & 0x800000000000 > 0) result = (result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB) >> 128;\\n if (x & 0x400000000000 > 0) result = (result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9) >> 128;\\n if (x & 0x200000000000 > 0) result = (result * 0x10000162E43F4F831060E02D839A9D16D) >> 128;\\n if (x & 0x100000000000 > 0) result = (result * 0x100000B1721BCFC99D9F890EA06911763) >> 128;\\n if (x & 0x80000000000 > 0) result = (result * 0x10000058B90CF1E6D97F9CA14DBCC1628) >> 128;\\n if (x & 0x40000000000 > 0) result = (result * 0x1000002C5C863B73F016468F6BAC5CA2B) >> 128;\\n if (x & 0x20000000000 > 0) result = (result * 0x100000162E430E5A18F6119E3C02282A5) >> 128;\\n if (x & 0x10000000000 > 0) result = (result * 0x1000000B1721835514B86E6D96EFD1BFE) >> 128;\\n if (x & 0x8000000000 > 0) result = (result * 0x100000058B90C0B48C6BE5DF846C5B2EF) >> 128;\\n if (x & 0x4000000000 > 0) result = (result * 0x10000002C5C8601CC6B9E94213C72737A) >> 128;\\n if (x & 0x2000000000 > 0) result = (result * 0x1000000162E42FFF037DF38AA2B219F06) >> 128;\\n if (x & 0x1000000000 > 0) result = (result * 0x10000000B17217FBA9C739AA5819F44F9) >> 128;\\n if (x & 0x800000000 > 0) result = (result * 0x1000000058B90BFCDEE5ACD3C1CEDC823) >> 128;\\n if (x & 0x400000000 > 0) result = (result * 0x100000002C5C85FE31F35A6A30DA1BE50) >> 128;\\n if (x & 0x200000000 > 0) result = (result * 0x10000000162E42FF0999CE3541B9FFFCF) >> 128;\\n if (x & 0x100000000 > 0) result = (result * 0x100000000B17217F80F4EF5AADDA45554) >> 128;\\n if (x & 0x80000000 > 0) result = (result * 0x10000000058B90BFBF8479BD5A81B51AD) >> 128;\\n if (x & 0x40000000 > 0) result = (result * 0x1000000002C5C85FDF84BD62AE30A74CC) >> 128;\\n if (x & 0x20000000 > 0) result = (result * 0x100000000162E42FEFB2FED257559BDAA) >> 128;\\n if (x & 0x10000000 > 0) result = (result * 0x1000000000B17217F7D5A7716BBA4A9AE) >> 128;\\n if (x & 0x8000000 > 0) result = (result * 0x100000000058B90BFBE9DDBAC5E109CCE) >> 128;\\n if (x & 0x4000000 > 0) result = (result * 0x10000000002C5C85FDF4B15DE6F17EB0D) >> 128;\\n if (x & 0x2000000 > 0) result = (result * 0x1000000000162E42FEFA494F1478FDE05) >> 128;\\n if (x & 0x1000000 > 0) result = (result * 0x10000000000B17217F7D20CF927C8E94C) >> 128;\\n if (x & 0x800000 > 0) result = (result * 0x1000000000058B90BFBE8F71CB4E4B33D) >> 128;\\n if (x & 0x400000 > 0) result = (result * 0x100000000002C5C85FDF477B662B26945) >> 128;\\n if (x & 0x200000 > 0) result = (result * 0x10000000000162E42FEFA3AE53369388C) >> 128;\\n if (x & 0x100000 > 0) result = (result * 0x100000000000B17217F7D1D351A389D40) >> 128;\\n if (x & 0x80000 > 0) result = (result * 0x10000000000058B90BFBE8E8B2D3D4EDE) >> 128;\\n if (x & 0x40000 > 0) result = (result * 0x1000000000002C5C85FDF4741BEA6E77E) >> 128;\\n if (x & 0x20000 > 0) result = (result * 0x100000000000162E42FEFA39FE95583C2) >> 128;\\n if (x & 0x10000 > 0) result = (result * 0x1000000000000B17217F7D1CFB72B45E1) >> 128;\\n if (x & 0x8000 > 0) result = (result * 0x100000000000058B90BFBE8E7CC35C3F0) >> 128;\\n if (x & 0x4000 > 0) result = (result * 0x10000000000002C5C85FDF473E242EA38) >> 128;\\n if (x & 0x2000 > 0) result = (result * 0x1000000000000162E42FEFA39F02B772C) >> 128;\\n if (x & 0x1000 > 0) result = (result * 0x10000000000000B17217F7D1CF7D83C1A) >> 128;\\n if (x & 0x800 > 0) result = (result * 0x1000000000000058B90BFBE8E7BDCBE2E) >> 128;\\n if (x & 0x400 > 0) result = (result * 0x100000000000002C5C85FDF473DEA871F) >> 128;\\n if (x & 0x200 > 0) result = (result * 0x10000000000000162E42FEFA39EF44D91) >> 128;\\n if (x & 0x100 > 0) result = (result * 0x100000000000000B17217F7D1CF79E949) >> 128;\\n if (x & 0x80 > 0) result = (result * 0x10000000000000058B90BFBE8E7BCE544) >> 128;\\n if (x & 0x40 > 0) result = (result * 0x1000000000000002C5C85FDF473DE6ECA) >> 128;\\n if (x & 0x20 > 0) result = (result * 0x100000000000000162E42FEFA39EF366F) >> 128;\\n if (x & 0x10 > 0) result = (result * 0x1000000000000000B17217F7D1CF79AFA) >> 128;\\n if (x & 0x8 > 0) result = (result * 0x100000000000000058B90BFBE8E7BCD6D) >> 128;\\n if (x & 0x4 > 0) result = (result * 0x10000000000000002C5C85FDF473DE6B2) >> 128;\\n if (x & 0x2 > 0) result = (result * 0x1000000000000000162E42FEFA39EF358) >> 128;\\n if (x & 0x1 > 0) result = (result * 0x10000000000000000B17217F7D1CF79AB) >> 128;\\n\\n result >>= uint256(63 - (x >> 64));\\n require(result <= uint256(MAX_64x64));\\n\\n return int128(result);\\n }\\n\\n /**\\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\\n * integer numbers. Revert on overflow or when y is zero.\\n *\\n * @param x unsigned 256-bit integer number\\n * @param y unsigned 256-bit integer number\\n * @return unsigned 64.64-bit fixed point number\\n */\\n function divuu(uint256 x, uint256 y) private pure returns (uint128) {\\n require(y != 0);\\n\\n uint256 result;\\n\\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) result = (x << 64) / y;\\n else {\\n uint256 msb = 192;\\n uint256 xc = x >> 192;\\n if (xc >= 0x100000000) {\\n xc >>= 32;\\n msb += 32;\\n }\\n if (xc >= 0x10000) {\\n xc >>= 16;\\n msb += 16;\\n }\\n if (xc >= 0x100) {\\n xc >>= 8;\\n msb += 8;\\n }\\n if (xc >= 0x10) {\\n xc >>= 4;\\n msb += 4;\\n }\\n if (xc >= 0x4) {\\n xc >>= 2;\\n msb += 2;\\n }\\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\\n\\n result = (x << (255 - msb)) / (((y - 1) >> (msb - 191)) + 1);\\n require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, \\\"DIVUU-OF1\\\");\\n\\n uint256 hi = result * (y >> 128);\\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\\n\\n uint256 xh = x >> 192;\\n uint256 xl = x << 64;\\n\\n if (xl < lo) xh -= 1;\\n xl -= lo; // We rely on overflow behavior here\\n lo = hi << 128;\\n if (xl < lo) xh -= 1;\\n xl -= lo; // We rely on overflow behavior here\\n\\n assert(xh == hi >> 128);\\n\\n result += xl / y;\\n }\\n\\n require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, \\\"DIVUU-OF2\\\");\\n return uint128(result);\\n }\\n}\\n\",\"keccak256\":\"0x56efa7c16e4fffb37ad80af15bd042d9f92532a4553d6b12915e3fa21609ad66\",\"license\":\"BSD-4-Clause\"},\"contracts/libs/Power2Base.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\n\\npragma solidity =0.7.6;\\n\\n//interface\\nimport {IOracle} from \\\"../interfaces/IOracle.sol\\\";\\n\\n//lib\\nimport {SafeMath} from \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\n\\nlibrary Power2Base {\\n using SafeMath for uint256;\\n\\n uint32 private constant TWAP_PERIOD = 420 seconds;\\n uint256 private constant INDEX_SCALE = 1e4;\\n uint256 private constant ONE = 1e18;\\n uint256 private constant ONE_ONE = 1e36;\\n\\n /**\\n * @notice return the scaled down index of the power perp in USD, scaled by 18 decimals\\n * @param _period period of time for the twap in seconds (cannot be longer than maximum period for the pool)\\n * @param _oracle oracle address\\n * @param _ethQuoteCurrencyPool uniswap v3 pool for weth / quoteCurrency\\n * @param _weth weth address\\n * @param _quoteCurrency quoteCurrency address\\n * @return for squeeth, return ethPrice^2\\n */\\n function _getIndex(\\n uint32 _period,\\n address _oracle,\\n address _ethQuoteCurrencyPool,\\n address _weth,\\n address _quoteCurrency\\n ) internal view returns (uint256) {\\n uint256 ethQuoteCurrencyPrice = _getScaledTwap(\\n _oracle,\\n _ethQuoteCurrencyPool,\\n _weth,\\n _quoteCurrency,\\n _period,\\n false\\n );\\n return ethQuoteCurrencyPrice.mul(ethQuoteCurrencyPrice).div(ONE);\\n }\\n\\n /**\\n * @notice return the unscaled index of the power perp in USD, scaled by 18 decimals\\n * @param _period period of time for the twap in seconds (cannot be longer than maximum period for the pool)\\n * @param _oracle oracle address\\n * @param _ethQuoteCurrencyPool uniswap v3 pool for weth / quoteCurrency\\n * @param _weth weth address\\n * @param _quoteCurrency quoteCurrency address\\n * @return for squeeth, return ethPrice^2\\n */\\n function _getUnscaledIndex(\\n uint32 _period,\\n address _oracle,\\n address _ethQuoteCurrencyPool,\\n address _weth,\\n address _quoteCurrency\\n ) internal view returns (uint256) {\\n uint256 ethQuoteCurrencyPrice = _getTwap(_oracle, _ethQuoteCurrencyPool, _weth, _quoteCurrency, _period, false);\\n return ethQuoteCurrencyPrice.mul(ethQuoteCurrencyPrice).div(ONE);\\n }\\n\\n /**\\n * @notice return the mark price of power perp in quoteCurrency, scaled by 18 decimals\\n * @param _period period of time for the twap in seconds (cannot be longer than maximum period for the pool)\\n * @param _oracle oracle address\\n * @param _wSqueethEthPool uniswap v3 pool for wSqueeth / weth\\n * @param _ethQuoteCurrencyPool uniswap v3 pool for weth / quoteCurrency\\n * @param _weth weth address\\n * @param _quoteCurrency quoteCurrency address\\n * @param _wSqueeth wSqueeth address\\n * @param _normalizationFactor current normalization factor\\n * @return for squeeth, return ethPrice * squeethPriceInEth\\n */\\n function _getDenormalizedMark(\\n uint32 _period,\\n address _oracle,\\n address _wSqueethEthPool,\\n address _ethQuoteCurrencyPool,\\n address _weth,\\n address _quoteCurrency,\\n address _wSqueeth,\\n uint256 _normalizationFactor\\n ) internal view returns (uint256) {\\n uint256 ethQuoteCurrencyPrice = _getScaledTwap(\\n _oracle,\\n _ethQuoteCurrencyPool,\\n _weth,\\n _quoteCurrency,\\n _period,\\n false\\n );\\n uint256 wsqueethEthPrice = _getTwap(_oracle, _wSqueethEthPool, _wSqueeth, _weth, _period, false);\\n\\n return wsqueethEthPrice.mul(ethQuoteCurrencyPrice).div(_normalizationFactor);\\n }\\n\\n /**\\n * @notice get the fair collateral value for a _debtAmount of wSqueeth\\n * @dev the actual amount liquidator can get should have a 10% bonus on top of this value.\\n * @param _debtAmount wSqueeth amount paid by liquidator\\n * @param _oracle oracle address\\n * @param _wSqueethEthPool uniswap v3 pool for wSqueeth / weth\\n * @param _wSqueeth wSqueeth address\\n * @param _weth weth address\\n * @return returns value of debt in ETH\\n */\\n function _getDebtValueInEth(\\n uint256 _debtAmount,\\n address _oracle,\\n address _wSqueethEthPool,\\n address _wSqueeth,\\n address _weth\\n ) internal view returns (uint256) {\\n uint256 wSqueethPrice = _getTwap(_oracle, _wSqueethEthPool, _wSqueeth, _weth, TWAP_PERIOD, false);\\n return _debtAmount.mul(wSqueethPrice).div(ONE);\\n }\\n\\n /**\\n * @notice request twap from our oracle, scaled down by INDEX_SCALE\\n * @param _oracle oracle address\\n * @param _pool uniswap v3 pool address\\n * @param _base base currency. to get eth/usd price, eth is base token\\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\\n * @param _period number of seconds in the past to start calculating time-weighted average.\\n * @param _checkPeriod check that period is not longer than maximum period for the pool to prevent reverts\\n * @return twap price scaled down by INDEX_SCALE\\n */\\n function _getScaledTwap(\\n address _oracle,\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _period,\\n bool _checkPeriod\\n ) internal view returns (uint256) {\\n uint256 twap = _getTwap(_oracle, _pool, _base, _quote, _period, _checkPeriod);\\n return twap.div(INDEX_SCALE);\\n }\\n\\n /**\\n * @notice request twap from our oracle\\n * @dev this will revert if period is > max period for the pool\\n * @param _oracle oracle address\\n * @param _pool uniswap v3 pool address\\n * @param _base base currency. to get eth/quoteCurrency price, eth is base token\\n * @param _quote quote currency. to get eth/quoteCurrency price, quoteCurrency is the quote currency\\n * @param _period number of seconds in the past to start calculating time-weighted average\\n * @param _checkPeriod check that period is not longer than maximum period for the pool to prevent reverts\\n * @return human readable price. scaled by 1e18\\n */\\n function _getTwap(\\n address _oracle,\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _period,\\n bool _checkPeriod\\n ) internal view returns (uint256) {\\n // period reaching this point should be check, otherwise might revert\\n return IOracle(_oracle).getTwap(_pool, _base, _quote, _period, _checkPeriod);\\n }\\n\\n /**\\n * @notice get the index value of wsqueeth in wei, used when system settles\\n * @dev the index of squeeth is ethPrice^2, so each squeeth will need to pay out {ethPrice} eth\\n * @param _wsqueethAmount amount of wsqueeth used in settlement\\n * @param _indexPriceForSettlement index price for settlement\\n * @param _normalizationFactor current normalization factor\\n * @return amount in wei that should be paid to the token holder\\n */\\n function _getLongSettlementValue(\\n uint256 _wsqueethAmount,\\n uint256 _indexPriceForSettlement,\\n uint256 _normalizationFactor\\n ) internal pure returns (uint256) {\\n return _wsqueethAmount.mul(_normalizationFactor).mul(_indexPriceForSettlement).div(ONE_ONE);\\n }\\n}\\n\",\"keccak256\":\"0x1938180c41ec0ee817b841df605b199e15ffbbe94700b640d031b4e4665a89af\",\"license\":\"GPL-2.0-or-later\"},\"contracts/libs/SqrtPriceMathPartial.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\nimport \\\"@uniswap/v3-core/contracts/libraries/FullMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/UnsafeMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\\\";\\n\\n/// @title Functions based on Q64.96 sqrt price and liquidity\\n/// @notice Exposes two functions from @uniswap/v3-core SqrtPriceMath\\n/// that use square root of price as a Q64.96 and liquidity to compute deltas\\nlibrary SqrtPriceMathPartial {\\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 ) external 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\\n require(sqrtRatioAX96 > 0);\\n\\n return\\n roundUp\\n ? UnsafeMath.divRoundingUp(\\n FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96),\\n sqrtRatioAX96\\n )\\n : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96;\\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 ) external 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\",\"keccak256\":\"0x34b98f373514d057151a41d35aa42031af3b1a47e910888ed73315f72520e429\",\"license\":\"GPL-2.0-or-later\"},\"contracts/libs/TickMathExternal.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.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 TickMathExternal {\\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) public pure returns (uint160 sqrtPriceX96) {\\n uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\\n require(absTick <= uint256(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 /// @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) external pure returns (int24 tick) {\\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\",\"keccak256\":\"0xfd917bc787958baa0b7fd6f526f88a63a5b98a32d3ff1c0f67665e7a1be86e10\",\"license\":\"GPL-2.0-or-later\"},\"contracts/libs/Uint256Casting.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nlibrary Uint256Casting {\\n /**\\n * @notice cast a uint256 to a uint128, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint128\\n */\\n function toUint128(uint256 y) internal pure returns (uint128 z) {\\n require((z = uint128(y)) == y, \\\"OF128\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint96, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint96\\n */\\n function toUint96(uint256 y) internal pure returns (uint96 z) {\\n require((z = uint96(y)) == y, \\\"OF96\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint32, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint32\\n */\\n function toUint32(uint256 y) internal pure returns (uint32 z) {\\n require((z = uint32(y)) == y, \\\"OF32\\\");\\n }\\n}\\n\",\"keccak256\":\"0xcccbe82f8696be398d0d0f5a44988e9bab70e18dd40c9563620cdf160d8bcd7c\",\"license\":\"MIT\"},\"contracts/libs/VaultLib.sol\":{\"content\":\"//SPDX-License-Identifier: GPL-2.0-or-later\\n\\npragma solidity =0.7.6;\\n\\n//interface\\nimport {INonfungiblePositionManager} from \\\"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\\\";\\n\\n//lib\\nimport {SafeMath} from \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport {TickMathExternal} from \\\"./TickMathExternal.sol\\\";\\nimport {SqrtPriceMathPartial} from \\\"./SqrtPriceMathPartial.sol\\\";\\nimport {Uint256Casting} from \\\"./Uint256Casting.sol\\\";\\n\\n/**\\n * Error code:\\n * V1: Vault already had nft\\n * V2: Vault has no NFT\\n */\\nlibrary VaultLib {\\n using SafeMath for uint256;\\n using Uint256Casting for uint256;\\n\\n uint256 constant ONE_ONE = 1e36;\\n\\n // the collateralization ratio (CR) is checked with the numerator and denominator separately\\n // a user is safe if - collateral value >= (COLLAT_RATIO_NUMER/COLLAT_RATIO_DENOM)* debt value\\n uint256 public constant CR_NUMERATOR = 3;\\n uint256 public constant CR_DENOMINATOR = 2;\\n\\n struct Vault {\\n // the address that can update the vault\\n address operator;\\n // uniswap position token id deposited into the vault as collateral\\n // 2^32 is 4,294,967,296, which means the vault structure will work with up to 4 billion positions\\n uint32 NftCollateralId;\\n // amount of eth (wei) used in the vault as collateral\\n // 2^96 / 1e18 = 79,228,162,514, which means a vault can store up to 79 billion eth\\n // when we need to do calculations, we always cast this number to uint256 to avoid overflow\\n uint96 collateralAmount;\\n // amount of wPowerPerp minted from the vault\\n uint128 shortAmount;\\n }\\n\\n /**\\n * @notice add eth collateral to a vault\\n * @param _vault in-memory vault\\n * @param _amount amount of eth to add\\n */\\n function addEthCollateral(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.collateralAmount = uint256(_vault.collateralAmount).add(_amount).toUint96();\\n }\\n\\n /**\\n * @notice add uniswap position token collateral to a vault\\n * @param _vault in-memory vault\\n * @param _tokenId uniswap position token id\\n */\\n function addUniNftCollateral(Vault memory _vault, uint256 _tokenId) internal pure {\\n require(_vault.NftCollateralId == 0, \\\"V1\\\");\\n require(_tokenId != 0, \\\"C23\\\");\\n _vault.NftCollateralId = _tokenId.toUint32();\\n }\\n\\n /**\\n * @notice remove eth collateral from a vault\\n * @param _vault in-memory vault\\n * @param _amount amount of eth to remove\\n */\\n function removeEthCollateral(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.collateralAmount = uint256(_vault.collateralAmount).sub(_amount).toUint96();\\n }\\n\\n /**\\n * @notice remove uniswap position token collateral from a vault\\n * @param _vault in-memory vault\\n */\\n function removeUniNftCollateral(Vault memory _vault) internal pure {\\n require(_vault.NftCollateralId != 0, \\\"V2\\\");\\n _vault.NftCollateralId = 0;\\n }\\n\\n /**\\n * @notice add debt to vault\\n * @param _vault in-memory vault\\n * @param _amount amount of debt to add\\n */\\n function addShort(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.shortAmount = uint256(_vault.shortAmount).add(_amount).toUint128();\\n }\\n\\n /**\\n * @notice remove debt from vault\\n * @param _vault in-memory vault\\n * @param _amount amount of debt to remove\\n */\\n function removeShort(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.shortAmount = uint256(_vault.shortAmount).sub(_amount).toUint128();\\n }\\n\\n /**\\n * @notice check if a vault is properly collateralized\\n * @param _vault the vault we want to check\\n * @param _positionManager address of the uniswap position manager\\n * @param _normalizationFactor current _normalizationFactor\\n * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18\\n * @param _minCollateral minimum collateral that needs to be in a vault\\n * @param _wsqueethPoolTick current price tick for wsqueeth pool\\n * @param _isWethToken0 whether weth is token0 in the wsqueeth pool\\n * @return true if the vault is sufficiently collateralized\\n * @return true if the vault is considered as a dust vault\\n */\\n function getVaultStatus(\\n Vault memory _vault,\\n address _positionManager,\\n uint256 _normalizationFactor,\\n uint256 _ethQuoteCurrencyPrice,\\n uint256 _minCollateral,\\n int24 _wsqueethPoolTick,\\n bool _isWethToken0\\n ) internal view returns (bool, bool) {\\n if (_vault.shortAmount == 0) return (true, false);\\n\\n uint256 debtValueInETH = uint256(_vault.shortAmount).mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div(\\n ONE_ONE\\n );\\n uint256 totalCollateral = _getEffectiveCollateral(\\n _vault,\\n _positionManager,\\n _normalizationFactor,\\n _ethQuoteCurrencyPrice,\\n _wsqueethPoolTick,\\n _isWethToken0\\n );\\n\\n bool isDust = totalCollateral < _minCollateral;\\n bool isAboveWater = totalCollateral.mul(CR_DENOMINATOR) >= debtValueInETH.mul(CR_NUMERATOR);\\n return (isAboveWater, isDust);\\n }\\n\\n /**\\n * @notice get the total effective collateral of a vault, which is:\\n * collateral amount + uniswap position token equivelent amount in eth\\n * @param _vault the vault we want to check\\n * @param _positionManager address of the uniswap position manager\\n * @param _normalizationFactor current _normalizationFactor\\n * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18\\n * @param _wsqueethPoolTick current price tick for wsqueeth pool\\n * @param _isWethToken0 whether weth is token0 in the wsqueeth pool\\n * @return the total worth of collateral in the vault\\n */\\n function _getEffectiveCollateral(\\n Vault memory _vault,\\n address _positionManager,\\n uint256 _normalizationFactor,\\n uint256 _ethQuoteCurrencyPrice,\\n int24 _wsqueethPoolTick,\\n bool _isWethToken0\\n ) internal view returns (uint256) {\\n if (_vault.NftCollateralId == 0) return _vault.collateralAmount;\\n\\n // the user has deposited uniswap position token as collateral, see how much eth / wSqueeth the uniswap position token has\\n (uint256 nftEthAmount, uint256 nftWsqueethAmount) = _getUniPositionBalances(\\n _positionManager,\\n _vault.NftCollateralId,\\n _wsqueethPoolTick,\\n _isWethToken0\\n );\\n // convert squeeth amount from uniswap position token as equivalent amount of collateral\\n uint256 wSqueethIndexValueInEth = nftWsqueethAmount.mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div(\\n ONE_ONE\\n );\\n // add eth value from uniswap position token as collateral\\n return nftEthAmount.add(wSqueethIndexValueInEth).add(_vault.collateralAmount);\\n }\\n\\n /**\\n * @notice determine how much eth / wPowerPerp the uniswap position contains\\n * @param _positionManager address of the uniswap position manager\\n * @param _tokenId uniswap position token id\\n * @param _wPowerPerpPoolTick current price tick\\n * @param _isWethToken0 whether weth is token0 in the pool\\n * @return ethAmount the eth amount this LP token contains\\n * @return wPowerPerpAmount the wPowerPerp amount this LP token contains\\n */\\n function _getUniPositionBalances(\\n address _positionManager,\\n uint256 _tokenId,\\n int24 _wPowerPerpPoolTick,\\n bool _isWethToken0\\n ) internal view returns (uint256 ethAmount, uint256 wPowerPerpAmount) {\\n (\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n ) = _getUniswapPositionInfo(_positionManager, _tokenId);\\n (uint256 amount0, uint256 amount1) = _getToken0Token1Balances(\\n tickLower,\\n tickUpper,\\n _wPowerPerpPoolTick,\\n liquidity\\n );\\n\\n return\\n _isWethToken0\\n ? (amount0 + tokensOwed0, amount1 + tokensOwed1)\\n : (amount1 + tokensOwed1, amount0 + tokensOwed0);\\n }\\n\\n /**\\n * @notice get uniswap position token info\\n * @param _positionManager address of the uniswap position position manager\\n * @param _tokenId uniswap position token id\\n * @return tickLower lower tick of the position\\n * @return tickUpper upper tick of the position\\n * @return liquidity raw liquidity amount of the position\\n * @return tokensOwed0 amount of token 0 can be collected as fee\\n * @return tokensOwed1 amount of token 1 can be collected as fee\\n */\\n function _getUniswapPositionInfo(address _positionManager, uint256 _tokenId)\\n internal\\n view\\n returns (\\n int24,\\n int24,\\n uint128,\\n uint128,\\n uint128\\n )\\n {\\n INonfungiblePositionManager positionManager = INonfungiblePositionManager(_positionManager);\\n (\\n ,\\n ,\\n ,\\n ,\\n ,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n ,\\n ,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n ) = positionManager.positions(_tokenId);\\n return (tickLower, tickUpper, liquidity, tokensOwed0, tokensOwed1);\\n }\\n\\n /**\\n * @notice get balances of token0 / token1 in a uniswap position\\n * @dev knowing liquidity, tick range, and current tick gives balances\\n * @param _tickLower address of the uniswap position manager\\n * @param _tickUpper uniswap position token id\\n * @param _tick current price tick used for calculation\\n * @return amount0 the amount of token0 in the uniswap position token\\n * @return amount1 the amount of token1 in the uniswap position token\\n */\\n function _getToken0Token1Balances(\\n int24 _tickLower,\\n int24 _tickUpper,\\n int24 _tick,\\n uint128 _liquidity\\n ) internal pure returns (uint256 amount0, uint256 amount1) {\\n // get the current price and tick from wPowerPerp pool\\n uint160 sqrtPriceX96 = TickMathExternal.getSqrtRatioAtTick(_tick);\\n\\n if (_tick < _tickLower) {\\n amount0 = SqrtPriceMathPartial.getAmount0Delta(\\n TickMathExternal.getSqrtRatioAtTick(_tickLower),\\n TickMathExternal.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n } else if (_tick < _tickUpper) {\\n amount0 = SqrtPriceMathPartial.getAmount0Delta(\\n sqrtPriceX96,\\n TickMathExternal.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n amount1 = SqrtPriceMathPartial.getAmount1Delta(\\n TickMathExternal.getSqrtRatioAtTick(_tickLower),\\n sqrtPriceX96,\\n _liquidity,\\n true\\n );\\n } else {\\n amount1 = SqrtPriceMathPartial.getAmount1Delta(\\n TickMathExternal.getSqrtRatioAtTick(_tickLower),\\n TickMathExternal.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n }\\n }\\n}\\n\",\"keccak256\":\"0x939175a827c8e9d8d09ee55957e8127a6a55bf42d6a0b3e48b0b59c895aa85af\",\"license\":\"GPL-2.0-or-later\"}},\"version\":1}", + "bytecode": "0x6101e060405260046005553480156200001757600080fd5b5060405162006630380380620066308339810160408190526200003a916200032c565b600062000046620002c4565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600180556001600160a01b038916620000c65760405162461bcd60e51b8152600401620000bd9062000462565b60405180910390fd5b6001600160a01b038816620000ef5760405162461bcd60e51b8152600401620000bd90620004b6565b6001600160a01b038716620001185760405162461bcd60e51b8152600401620000bd90620003f0565b6001600160a01b038616620001415760405162461bcd60e51b8152600401620000bd9062000446565b6001600160a01b0385166200016a5760405162461bcd60e51b8152600401620000bd906200049a565b6001600160a01b038416620001935760405162461bcd60e51b8152600401620000bd906200047e565b6001600160a01b038316620001bc5760405162461bcd60e51b8152600401620000bd906200040c565b6001600160a01b038216620001e55760405162461bcd60e51b8152600401620000bd9062000429565b6001600160601b031960608a811b82166101805289811b82166101405288811b82166101605287811b821660a05286811b821660c05285811b821660e05284811b82166101005283901b16610120526001600160e81b031960e882901b166080526001600160a01b038781169087161060f81b6101c052600780546001600160801b031916670de0b6b3a7640000179055426101a081905262000297906200274f620002c8602090811b91909117901c565b600780546001600160801b03928316600160801b02921691909117905550620004d2975050505050505050565b3390565b806001600160801b03811681146200030f576040805162461bcd60e51b815260206004820152600560248201526409e8c6264760db1b604482015290519081900360640190fd5b919050565b80516001600160a01b03811681146200030f57600080fd5b60008060008060008060008060006101208a8c0312156200034b578485fd5b620003568a62000314565b98506200036660208b0162000314565b97506200037660408b0162000314565b96506200038660608b0162000314565b95506200039660808b0162000314565b9450620003a660a08b0162000314565b9350620003b660c08b0162000314565b9250620003c660e08b0162000314565b91506101008a015162ffffff81168114620003df578182fd5b809150509295985092959850929598565b602080825260029082015261219b60f11b604082015260600190565b60208082526003908201526204331360ec1b604082015260600190565b60208082526003908201526243313160e81b604082015260600190565b602080825260029082015261433760f01b604082015260600190565b60208082526002908201526110cd60f21b604082015260600190565b602080825260029082015261433960f01b604082015260600190565b602080825260029082015261086760f31b604082015260600190565b602080825260029082015261433560f01b604082015260600190565b60805160e81c60a05160601c60c05160601c60e05160601c6101005160601c6101205160601c6101405160601c6101605160601c6101805160601c6101a0516101c05160f81c615f2f620007016000398061465452806148f55250806115bc525080610af15280610bc95280610d3a52806113f9528061173c528061243c5280612ac65280612b9a5280613e765280614050528061411052806144d452806145945280614cd35280614d7e525080610ddf528061141d5280611b9952806124e15280612b6b52806135da52806136525280613897528061393f5280613b125280613eb85280613f6b52806144125280614d155280614dc0525080611a795280611d9f5280611de05280611ff352806121a6528061270f5280612f395280613d6452508061339352806134bb52806136ff52806145685280614769525080610d5b5280611d7b528061245d5280612ae75280613e97528061413f52806145c35280614cf45280614d9f525080610b125280610bea5280610d7c528061109e528061175d528061247e5280612b085280612bbb528061407f52806144f5525080610b545280610c2c5280610dbe52806114b1528061179f52806124c05280612b4a5280612bfd52806145375250806103535280610b335280610c0b5280610d9d5280610ebc528061177e528061249f5280612b295280612bdc5280613616528061368e52806137fa5280613ed952806145165280614d365280614de15250806113c152806135915250615f2f6000f3fe6080604052600436106103435760003560e01c80638456cb59116101b0578063b707ab99116100ec578063e74b981b11610095578063f2fde38b1161006f578063f2fde38b146108d0578063f90c3f27146108f0578063fbfc6bc014610905578063ff947525146109255761039b565b8063e74b981b14610888578063ed88c68e146108a8578063ee3189ff146108b05761039b565b8063d296d1f1116100c6578063d296d1f11461083e578063d52725841461085e578063de4a427a146108735761039b565b8063b707ab99146107e9578063c65a391d146107fe578063c9e77ee81461081e5761039b565b806391b8d34a116101595780639d4c9442116101335780639d4c944214610781578063a847e67414610796578063ac6cd5ef146107b6578063b6b55f25146107d65761039b565b806391b8d34a1461072c578063978bbdb91461074c57806397efa942146107615761039b565b80638cd21d7c1161018a5780638cd21d7c146106e25780638da5cb5b1461070257806391b4ded9146107175761039b565b80638456cb591461067d5780638632cb03146106925780638c64ea4a146106b25761039b565b806345596e2e1161027f57806372f5d98a116102285780637dc0d1d0116102025780637dc0d1d0146106295780637f07b1301461063e5780638146b09f1461065357806382564bca146106685761039b565b806372f5d98a146105c35780637691c4ac146105e55780637ca25184146106075761039b565b806363b38ae41161025957806363b38ae414610579578063713d517f1461058e578063715018a6146105ae5761039b565b806345596e2e1461052257806346904840146105425780634be2822c146105575761039b565b806324f5f531116102ec5780633fc8cef3116102c65780633fc8cef3146104ab5780634394318d146104cd578063441a3e70146104ed5780634468c0221461050d5761039b565b806324f5f53114610463578063377a19361461047857806339467918146104985761039b565b806315aded831161031d57806315aded83146104005780631bf7bf6c1461042d578063200f4b8d1461044e5761039b565b806307633669146103a057806310b9e583146103b5578063150b7a02146103ca5761039b565b3661039b57336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146103995760405162461bcd60e51b815260040161039090615cc9565b60405180910390fd5b005b600080fd5b3480156103ac57600080fd5b5061039961093a565b3480156103c157600080fd5b50610399610a3d565b3480156103d657600080fd5b506103ea6103e5366004615662565b610bb0565b6040516103f79190615ad9565b60405180910390f35b34801561040c57600080fd5b5061042061041b36600461584f565b610bc1565b6040516103f79190615df3565b61044061043b366004615824565b610c58565b6040516103f7929190615dfc565b34801561045a57600080fd5b50610399610cef565b34801561046f57600080fd5b50610420610d22565b34801561048457600080fd5b5061042061049336600461584f565b610d32565b6104206104a6366004615824565b610e22565b3480156104b757600080fd5b506104c0610eba565b6040516103f79190615961565b3480156104d957600080fd5b506104206104e8366004615824565b610ede565b3480156104f957600080fd5b506103996105083660046157e0565b610f78565b34801561051957600080fd5b506104c061109c565b34801561052e57600080fd5b5061039961053d366004615781565b6110c0565b34801561054e57600080fd5b506104c06111bd565b34801561056357600080fd5b5061056c6111cc565b6040516103f79190615da5565b34801561058557600080fd5b506104206111e2565b34801561059a57600080fd5b506103996105a9366004615781565b6111e8565b3480156105ba57600080fd5b50610399611301565b3480156105cf57600080fd5b506105d86113bf565b6040516103f79190615de3565b3480156105f157600080fd5b506105fa6113e3565b6040516103f79190615ace565b34801561061357600080fd5b5061061c6113f1565b6040516103f79190615e0a565b34801561063557600080fd5b506104c06113f7565b34801561064a57600080fd5b506104c061141b565b34801561065f57600080fd5b5061039961143f565b34801561067457600080fd5b506104c06114af565b34801561068957600080fd5b506103996114d3565b34801561069e57600080fd5b506103996106ad366004615824565b61165c565b3480156106be57600080fd5b506106d26106cd366004615781565b6116e7565b6040516103f79493929190615a90565b3480156106ee57600080fd5b506104206106fd36600461584f565b611734565b34801561070e57600080fd5b506104c06117c3565b34801561072357600080fd5b506104206117d2565b34801561073857600080fd5b506103996107473660046157e0565b6117d8565b34801561075857600080fd5b506104206118d1565b34801561076d57600080fd5b5061039961077c366004615781565b6118d7565b34801561078d57600080fd5b506104c0611a77565b3480156107a257600080fd5b506105fa6107b1366004615781565b611a9b565b3480156107c257600080fd5b506103996107d1366004615781565b611b15565b6103996107e4366004615781565b611c6f565b3480156107f557600080fd5b506104c0611d79565b34801561080a57600080fd5b506103996108193660046157b1565b611d9d565b34801561082a57600080fd5b50610399610839366004615781565b611efb565b34801561084a57600080fd5b506104206108593660046157e0565b61208d565b34801561086a57600080fd5b5061056c6122f8565b34801561087f57600080fd5b50610420612307565b34801561089457600080fd5b506103996108a336600461562a565b61230d565b610399612410565b3480156108bc57600080fd5b506104206108cb36600461584f565b612434565b3480156108dc57600080fd5b506103996108eb36600461562a565b61250d565b3480156108fc57600080fd5b50610420612621565b34801561091157600080fd5b50610399610920366004615781565b612628565b34801561093157600080fd5b506105fa612746565b6109426127ad565b6001600160a01b03166109536117c3565b6001600160a01b0316146109ae576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600854610100900460ff166109d55760405162461bcd60e51b815260040161039090615c1d565b60085460ff16156109f85760405162461bcd60e51b815260040161039090615b53565b6008805461ff00191690556040517fff2b959f2bcdb44c7ecb4b16dae055431019d7350607125cfc2b74a06632c90e90610a33903390615961565b60405180910390a1565b610a456127ad565b6001600160a01b0316610a566117c3565b6001600160a01b031614610ab1576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60085460ff1615610ad45760405162461bcd60e51b815260040161039090615b53565b6008805460ff1961ff001990911661010017166001179055610b7d7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006101a460006127b1565b60048190556040517f574214b195bf5273a95bb4498e35cf1fde0ce327c727a95ec2ab359f7ba4e11a91610a3391615df3565b630a85bd0160e11b5b949350505050565b6000610c50827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006127de565b90505b919050565b6008546000908190610100900460ff1615610c855760405162461bcd60e51b815260040161039090615c39565b60026001541415610ccb576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b6002600155610cdf33868634876000612819565b6001805590969095509350505050565b600854610100900460ff1615610d175760405162461bcd60e51b815260040161039090615c39565b610d1f61296a565b50565b6000610d2c612a58565b90505b90565b6000610c50827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000600760009054906101000a90046001600160801b03166001600160801b0316612ee9565b600854600090610100900460ff1615610e4d5760405162461bcd60e51b815260040161039090615c39565b60026001541415610e93576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b60026001819055506000610eac33868634876001612819565b506001805595945050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600854600090610100900460ff1615610f095760405162461bcd60e51b815260040161039090615c39565b60026001541415610f4f576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b6002600155610f5e8433612f2d565b610f6c338585856000613021565b60018055949350505050565b600854610100900460ff1615610fa05760405162461bcd60e51b815260040161039090615c39565b60026001541415610fe6576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b6002600155610ff58233612f2d565b6000610fff61296a565b600084815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b0316606082015290915061107481858561310f565b61107e8183613159565b61108884826131ab565b611092338461327e565b5050600180555050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6110c86127ad565b6001600160a01b03166110d96117c3565b6001600160a01b031614611134576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6002546001600160a01b031661115c5760405162461bcd60e51b815260040161039090615afc565b606481111561117d5760405162461bcd60e51b815260040161039090615c55565b7f14914da2bf76024616fbe1859783fcd4dbddcb179b1f3a854949fbf920dcb957600354826040516111b0929190615dfc565b60405180910390a1600355565b6002546001600160a01b031681565b600754600160801b90046001600160801b031681565b60055481565b600854610100900460ff16156112105760405162461bcd60e51b815260040161039090615c39565b60026001541415611256576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b60026001556112658133612f2d565b600061126f61296a565b600083815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b031660608201529091506112e4813385613368565b6112ee8183613159565b6112f883826131ab565b50506001805550565b6113096127ad565b6001600160a01b031661131a6117c3565b6001600160a01b031614611375576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b7f000000000000000000000000000000000000000000000000000000000000000081565b600854610100900460ff1681565b6101a481565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600854610100900460ff166114665760405162461bcd60e51b815260040161039090615c1d565b60085460ff16156114895760405162461bcd60e51b815260040161039090615b53565b600654620151800142116109f85760405162461bcd60e51b815260040161039090615be3565b7f000000000000000000000000000000000000000000000000000000000000000081565b6114db6127ad565b6001600160a01b03166114ec6117c3565b6001600160a01b031614611547576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60085460ff161561156a5760405162461bcd60e51b815260040161039090615b53565b600854610100900460ff16156115925760405162461bcd60e51b815260040161039090615c39565b6000600554116115b45760405162461bcd60e51b815260040161039090615b6f565b60006115e0427f000000000000000000000000000000000000000000000000000000000000000061343f565b905062eff10081106116045760405162461bcd60e51b815260040161039090615ce6565b6008805461ff001916610100179055600580546000190190819055426006556040517f32fb7c9891bc4f963c7de9f1186d2a7755c7d6e9f4604dabe1d8bb3027c2f49e9161165191615df3565b60405180910390a150565b600854610100900460ff16156116845760405162461bcd60e51b815260040161039090615c39565b600260015414156116ca576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b60026001556116d98333612f2d565b611092338484846001613021565b600960205260009081526040902080546001909101546001600160a01b03821691600160a01b900463ffffffff16906001600160601b03811690600160601b90046001600160801b031684565b6000610c50827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006134a1565b6000546001600160a01b031690565b60065481565b600854610100900460ff16156118005760405162461bcd60e51b815260040161039090615c39565b60026001541415611846576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b60026001556118558233612f2d565b61185d61296a565b50600082815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b031660608201526112ee813385856134b3565b60035481565b60085460ff166118f95760405162461bcd60e51b815260040161039090615d03565b6002600154141561193f576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b600260015561194e8133612f2d565b6000818152600960209081526040808320815160808101835281546001600160a01b0381168252600160a01b900463ffffffff1693810193909352600101546001600160601b03811691830191909152600160601b90046001600160801b03908116606083015260075491929116906119cc908390339086906137af565b5060006119e983606001516001600160801b0316600454846139fa565b90506000611a0d8285604001516001600160601b031661343f90919063ffffffff16565b60006060860181905260408601529050611a2785856131ab565b611a31338261327e565b7f7dff8cdaec6a8d4d1ad32d3c947ed0f0281c3d6456621ef928defae96ec6cddb338683604051611a64939291906159d5565b60405180910390a1505060018055505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000818152600960209081526040808320815160808101835281546001600160a01b0381168252600160a01b900463ffffffff1693810193909352600101546001600160601b03811691830191909152600160601b90046001600160801b0316606082015281611b09612a58565b9050610bb98282613a23565b60085460ff16611b375760405162461bcd60e51b815260040161039090615d03565b60026001541415611b7d576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b6002600155604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac90611bd09033908590600401615999565b600060405180830381600087803b158015611bea57600080fd5b505af1158015611bfe573d6000803e3d6000fd5b505060045460075460009350611c2092508491906001600160801b03166139fa565b9050611c2c338261327e565b7f2131ef4f2f82ca75fe7d2e646ebfa45b6be25e53510c829629c76b641500ec67338383604051611c5f939291906159d5565b60405180910390a1505060018055565b600854610100900460ff1615611c975760405162461bcd60e51b815260040161039090615c39565b60026001541415611cdd576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b6002600155611cec8133612f2d565b611cf461296a565b50600081815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b03166060820152611d67818334613a39565b611d7182826131ab565b505060018055565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316331480611e7857506040516331a9108f60e11b815233907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90611e1d908690600401615df3565b60206040518083038186803b158015611e3557600080fd5b505afa158015611e49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6d9190615646565b6001600160a01b0316145b611e945760405162461bcd60e51b815260040161039090615b19565b6000828152600960205260409081902080546001600160a01b0319166001600160a01b038416179055517f3137fc9cd2e33c34f86e29c24d81f3c75b0bce639d3c4ed0d31eeff1160a7ff590611eef903390859085906159b2565b60405180910390a15050565b600854610100900460ff1615611f235760405162461bcd60e51b815260040161039090615c39565b60026001541415611f69576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b6002600155611f788133612f2d565b600081815260096020908152604091829020825160808101845281546001600160a01b038082168352600160a01b90910463ffffffff16938201939093526001909101546001600160601b03811682850152600160601b90046001600160801b0316606082015291516331a9108f60e11b81526120829183917f000000000000000000000000000000000000000000000000000000000000000090911690636352211e9061202a908790600401615df3565b60206040518083038186803b15801561204257600080fd5b505afa158015612056573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061207a9190615646565b8460006137af565b50611d7182826131ab565b600854600090610100900460ff16156120b85760405162461bcd60e51b815260040161039090615c39565b600260015414156120fe576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b6002600155600061210d61296a565b600085815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b031660608201529091506121818183613a23565b1561219e5760405162461bcd60e51b815260040161039090615c72565b6000612248827f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636352211e896040518263ffffffff1660e01b81526004016121f09190615df3565b60206040518083038186803b15801561220857600080fd5b505afa15801561221c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122409190615646565b8860016137af565b90506122548284613a23565b156122795761226386836131ab565b61226d338261327e565b600093505050506122ee565b6122838282613a76565b60008061229284888733613aac565b915091507f158ba9ab7bbbd08eeffa4753bad41f4d450e24831d293427308badf3eadd8c76338984846040516122cb94939291906159f6565b60405180910390a16122dd88856131ab565b6122e7338261327e565b5093505050505b6001805592915050565b6007546001600160801b031681565b60045481565b6123156127ad565b6001600160a01b03166123266117c3565b6001600160a01b031614612381576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166123a75760405162461bcd60e51b815260040161039090615b8c565b6002546040517faaebcf1bfa00580e41d966056b48521fa9f202645c86d4ddf28113e617c1b1d3916123e6916001600160a01b03909116908490615a57565b60405180910390a1600280546001600160a01b0319166001600160a01b0392909216919091179055565b60085460ff166124325760405162461bcd60e51b815260040161039090615d03565b565b6000610c50827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000612508612a58565b612ee9565b6125156127ad565b6001600160a01b03166125266117c3565b6001600160a01b031614612581576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166125c65760405162461bcd60e51b8152600401808060200182810382526026815260200180615e796026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6217124081565b60085460ff1661264a5760405162461bcd60e51b815260040161039090615d03565b60026001541415612690576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b60026001908155600082815260096020908152604091829020825160808101845281546001600160a01b038082168352600160a01b90910463ffffffff16938201939093529301546001600160601b03811684840152600160601b90046001600160801b0316606084015290516331a9108f60e11b81526120829183917f000000000000000000000000000000000000000000000000000000000000000090911690636352211e9061202a908790600401615df3565b60085460ff1681565b806001600160801b0381168114610c53576040805162461bcd60e51b815260206004820152600560248201527f4f46313238000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b3390565b6000806127c2888888888888613bd3565b90506127d081612710613c79565b9150505b9695505050505050565b6000806127f0868686868b6000613bd3565b905061280e670de0b6b3a76400006128088380613ce0565b90613c79565b979650505050505050565b600080600061282661296a565b90508560008561284b57612846836128088b670de0b6b3a7640000613ce0565b61284d565b885b905060006128596155bc565b8b612871576128678d613d40565b909c5090506128e4565b61287b8c33612f2d565b5060008b815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b031660608201525b8215612905576128f581848c613e53565b94509150612905818e8e86613f4a565b891561291657612916818d86613a39565b881561292857612928818e8e8c6134b3565b6129328186613159565b61293c8c826131ab565b811561295857600254612958906001600160a01b03168361327e565b50999b909a5098505050505050505050565b6007546000906001600160801b03600160801b9091041642141561299a57506007546001600160801b0316610d2f565b60006129a4612a58565b6007546040519192507f339e53729b0447795ff69e70a74fed98fc7fef6fe94b7521099b32f0f8de4822916129f3916001600160801b03808216928692600160801b9004909116904290615db9565b60405180910390a1612a048161274f565b600780546fffffffffffffffffffffffffffffffff19166001600160801b0392909216919091179055612a364261274f565b600780546001600160801b03928316600160801b029216919091179055905090565b6007546000908190612a8490612a7f904290600160801b90046001600160801b031661343f565b614007565b905063ffffffff8116612aa45750506007546001600160801b0316610d2f565b6000612aaf8261404b565b6007549091506001600160801b03166000612b90837f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000089612ee9565b90506000612c21847f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006134a1565b905060007321A8D15322C257Abd2b22a56eDde758398be0F3263fc505d3787621712406040518363ffffffff1660e01b8152600401612c61929190615e1b565b60206040518083038186803b158015612c7957600080fd5b505af4158015612c8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb19190615746565b90506000612cd3670de0b6b3a764000061280885670b1a2bc2ec500000613ce0565b905080841015612ce557809350612d15565b6000612d05670de0b6b3a76400006128088667136dcc951d8c0000613ce0565b905080851115612d13578094505b505b60405163fc505d3760e01b81526000907321A8D15322C257Abd2b22a56eDde758398be0F329063fc505d3790612d519087908990600401615dfc565b60206040518083038186803b158015612d6957600080fd5b505af4158015612d7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612da19190615746565b90506000612e39847321A8D15322C257Abd2b22a56eDde758398be0F32632cbbdee5856040518263ffffffff1660e01b8152600401612de09190615aee565b60206040518083038186803b158015612df857600080fd5b505af4158015612e0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e309190615746565b600f0b9061420f565b604051637e0c9e7960e11b81529091506000907321A8D15322C257Abd2b22a56eDde758398be0F329063fc193cf290612e7a90600f86900b90600401615aee565b60206040518083038186803b158015612e9257600080fd5b505af4158015612ea6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eca9190615746565b9050612eda600f82900b896142a0565b9a505050505050505050505090565b600080612efb898888888e60006127b1565b90506000612f0e8a8a878a8f6000613bd3565b9050612f1e846128088385613ce0565b9b9a5050505050505050505050565b806001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636352211e846040518263ffffffff1660e01b8152600401612f839190615df3565b60206040518083038186803b158015612f9b57600080fd5b505afa158015612faf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fd39190615646565b6001600160a01b0316148061300157506000828152600960205260409020546001600160a01b038281169116145b61301d5760405162461bcd60e51b815260040161039090615b19565b5050565b60008061302c61296a565b90506000836130505761304b8261280888670de0b6b3a7640000613ce0565b613052565b855b600088815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b0316606082015290915081156130ce576130ce818a8a856143f1565b85156130df576130df81898861310f565b6130e98184613159565b6130f388826131ab565b851561310357613103338761327e565b50979650505050505050565b61311983826144ae565b7f627a692d5a03ab34732c0d2aa319f3ecdebdc4528f383eabcb25441dc0a70cfb33838360405161314c939291906159d5565b60405180910390a1505050565b60008061316684846144ca565b91509150816131875760405162461bcd60e51b815260040161039090615c8f565b80156131a55760405162461bcd60e51b815260040161039090615cac565b50505050565b600091825260096020908152604092839020825181549284015163ffffffff16600160a01b027fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff6001600160a01b039092166001600160a01b0319909416939093171691909117815591810151600190920180546060909201516001600160801b0316600160601b027fffffffff00000000000000000000000000000000ffffffffffffffffffffffff6001600160601b039094166bffffffffffffffffffffffff199093169290921792909216179055565b804710156132d3576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d806000811461331e576040519150601f19603f3d011682016040523d82523d6000602084013e613323565b606091505b50509050806133635760405162461bcd60e51b815260040180806020018281038252603a815260200180615e9f603a913960400191505060405180910390fd5b505050565b602083015163ffffffff1661337c84614684565b604051632142170760e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906342842e0e906133cc90309087908690600401615975565b600060405180830381600087803b1580156133e657600080fd5b505af11580156133fa573d6000803e3d6000fd5b505050507fe59f38fa1264fc25c9f0185eee136eaf810d90b8e7293b342e4037c68720177a338383604051613431939291906159d5565b60405180910390a150505050565b600082821115613496576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b6000806127f0868686868b60006127b1565b6000806000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166399fbab88866040518263ffffffff1660e01b81526004016135059190615df3565b6101806040518083038186803b15801561351e57600080fd5b505afa158015613532573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135569190615887565b505050509750505095509550955050506000816001600160801b03161161358f5760405162461bcd60e51b815260040161039090615bc6565b7f000000000000000000000000000000000000000000000000000000000000000062ffffff168262ffffff16146135d85760405162461bcd60e51b815260040161039090615b36565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b031614801561364a57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b0316145b806136c257507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03161480156136c257507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b0316145b6136de5760405162461bcd60e51b815260040161039090615ba9565b6136e888866146cf565b604051632142170760e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906342842e0e90613738908a9030908a90600401615975565b600060405180830381600087803b15801561375257600080fd5b505af1158015613766573d6000803e3d6000fd5b505050507f3917c2f26ce18614e3aedd1289da672ef6563c5c295f49e9b1697ae0ad31556233878760405161379d939291906159d5565b60405180910390a15050505050505050565b602084015160009063ffffffff16806137cc576000915050610bb9565b6000806137d883614764565b9092509050811561386257604051632e1a7d4d60e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690632e1a7d4d9061382f908590600401615df3565b600060405180830381600087803b15801561384957600080fd5b505af115801561385d573d6000803e3d6000fd5b505050505b60008060006138738b86868b614931565b9194509250905081156139225760405163a9059cbb60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906138ce908d908690600401615999565b602060405180830381600087803b1580156138e857600080fd5b505af11580156138fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139209190615726565b505b82156139a957604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac906139769030908790600401615999565b600060405180830381600087803b15801561399057600080fd5b505af11580156139a4573d6000803e3d6000fd5b505050505b7ffd0ae2fd36bd955810ae42615bc5ff277c0d0dfcb930f06c9f1777c0ef0752e3338a87878787876040516139e49796959493929190615a1c565b60405180910390a19a9950505050505050505050565b6000610bb96ec097ce7bc90715b34b9f100000000061280885613a1d8887613ce0565b90613ce0565b600080613a3084846144ca565b50949350505050565b613a438382613a76565b7f3ca13b7aab12bad7472691fe558faa6b25e99099824a0070a88bd5aa84be610f33838360405161314c939291906159d5565b6040820151613a9790613a92906001600160601b0316836149c7565b614a21565b6001600160601b031660409092019190915250565b600080600080613ad78789606001516001600160801b03168a604001516001600160601b0316614a68565b9150915081871015613afb5760405162461bcd60e51b815260040161039090615c00565b604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac90613b499088908690600401615999565b600060405180830381600087803b158015613b6357600080fd5b505af1158015613b77573d6000803e3d6000fd5b50505050613b8e8289614ad090919063ffffffff16565b613b9888826144ae565b6000613ba489886144ca565b9150508015613bc55760405162461bcd60e51b815260040161039090615cac565b509097909650945050505050565b6040805163cce79bd560e01b81526001600160a01b0387811660048301528681166024830152858116604483015263ffffffff851660648301528315156084830152915160009289169163cce79bd59160a4808301926020929190829003018186803b158015613c4257600080fd5b505afa158015613c56573d6000803e3d6000fd5b505050506040513d6020811015613c6c57600080fd5b5051979650505050505050565b6000808211613ccf576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381613cd857fe5b049392505050565b600082613cef5750600061349b565b82820282848281613cfc57fe5b0414613d395760405162461bcd60e51b8152600401808060200182810382526021815260200180615ed96021913960400191505060405180910390fd5b9392505050565b6000613d4a6155bc565b6040516354ba0f2760e01b81526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906354ba0f2790613d99908790600401615961565b602060405180830381600087803b158015613db357600080fd5b505af1158015613dc7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613deb9190615799565b6040805160808101825260008082526020820181905281830181905260608201529051919250907f25ff1e0131762176a9084e92880f880f39d6d0e62134607f37e631efe1bad87190613e419033908590615999565b60405180910390a19092509050915091565b600354600090819080613e6d576000849250925050613f42565b600080613efd877f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000614b06565b90506000613f116127106128088487613ce0565b905080871115613f2c57613f25878261343f565b9250613f3a565b613f3689826144ae565b8692505b945090925050505b935093915050565b613f548482614b32565b6040516340c10f1960e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340c10f1990613fa29086908590600401615999565b600060405180830381600087803b158015613fbc57600080fd5b505af1158015613fd0573d6000803e3d6000fd5b505050507fb19fa182730a088464dad0e9e0badeb470d0d8d937d854f5caf15c6ad1992c36338284604051613431939291906159d5565b8063ffffffff81168114610c53576040805162461bcd60e51b8152602060048083019190915260248201526327a3199960e11b604482015290519081900360640190fd5b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663de5a6e227f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b81526004016140ba9190615961565b60206040518083038186803b1580156140d257600080fd5b505afa1580156140e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061410a919061586b565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663de5a6e227f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b815260040161417a9190615961565b60206040518083038186803b15801561419257600080fd5b505afa1580156141a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141ca919061586b565b905060008163ffffffff168363ffffffff16116141e757826141e9565b815b90508063ffffffff168563ffffffff16116142045784614206565b805b95945050505050565b6000600f83810b9083900b0260401d6f7fffffffffffffffffffffffffffffff19811280159061424f57506f7fffffffffffffffffffffffffffffff8113155b613d39576040805162461bcd60e51b815260206004820152600860248201527f4d554c2d4f565546000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000816142af5750600061349b565b600083600f0b1215614308576040805162461bcd60e51b815260206004820152600760248201527f4d554c552d583000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b600f83900b6001600160801b038316810260401c90608084901c0277ffffffffffffffffffffffffffffffffffffffffffffffff811115614390576040805162461bcd60e51b815260206004820152600860248201527f4d554c552d4f4631000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60401b81198111156143e9576040805162461bcd60e51b815260206004820152600860248201527f4d554c552d4f4632000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b019392505050565b6143fb8482614ad0565b604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac906144499086908590600401615999565b600060405180830381600087803b15801561446357600080fd5b505af1158015614477573d6000803e3d6000fd5b505050507fea19ffc45b48de6d95594aacff7214dd24595fdb0c60e98c8f0b269058c2f792338284604051613431939291906159d5565b6040820151613a9790613a92906001600160601b03168361343f565b60008060006145607f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006101a460016127b1565b9050614678857f00000000000000000000000000000000000000000000000000000000000000008684675fc1b971363200007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316634a0a96eb7f00000000000000000000000000000000000000000000000000000000000000006101a46040518363ffffffff1660e01b8152600401614602929190615a71565b60206040518083038186803b15801561461a57600080fd5b505afa15801561462e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146529190615767565b7f0000000000000000000000000000000000000000000000000000000000000000614b4e565b92509250509250929050565b602081015163ffffffff166146c5576040805162461bcd60e51b81526020600482015260026024820152612b1960f11b604482015290519081900360640190fd5b6000602090910152565b602082015163ffffffff1615614711576040805162461bcd60e51b8152602060048201526002602482015261563160f01b604482015290519081900360640190fd5b80614749576040805162461bcd60e51b815260206004820152600360248201526243323360e81b604482015290519081900360640190fd5b61475281614007565b63ffffffff1660209092019190915250565b6000807f0000000000000000000000000000000000000000000000000000000000000000816147938286614bf2565b50506040805160a0810182528981526001600160801b0383166020820152600081830181905260608201524260808201529051630624e65f60e11b815291945092506001600160a01b0385169150630c49ccbe906147f5908490600401615d62565b6040805180830381600087803b15801561480e57600080fd5b505af1158015614822573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148469190615801565b5050604080516080810182528781523060208201526001600160801b038183018190526060820152905163fc6f786560e01b815260009081906001600160a01b0387169063fc6f78659061489e908690600401615d1f565b6040805180830381600087803b1580156148b757600080fd5b505af11580156148cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148ef9190615801565b915091507f000000000000000000000000000000000000000000000000000000000000000061491f578082614922565b81815b97509750505050505050915091565b600080600080841561494a576149478787614cb0565b90505b606088015186906000906001600160801b03168211156149905760608a015161497d9089906001600160801b031661343f565b905089606001516001600160801b031691505b61499a8a83614ad0565b6149a38a614684565b6149ad8a8a613a76565b6149b78a846144ae565b9099909850909650945050505050565b600082820183811015613d39576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b806001600160601b0381168114610c53576040805162461bcd60e51b8152602060048083019190915260248201526327a31c9b60e11b604482015290519081900360640190fd5b6000808080614a8187614a7c886002613c79565b614d60565b9150915080851115614ab657675fc1b97136320000614aa0868361343f565b1015614ab657614ab08787614d60565b90925090505b84811115614ac45750849050835b90969095509350505050565b6060820151614af190614aec906001600160801b03168361343f565b61274f565b6001600160801b031660609092019190915250565b600080614b1a868686866101a46000613bd3565b905061280e670de0b6b3a76400006128088984613ce0565b6060820151614af190614aec906001600160801b0316836149c7565b60008088606001516001600160801b031660001415614b735750600190506000614be6565b6000614bac6ec097ce7bc90715b34b9f100000000061280889613a1d8c8f606001516001600160801b0316613ce090919063ffffffff16565b90506000614bbe8b8b8b8b8a8a614e3c565b90508681106000614bd0846003613ce0565b614bdb846002613ce0565b101595509093505050505b97509795505050505050565b6000806000806000808790506000806000806000856001600160a01b03166399fbab888d6040518263ffffffff1660e01b8152600401808281526020019150506101806040518083038186803b158015614c4b57600080fd5b505afa158015614c5f573d6000803e3d6000fd5b505050506040513d610180811015614c7657600080fd5b5060a081015160c082015160e083015161014084015161016090940151929e50909c509a5090985096505050505050509295509295909350565b6000613d39670de0b6b3a764000061280866470de4df820000613a1d87614d5a887f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000614b06565b906149c7565b6000806000838511614d725784614d74565b835b90506000614e05827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000614b06565b9050614e2f614e28670de0b6b3a76400006128088467016345785d8a0000613ce0565b82906149c7565b9196919550909350505050565b6000866020015163ffffffff1660001415614e65575060408601516001600160601b03166127d4565b600080614e7e888a6020015163ffffffff168787614ed3565b90925090506000614ea66ec097ce7bc90715b34b9f100000000061280889613a1d868d613ce0565b60408b0151909150614ec5906001600160601b0316614d5a85846149c7565b9a9950505050505050505050565b6000806000806000806000614ee88b8b614bf2565b94509450945094509450600080614f0187878d88614f54565b9150915089614f2757826001600160801b03168101846001600160801b03168301614f40565b836001600160801b03168201836001600160801b031682015b985098505050505050505094509492505050565b6000806000734d9d7F7aE80d51628Aa56eF37720718C99E6FDfC63986cfba3866040518263ffffffff1660e01b8152600401808260020b815260200191505060206040518083038186803b158015614fab57600080fd5b505af4158015614fbf573d6000803e3d6000fd5b505050506040513d6020811015614fd557600080fd5b50519050600287810b9086900b121561519857739cf8dcbCf115B06d8f577E73Cb9EdFdb27828460632c32d4b6734d9d7F7aE80d51628Aa56eF37720718C99E6FDfC63986cfba38a6040518263ffffffff1660e01b8152600401808260020b815260200191505060206040518083038186803b15801561505457600080fd5b505af4158015615068573d6000803e3d6000fd5b505050506040513d602081101561507e57600080fd5b50516040805163986cfba360e01b815260028b900b60048201529051734d9d7F7aE80d51628Aa56eF37720718C99E6FDfC9163986cfba3916024808301926020929190829003018186803b1580156150d557600080fd5b505af41580156150e9573d6000803e3d6000fd5b505050506040513d60208110156150ff57600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526001600160801b038816604483015260016064830152516084808301926020929190829003018186803b15801561516557600080fd5b505af4158015615179573d6000803e3d6000fd5b505050506040513d602081101561518f57600080fd5b505192506155b2565b8560020b8560020b121561540657739cf8dcbCf115B06d8f577E73Cb9EdFdb27828460632c32d4b682734d9d7F7aE80d51628Aa56eF37720718C99E6FDfC63986cfba38a6040518263ffffffff1660e01b8152600401808260020b815260200191505060206040518083038186803b15801561521357600080fd5b505af4158015615227573d6000803e3d6000fd5b505050506040513d602081101561523d57600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526001600160801b038816604483015260016064830152516084808301926020929190829003018186803b1580156152a357600080fd5b505af41580156152b7573d6000803e3d6000fd5b505050506040513d60208110156152cd57600080fd5b50516040805163986cfba360e01b815260028a900b60048201529051919450739cf8dcbCf115B06d8f577E73Cb9EdFdb27828460916348a0c5bd91734d9d7F7aE80d51628Aa56eF37720718C99E6FDfC9163986cfba391602480820192602092909190829003018186803b15801561534457600080fd5b505af4158015615358573d6000803e3d6000fd5b505050506040513d602081101561536e57600080fd5b5051604080516001600160e01b031960e085901b1681526001600160a01b03928316600482015291851660248301526001600160801b038816604483015260016064830152516084808301926020929190829003018186803b1580156153d357600080fd5b505af41580156153e7573d6000803e3d6000fd5b505050506040513d60208110156153fd57600080fd5b505191506155b2565b739cf8dcbCf115B06d8f577E73Cb9EdFdb278284606348a0c5bd734d9d7F7aE80d51628Aa56eF37720718C99E6FDfC63986cfba38a6040518263ffffffff1660e01b8152600401808260020b815260200191505060206040518083038186803b15801561547257600080fd5b505af4158015615486573d6000803e3d6000fd5b505050506040513d602081101561549c57600080fd5b50516040805163986cfba360e01b815260028b900b60048201529051734d9d7F7aE80d51628Aa56eF37720718C99E6FDfC9163986cfba3916024808301926020929190829003018186803b1580156154f357600080fd5b505af4158015615507573d6000803e3d6000fd5b505050506040513d602081101561551d57600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526001600160801b038816604483015260016064830152516084808301926020929190829003018186803b15801561558357600080fd5b505af4158015615597573d6000803e3d6000fd5b505050506040513d60208110156155ad57600080fd5b505191505b5094509492505050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b8051610c5381615e31565b8051600281900b8114610c5357600080fd5b80516001600160801b0381168114610c5357600080fd5b805162ffffff81168114610c5357600080fd5b60006020828403121561563b578081fd5b8135613d3981615e31565b600060208284031215615657578081fd5b8151613d3981615e31565b60008060008060808587031215615677578283fd5b843561568281615e31565b935060208581013561569381615e31565b935060408601359250606086013567ffffffffffffffff808211156156b6578384fd5b818801915088601f8301126156c9578384fd5b8135818111156156d557fe5b604051601f8201601f19168101850183811182821017156156f257fe5b60405281815283820185018b1015615708578586fd5b81858501868301379081019093019390935250939692955090935050565b600060208284031215615737578081fd5b81518015158114613d39578182fd5b600060208284031215615757578081fd5b815180600f0b8114613d39578182fd5b600060208284031215615778578081fd5b613d39826155ee565b600060208284031215615792578081fd5b5035919050565b6000602082840312156157aa578081fd5b5051919050565b600080604083850312156157c3578182fd5b8235915060208301356157d581615e31565b809150509250929050565b600080604083850312156157f2578182fd5b50508035926020909101359150565b60008060408385031215615813578182fd5b505080516020909101519092909150565b600080600060608486031215615838578283fd5b505081359360208301359350604090920135919050565b600060208284031215615860578081fd5b8135613d3981615e46565b60006020828403121561587c578081fd5b8151613d3981615e46565b6000806000806000806000806000806000806101808d8f0312156158a957898afd5b8c516001600160601b03811681146158bf578a8bfd5b9b506158cd60208e016155e3565b9a506158db60408e016155e3565b99506158e960608e016155e3565b98506158f760808e01615617565b975061590560a08e016155ee565b965061591360c08e016155ee565b955061592160e08e01615600565b94506101008d015193506101208d015192506159406101408e01615600565b915061594f6101608e01615600565b90509295989b509295989b509295989b565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b6001600160a01b039390931683526020830191909152604082015260600190565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b6001600160a01b03979097168752602087019590955260408601939093526060850191909152608084015260a083015260c082015260e00190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b0392909216825263ffffffff16602082015260400190565b6001600160a01b0394909416845263ffffffff9290921660208401526001600160601b031660408301526001600160801b0316606082015260800190565b901515815260200190565b6001600160e01b031991909116815260200190565b600f9190910b815260200190565b60208082526003908201526210cc4d60ea1b604082015260600190565b60208082526003908201526204332360ec1b604082015260600190565b60208082526003908201526221991b60e91b604082015260600190565b602080825260029082015261219960f11b604082015260600190565b60208082526003908201526221989b60e91b604082015260600190565b60208082526003908201526243313360e81b604082015260600190565b60208082526003908201526243323360e81b604082015260600190565b60208082526003908201526243323560e81b604082015260600190565b60208082526003908201526208662760eb1b604082015260600190565b60208082526003908201526243323160e81b604082015260600190565b602080825260029082015261433160f01b604082015260600190565b602080825260029082015261043360f41b604082015260600190565b60208082526003908201526243313560e81b604082015260600190565b60208082526003908201526221989960e91b604082015260600190565b60208082526003908201526210cc8d60ea1b604082015260600190565b60208082526003908201526221991960e91b604082015260600190565b60208082526003908201526243313960e81b604082015260600190565b60208082526003908201526243313760e81b604082015260600190565b602080825260029082015261433360f01b604082015260600190565b815181526020808301516001600160a01b0316908201526040808301516001600160801b0390811691830191909152606092830151169181019190915260800190565b600060a082019050825182526001600160801b03602084015116602083015260408301516040830152606083015160608301526080830151608083015292915050565b6001600160801b0391909116815260200190565b6001600160801b039485168152602081019390935292166040820152606081019190915260800190565b62ffffff91909116815260200190565b90815260200190565b918252602082015260400190565b63ffffffff91909116815260200190565b63ffffffff929092168252602082015260400190565b6001600160a01b0381168114610d1f57600080fd5b63ffffffff81168114610d1f57600080fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c004f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212201ca81e10125d74fc4d8a6f7c39e0648cc26a50a8c5deec6ca4fb49cb3041e74964736f6c63430007060033", + "deployedBytecode": "0x6080604052600436106103435760003560e01c80638456cb59116101b0578063b707ab99116100ec578063e74b981b11610095578063f2fde38b1161006f578063f2fde38b146108d0578063f90c3f27146108f0578063fbfc6bc014610905578063ff947525146109255761039b565b8063e74b981b14610888578063ed88c68e146108a8578063ee3189ff146108b05761039b565b8063d296d1f1116100c6578063d296d1f11461083e578063d52725841461085e578063de4a427a146108735761039b565b8063b707ab99146107e9578063c65a391d146107fe578063c9e77ee81461081e5761039b565b806391b8d34a116101595780639d4c9442116101335780639d4c944214610781578063a847e67414610796578063ac6cd5ef146107b6578063b6b55f25146107d65761039b565b806391b8d34a1461072c578063978bbdb91461074c57806397efa942146107615761039b565b80638cd21d7c1161018a5780638cd21d7c146106e25780638da5cb5b1461070257806391b4ded9146107175761039b565b80638456cb591461067d5780638632cb03146106925780638c64ea4a146106b25761039b565b806345596e2e1161027f57806372f5d98a116102285780637dc0d1d0116102025780637dc0d1d0146106295780637f07b1301461063e5780638146b09f1461065357806382564bca146106685761039b565b806372f5d98a146105c35780637691c4ac146105e55780637ca25184146106075761039b565b806363b38ae41161025957806363b38ae414610579578063713d517f1461058e578063715018a6146105ae5761039b565b806345596e2e1461052257806346904840146105425780634be2822c146105575761039b565b806324f5f531116102ec5780633fc8cef3116102c65780633fc8cef3146104ab5780634394318d146104cd578063441a3e70146104ed5780634468c0221461050d5761039b565b806324f5f53114610463578063377a19361461047857806339467918146104985761039b565b806315aded831161031d57806315aded83146104005780631bf7bf6c1461042d578063200f4b8d1461044e5761039b565b806307633669146103a057806310b9e583146103b5578063150b7a02146103ca5761039b565b3661039b57336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146103995760405162461bcd60e51b815260040161039090615cc9565b60405180910390fd5b005b600080fd5b3480156103ac57600080fd5b5061039961093a565b3480156103c157600080fd5b50610399610a3d565b3480156103d657600080fd5b506103ea6103e5366004615662565b610bb0565b6040516103f79190615ad9565b60405180910390f35b34801561040c57600080fd5b5061042061041b36600461584f565b610bc1565b6040516103f79190615df3565b61044061043b366004615824565b610c58565b6040516103f7929190615dfc565b34801561045a57600080fd5b50610399610cef565b34801561046f57600080fd5b50610420610d22565b34801561048457600080fd5b5061042061049336600461584f565b610d32565b6104206104a6366004615824565b610e22565b3480156104b757600080fd5b506104c0610eba565b6040516103f79190615961565b3480156104d957600080fd5b506104206104e8366004615824565b610ede565b3480156104f957600080fd5b506103996105083660046157e0565b610f78565b34801561051957600080fd5b506104c061109c565b34801561052e57600080fd5b5061039961053d366004615781565b6110c0565b34801561054e57600080fd5b506104c06111bd565b34801561056357600080fd5b5061056c6111cc565b6040516103f79190615da5565b34801561058557600080fd5b506104206111e2565b34801561059a57600080fd5b506103996105a9366004615781565b6111e8565b3480156105ba57600080fd5b50610399611301565b3480156105cf57600080fd5b506105d86113bf565b6040516103f79190615de3565b3480156105f157600080fd5b506105fa6113e3565b6040516103f79190615ace565b34801561061357600080fd5b5061061c6113f1565b6040516103f79190615e0a565b34801561063557600080fd5b506104c06113f7565b34801561064a57600080fd5b506104c061141b565b34801561065f57600080fd5b5061039961143f565b34801561067457600080fd5b506104c06114af565b34801561068957600080fd5b506103996114d3565b34801561069e57600080fd5b506103996106ad366004615824565b61165c565b3480156106be57600080fd5b506106d26106cd366004615781565b6116e7565b6040516103f79493929190615a90565b3480156106ee57600080fd5b506104206106fd36600461584f565b611734565b34801561070e57600080fd5b506104c06117c3565b34801561072357600080fd5b506104206117d2565b34801561073857600080fd5b506103996107473660046157e0565b6117d8565b34801561075857600080fd5b506104206118d1565b34801561076d57600080fd5b5061039961077c366004615781565b6118d7565b34801561078d57600080fd5b506104c0611a77565b3480156107a257600080fd5b506105fa6107b1366004615781565b611a9b565b3480156107c257600080fd5b506103996107d1366004615781565b611b15565b6103996107e4366004615781565b611c6f565b3480156107f557600080fd5b506104c0611d79565b34801561080a57600080fd5b506103996108193660046157b1565b611d9d565b34801561082a57600080fd5b50610399610839366004615781565b611efb565b34801561084a57600080fd5b506104206108593660046157e0565b61208d565b34801561086a57600080fd5b5061056c6122f8565b34801561087f57600080fd5b50610420612307565b34801561089457600080fd5b506103996108a336600461562a565b61230d565b610399612410565b3480156108bc57600080fd5b506104206108cb36600461584f565b612434565b3480156108dc57600080fd5b506103996108eb36600461562a565b61250d565b3480156108fc57600080fd5b50610420612621565b34801561091157600080fd5b50610399610920366004615781565b612628565b34801561093157600080fd5b506105fa612746565b6109426127ad565b6001600160a01b03166109536117c3565b6001600160a01b0316146109ae576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600854610100900460ff166109d55760405162461bcd60e51b815260040161039090615c1d565b60085460ff16156109f85760405162461bcd60e51b815260040161039090615b53565b6008805461ff00191690556040517fff2b959f2bcdb44c7ecb4b16dae055431019d7350607125cfc2b74a06632c90e90610a33903390615961565b60405180910390a1565b610a456127ad565b6001600160a01b0316610a566117c3565b6001600160a01b031614610ab1576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60085460ff1615610ad45760405162461bcd60e51b815260040161039090615b53565b6008805460ff1961ff001990911661010017166001179055610b7d7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006101a460006127b1565b60048190556040517f574214b195bf5273a95bb4498e35cf1fde0ce327c727a95ec2ab359f7ba4e11a91610a3391615df3565b630a85bd0160e11b5b949350505050565b6000610c50827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006127de565b90505b919050565b6008546000908190610100900460ff1615610c855760405162461bcd60e51b815260040161039090615c39565b60026001541415610ccb576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b6002600155610cdf33868634876000612819565b6001805590969095509350505050565b600854610100900460ff1615610d175760405162461bcd60e51b815260040161039090615c39565b610d1f61296a565b50565b6000610d2c612a58565b90505b90565b6000610c50827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000600760009054906101000a90046001600160801b03166001600160801b0316612ee9565b600854600090610100900460ff1615610e4d5760405162461bcd60e51b815260040161039090615c39565b60026001541415610e93576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b60026001819055506000610eac33868634876001612819565b506001805595945050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600854600090610100900460ff1615610f095760405162461bcd60e51b815260040161039090615c39565b60026001541415610f4f576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b6002600155610f5e8433612f2d565b610f6c338585856000613021565b60018055949350505050565b600854610100900460ff1615610fa05760405162461bcd60e51b815260040161039090615c39565b60026001541415610fe6576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b6002600155610ff58233612f2d565b6000610fff61296a565b600084815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b0316606082015290915061107481858561310f565b61107e8183613159565b61108884826131ab565b611092338461327e565b5050600180555050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6110c86127ad565b6001600160a01b03166110d96117c3565b6001600160a01b031614611134576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6002546001600160a01b031661115c5760405162461bcd60e51b815260040161039090615afc565b606481111561117d5760405162461bcd60e51b815260040161039090615c55565b7f14914da2bf76024616fbe1859783fcd4dbddcb179b1f3a854949fbf920dcb957600354826040516111b0929190615dfc565b60405180910390a1600355565b6002546001600160a01b031681565b600754600160801b90046001600160801b031681565b60055481565b600854610100900460ff16156112105760405162461bcd60e51b815260040161039090615c39565b60026001541415611256576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b60026001556112658133612f2d565b600061126f61296a565b600083815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b031660608201529091506112e4813385613368565b6112ee8183613159565b6112f883826131ab565b50506001805550565b6113096127ad565b6001600160a01b031661131a6117c3565b6001600160a01b031614611375576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b7f000000000000000000000000000000000000000000000000000000000000000081565b600854610100900460ff1681565b6101a481565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600854610100900460ff166114665760405162461bcd60e51b815260040161039090615c1d565b60085460ff16156114895760405162461bcd60e51b815260040161039090615b53565b600654620151800142116109f85760405162461bcd60e51b815260040161039090615be3565b7f000000000000000000000000000000000000000000000000000000000000000081565b6114db6127ad565b6001600160a01b03166114ec6117c3565b6001600160a01b031614611547576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60085460ff161561156a5760405162461bcd60e51b815260040161039090615b53565b600854610100900460ff16156115925760405162461bcd60e51b815260040161039090615c39565b6000600554116115b45760405162461bcd60e51b815260040161039090615b6f565b60006115e0427f000000000000000000000000000000000000000000000000000000000000000061343f565b905062eff10081106116045760405162461bcd60e51b815260040161039090615ce6565b6008805461ff001916610100179055600580546000190190819055426006556040517f32fb7c9891bc4f963c7de9f1186d2a7755c7d6e9f4604dabe1d8bb3027c2f49e9161165191615df3565b60405180910390a150565b600854610100900460ff16156116845760405162461bcd60e51b815260040161039090615c39565b600260015414156116ca576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b60026001556116d98333612f2d565b611092338484846001613021565b600960205260009081526040902080546001909101546001600160a01b03821691600160a01b900463ffffffff16906001600160601b03811690600160601b90046001600160801b031684565b6000610c50827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006134a1565b6000546001600160a01b031690565b60065481565b600854610100900460ff16156118005760405162461bcd60e51b815260040161039090615c39565b60026001541415611846576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b60026001556118558233612f2d565b61185d61296a565b50600082815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b031660608201526112ee813385856134b3565b60035481565b60085460ff166118f95760405162461bcd60e51b815260040161039090615d03565b6002600154141561193f576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b600260015561194e8133612f2d565b6000818152600960209081526040808320815160808101835281546001600160a01b0381168252600160a01b900463ffffffff1693810193909352600101546001600160601b03811691830191909152600160601b90046001600160801b03908116606083015260075491929116906119cc908390339086906137af565b5060006119e983606001516001600160801b0316600454846139fa565b90506000611a0d8285604001516001600160601b031661343f90919063ffffffff16565b60006060860181905260408601529050611a2785856131ab565b611a31338261327e565b7f7dff8cdaec6a8d4d1ad32d3c947ed0f0281c3d6456621ef928defae96ec6cddb338683604051611a64939291906159d5565b60405180910390a1505060018055505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000818152600960209081526040808320815160808101835281546001600160a01b0381168252600160a01b900463ffffffff1693810193909352600101546001600160601b03811691830191909152600160601b90046001600160801b0316606082015281611b09612a58565b9050610bb98282613a23565b60085460ff16611b375760405162461bcd60e51b815260040161039090615d03565b60026001541415611b7d576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b6002600155604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac90611bd09033908590600401615999565b600060405180830381600087803b158015611bea57600080fd5b505af1158015611bfe573d6000803e3d6000fd5b505060045460075460009350611c2092508491906001600160801b03166139fa565b9050611c2c338261327e565b7f2131ef4f2f82ca75fe7d2e646ebfa45b6be25e53510c829629c76b641500ec67338383604051611c5f939291906159d5565b60405180910390a1505060018055565b600854610100900460ff1615611c975760405162461bcd60e51b815260040161039090615c39565b60026001541415611cdd576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b6002600155611cec8133612f2d565b611cf461296a565b50600081815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b03166060820152611d67818334613a39565b611d7182826131ab565b505060018055565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316331480611e7857506040516331a9108f60e11b815233907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90611e1d908690600401615df3565b60206040518083038186803b158015611e3557600080fd5b505afa158015611e49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6d9190615646565b6001600160a01b0316145b611e945760405162461bcd60e51b815260040161039090615b19565b6000828152600960205260409081902080546001600160a01b0319166001600160a01b038416179055517f3137fc9cd2e33c34f86e29c24d81f3c75b0bce639d3c4ed0d31eeff1160a7ff590611eef903390859085906159b2565b60405180910390a15050565b600854610100900460ff1615611f235760405162461bcd60e51b815260040161039090615c39565b60026001541415611f69576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b6002600155611f788133612f2d565b600081815260096020908152604091829020825160808101845281546001600160a01b038082168352600160a01b90910463ffffffff16938201939093526001909101546001600160601b03811682850152600160601b90046001600160801b0316606082015291516331a9108f60e11b81526120829183917f000000000000000000000000000000000000000000000000000000000000000090911690636352211e9061202a908790600401615df3565b60206040518083038186803b15801561204257600080fd5b505afa158015612056573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061207a9190615646565b8460006137af565b50611d7182826131ab565b600854600090610100900460ff16156120b85760405162461bcd60e51b815260040161039090615c39565b600260015414156120fe576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b6002600155600061210d61296a565b600085815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b031660608201529091506121818183613a23565b1561219e5760405162461bcd60e51b815260040161039090615c72565b6000612248827f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636352211e896040518263ffffffff1660e01b81526004016121f09190615df3565b60206040518083038186803b15801561220857600080fd5b505afa15801561221c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122409190615646565b8860016137af565b90506122548284613a23565b156122795761226386836131ab565b61226d338261327e565b600093505050506122ee565b6122838282613a76565b60008061229284888733613aac565b915091507f158ba9ab7bbbd08eeffa4753bad41f4d450e24831d293427308badf3eadd8c76338984846040516122cb94939291906159f6565b60405180910390a16122dd88856131ab565b6122e7338261327e565b5093505050505b6001805592915050565b6007546001600160801b031681565b60045481565b6123156127ad565b6001600160a01b03166123266117c3565b6001600160a01b031614612381576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166123a75760405162461bcd60e51b815260040161039090615b8c565b6002546040517faaebcf1bfa00580e41d966056b48521fa9f202645c86d4ddf28113e617c1b1d3916123e6916001600160a01b03909116908490615a57565b60405180910390a1600280546001600160a01b0319166001600160a01b0392909216919091179055565b60085460ff166124325760405162461bcd60e51b815260040161039090615d03565b565b6000610c50827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000612508612a58565b612ee9565b6125156127ad565b6001600160a01b03166125266117c3565b6001600160a01b031614612581576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166125c65760405162461bcd60e51b8152600401808060200182810382526026815260200180615e796026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6217124081565b60085460ff1661264a5760405162461bcd60e51b815260040161039090615d03565b60026001541415612690576040805162461bcd60e51b815260206004820152601f6024820152600080516020615e59833981519152604482015290519081900360640190fd5b60026001908155600082815260096020908152604091829020825160808101845281546001600160a01b038082168352600160a01b90910463ffffffff16938201939093529301546001600160601b03811684840152600160601b90046001600160801b0316606084015290516331a9108f60e11b81526120829183917f000000000000000000000000000000000000000000000000000000000000000090911690636352211e9061202a908790600401615df3565b60085460ff1681565b806001600160801b0381168114610c53576040805162461bcd60e51b815260206004820152600560248201527f4f46313238000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b3390565b6000806127c2888888888888613bd3565b90506127d081612710613c79565b9150505b9695505050505050565b6000806127f0868686868b6000613bd3565b905061280e670de0b6b3a76400006128088380613ce0565b90613c79565b979650505050505050565b600080600061282661296a565b90508560008561284b57612846836128088b670de0b6b3a7640000613ce0565b61284d565b885b905060006128596155bc565b8b612871576128678d613d40565b909c5090506128e4565b61287b8c33612f2d565b5060008b815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b031660608201525b8215612905576128f581848c613e53565b94509150612905818e8e86613f4a565b891561291657612916818d86613a39565b881561292857612928818e8e8c6134b3565b6129328186613159565b61293c8c826131ab565b811561295857600254612958906001600160a01b03168361327e565b50999b909a5098505050505050505050565b6007546000906001600160801b03600160801b9091041642141561299a57506007546001600160801b0316610d2f565b60006129a4612a58565b6007546040519192507f339e53729b0447795ff69e70a74fed98fc7fef6fe94b7521099b32f0f8de4822916129f3916001600160801b03808216928692600160801b9004909116904290615db9565b60405180910390a1612a048161274f565b600780546fffffffffffffffffffffffffffffffff19166001600160801b0392909216919091179055612a364261274f565b600780546001600160801b03928316600160801b029216919091179055905090565b6007546000908190612a8490612a7f904290600160801b90046001600160801b031661343f565b614007565b905063ffffffff8116612aa45750506007546001600160801b0316610d2f565b6000612aaf8261404b565b6007549091506001600160801b03166000612b90837f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000089612ee9565b90506000612c21847f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006134a1565b9050600073__$f98cbc68e241c61b30349ba6b91a975736$__63fc505d3787621712406040518363ffffffff1660e01b8152600401612c61929190615e1b565b60206040518083038186803b158015612c7957600080fd5b505af4158015612c8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb19190615746565b90506000612cd3670de0b6b3a764000061280885670b1a2bc2ec500000613ce0565b905080841015612ce557809350612d15565b6000612d05670de0b6b3a76400006128088667136dcc951d8c0000613ce0565b905080851115612d13578094505b505b60405163fc505d3760e01b815260009073__$f98cbc68e241c61b30349ba6b91a975736$__9063fc505d3790612d519087908990600401615dfc565b60206040518083038186803b158015612d6957600080fd5b505af4158015612d7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612da19190615746565b90506000612e398473__$f98cbc68e241c61b30349ba6b91a975736$__632cbbdee5856040518263ffffffff1660e01b8152600401612de09190615aee565b60206040518083038186803b158015612df857600080fd5b505af4158015612e0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e309190615746565b600f0b9061420f565b604051637e0c9e7960e11b815290915060009073__$f98cbc68e241c61b30349ba6b91a975736$__9063fc193cf290612e7a90600f86900b90600401615aee565b60206040518083038186803b158015612e9257600080fd5b505af4158015612ea6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eca9190615746565b9050612eda600f82900b896142a0565b9a505050505050505050505090565b600080612efb898888888e60006127b1565b90506000612f0e8a8a878a8f6000613bd3565b9050612f1e846128088385613ce0565b9b9a5050505050505050505050565b806001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636352211e846040518263ffffffff1660e01b8152600401612f839190615df3565b60206040518083038186803b158015612f9b57600080fd5b505afa158015612faf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fd39190615646565b6001600160a01b0316148061300157506000828152600960205260409020546001600160a01b038281169116145b61301d5760405162461bcd60e51b815260040161039090615b19565b5050565b60008061302c61296a565b90506000836130505761304b8261280888670de0b6b3a7640000613ce0565b613052565b855b600088815260096020908152604091829020825160808101845281546001600160a01b0381168252600160a01b900463ffffffff1692810192909252600101546001600160601b03811692820192909252600160601b9091046001600160801b0316606082015290915081156130ce576130ce818a8a856143f1565b85156130df576130df81898861310f565b6130e98184613159565b6130f388826131ab565b851561310357613103338761327e565b50979650505050505050565b61311983826144ae565b7f627a692d5a03ab34732c0d2aa319f3ecdebdc4528f383eabcb25441dc0a70cfb33838360405161314c939291906159d5565b60405180910390a1505050565b60008061316684846144ca565b91509150816131875760405162461bcd60e51b815260040161039090615c8f565b80156131a55760405162461bcd60e51b815260040161039090615cac565b50505050565b600091825260096020908152604092839020825181549284015163ffffffff16600160a01b027fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff6001600160a01b039092166001600160a01b0319909416939093171691909117815591810151600190920180546060909201516001600160801b0316600160601b027fffffffff00000000000000000000000000000000ffffffffffffffffffffffff6001600160601b039094166bffffffffffffffffffffffff199093169290921792909216179055565b804710156132d3576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d806000811461331e576040519150601f19603f3d011682016040523d82523d6000602084013e613323565b606091505b50509050806133635760405162461bcd60e51b815260040180806020018281038252603a815260200180615e9f603a913960400191505060405180910390fd5b505050565b602083015163ffffffff1661337c84614684565b604051632142170760e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906342842e0e906133cc90309087908690600401615975565b600060405180830381600087803b1580156133e657600080fd5b505af11580156133fa573d6000803e3d6000fd5b505050507fe59f38fa1264fc25c9f0185eee136eaf810d90b8e7293b342e4037c68720177a338383604051613431939291906159d5565b60405180910390a150505050565b600082821115613496576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b6000806127f0868686868b60006127b1565b6000806000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166399fbab88866040518263ffffffff1660e01b81526004016135059190615df3565b6101806040518083038186803b15801561351e57600080fd5b505afa158015613532573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135569190615887565b505050509750505095509550955050506000816001600160801b03161161358f5760405162461bcd60e51b815260040161039090615bc6565b7f000000000000000000000000000000000000000000000000000000000000000062ffffff168262ffffff16146135d85760405162461bcd60e51b815260040161039090615b36565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b031614801561364a57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b0316145b806136c257507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03161480156136c257507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b0316145b6136de5760405162461bcd60e51b815260040161039090615ba9565b6136e888866146cf565b604051632142170760e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906342842e0e90613738908a9030908a90600401615975565b600060405180830381600087803b15801561375257600080fd5b505af1158015613766573d6000803e3d6000fd5b505050507f3917c2f26ce18614e3aedd1289da672ef6563c5c295f49e9b1697ae0ad31556233878760405161379d939291906159d5565b60405180910390a15050505050505050565b602084015160009063ffffffff16806137cc576000915050610bb9565b6000806137d883614764565b9092509050811561386257604051632e1a7d4d60e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690632e1a7d4d9061382f908590600401615df3565b600060405180830381600087803b15801561384957600080fd5b505af115801561385d573d6000803e3d6000fd5b505050505b60008060006138738b86868b614931565b9194509250905081156139225760405163a9059cbb60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906138ce908d908690600401615999565b602060405180830381600087803b1580156138e857600080fd5b505af11580156138fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139209190615726565b505b82156139a957604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac906139769030908790600401615999565b600060405180830381600087803b15801561399057600080fd5b505af11580156139a4573d6000803e3d6000fd5b505050505b7ffd0ae2fd36bd955810ae42615bc5ff277c0d0dfcb930f06c9f1777c0ef0752e3338a87878787876040516139e49796959493929190615a1c565b60405180910390a19a9950505050505050505050565b6000610bb96ec097ce7bc90715b34b9f100000000061280885613a1d8887613ce0565b90613ce0565b600080613a3084846144ca565b50949350505050565b613a438382613a76565b7f3ca13b7aab12bad7472691fe558faa6b25e99099824a0070a88bd5aa84be610f33838360405161314c939291906159d5565b6040820151613a9790613a92906001600160601b0316836149c7565b614a21565b6001600160601b031660409092019190915250565b600080600080613ad78789606001516001600160801b03168a604001516001600160601b0316614a68565b9150915081871015613afb5760405162461bcd60e51b815260040161039090615c00565b604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac90613b499088908690600401615999565b600060405180830381600087803b158015613b6357600080fd5b505af1158015613b77573d6000803e3d6000fd5b50505050613b8e8289614ad090919063ffffffff16565b613b9888826144ae565b6000613ba489886144ca565b9150508015613bc55760405162461bcd60e51b815260040161039090615cac565b509097909650945050505050565b6040805163cce79bd560e01b81526001600160a01b0387811660048301528681166024830152858116604483015263ffffffff851660648301528315156084830152915160009289169163cce79bd59160a4808301926020929190829003018186803b158015613c4257600080fd5b505afa158015613c56573d6000803e3d6000fd5b505050506040513d6020811015613c6c57600080fd5b5051979650505050505050565b6000808211613ccf576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381613cd857fe5b049392505050565b600082613cef5750600061349b565b82820282848281613cfc57fe5b0414613d395760405162461bcd60e51b8152600401808060200182810382526021815260200180615ed96021913960400191505060405180910390fd5b9392505050565b6000613d4a6155bc565b6040516354ba0f2760e01b81526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906354ba0f2790613d99908790600401615961565b602060405180830381600087803b158015613db357600080fd5b505af1158015613dc7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613deb9190615799565b6040805160808101825260008082526020820181905281830181905260608201529051919250907f25ff1e0131762176a9084e92880f880f39d6d0e62134607f37e631efe1bad87190613e419033908590615999565b60405180910390a19092509050915091565b600354600090819080613e6d576000849250925050613f42565b600080613efd877f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000614b06565b90506000613f116127106128088487613ce0565b905080871115613f2c57613f25878261343f565b9250613f3a565b613f3689826144ae565b8692505b945090925050505b935093915050565b613f548482614b32565b6040516340c10f1960e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340c10f1990613fa29086908590600401615999565b600060405180830381600087803b158015613fbc57600080fd5b505af1158015613fd0573d6000803e3d6000fd5b505050507fb19fa182730a088464dad0e9e0badeb470d0d8d937d854f5caf15c6ad1992c36338284604051613431939291906159d5565b8063ffffffff81168114610c53576040805162461bcd60e51b8152602060048083019190915260248201526327a3199960e11b604482015290519081900360640190fd5b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663de5a6e227f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b81526004016140ba9190615961565b60206040518083038186803b1580156140d257600080fd5b505afa1580156140e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061410a919061586b565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663de5a6e227f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b815260040161417a9190615961565b60206040518083038186803b15801561419257600080fd5b505afa1580156141a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141ca919061586b565b905060008163ffffffff168363ffffffff16116141e757826141e9565b815b90508063ffffffff168563ffffffff16116142045784614206565b805b95945050505050565b6000600f83810b9083900b0260401d6f7fffffffffffffffffffffffffffffff19811280159061424f57506f7fffffffffffffffffffffffffffffff8113155b613d39576040805162461bcd60e51b815260206004820152600860248201527f4d554c2d4f565546000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000816142af5750600061349b565b600083600f0b1215614308576040805162461bcd60e51b815260206004820152600760248201527f4d554c552d583000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b600f83900b6001600160801b038316810260401c90608084901c0277ffffffffffffffffffffffffffffffffffffffffffffffff811115614390576040805162461bcd60e51b815260206004820152600860248201527f4d554c552d4f4631000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60401b81198111156143e9576040805162461bcd60e51b815260206004820152600860248201527f4d554c552d4f4632000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b019392505050565b6143fb8482614ad0565b604051632770a7eb60e21b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690639dc29fac906144499086908590600401615999565b600060405180830381600087803b15801561446357600080fd5b505af1158015614477573d6000803e3d6000fd5b505050507fea19ffc45b48de6d95594aacff7214dd24595fdb0c60e98c8f0b269058c2f792338284604051613431939291906159d5565b6040820151613a9790613a92906001600160601b03168361343f565b60008060006145607f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006101a460016127b1565b9050614678857f00000000000000000000000000000000000000000000000000000000000000008684675fc1b971363200007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316634a0a96eb7f00000000000000000000000000000000000000000000000000000000000000006101a46040518363ffffffff1660e01b8152600401614602929190615a71565b60206040518083038186803b15801561461a57600080fd5b505afa15801561462e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146529190615767565b7f0000000000000000000000000000000000000000000000000000000000000000614b4e565b92509250509250929050565b602081015163ffffffff166146c5576040805162461bcd60e51b81526020600482015260026024820152612b1960f11b604482015290519081900360640190fd5b6000602090910152565b602082015163ffffffff1615614711576040805162461bcd60e51b8152602060048201526002602482015261563160f01b604482015290519081900360640190fd5b80614749576040805162461bcd60e51b815260206004820152600360248201526243323360e81b604482015290519081900360640190fd5b61475281614007565b63ffffffff1660209092019190915250565b6000807f0000000000000000000000000000000000000000000000000000000000000000816147938286614bf2565b50506040805160a0810182528981526001600160801b0383166020820152600081830181905260608201524260808201529051630624e65f60e11b815291945092506001600160a01b0385169150630c49ccbe906147f5908490600401615d62565b6040805180830381600087803b15801561480e57600080fd5b505af1158015614822573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148469190615801565b5050604080516080810182528781523060208201526001600160801b038183018190526060820152905163fc6f786560e01b815260009081906001600160a01b0387169063fc6f78659061489e908690600401615d1f565b6040805180830381600087803b1580156148b757600080fd5b505af11580156148cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148ef9190615801565b915091507f000000000000000000000000000000000000000000000000000000000000000061491f578082614922565b81815b97509750505050505050915091565b600080600080841561494a576149478787614cb0565b90505b606088015186906000906001600160801b03168211156149905760608a015161497d9089906001600160801b031661343f565b905089606001516001600160801b031691505b61499a8a83614ad0565b6149a38a614684565b6149ad8a8a613a76565b6149b78a846144ae565b9099909850909650945050505050565b600082820183811015613d39576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b806001600160601b0381168114610c53576040805162461bcd60e51b8152602060048083019190915260248201526327a31c9b60e11b604482015290519081900360640190fd5b6000808080614a8187614a7c886002613c79565b614d60565b9150915080851115614ab657675fc1b97136320000614aa0868361343f565b1015614ab657614ab08787614d60565b90925090505b84811115614ac45750849050835b90969095509350505050565b6060820151614af190614aec906001600160801b03168361343f565b61274f565b6001600160801b031660609092019190915250565b600080614b1a868686866101a46000613bd3565b905061280e670de0b6b3a76400006128088984613ce0565b6060820151614af190614aec906001600160801b0316836149c7565b60008088606001516001600160801b031660001415614b735750600190506000614be6565b6000614bac6ec097ce7bc90715b34b9f100000000061280889613a1d8c8f606001516001600160801b0316613ce090919063ffffffff16565b90506000614bbe8b8b8b8b8a8a614e3c565b90508681106000614bd0846003613ce0565b614bdb846002613ce0565b101595509093505050505b97509795505050505050565b6000806000806000808790506000806000806000856001600160a01b03166399fbab888d6040518263ffffffff1660e01b8152600401808281526020019150506101806040518083038186803b158015614c4b57600080fd5b505afa158015614c5f573d6000803e3d6000fd5b505050506040513d610180811015614c7657600080fd5b5060a081015160c082015160e083015161014084015161016090940151929e50909c509a5090985096505050505050509295509295909350565b6000613d39670de0b6b3a764000061280866470de4df820000613a1d87614d5a887f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000614b06565b906149c7565b6000806000838511614d725784614d74565b835b90506000614e05827f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000614b06565b9050614e2f614e28670de0b6b3a76400006128088467016345785d8a0000613ce0565b82906149c7565b9196919550909350505050565b6000866020015163ffffffff1660001415614e65575060408601516001600160601b03166127d4565b600080614e7e888a6020015163ffffffff168787614ed3565b90925090506000614ea66ec097ce7bc90715b34b9f100000000061280889613a1d868d613ce0565b60408b0151909150614ec5906001600160601b0316614d5a85846149c7565b9a9950505050505050505050565b6000806000806000806000614ee88b8b614bf2565b94509450945094509450600080614f0187878d88614f54565b9150915089614f2757826001600160801b03168101846001600160801b03168301614f40565b836001600160801b03168201836001600160801b031682015b985098505050505050505094509492505050565b600080600073__$d199f155f9376dc21890c162698c9ef049$__63986cfba3866040518263ffffffff1660e01b8152600401808260020b815260200191505060206040518083038186803b158015614fab57600080fd5b505af4158015614fbf573d6000803e3d6000fd5b505050506040513d6020811015614fd557600080fd5b50519050600287810b9086900b12156151985773__$a98c5df505b68ab2f483703658c95acb30$__632c32d4b673__$d199f155f9376dc21890c162698c9ef049$__63986cfba38a6040518263ffffffff1660e01b8152600401808260020b815260200191505060206040518083038186803b15801561505457600080fd5b505af4158015615068573d6000803e3d6000fd5b505050506040513d602081101561507e57600080fd5b50516040805163986cfba360e01b815260028b900b6004820152905173__$d199f155f9376dc21890c162698c9ef049$__9163986cfba3916024808301926020929190829003018186803b1580156150d557600080fd5b505af41580156150e9573d6000803e3d6000fd5b505050506040513d60208110156150ff57600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526001600160801b038816604483015260016064830152516084808301926020929190829003018186803b15801561516557600080fd5b505af4158015615179573d6000803e3d6000fd5b505050506040513d602081101561518f57600080fd5b505192506155b2565b8560020b8560020b12156154065773__$a98c5df505b68ab2f483703658c95acb30$__632c32d4b68273__$d199f155f9376dc21890c162698c9ef049$__63986cfba38a6040518263ffffffff1660e01b8152600401808260020b815260200191505060206040518083038186803b15801561521357600080fd5b505af4158015615227573d6000803e3d6000fd5b505050506040513d602081101561523d57600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526001600160801b038816604483015260016064830152516084808301926020929190829003018186803b1580156152a357600080fd5b505af41580156152b7573d6000803e3d6000fd5b505050506040513d60208110156152cd57600080fd5b50516040805163986cfba360e01b815260028a900b6004820152905191945073__$a98c5df505b68ab2f483703658c95acb30$__916348a0c5bd9173__$d199f155f9376dc21890c162698c9ef049$__9163986cfba391602480820192602092909190829003018186803b15801561534457600080fd5b505af4158015615358573d6000803e3d6000fd5b505050506040513d602081101561536e57600080fd5b5051604080516001600160e01b031960e085901b1681526001600160a01b03928316600482015291851660248301526001600160801b038816604483015260016064830152516084808301926020929190829003018186803b1580156153d357600080fd5b505af41580156153e7573d6000803e3d6000fd5b505050506040513d60208110156153fd57600080fd5b505191506155b2565b73__$a98c5df505b68ab2f483703658c95acb30$__6348a0c5bd73__$d199f155f9376dc21890c162698c9ef049$__63986cfba38a6040518263ffffffff1660e01b8152600401808260020b815260200191505060206040518083038186803b15801561547257600080fd5b505af4158015615486573d6000803e3d6000fd5b505050506040513d602081101561549c57600080fd5b50516040805163986cfba360e01b815260028b900b6004820152905173__$d199f155f9376dc21890c162698c9ef049$__9163986cfba3916024808301926020929190829003018186803b1580156154f357600080fd5b505af4158015615507573d6000803e3d6000fd5b505050506040513d602081101561551d57600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526001600160801b038816604483015260016064830152516084808301926020929190829003018186803b15801561558357600080fd5b505af4158015615597573d6000803e3d6000fd5b505050506040513d60208110156155ad57600080fd5b505191505b5094509492505050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b8051610c5381615e31565b8051600281900b8114610c5357600080fd5b80516001600160801b0381168114610c5357600080fd5b805162ffffff81168114610c5357600080fd5b60006020828403121561563b578081fd5b8135613d3981615e31565b600060208284031215615657578081fd5b8151613d3981615e31565b60008060008060808587031215615677578283fd5b843561568281615e31565b935060208581013561569381615e31565b935060408601359250606086013567ffffffffffffffff808211156156b6578384fd5b818801915088601f8301126156c9578384fd5b8135818111156156d557fe5b604051601f8201601f19168101850183811182821017156156f257fe5b60405281815283820185018b1015615708578586fd5b81858501868301379081019093019390935250939692955090935050565b600060208284031215615737578081fd5b81518015158114613d39578182fd5b600060208284031215615757578081fd5b815180600f0b8114613d39578182fd5b600060208284031215615778578081fd5b613d39826155ee565b600060208284031215615792578081fd5b5035919050565b6000602082840312156157aa578081fd5b5051919050565b600080604083850312156157c3578182fd5b8235915060208301356157d581615e31565b809150509250929050565b600080604083850312156157f2578182fd5b50508035926020909101359150565b60008060408385031215615813578182fd5b505080516020909101519092909150565b600080600060608486031215615838578283fd5b505081359360208301359350604090920135919050565b600060208284031215615860578081fd5b8135613d3981615e46565b60006020828403121561587c578081fd5b8151613d3981615e46565b6000806000806000806000806000806000806101808d8f0312156158a957898afd5b8c516001600160601b03811681146158bf578a8bfd5b9b506158cd60208e016155e3565b9a506158db60408e016155e3565b99506158e960608e016155e3565b98506158f760808e01615617565b975061590560a08e016155ee565b965061591360c08e016155ee565b955061592160e08e01615600565b94506101008d015193506101208d015192506159406101408e01615600565b915061594f6101608e01615600565b90509295989b509295989b509295989b565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b6001600160a01b039390931683526020830191909152604082015260600190565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b6001600160a01b03979097168752602087019590955260408601939093526060850191909152608084015260a083015260c082015260e00190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b0392909216825263ffffffff16602082015260400190565b6001600160a01b0394909416845263ffffffff9290921660208401526001600160601b031660408301526001600160801b0316606082015260800190565b901515815260200190565b6001600160e01b031991909116815260200190565b600f9190910b815260200190565b60208082526003908201526210cc4d60ea1b604082015260600190565b60208082526003908201526204332360ec1b604082015260600190565b60208082526003908201526221991b60e91b604082015260600190565b602080825260029082015261219960f11b604082015260600190565b60208082526003908201526221989b60e91b604082015260600190565b60208082526003908201526243313360e81b604082015260600190565b60208082526003908201526243323360e81b604082015260600190565b60208082526003908201526243323560e81b604082015260600190565b60208082526003908201526208662760eb1b604082015260600190565b60208082526003908201526243323160e81b604082015260600190565b602080825260029082015261433160f01b604082015260600190565b602080825260029082015261043360f41b604082015260600190565b60208082526003908201526243313560e81b604082015260600190565b60208082526003908201526221989960e91b604082015260600190565b60208082526003908201526210cc8d60ea1b604082015260600190565b60208082526003908201526221991960e91b604082015260600190565b60208082526003908201526243313960e81b604082015260600190565b60208082526003908201526243313760e81b604082015260600190565b602080825260029082015261433360f01b604082015260600190565b815181526020808301516001600160a01b0316908201526040808301516001600160801b0390811691830191909152606092830151169181019190915260800190565b600060a082019050825182526001600160801b03602084015116602083015260408301516040830152606083015160608301526080830151608083015292915050565b6001600160801b0391909116815260200190565b6001600160801b039485168152602081019390935292166040820152606081019190915260800190565b62ffffff91909116815260200190565b90815260200190565b918252602082015260400190565b63ffffffff91909116815260200190565b63ffffffff929092168252602082015260400190565b6001600160a01b0381168114610d1f57600080fd5b63ffffffff81168114610d1f57600080fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c004f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212201ca81e10125d74fc4d8a6f7c39e0648cc26a50a8c5deec6ca4fb49cb3041e74964736f6c63430007060033", "libraries": { - "ABDKMath64x64": "0xB0069E6586F70003342309B9289e07035cC41400" + "ABDKMath64x64": "0x21A8D15322C257Abd2b22a56eDde758398be0F32", + "SqrtPriceMathPartial": "0x9cf8dcbCf115B06d8f577E73Cb9EdFdb27828460", + "TickMathExternal": "0x4d9d7F7aE80d51628Aa56eF37720718C99E6FDfC" }, "devdoc": { "kind": "dev", @@ -1689,7 +1691,7 @@ "type": "t_uint256" }, { - "astId": 7756, + "astId": 7240, "contract": "contracts/core/Controller.sol:Controller", "label": "feeRecipient", "offset": 0, @@ -1697,7 +1699,7 @@ "type": "t_address" }, { - "astId": 7761, + "astId": 7245, "contract": "contracts/core/Controller.sol:Controller", "label": "feeRate", "offset": 0, @@ -1705,7 +1707,7 @@ "type": "t_uint256" }, { - "astId": 7764, + "astId": 7248, "contract": "contracts/core/Controller.sol:Controller", "label": "indexForSettlement", "offset": 0, @@ -1713,7 +1715,7 @@ "type": "t_uint256" }, { - "astId": 7767, + "astId": 7251, "contract": "contracts/core/Controller.sol:Controller", "label": "pausesLeft", "offset": 0, @@ -1721,7 +1723,7 @@ "type": "t_uint256" }, { - "astId": 7769, + "astId": 7253, "contract": "contracts/core/Controller.sol:Controller", "label": "lastPauseTime", "offset": 0, @@ -1729,7 +1731,7 @@ "type": "t_uint256" }, { - "astId": 7771, + "astId": 7255, "contract": "contracts/core/Controller.sol:Controller", "label": "normalizationFactor", "offset": 0, @@ -1737,7 +1739,7 @@ "type": "t_uint128" }, { - "astId": 7773, + "astId": 7257, "contract": "contracts/core/Controller.sol:Controller", "label": "lastFundingUpdateTimestamp", "offset": 16, @@ -1745,7 +1747,7 @@ "type": "t_uint128" }, { - "astId": 7777, + "astId": 7261, "contract": "contracts/core/Controller.sol:Controller", "label": "isShutDown", "offset": 0, @@ -1753,7 +1755,7 @@ "type": "t_bool" }, { - "astId": 7779, + "astId": 7263, "contract": "contracts/core/Controller.sol:Controller", "label": "isSystemPaused", "offset": 1, @@ -1761,12 +1763,12 @@ "type": "t_bool" }, { - "astId": 7784, + "astId": 7268, "contract": "contracts/core/Controller.sol:Controller", "label": "vaults", "offset": 0, "slot": "9", - "type": "t_mapping(t_uint256,t_struct(Vault)13635_storage)" + "type": "t_mapping(t_uint256,t_struct(Vault)13791_storage)" } ], "types": { @@ -1780,19 +1782,19 @@ "label": "bool", "numberOfBytes": "1" }, - "t_mapping(t_uint256,t_struct(Vault)13635_storage)": { + "t_mapping(t_uint256,t_struct(Vault)13791_storage)": { "encoding": "mapping", "key": "t_uint256", "label": "mapping(uint256 => struct VaultLib.Vault)", "numberOfBytes": "32", - "value": "t_struct(Vault)13635_storage" + "value": "t_struct(Vault)13791_storage" }, - "t_struct(Vault)13635_storage": { + "t_struct(Vault)13791_storage": { "encoding": "inplace", "label": "struct VaultLib.Vault", "members": [ { - "astId": 13628, + "astId": 13784, "contract": "contracts/core/Controller.sol:Controller", "label": "operator", "offset": 0, @@ -1800,7 +1802,7 @@ "type": "t_address" }, { - "astId": 13630, + "astId": 13786, "contract": "contracts/core/Controller.sol:Controller", "label": "NftCollateralId", "offset": 20, @@ -1808,7 +1810,7 @@ "type": "t_uint32" }, { - "astId": 13632, + "astId": 13788, "contract": "contracts/core/Controller.sol:Controller", "label": "collateralAmount", "offset": 0, @@ -1816,7 +1818,7 @@ "type": "t_uint96" }, { - "astId": 13634, + "astId": 13790, "contract": "contracts/core/Controller.sol:Controller", "label": "shortAmount", "offset": 12, diff --git a/packages/hardhat/deployments/mainnet/Oracle.json b/packages/hardhat/deployments/mainnet/Oracle.json index af96800fe..c0e4511b4 100644 --- a/packages/hardhat/deployments/mainnet/Oracle.json +++ b/packages/hardhat/deployments/mainnet/Oracle.json @@ -1,5 +1,5 @@ { - "address": "0xF3822177e77319528a82cad3AC5aa55c4B3792f3", + "address": "0x65D66c76447ccB45dAf1e8044e918fA786A483A1", "abi": [ { "inputs": [ @@ -123,27 +123,27 @@ "type": "function" } ], - "transactionHash": "0x276f7d65ab31b06ecb5739f44f689a22f42a99269982812e2798356b33eca134", + "transactionHash": "0x4d0c737c0edf0caa8485a9b143b5e71e1f71d5354817159681c12fdeca737dd7", "receipt": { "to": null, - "from": "0x80010e7575b24f47097598474502F0fd0aDbF3a8", - "contractAddress": "0xF3822177e77319528a82cad3AC5aa55c4B3792f3", - "transactionIndex": 83, - "gasUsed": "884189", + "from": "0xa3cB04d8BD927EEC8826BD77b7C71abE3d29c081", + "contractAddress": "0x65D66c76447ccB45dAf1e8044e918fA786A483A1", + "transactionIndex": 53, + "gasUsed": "874024", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5067bfa75bce3797a1f27f7558e89577379ab8e18c6237bf593753e172376c9e", - "transactionHash": "0x276f7d65ab31b06ecb5739f44f689a22f42a99269982812e2798356b33eca134", + "blockHash": "0x81d05eaef0fb7b3cb4c879eebc5e66f8ace5fbabb883e4f2601c99359b0dca6b", + "transactionHash": "0x4d0c737c0edf0caa8485a9b143b5e71e1f71d5354817159681c12fdeca737dd7", "logs": [], - "blockNumber": 13977442, - "cumulativeGasUsed": "5997814", + "blockNumber": 13982498, + "cumulativeGasUsed": "4186962", "status": 1, "byzantium": true }, "args": [], - "solcInputHash": "56b4ec4ab07157f3d2fb7e1de805d93e", - "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_pool\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_base\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_quote\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"_secondsAgoToStartOfTwap\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_secondsAgoToEndOfTwap\",\"type\":\"uint32\"}],\"name\":\"getHistoricalTwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_pool\",\"type\":\"address\"}],\"name\":\"getMaxPeriod\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_pool\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"_period\",\"type\":\"uint32\"}],\"name\":\"getTimeWeightedAverageTickSafe\",\"outputs\":[{\"internalType\":\"int24\",\"name\":\"timeWeightedAverageTick\",\"type\":\"int24\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_pool\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_base\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_quote\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"_period\",\"type\":\"uint32\"},{\"internalType\":\"bool\",\"name\":\"_checkPeriod\",\"type\":\"bool\"}],\"name\":\"getTwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"if ETH price is $3000, both ETH/USDC price and ETH/DAI price will be reported as 3000 * 1e18 by this oracle\",\"kind\":\"dev\",\"methods\":{\"getHistoricalTwap(address,address,address,uint32,uint32)\":{\"details\":\"if the _secondsAgoToStartOfTwap period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \\\"OLD\\\"\",\"params\":{\"_base\":\"base currency. to get eth/usd price, eth is base token\",\"_pool\":\"uniswap pool address\",\"_quote\":\"quote currency. to get eth/usd price, usd is the quote currency\",\"_secondsAgoToEndOfTwap\":\"amount of seconds in the past to end calculating time-weighted average\",\"_secondsAgoToStartOfTwap\":\"amount of seconds in the past to start calculating time-weighted average\"},\"returns\":{\"_0\":\"price of 1 base currency in quote currency. scaled by 1e18\"}},\"getMaxPeriod(address)\":{\"params\":{\"_pool\":\"uniswap pool address\"},\"returns\":{\"_0\":\"max period can be used to request twap\"}},\"getTimeWeightedAverageTickSafe(address,uint32)\":{\"details\":\"this function will not revert\",\"params\":{\"_period\":\"period in second that we want to calculate average on\",\"_pool\":\"address of the pool\"},\"returns\":{\"timeWeightedAverageTick\":\"the time weighted average tick\"}},\"getTwap(address,address,address,uint32,bool)\":{\"details\":\"if period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \\\"OLD\\\"\",\"params\":{\"_base\":\"base currency. to get eth/usd price, eth is base token\",\"_period\":\"number of seconds in the past to start calculating time-weighted average\",\"_pool\":\"uniswap pool address\",\"_quote\":\"quote currency. to get eth/usd price, usd is the quote currency\"},\"returns\":{\"_0\":\"price of 1 base currency in quote currency. scaled by 1e18\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getHistoricalTwap(address,address,address,uint32,uint32)\":{\"notice\":\"get twap for a specific period of time, converted with base & quote token decimals\"},\"getMaxPeriod(address)\":{\"notice\":\"get the max period that can be used to request twap\"},\"getTimeWeightedAverageTickSafe(address,uint32)\":{\"notice\":\"get time weighed average tick, not converted to price\"},\"getTwap(address,address,address,uint32,bool)\":{\"notice\":\"get twap converted with base & quote token decimals\"}},\"notice\":\"read UniswapV3 pool TWAP prices, and convert to human readable term with (18 decimals)\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/core/Oracle.sol\":\"Oracle\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":850},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0xe22a1fc7400ae196eba2ad1562d0386462b00a6363b742d55a2fd2021a58586f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0xbd74f587ab9b9711801baf667db1426e4a03fd2d7f15af33e0e0d0394e7cef76\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\nimport './pool/IUniswapV3PoolImmutables.sol';\\nimport './pool/IUniswapV3PoolState.sol';\\nimport './pool/IUniswapV3PoolDerivedState.sol';\\nimport './pool/IUniswapV3PoolActions.sol';\\nimport './pool/IUniswapV3PoolOwnerActions.sol';\\nimport './pool/IUniswapV3PoolEvents.sol';\\n\\n/// @title The interface for a Uniswap V3 Pool\\n/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform\\n/// to the ERC20 specification\\n/// @dev The pool interface is broken up into many smaller pieces\\ninterface IUniswapV3Pool is\\n IUniswapV3PoolImmutables,\\n IUniswapV3PoolState,\\n IUniswapV3PoolDerivedState,\\n IUniswapV3PoolActions,\\n IUniswapV3PoolOwnerActions,\\n IUniswapV3PoolEvents\\n{\\n\\n}\\n\",\"keccak256\":\"0xfe6113d518466cd6652c85b111e01f33eb62157f49ae5ed7d5a3947a2044adb1\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/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\":\"0x9453dd0e7442188667d01d9b65de3f1e14e9511ff3e303179a15f6fc267f7634\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolDerivedState.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Pool state that is not stored\\n/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the\\n/// blockchain. The functions here may have variable gas costs.\\ninterface IUniswapV3PoolDerivedState {\\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 secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block\\n /// timestamp\\n function observe(uint32[] calldata secondsAgos)\\n external\\n view\\n returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);\\n\\n /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range\\n /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.\\n /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first\\n /// snapshot is taken and the second snapshot is taken.\\n /// @param tickLower The lower tick of the range\\n /// @param tickUpper The upper tick of the range\\n /// @return tickCumulativeInside The snapshot of the tick accumulator for the range\\n /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range\\n /// @return secondsInside The snapshot of seconds per liquidity for the range\\n function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)\\n external\\n view\\n returns (\\n int56 tickCumulativeInside,\\n uint160 secondsPerLiquidityInsideX128,\\n uint32 secondsInside\\n );\\n}\\n\",\"keccak256\":\"0xe603ac5b17ecdee73ba2b27efdf386c257a19c14206e87eee77e2017b742d9e5\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolEvents.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Events emitted by a pool\\n/// @notice Contains all events emitted by the pool\\ninterface IUniswapV3PoolEvents {\\n /// @notice Emitted exactly once by a pool when #initialize is first called on the pool\\n /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize\\n /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96\\n /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool\\n event Initialize(uint160 sqrtPriceX96, int24 tick);\\n\\n /// @notice Emitted when liquidity is minted for a given position\\n /// @param sender The address that minted the liquidity\\n /// @param owner The owner of the position and recipient of any minted liquidity\\n /// @param tickLower The lower tick of the position\\n /// @param tickUpper The upper tick of the position\\n /// @param amount The amount of liquidity minted to the position range\\n /// @param amount0 How much token0 was required for the minted liquidity\\n /// @param amount1 How much token1 was required for the minted liquidity\\n event Mint(\\n address sender,\\n address indexed owner,\\n int24 indexed tickLower,\\n int24 indexed tickUpper,\\n uint128 amount,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n /// @notice Emitted when fees are collected by the owner of a position\\n /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees\\n /// @param owner The owner of the position for which fees are collected\\n /// @param tickLower The lower tick of the position\\n /// @param tickUpper The upper tick of the position\\n /// @param amount0 The amount of token0 fees collected\\n /// @param amount1 The amount of token1 fees collected\\n event Collect(\\n address indexed owner,\\n address recipient,\\n int24 indexed tickLower,\\n int24 indexed tickUpper,\\n uint128 amount0,\\n uint128 amount1\\n );\\n\\n /// @notice Emitted when a position's liquidity is removed\\n /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect\\n /// @param owner The owner of the position for which liquidity is removed\\n /// @param tickLower The lower tick of the position\\n /// @param tickUpper The upper tick of the position\\n /// @param amount The amount of liquidity to remove\\n /// @param amount0 The amount of token0 withdrawn\\n /// @param amount1 The amount of token1 withdrawn\\n event Burn(\\n address indexed owner,\\n int24 indexed tickLower,\\n int24 indexed tickUpper,\\n uint128 amount,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n /// @notice Emitted by the pool for any swaps between token0 and token1\\n /// @param sender The address that initiated the swap call, and that received the callback\\n /// @param recipient The address that received the output of the swap\\n /// @param amount0 The delta of the token0 balance of the pool\\n /// @param amount1 The delta of the token1 balance of the pool\\n /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96\\n /// @param liquidity The liquidity of the pool after the swap\\n /// @param tick The log base 1.0001 of price of the pool after the swap\\n event Swap(\\n address indexed sender,\\n address indexed recipient,\\n int256 amount0,\\n int256 amount1,\\n uint160 sqrtPriceX96,\\n uint128 liquidity,\\n int24 tick\\n );\\n\\n /// @notice Emitted by the pool for any flashes of token0/token1\\n /// @param sender The address that initiated the swap call, and that received the callback\\n /// @param recipient The address that received the tokens from flash\\n /// @param amount0 The amount of token0 that was flashed\\n /// @param amount1 The amount of token1 that was flashed\\n /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee\\n /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee\\n event Flash(\\n address indexed sender,\\n address indexed recipient,\\n uint256 amount0,\\n uint256 amount1,\\n uint256 paid0,\\n uint256 paid1\\n );\\n\\n /// @notice Emitted by the pool 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 observationCardinalityNextOld The previous value of the next observation cardinality\\n /// @param observationCardinalityNextNew The updated value of the next observation cardinality\\n event IncreaseObservationCardinalityNext(\\n uint16 observationCardinalityNextOld,\\n uint16 observationCardinalityNextNew\\n );\\n\\n /// @notice Emitted when the protocol fee is changed by the pool\\n /// @param feeProtocol0Old The previous value of the token0 protocol fee\\n /// @param feeProtocol1Old The previous value of the token1 protocol fee\\n /// @param feeProtocol0New The updated value of the token0 protocol fee\\n /// @param feeProtocol1New The updated value of the token1 protocol fee\\n event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);\\n\\n /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner\\n /// @param sender The address that collects the protocol fees\\n /// @param recipient The address that receives the collected protocol fees\\n /// @param amount0 The amount of token0 protocol fees that is withdrawn\\n /// @param amount0 The amount of token1 protocol fees that is withdrawn\\n event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);\\n}\\n\",\"keccak256\":\"0x8071514d0fe5d17d6fbd31c191cdfb703031c24e0ece3621d88ab10e871375cd\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/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\":\"0xf6e5d2cd1139c4c276bdbc8e1d2b256e456c866a91f1b868da265c6d2685c3f7\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolOwnerActions.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Permissioned pool actions\\n/// @notice Contains pool methods that may only be called by the factory owner\\ninterface IUniswapV3PoolOwnerActions {\\n /// @notice Set the denominator of the protocol's % share of the fees\\n /// @param feeProtocol0 new protocol fee for token0 of the pool\\n /// @param feeProtocol1 new protocol fee for token1 of the pool\\n function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;\\n\\n /// @notice Collect the protocol fee accrued to the pool\\n /// @param recipient The address to which collected protocol fees should be sent\\n /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1\\n /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0\\n /// @return amount0 The protocol fee collected in token0\\n /// @return amount1 The protocol fee collected in token1\\n function collectProtocol(\\n address recipient,\\n uint128 amount0Requested,\\n uint128 amount1Requested\\n ) external returns (uint128 amount0, uint128 amount1);\\n}\\n\",\"keccak256\":\"0x759b78a2918af9e99e246dc3af084f654e48ef32bb4e4cb8a966aa3dcaece235\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolState.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Pool state that can change\\n/// @notice These methods compose the pool's state, and can change with any frequency including multiple times\\n/// per transaction\\ninterface IUniswapV3PoolState {\\n /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas\\n /// when accessed externally.\\n /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value\\n /// tick The current tick of the pool, i.e. according to the last tick transition that was run.\\n /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick\\n /// boundary.\\n /// observationIndex The index of the last oracle observation that was written,\\n /// observationCardinality The current maximum number of observations stored in the pool,\\n /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.\\n /// feeProtocol The protocol fee for both tokens of the pool.\\n /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0\\n /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.\\n /// unlocked Whether the pool is currently locked to reentrancy\\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 /// @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 function feeGrowthGlobal0X128() external view returns (uint256);\\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 function feeGrowthGlobal1X128() external view returns (uint256);\\n\\n /// @notice The amounts of token0 and token1 that are owed to the protocol\\n /// @dev Protocol fees will never exceed uint128 max in either token\\n function protocolFees() external view returns (uint128 token0, uint128 token1);\\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 function liquidity() 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 the total amount of position liquidity that uses the pool either as tick lower or\\n /// tick upper,\\n /// liquidityNet how much liquidity changes when the pool price crosses the tick,\\n /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,\\n /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,\\n /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick\\n /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,\\n /// secondsOutside the seconds spent on the other side of the tick from the current tick,\\n /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.\\n /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.\\n /// In addition, these values are only relative and must be used only in comparison to previous snapshots for\\n /// a specific position.\\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 /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information\\n function tickBitmap(int16 wordPosition) external view returns (uint256);\\n\\n /// @notice Returns the information about a position by the position's key\\n /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper\\n /// @return _liquidity The amount of liquidity in the position,\\n /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,\\n /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,\\n /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,\\n /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke\\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 /// @notice Returns data about a specific observation index\\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 secondsPerLiquidityCumulativeX128 the seconds per in range liquidity 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 observations(uint256 index)\\n external\\n view\\n returns (\\n uint32 blockTimestamp,\\n int56 tickCumulative,\\n uint160 secondsPerLiquidityCumulativeX128,\\n bool initialized\\n );\\n}\\n\",\"keccak256\":\"0x852dc1f5df7dcf7f11e7bb3eed79f0cea72ad4b25f6a9d2c35aafb48925fd49f\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/FullMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.4.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 // 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;\\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 /// @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 result = mulDiv(a, b, denominator);\\n if (mulmod(a, b, denominator) > 0) {\\n require(result < type(uint256).max);\\n result++;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe511530871deaef86692cea9adb6076d26d7b47fd4815ce51af52af981026057\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/libraries/TickMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.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 uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\\n require(absTick <= uint256(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 /// @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 // 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\",\"keccak256\":\"0x1f864a2bf61ba05f3173eaf2e3f94c5e1da4bec0554757527b6d1ef1fe439e4e\",\"license\":\"GPL-2.0-or-later\"},\"contracts/core/Oracle.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\n\\n// uniswap Library only works under 0.7.6\\npragma solidity =0.7.6;\\n\\n//interface\\nimport {IUniswapV3Pool} from \\\"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\\\";\\nimport {IERC20Detailed} from \\\"../interfaces/IERC20Detailed.sol\\\";\\n\\n//library\\nimport {SafeMath} from \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport {Uint256Casting} from \\\"../libs/Uint256Casting.sol\\\";\\nimport {OracleLibrary} from \\\"../libs/OracleLibrary.sol\\\";\\n\\n/**\\n * @notice read UniswapV3 pool TWAP prices, and convert to human readable term with (18 decimals)\\n * @dev if ETH price is $3000, both ETH/USDC price and ETH/DAI price will be reported as 3000 * 1e18 by this oracle\\n */\\ncontract Oracle {\\n using SafeMath for uint256;\\n using Uint256Casting for uint256;\\n\\n uint128 private constant ONE = 1e18;\\n\\n /**\\n * @notice get twap converted with base & quote token decimals\\n * @dev if period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \\\"OLD\\\"\\n * @param _pool uniswap pool address\\n * @param _base base currency. to get eth/usd price, eth is base token\\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\\n * @param _period number of seconds in the past to start calculating time-weighted average\\n * @return price of 1 base currency in quote currency. scaled by 1e18\\n */\\n function getTwap(\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _period,\\n bool _checkPeriod\\n ) external view returns (uint256) {\\n // if the period is already checked, request TWAP directly. Will revert if period is too long.\\n if (!_checkPeriod) return _fetchTwap(_pool, _base, _quote, _period);\\n\\n // make sure the requested period < maxPeriod the pool recorded.\\n uint32 maxPeriod = _getMaxPeriod(_pool);\\n uint32 requestPeriod = _period > maxPeriod ? maxPeriod : _period;\\n return _fetchTwap(_pool, _base, _quote, requestPeriod);\\n }\\n\\n /**\\n * @notice get twap for a specific period of time, converted with base & quote token decimals\\n * @dev if the _secondsAgoToStartOfTwap period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \\\"OLD\\\"\\n * @param _pool uniswap pool address\\n * @param _base base currency. to get eth/usd price, eth is base token\\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\\n * @param _secondsAgoToStartOfTwap amount of seconds in the past to start calculating time-weighted average\\n * @param _secondsAgoToEndOfTwap amount of seconds in the past to end calculating time-weighted average\\n * @return price of 1 base currency in quote currency. scaled by 1e18\\n */\\n function getHistoricalTwap(\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _secondsAgoToStartOfTwap,\\n uint32 _secondsAgoToEndOfTwap\\n ) external view returns (uint256) {\\n return _fetchHistoricTwap(_pool, _base, _quote, _secondsAgoToStartOfTwap, _secondsAgoToEndOfTwap);\\n }\\n\\n /**\\n * @notice get the max period that can be used to request twap\\n * @param _pool uniswap pool address\\n * @return max period can be used to request twap\\n */\\n function getMaxPeriod(address _pool) external view returns (uint32) {\\n return _getMaxPeriod(_pool);\\n }\\n\\n /**\\n * @notice get time weighed average tick, not converted to price\\n * @dev this function will not revert\\n * @param _pool address of the pool\\n * @param _period period in second that we want to calculate average on\\n * @return timeWeightedAverageTick the time weighted average tick\\n */\\n function getTimeWeightedAverageTickSafe(address _pool, uint32 _period)\\n external\\n view\\n returns (int24 timeWeightedAverageTick)\\n {\\n uint32 maxPeriod = _getMaxPeriod(_pool);\\n uint32 requestPeriod = _period > maxPeriod ? maxPeriod : _period;\\n return OracleLibrary.consultAtHistoricTime(_pool, requestPeriod, 0);\\n }\\n\\n /**\\n * @notice get twap converted with base & quote token decimals\\n * @dev if period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \\\"OLD\\\"\\n * @param _pool uniswap pool address\\n * @param _base base currency. to get eth/usd price, eth is base token\\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\\n * @param _period number of seconds in the past to start calculating time-weighted average\\n * @return twap price which is scaled\\n */\\n function _fetchTwap(\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _period\\n ) internal view returns (uint256) {\\n uint256 quoteAmountOut = _fetchRawTwap(_pool, _base, _quote, _period);\\n\\n uint8 baseDecimals = IERC20Detailed(_base).decimals();\\n uint8 quoteDecimals = IERC20Detailed(_quote).decimals();\\n if (baseDecimals == quoteDecimals) return quoteAmountOut;\\n\\n // if quote token has less decimals, the returned quoteAmountOut will be lower, need to scale up by decimal difference\\n if (baseDecimals > quoteDecimals) return quoteAmountOut.mul(10**(baseDecimals - quoteDecimals));\\n\\n // if quote token has more decimals, the returned quoteAmountOut will be higher, need to scale down by decimal difference\\n return quoteAmountOut.div(10**(quoteDecimals - baseDecimals));\\n }\\n\\n /**\\n * @notice get raw twap from the uniswap pool\\n * @dev if period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \\\"OLD\\\".\\n * @param _pool uniswap pool address\\n * @param _base base currency. to get eth/usd price, eth is base token\\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\\n * @param _period number of seconds in the past to start calculating time-weighted average\\n * @return amount of quote currency received for _amountIn of base currency\\n */\\n function _fetchRawTwap(\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _period\\n ) internal view returns (uint256) {\\n int24 twapTick = OracleLibrary.consultAtHistoricTime(_pool, _period, 0);\\n return OracleLibrary.getQuoteAtTick(twapTick, ONE, _base, _quote);\\n }\\n\\n /**\\n * @notice get twap for a specific period of time, converted with base & quote token decimals\\n * @dev if the _secondsAgoToStartOfTwap period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \\\"OLD\\\"\\n * @param _pool uniswap pool address\\n * @param _base base currency. to get eth/usd price, eth is base token\\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\\n * @param _secondsAgoToStartOfTwap amount of seconds in the past to start calculating time-weighted average\\n * @param _secondsAgoToEndOfTwap amount of seconds in the past to end calculating time-weighted average\\n * @return price of 1 base currency in quote currency. scaled by 1e18\\n */\\n function _fetchHistoricTwap(\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _secondsAgoToStartOfTwap,\\n uint32 _secondsAgoToEndOfTwap\\n ) internal view returns (uint256) {\\n int24 twapTick = OracleLibrary.consultAtHistoricTime(_pool, _secondsAgoToStartOfTwap, _secondsAgoToEndOfTwap);\\n\\n return OracleLibrary.getQuoteAtTick(twapTick, ONE, _base, _quote);\\n }\\n\\n /**\\n * @notice get the max period that can be used to request twap\\n * @param _pool uniswap pool address\\n * @return max period can be used to request twap\\n */\\n function _getMaxPeriod(address _pool) internal view returns (uint32) {\\n IUniswapV3Pool pool = IUniswapV3Pool(_pool);\\n // observationIndex: the index of the last oracle observation that was written\\n // cardinality: the current maximum number of observations stored in the pool\\n (, , uint16 observationIndex, uint16 cardinality, , , ) = pool.slot0();\\n\\n // first observation index\\n // it's safe to use % without checking cardinality = 0 because cardinality is always >= 1\\n uint16 oldestObservationIndex = (observationIndex + 1) % cardinality;\\n\\n (uint32 oldestObservationTimestamp, , , bool initialized) = pool.observations(oldestObservationIndex);\\n\\n if (initialized) return uint32(block.timestamp) - oldestObservationTimestamp;\\n\\n // (index + 1) % cardinality is not the oldest index,\\n // probably because cardinality is increased after last observation.\\n // in this case, observation at index 0 should be the oldest.\\n (oldestObservationTimestamp, , , ) = pool.observations(0);\\n\\n return uint32(block.timestamp) - oldestObservationTimestamp;\\n }\\n}\\n\",\"keccak256\":\"0x131f346535285fd0b2ab3520493eb1ca7234baa7c36513b1d18dcf681d85e634\",\"license\":\"BUSL-1.1\"},\"contracts/interfaces/IERC20Detailed.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n// uniswap Library only works under 0.7.6\\npragma solidity =0.7.6;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IERC20Detailed is IERC20 {\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0xcd59a0158d0711810c499904b9d37a71fdb34d1c4403f3cb67ca47de5e88bf7b\",\"license\":\"MIT\"},\"contracts/libs/OracleLibrary.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later AND MIT\\n\\npragma solidity >=0.5.0 <0.8.0;\\n\\n//interface\\nimport \\\"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\\\";\\n\\n//lib\\nimport \\\"@uniswap/v3-core/contracts/libraries/FullMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/TickMath.sol\\\";\\n\\n/// @title oracle library\\n/// @notice provides functions to integrate with uniswap v3 oracle\\n/// @author uniswap team other than consultAtHistoricTime(), built by opyn\\nlibrary OracleLibrary {\\n /// @notice fetches time-weighted average tick using uniswap v3 oracle\\n /// @dev written by opyn team\\n /// @param pool Address of uniswap v3 pool that we want to observe\\n /// @param _secondsAgoToStartOfTwap number of seconds to start of TWAP period\\n /// @param _secondsAgoToEndOfTwap number of seconds to end of TWAP period\\n /// @return timeWeightedAverageTick The time-weighted average tick from (block.timestamp - _secondsAgoToStartOfTwap) to _secondsAgoToEndOfTwap\\n function consultAtHistoricTime(\\n address pool,\\n uint32 _secondsAgoToStartOfTwap,\\n uint32 _secondsAgoToEndOfTwap\\n ) internal view returns (int24) {\\n require(_secondsAgoToStartOfTwap > _secondsAgoToEndOfTwap, \\\"BP\\\");\\n int24 timeWeightedAverageTick;\\n uint32[] memory secondAgos = new uint32[](2);\\n\\n uint32 twapDuration = _secondsAgoToStartOfTwap - _secondsAgoToEndOfTwap;\\n\\n // get TWAP from (now - _secondsAgoToStartOfTwap) -> (now - _secondsAgoToEndOfTwap)\\n secondAgos[0] = _secondsAgoToStartOfTwap;\\n secondAgos[1] = _secondsAgoToEndOfTwap;\\n\\n (int56[] memory tickCumulatives, ) = IUniswapV3Pool(pool).observe(secondAgos);\\n int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];\\n\\n timeWeightedAverageTick = int24(tickCumulativesDelta / (twapDuration));\\n\\n // Always round to negative infinity\\n if (tickCumulativesDelta < 0 && (tickCumulativesDelta % (twapDuration) != 0)) timeWeightedAverageTick--;\\n\\n return timeWeightedAverageTick;\\n }\\n\\n /// @notice given a tick and a token amount, calculates the amount of token received in exchange\\n /// @param tick tick value used to calculate the quote\\n /// @param baseAmount amount of token to be converted\\n /// @param baseToken address of an ERC20 token contract used as the baseAmount denomination\\n /// @param quoteToken address of an ERC20 token contract used as the quoteAmount denomination\\n /// @return quoteAmount Amount of quoteToken received for baseAmount of baseToken\\n function getQuoteAtTick(\\n int24 tick,\\n uint128 baseAmount,\\n address baseToken,\\n address quoteToken\\n ) internal pure returns (uint256 quoteAmount) {\\n uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick);\\n\\n // Calculate quoteAmount with better precision if it doesn't overflow when multiplied by itself\\n if (sqrtRatioX96 <= type(uint128).max) {\\n uint256 ratioX192 = uint256(sqrtRatioX96) * sqrtRatioX96;\\n quoteAmount = baseToken < quoteToken\\n ? FullMath.mulDiv(ratioX192, baseAmount, 1 << 192)\\n : FullMath.mulDiv(1 << 192, baseAmount, ratioX192);\\n } else {\\n uint256 ratioX128 = FullMath.mulDiv(sqrtRatioX96, sqrtRatioX96, 1 << 64);\\n quoteAmount = baseToken < quoteToken\\n ? FullMath.mulDiv(ratioX128, baseAmount, 1 << 128)\\n : FullMath.mulDiv(1 << 128, baseAmount, ratioX128);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe8f175ffbbcc7b4d611c47eb190e2c114782d845fd3414b36f87ceec5cb41157\",\"license\":\"GPL-2.0-or-later AND MIT\"},\"contracts/libs/Uint256Casting.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nlibrary Uint256Casting {\\n /**\\n * @notice cast a uint256 to a uint128, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint128\\n */\\n function toUint128(uint256 y) internal pure returns (uint128 z) {\\n require((z = uint128(y)) == y, \\\"OF128\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint96, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint96\\n */\\n function toUint96(uint256 y) internal pure returns (uint96 z) {\\n require((z = uint96(y)) == y, \\\"OF96\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint32, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint32\\n */\\n function toUint32(uint256 y) internal pure returns (uint32 z) {\\n require((z = uint32(y)) == y, \\\"OF32\\\");\\n }\\n}\\n\",\"keccak256\":\"0xcccbe82f8696be398d0d0f5a44988e9bab70e18dd40c9563620cdf160d8bcd7c\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x608060405234801561001057600080fd5b50610f0e806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80634a0a96eb146100515780634ac78d111461009a578063cce79bd5146100f6578063de5a6e2214610140575b600080fd5b6100836004803603604081101561006757600080fd5b5080356001600160a01b0316906020013563ffffffff1661017f565b6040805160029290920b8252519081900360200190f35b6100e4600480360360a08110156100b057600080fd5b506001600160a01b03813581169160208101358216916040820135169063ffffffff606082013581169160800135166101c3565b60408051918252519081900360200190f35b6100e4600480360360a081101561010c57600080fd5b506001600160a01b03813581169160208101358216916040820135169063ffffffff606082013516906080013515156101de565b6101666004803603602081101561015657600080fd5b50356001600160a01b031661023c565b6040805163ffffffff9092168252519081900360200190f35b60008061018b8461024f565b905060008163ffffffff168463ffffffff16116101a857836101aa565b815b90506101b8858260006103fb565b925050505b92915050565b60006101d2868686868661072c565b90505b95945050505050565b6000816101f8576101f18686868661075b565b90506101d5565b60006102038761024f565b905060008163ffffffff168563ffffffff16116102205784610222565b815b90506102308888888461075b565b98975050505050505050565b60006102478261024f565b90505b919050565b600080829050600080826001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561029157600080fd5b505afa1580156102a5573d6000803e3d6000fd5b505050506040513d60e08110156102bb57600080fd5b5060408101516060909101519092509050600061ffff808316906001850116816102e157fe5b069050600080856001600160a01b031663252c09d7846040518263ffffffff1660e01b8152600401808261ffff16815260200191505060806040518083038186803b15801561032f57600080fd5b505afa158015610343573d6000803e3d6000fd5b505050506040513d608081101561035957600080fd5b5080516060909101519092509050801561037c57504203945061024a9350505050565b856001600160a01b031663252c09d760006040518263ffffffff1660e01b81526004018082815260200191505060806040518083038186803b1580156103c157600080fd5b505afa1580156103d5573d6000803e3d6000fd5b505050506040513d60808110156103eb57600080fd5b5051420398975050505050505050565b60008163ffffffff168363ffffffff1611610442576040805162461bcd60e51b8152602060048201526002602482015261042560f41b604482015290519081900360640190fd5b6040805160028082526060820183526000928392919060208301908036833701905050905060008486039050858260008151811061047c57fe5b602002602001019063ffffffff16908163ffffffff168152505084826001815181106104a457fe5b63ffffffff9092166020928302919091018201526040517f883bdbfd000000000000000000000000000000000000000000000000000000008152600481018281528451602483015284516000936001600160a01b038c169363883bdbfd938893909283926044019185820191028083838b5b8381101561052e578181015183820152602001610516565b505050509050019250505060006040518083038186803b15801561055157600080fd5b505afa158015610565573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561058e57600080fd5b81019080805160405193929190846401000000008211156105ae57600080fd5b9083019060208201858111156105c357600080fd5b82518660208202830111640100000000821117156105e057600080fd5b82525081516020918201928201910280838360005b8381101561060d5781810151838201526020016105f5565b505050509050016040526020018051604051939291908464010000000082111561063657600080fd5b90830190602082018581111561064b57600080fd5b825186602082028301116401000000008211171561066857600080fd5b82525081516020918201928201910280838360005b8381101561069557818101518382015260200161067d565b505050509050016040525050505090506000816000815181106106b457fe5b6020026020010151826001815181106106c957fe5b60200260200101510390508263ffffffff168160060b816106e657fe5b05945060008160060b12801561071057508263ffffffff168160060b8161070957fe5b0760060b15155b1561071d57600019909401935b509293505050505b9392505050565b60008061073a8785856103fb565b905061075081670de0b6b3a764000088886108c3565b979650505050505050565b60008061076a868686866109e7565b90506000856001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156107a757600080fd5b505afa1580156107bb573d6000803e3d6000fd5b505050506040513d60208110156107d157600080fd5b5051604080517f313ce56700000000000000000000000000000000000000000000000000000000815290519192506000916001600160a01b0388169163313ce567916004808301926020929190829003018186803b15801561083257600080fd5b505afa158015610846573d6000803e3d6000fd5b505050506040513d602081101561085c57600080fd5b5051905060ff8281169082161415610879578293505050506108bb565b8060ff168260ff1611156108a3576108998360ff83850316600a0a610a16565b93505050506108bb565b6108b58360ff84840316600a0a610a6f565b93505050505b949350505050565b6000806108cf86610ad6565b90506fffffffffffffffffffffffffffffffff6001600160a01b03821611610959576001600160a01b03808216800290848116908616106109305761092b600160c01b876fffffffffffffffffffffffffffffffff1683610e08565b610951565b61095181876fffffffffffffffffffffffffffffffff16600160c01b610e08565b9250506109de565b60006109786001600160a01b0383168068010000000000000000610e08565b9050836001600160a01b0316856001600160a01b0316106109b9576109b4600160801b876fffffffffffffffffffffffffffffffff1683610e08565b6109da565b6109da81876fffffffffffffffffffffffffffffffff16600160801b610e08565b9250505b50949350505050565b6000806109f6868460006103fb565b9050610a0c81670de0b6b3a764000087876108c3565b9695505050505050565b600082610a25575060006101bd565b82820282848281610a3257fe5b04146107255760405162461bcd60e51b8152600401808060200182810382526021815260200180610eb86021913960400191505060405180910390fd5b6000808211610ac5576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381610ace57fe5b049392505050565b60008060008360020b12610aed578260020b610af5565b8260020b6000035b9050620d89e8811115610b33576040805162461bcd60e51b81526020600482015260016024820152601560fa1b604482015290519081900360640190fd5b600060018216610b4757600160801b610b59565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615610b8d576ffff97272373d413259a46990580e213a0260801c5b6004821615610bac576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615610bcb576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615610bea576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615610c09576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615610c28576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615610c47576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615610c67576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615610c87576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615610ca7576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615610cc7576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615610ce7576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615610d07576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615610d27576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615610d47576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615610d68576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615610d88576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615610da7576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615610dc4576b048a170391f7dc42444e8fa20260801c5b60008460020b1315610ddf578060001981610ddb57fe5b0490505b640100000000810615610df3576001610df6565b60005b60ff16602082901c0192505050919050565b6000808060001985870986860292508281109083900303905080610e3e5760008411610e3357600080fd5b508290049050610725565b808411610e4a57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a0290910302918190038190046001018684119095039490940291909403929092049190911791909102915050939250505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212202bf34af056d51ac4bbbe405d15d8c371d4f6a6e21964bf0393ea7872a9562a8964736f6c63430007060033", - "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80634a0a96eb146100515780634ac78d111461009a578063cce79bd5146100f6578063de5a6e2214610140575b600080fd5b6100836004803603604081101561006757600080fd5b5080356001600160a01b0316906020013563ffffffff1661017f565b6040805160029290920b8252519081900360200190f35b6100e4600480360360a08110156100b057600080fd5b506001600160a01b03813581169160208101358216916040820135169063ffffffff606082013581169160800135166101c3565b60408051918252519081900360200190f35b6100e4600480360360a081101561010c57600080fd5b506001600160a01b03813581169160208101358216916040820135169063ffffffff606082013516906080013515156101de565b6101666004803603602081101561015657600080fd5b50356001600160a01b031661023c565b6040805163ffffffff9092168252519081900360200190f35b60008061018b8461024f565b905060008163ffffffff168463ffffffff16116101a857836101aa565b815b90506101b8858260006103fb565b925050505b92915050565b60006101d2868686868661072c565b90505b95945050505050565b6000816101f8576101f18686868661075b565b90506101d5565b60006102038761024f565b905060008163ffffffff168563ffffffff16116102205784610222565b815b90506102308888888461075b565b98975050505050505050565b60006102478261024f565b90505b919050565b600080829050600080826001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561029157600080fd5b505afa1580156102a5573d6000803e3d6000fd5b505050506040513d60e08110156102bb57600080fd5b5060408101516060909101519092509050600061ffff808316906001850116816102e157fe5b069050600080856001600160a01b031663252c09d7846040518263ffffffff1660e01b8152600401808261ffff16815260200191505060806040518083038186803b15801561032f57600080fd5b505afa158015610343573d6000803e3d6000fd5b505050506040513d608081101561035957600080fd5b5080516060909101519092509050801561037c57504203945061024a9350505050565b856001600160a01b031663252c09d760006040518263ffffffff1660e01b81526004018082815260200191505060806040518083038186803b1580156103c157600080fd5b505afa1580156103d5573d6000803e3d6000fd5b505050506040513d60808110156103eb57600080fd5b5051420398975050505050505050565b60008163ffffffff168363ffffffff1611610442576040805162461bcd60e51b8152602060048201526002602482015261042560f41b604482015290519081900360640190fd5b6040805160028082526060820183526000928392919060208301908036833701905050905060008486039050858260008151811061047c57fe5b602002602001019063ffffffff16908163ffffffff168152505084826001815181106104a457fe5b63ffffffff9092166020928302919091018201526040517f883bdbfd000000000000000000000000000000000000000000000000000000008152600481018281528451602483015284516000936001600160a01b038c169363883bdbfd938893909283926044019185820191028083838b5b8381101561052e578181015183820152602001610516565b505050509050019250505060006040518083038186803b15801561055157600080fd5b505afa158015610565573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561058e57600080fd5b81019080805160405193929190846401000000008211156105ae57600080fd5b9083019060208201858111156105c357600080fd5b82518660208202830111640100000000821117156105e057600080fd5b82525081516020918201928201910280838360005b8381101561060d5781810151838201526020016105f5565b505050509050016040526020018051604051939291908464010000000082111561063657600080fd5b90830190602082018581111561064b57600080fd5b825186602082028301116401000000008211171561066857600080fd5b82525081516020918201928201910280838360005b8381101561069557818101518382015260200161067d565b505050509050016040525050505090506000816000815181106106b457fe5b6020026020010151826001815181106106c957fe5b60200260200101510390508263ffffffff168160060b816106e657fe5b05945060008160060b12801561071057508263ffffffff168160060b8161070957fe5b0760060b15155b1561071d57600019909401935b509293505050505b9392505050565b60008061073a8785856103fb565b905061075081670de0b6b3a764000088886108c3565b979650505050505050565b60008061076a868686866109e7565b90506000856001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156107a757600080fd5b505afa1580156107bb573d6000803e3d6000fd5b505050506040513d60208110156107d157600080fd5b5051604080517f313ce56700000000000000000000000000000000000000000000000000000000815290519192506000916001600160a01b0388169163313ce567916004808301926020929190829003018186803b15801561083257600080fd5b505afa158015610846573d6000803e3d6000fd5b505050506040513d602081101561085c57600080fd5b5051905060ff8281169082161415610879578293505050506108bb565b8060ff168260ff1611156108a3576108998360ff83850316600a0a610a16565b93505050506108bb565b6108b58360ff84840316600a0a610a6f565b93505050505b949350505050565b6000806108cf86610ad6565b90506fffffffffffffffffffffffffffffffff6001600160a01b03821611610959576001600160a01b03808216800290848116908616106109305761092b600160c01b876fffffffffffffffffffffffffffffffff1683610e08565b610951565b61095181876fffffffffffffffffffffffffffffffff16600160c01b610e08565b9250506109de565b60006109786001600160a01b0383168068010000000000000000610e08565b9050836001600160a01b0316856001600160a01b0316106109b9576109b4600160801b876fffffffffffffffffffffffffffffffff1683610e08565b6109da565b6109da81876fffffffffffffffffffffffffffffffff16600160801b610e08565b9250505b50949350505050565b6000806109f6868460006103fb565b9050610a0c81670de0b6b3a764000087876108c3565b9695505050505050565b600082610a25575060006101bd565b82820282848281610a3257fe5b04146107255760405162461bcd60e51b8152600401808060200182810382526021815260200180610eb86021913960400191505060405180910390fd5b6000808211610ac5576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381610ace57fe5b049392505050565b60008060008360020b12610aed578260020b610af5565b8260020b6000035b9050620d89e8811115610b33576040805162461bcd60e51b81526020600482015260016024820152601560fa1b604482015290519081900360640190fd5b600060018216610b4757600160801b610b59565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615610b8d576ffff97272373d413259a46990580e213a0260801c5b6004821615610bac576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615610bcb576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615610bea576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615610c09576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615610c28576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615610c47576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615610c67576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615610c87576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615610ca7576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615610cc7576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615610ce7576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615610d07576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615610d27576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615610d47576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615610d68576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615610d88576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615610da7576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615610dc4576b048a170391f7dc42444e8fa20260801c5b60008460020b1315610ddf578060001981610ddb57fe5b0490505b640100000000810615610df3576001610df6565b60005b60ff16602082901c0192505050919050565b6000808060001985870986860292508281109083900303905080610e3e5760008411610e3357600080fd5b508290049050610725565b808411610e4a57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a0290910302918190038190046001018684119095039490940291909403929092049190911791909102915050939250505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212202bf34af056d51ac4bbbe405d15d8c371d4f6a6e21964bf0393ea7872a9562a8964736f6c63430007060033", + "solcInputHash": "d97d3d4b09e0d70518330d405a7dd9ff", + "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_pool\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_base\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_quote\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"_secondsAgoToStartOfTwap\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"_secondsAgoToEndOfTwap\",\"type\":\"uint32\"}],\"name\":\"getHistoricalTwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_pool\",\"type\":\"address\"}],\"name\":\"getMaxPeriod\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_pool\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"_period\",\"type\":\"uint32\"}],\"name\":\"getTimeWeightedAverageTickSafe\",\"outputs\":[{\"internalType\":\"int24\",\"name\":\"timeWeightedAverageTick\",\"type\":\"int24\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_pool\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_base\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_quote\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"_period\",\"type\":\"uint32\"},{\"internalType\":\"bool\",\"name\":\"_checkPeriod\",\"type\":\"bool\"}],\"name\":\"getTwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"if ETH price is $3000, both ETH/USDC price and ETH/DAI price will be reported as 3000 * 1e18 by this oracle\",\"kind\":\"dev\",\"methods\":{\"getHistoricalTwap(address,address,address,uint32,uint32)\":{\"details\":\"if the _secondsAgoToStartOfTwap period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \\\"OLD\\\"\",\"params\":{\"_base\":\"base currency. to get eth/usd price, eth is base token\",\"_pool\":\"uniswap pool address\",\"_quote\":\"quote currency. to get eth/usd price, usd is the quote currency\",\"_secondsAgoToEndOfTwap\":\"amount of seconds in the past to end calculating time-weighted average\",\"_secondsAgoToStartOfTwap\":\"amount of seconds in the past to start calculating time-weighted average\"},\"returns\":{\"_0\":\"price of 1 base currency in quote currency. scaled by 1e18\"}},\"getMaxPeriod(address)\":{\"params\":{\"_pool\":\"uniswap pool address\"},\"returns\":{\"_0\":\"max period can be used to request twap\"}},\"getTimeWeightedAverageTickSafe(address,uint32)\":{\"details\":\"this function will not revert\",\"params\":{\"_period\":\"period in second that we want to calculate average on\",\"_pool\":\"address of the pool\"},\"returns\":{\"timeWeightedAverageTick\":\"the time weighted average tick\"}},\"getTwap(address,address,address,uint32,bool)\":{\"details\":\"if period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \\\"OLD\\\"\",\"params\":{\"_base\":\"base currency. to get eth/usd price, eth is base token\",\"_period\":\"number of seconds in the past to start calculating time-weighted average\",\"_pool\":\"uniswap pool address\",\"_quote\":\"quote currency. to get eth/usd price, usd is the quote currency\"},\"returns\":{\"_0\":\"price of 1 base currency in quote currency. scaled by 1e18\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getHistoricalTwap(address,address,address,uint32,uint32)\":{\"notice\":\"get twap for a specific period of time, converted with base & quote token decimals\"},\"getMaxPeriod(address)\":{\"notice\":\"get the max period that can be used to request twap\"},\"getTimeWeightedAverageTickSafe(address,uint32)\":{\"notice\":\"get time weighed average tick, not converted to price\"},\"getTwap(address,address,address,uint32,bool)\":{\"notice\":\"get twap converted with base & quote token decimals\"}},\"notice\":\"read UniswapV3 pool TWAP prices, and convert to human readable term with (18 decimals)\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/core/Oracle.sol\":\"Oracle\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":825},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0xe22a1fc7400ae196eba2ad1562d0386462b00a6363b742d55a2fd2021a58586f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0xbd74f587ab9b9711801baf667db1426e4a03fd2d7f15af33e0e0d0394e7cef76\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\nimport './pool/IUniswapV3PoolImmutables.sol';\\nimport './pool/IUniswapV3PoolState.sol';\\nimport './pool/IUniswapV3PoolDerivedState.sol';\\nimport './pool/IUniswapV3PoolActions.sol';\\nimport './pool/IUniswapV3PoolOwnerActions.sol';\\nimport './pool/IUniswapV3PoolEvents.sol';\\n\\n/// @title The interface for a Uniswap V3 Pool\\n/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform\\n/// to the ERC20 specification\\n/// @dev The pool interface is broken up into many smaller pieces\\ninterface IUniswapV3Pool is\\n IUniswapV3PoolImmutables,\\n IUniswapV3PoolState,\\n IUniswapV3PoolDerivedState,\\n IUniswapV3PoolActions,\\n IUniswapV3PoolOwnerActions,\\n IUniswapV3PoolEvents\\n{\\n\\n}\\n\",\"keccak256\":\"0xfe6113d518466cd6652c85b111e01f33eb62157f49ae5ed7d5a3947a2044adb1\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/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\":\"0x9453dd0e7442188667d01d9b65de3f1e14e9511ff3e303179a15f6fc267f7634\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolDerivedState.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Pool state that is not stored\\n/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the\\n/// blockchain. The functions here may have variable gas costs.\\ninterface IUniswapV3PoolDerivedState {\\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 secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block\\n /// timestamp\\n function observe(uint32[] calldata secondsAgos)\\n external\\n view\\n returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);\\n\\n /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range\\n /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.\\n /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first\\n /// snapshot is taken and the second snapshot is taken.\\n /// @param tickLower The lower tick of the range\\n /// @param tickUpper The upper tick of the range\\n /// @return tickCumulativeInside The snapshot of the tick accumulator for the range\\n /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range\\n /// @return secondsInside The snapshot of seconds per liquidity for the range\\n function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)\\n external\\n view\\n returns (\\n int56 tickCumulativeInside,\\n uint160 secondsPerLiquidityInsideX128,\\n uint32 secondsInside\\n );\\n}\\n\",\"keccak256\":\"0xe603ac5b17ecdee73ba2b27efdf386c257a19c14206e87eee77e2017b742d9e5\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolEvents.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Events emitted by a pool\\n/// @notice Contains all events emitted by the pool\\ninterface IUniswapV3PoolEvents {\\n /// @notice Emitted exactly once by a pool when #initialize is first called on the pool\\n /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize\\n /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96\\n /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool\\n event Initialize(uint160 sqrtPriceX96, int24 tick);\\n\\n /// @notice Emitted when liquidity is minted for a given position\\n /// @param sender The address that minted the liquidity\\n /// @param owner The owner of the position and recipient of any minted liquidity\\n /// @param tickLower The lower tick of the position\\n /// @param tickUpper The upper tick of the position\\n /// @param amount The amount of liquidity minted to the position range\\n /// @param amount0 How much token0 was required for the minted liquidity\\n /// @param amount1 How much token1 was required for the minted liquidity\\n event Mint(\\n address sender,\\n address indexed owner,\\n int24 indexed tickLower,\\n int24 indexed tickUpper,\\n uint128 amount,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n /// @notice Emitted when fees are collected by the owner of a position\\n /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees\\n /// @param owner The owner of the position for which fees are collected\\n /// @param tickLower The lower tick of the position\\n /// @param tickUpper The upper tick of the position\\n /// @param amount0 The amount of token0 fees collected\\n /// @param amount1 The amount of token1 fees collected\\n event Collect(\\n address indexed owner,\\n address recipient,\\n int24 indexed tickLower,\\n int24 indexed tickUpper,\\n uint128 amount0,\\n uint128 amount1\\n );\\n\\n /// @notice Emitted when a position's liquidity is removed\\n /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect\\n /// @param owner The owner of the position for which liquidity is removed\\n /// @param tickLower The lower tick of the position\\n /// @param tickUpper The upper tick of the position\\n /// @param amount The amount of liquidity to remove\\n /// @param amount0 The amount of token0 withdrawn\\n /// @param amount1 The amount of token1 withdrawn\\n event Burn(\\n address indexed owner,\\n int24 indexed tickLower,\\n int24 indexed tickUpper,\\n uint128 amount,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n /// @notice Emitted by the pool for any swaps between token0 and token1\\n /// @param sender The address that initiated the swap call, and that received the callback\\n /// @param recipient The address that received the output of the swap\\n /// @param amount0 The delta of the token0 balance of the pool\\n /// @param amount1 The delta of the token1 balance of the pool\\n /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96\\n /// @param liquidity The liquidity of the pool after the swap\\n /// @param tick The log base 1.0001 of price of the pool after the swap\\n event Swap(\\n address indexed sender,\\n address indexed recipient,\\n int256 amount0,\\n int256 amount1,\\n uint160 sqrtPriceX96,\\n uint128 liquidity,\\n int24 tick\\n );\\n\\n /// @notice Emitted by the pool for any flashes of token0/token1\\n /// @param sender The address that initiated the swap call, and that received the callback\\n /// @param recipient The address that received the tokens from flash\\n /// @param amount0 The amount of token0 that was flashed\\n /// @param amount1 The amount of token1 that was flashed\\n /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee\\n /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee\\n event Flash(\\n address indexed sender,\\n address indexed recipient,\\n uint256 amount0,\\n uint256 amount1,\\n uint256 paid0,\\n uint256 paid1\\n );\\n\\n /// @notice Emitted by the pool 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 observationCardinalityNextOld The previous value of the next observation cardinality\\n /// @param observationCardinalityNextNew The updated value of the next observation cardinality\\n event IncreaseObservationCardinalityNext(\\n uint16 observationCardinalityNextOld,\\n uint16 observationCardinalityNextNew\\n );\\n\\n /// @notice Emitted when the protocol fee is changed by the pool\\n /// @param feeProtocol0Old The previous value of the token0 protocol fee\\n /// @param feeProtocol1Old The previous value of the token1 protocol fee\\n /// @param feeProtocol0New The updated value of the token0 protocol fee\\n /// @param feeProtocol1New The updated value of the token1 protocol fee\\n event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);\\n\\n /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner\\n /// @param sender The address that collects the protocol fees\\n /// @param recipient The address that receives the collected protocol fees\\n /// @param amount0 The amount of token0 protocol fees that is withdrawn\\n /// @param amount0 The amount of token1 protocol fees that is withdrawn\\n event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);\\n}\\n\",\"keccak256\":\"0x8071514d0fe5d17d6fbd31c191cdfb703031c24e0ece3621d88ab10e871375cd\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/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\":\"0xf6e5d2cd1139c4c276bdbc8e1d2b256e456c866a91f1b868da265c6d2685c3f7\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolOwnerActions.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Permissioned pool actions\\n/// @notice Contains pool methods that may only be called by the factory owner\\ninterface IUniswapV3PoolOwnerActions {\\n /// @notice Set the denominator of the protocol's % share of the fees\\n /// @param feeProtocol0 new protocol fee for token0 of the pool\\n /// @param feeProtocol1 new protocol fee for token1 of the pool\\n function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;\\n\\n /// @notice Collect the protocol fee accrued to the pool\\n /// @param recipient The address to which collected protocol fees should be sent\\n /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1\\n /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0\\n /// @return amount0 The protocol fee collected in token0\\n /// @return amount1 The protocol fee collected in token1\\n function collectProtocol(\\n address recipient,\\n uint128 amount0Requested,\\n uint128 amount1Requested\\n ) external returns (uint128 amount0, uint128 amount1);\\n}\\n\",\"keccak256\":\"0x759b78a2918af9e99e246dc3af084f654e48ef32bb4e4cb8a966aa3dcaece235\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolState.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Pool state that can change\\n/// @notice These methods compose the pool's state, and can change with any frequency including multiple times\\n/// per transaction\\ninterface IUniswapV3PoolState {\\n /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas\\n /// when accessed externally.\\n /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value\\n /// tick The current tick of the pool, i.e. according to the last tick transition that was run.\\n /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick\\n /// boundary.\\n /// observationIndex The index of the last oracle observation that was written,\\n /// observationCardinality The current maximum number of observations stored in the pool,\\n /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.\\n /// feeProtocol The protocol fee for both tokens of the pool.\\n /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0\\n /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.\\n /// unlocked Whether the pool is currently locked to reentrancy\\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 /// @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 function feeGrowthGlobal0X128() external view returns (uint256);\\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 function feeGrowthGlobal1X128() external view returns (uint256);\\n\\n /// @notice The amounts of token0 and token1 that are owed to the protocol\\n /// @dev Protocol fees will never exceed uint128 max in either token\\n function protocolFees() external view returns (uint128 token0, uint128 token1);\\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 function liquidity() 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 the total amount of position liquidity that uses the pool either as tick lower or\\n /// tick upper,\\n /// liquidityNet how much liquidity changes when the pool price crosses the tick,\\n /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,\\n /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,\\n /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick\\n /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,\\n /// secondsOutside the seconds spent on the other side of the tick from the current tick,\\n /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.\\n /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.\\n /// In addition, these values are only relative and must be used only in comparison to previous snapshots for\\n /// a specific position.\\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 /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information\\n function tickBitmap(int16 wordPosition) external view returns (uint256);\\n\\n /// @notice Returns the information about a position by the position's key\\n /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper\\n /// @return _liquidity The amount of liquidity in the position,\\n /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,\\n /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,\\n /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,\\n /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke\\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 /// @notice Returns data about a specific observation index\\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 secondsPerLiquidityCumulativeX128 the seconds per in range liquidity 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 observations(uint256 index)\\n external\\n view\\n returns (\\n uint32 blockTimestamp,\\n int56 tickCumulative,\\n uint160 secondsPerLiquidityCumulativeX128,\\n bool initialized\\n );\\n}\\n\",\"keccak256\":\"0x852dc1f5df7dcf7f11e7bb3eed79f0cea72ad4b25f6a9d2c35aafb48925fd49f\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/FullMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.4.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 // 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;\\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 /// @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 result = mulDiv(a, b, denominator);\\n if (mulmod(a, b, denominator) > 0) {\\n require(result < type(uint256).max);\\n result++;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe511530871deaef86692cea9adb6076d26d7b47fd4815ce51af52af981026057\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/libraries/TickMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.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 uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\\n require(absTick <= uint256(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 /// @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 // 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\",\"keccak256\":\"0x1f864a2bf61ba05f3173eaf2e3f94c5e1da4bec0554757527b6d1ef1fe439e4e\",\"license\":\"GPL-2.0-or-later\"},\"contracts/core/Oracle.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\n\\n// uniswap Library only works under 0.7.6\\npragma solidity =0.7.6;\\n\\n//interface\\nimport {IUniswapV3Pool} from \\\"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\\\";\\nimport {IERC20Detailed} from \\\"../interfaces/IERC20Detailed.sol\\\";\\n\\n//library\\nimport {SafeMath} from \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport {Uint256Casting} from \\\"../libs/Uint256Casting.sol\\\";\\nimport {OracleLibrary} from \\\"../libs/OracleLibrary.sol\\\";\\n\\n/**\\n * @notice read UniswapV3 pool TWAP prices, and convert to human readable term with (18 decimals)\\n * @dev if ETH price is $3000, both ETH/USDC price and ETH/DAI price will be reported as 3000 * 1e18 by this oracle\\n */\\ncontract Oracle {\\n using SafeMath for uint256;\\n using Uint256Casting for uint256;\\n\\n uint128 private constant ONE = 1e18;\\n\\n /**\\n * @notice get twap converted with base & quote token decimals\\n * @dev if period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \\\"OLD\\\"\\n * @param _pool uniswap pool address\\n * @param _base base currency. to get eth/usd price, eth is base token\\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\\n * @param _period number of seconds in the past to start calculating time-weighted average\\n * @return price of 1 base currency in quote currency. scaled by 1e18\\n */\\n function getTwap(\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _period,\\n bool _checkPeriod\\n ) external view returns (uint256) {\\n // if the period is already checked, request TWAP directly. Will revert if period is too long.\\n if (!_checkPeriod) return _fetchTwap(_pool, _base, _quote, _period);\\n\\n // make sure the requested period < maxPeriod the pool recorded.\\n uint32 maxPeriod = _getMaxPeriod(_pool);\\n uint32 requestPeriod = _period > maxPeriod ? maxPeriod : _period;\\n return _fetchTwap(_pool, _base, _quote, requestPeriod);\\n }\\n\\n /**\\n * @notice get twap for a specific period of time, converted with base & quote token decimals\\n * @dev if the _secondsAgoToStartOfTwap period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \\\"OLD\\\"\\n * @param _pool uniswap pool address\\n * @param _base base currency. to get eth/usd price, eth is base token\\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\\n * @param _secondsAgoToStartOfTwap amount of seconds in the past to start calculating time-weighted average\\n * @param _secondsAgoToEndOfTwap amount of seconds in the past to end calculating time-weighted average\\n * @return price of 1 base currency in quote currency. scaled by 1e18\\n */\\n function getHistoricalTwap(\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _secondsAgoToStartOfTwap,\\n uint32 _secondsAgoToEndOfTwap\\n ) external view returns (uint256) {\\n return _fetchHistoricTwap(_pool, _base, _quote, _secondsAgoToStartOfTwap, _secondsAgoToEndOfTwap);\\n }\\n\\n /**\\n * @notice get the max period that can be used to request twap\\n * @param _pool uniswap pool address\\n * @return max period can be used to request twap\\n */\\n function getMaxPeriod(address _pool) external view returns (uint32) {\\n return _getMaxPeriod(_pool);\\n }\\n\\n /**\\n * @notice get time weighed average tick, not converted to price\\n * @dev this function will not revert\\n * @param _pool address of the pool\\n * @param _period period in second that we want to calculate average on\\n * @return timeWeightedAverageTick the time weighted average tick\\n */\\n function getTimeWeightedAverageTickSafe(address _pool, uint32 _period)\\n external\\n view\\n returns (int24 timeWeightedAverageTick)\\n {\\n uint32 maxPeriod = _getMaxPeriod(_pool);\\n uint32 requestPeriod = _period > maxPeriod ? maxPeriod : _period;\\n return OracleLibrary.consultAtHistoricTime(_pool, requestPeriod, 0);\\n }\\n\\n /**\\n * @notice get twap converted with base & quote token decimals\\n * @dev if period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \\\"OLD\\\"\\n * @param _pool uniswap pool address\\n * @param _base base currency. to get eth/usd price, eth is base token\\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\\n * @param _period number of seconds in the past to start calculating time-weighted average\\n * @return twap price which is scaled\\n */\\n function _fetchTwap(\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _period\\n ) internal view returns (uint256) {\\n uint256 quoteAmountOut = _fetchRawTwap(_pool, _base, _quote, _period);\\n\\n uint8 baseDecimals = IERC20Detailed(_base).decimals();\\n uint8 quoteDecimals = IERC20Detailed(_quote).decimals();\\n if (baseDecimals == quoteDecimals) return quoteAmountOut;\\n\\n // if quote token has less decimals, the returned quoteAmountOut will be lower, need to scale up by decimal difference\\n if (baseDecimals > quoteDecimals) return quoteAmountOut.mul(10**(baseDecimals - quoteDecimals));\\n\\n // if quote token has more decimals, the returned quoteAmountOut will be higher, need to scale down by decimal difference\\n return quoteAmountOut.div(10**(quoteDecimals - baseDecimals));\\n }\\n\\n /**\\n * @notice get raw twap from the uniswap pool\\n * @dev if period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \\\"OLD\\\".\\n * @param _pool uniswap pool address\\n * @param _base base currency. to get eth/usd price, eth is base token\\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\\n * @param _period number of seconds in the past to start calculating time-weighted average\\n * @return amount of quote currency received for _amountIn of base currency\\n */\\n function _fetchRawTwap(\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _period\\n ) internal view returns (uint256) {\\n int24 twapTick = OracleLibrary.consultAtHistoricTime(_pool, _period, 0);\\n return OracleLibrary.getQuoteAtTick(twapTick, ONE, _base, _quote);\\n }\\n\\n /**\\n * @notice get twap for a specific period of time, converted with base & quote token decimals\\n * @dev if the _secondsAgoToStartOfTwap period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \\\"OLD\\\"\\n * @param _pool uniswap pool address\\n * @param _base base currency. to get eth/usd price, eth is base token\\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\\n * @param _secondsAgoToStartOfTwap amount of seconds in the past to start calculating time-weighted average\\n * @param _secondsAgoToEndOfTwap amount of seconds in the past to end calculating time-weighted average\\n * @return price of 1 base currency in quote currency. scaled by 1e18\\n */\\n function _fetchHistoricTwap(\\n address _pool,\\n address _base,\\n address _quote,\\n uint32 _secondsAgoToStartOfTwap,\\n uint32 _secondsAgoToEndOfTwap\\n ) internal view returns (uint256) {\\n int24 twapTick = OracleLibrary.consultAtHistoricTime(_pool, _secondsAgoToStartOfTwap, _secondsAgoToEndOfTwap);\\n\\n return OracleLibrary.getQuoteAtTick(twapTick, ONE, _base, _quote);\\n }\\n\\n /**\\n * @notice get the max period that can be used to request twap\\n * @param _pool uniswap pool address\\n * @return max period can be used to request twap\\n */\\n function _getMaxPeriod(address _pool) internal view returns (uint32) {\\n IUniswapV3Pool pool = IUniswapV3Pool(_pool);\\n // observationIndex: the index of the last oracle observation that was written\\n // cardinality: the current maximum number of observations stored in the pool\\n (, , uint16 observationIndex, uint16 cardinality, , , ) = pool.slot0();\\n\\n // first observation index\\n // it's safe to use % without checking cardinality = 0 because cardinality is always >= 1\\n uint16 oldestObservationIndex = (observationIndex + 1) % cardinality;\\n\\n (uint32 oldestObservationTimestamp, , , bool initialized) = pool.observations(oldestObservationIndex);\\n\\n if (initialized) return uint32(block.timestamp) - oldestObservationTimestamp;\\n\\n // (index + 1) % cardinality is not the oldest index,\\n // probably because cardinality is increased after last observation.\\n // in this case, observation at index 0 should be the oldest.\\n (oldestObservationTimestamp, , , ) = pool.observations(0);\\n\\n return uint32(block.timestamp) - oldestObservationTimestamp;\\n }\\n}\\n\",\"keccak256\":\"0xc264ae8c3df6e1db22a95c30e3bbca563d4a351fbfc7d0428fb0da76567aa661\",\"license\":\"GPL-2.0-or-later\"},\"contracts/interfaces/IERC20Detailed.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n// uniswap Library only works under 0.7.6\\npragma solidity =0.7.6;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IERC20Detailed is IERC20 {\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0xcd59a0158d0711810c499904b9d37a71fdb34d1c4403f3cb67ca47de5e88bf7b\",\"license\":\"MIT\"},\"contracts/libs/OracleLibrary.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\n\\npragma solidity >=0.5.0 <0.8.0;\\n\\n//interface\\nimport \\\"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\\\";\\n\\n//lib\\nimport \\\"@uniswap/v3-core/contracts/libraries/FullMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/TickMath.sol\\\";\\n\\n/// @title oracle library\\n/// @notice provides functions to integrate with uniswap v3 oracle\\n/// @author uniswap team other than consultAtHistoricTime(), built by opyn\\nlibrary OracleLibrary {\\n /// @notice fetches time-weighted average tick using uniswap v3 oracle\\n /// @dev written by opyn team\\n /// @param pool Address of uniswap v3 pool that we want to observe\\n /// @param _secondsAgoToStartOfTwap number of seconds to start of TWAP period\\n /// @param _secondsAgoToEndOfTwap number of seconds to end of TWAP period\\n /// @return timeWeightedAverageTick The time-weighted average tick from (block.timestamp - _secondsAgoToStartOfTwap) to _secondsAgoToEndOfTwap\\n function consultAtHistoricTime(\\n address pool,\\n uint32 _secondsAgoToStartOfTwap,\\n uint32 _secondsAgoToEndOfTwap\\n ) internal view returns (int24) {\\n require(_secondsAgoToStartOfTwap > _secondsAgoToEndOfTwap, \\\"BP\\\");\\n int24 timeWeightedAverageTick;\\n uint32[] memory secondAgos = new uint32[](2);\\n\\n uint32 twapDuration = _secondsAgoToStartOfTwap - _secondsAgoToEndOfTwap;\\n\\n // get TWAP from (now - _secondsAgoToStartOfTwap) -> (now - _secondsAgoToEndOfTwap)\\n secondAgos[0] = _secondsAgoToStartOfTwap;\\n secondAgos[1] = _secondsAgoToEndOfTwap;\\n\\n (int56[] memory tickCumulatives, ) = IUniswapV3Pool(pool).observe(secondAgos);\\n int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];\\n\\n timeWeightedAverageTick = int24(tickCumulativesDelta / (twapDuration));\\n\\n // Always round to negative infinity\\n if (tickCumulativesDelta < 0 && (tickCumulativesDelta % (twapDuration) != 0)) timeWeightedAverageTick--;\\n\\n return timeWeightedAverageTick;\\n }\\n\\n /// @notice given a tick and a token amount, calculates the amount of token received in exchange\\n /// @param tick tick value used to calculate the quote\\n /// @param baseAmount amount of token to be converted\\n /// @param baseToken address of an ERC20 token contract used as the baseAmount denomination\\n /// @param quoteToken address of an ERC20 token contract used as the quoteAmount denomination\\n /// @return quoteAmount Amount of quoteToken received for baseAmount of baseToken\\n function getQuoteAtTick(\\n int24 tick,\\n uint128 baseAmount,\\n address baseToken,\\n address quoteToken\\n ) internal pure returns (uint256 quoteAmount) {\\n uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick);\\n\\n // Calculate quoteAmount with better precision if it doesn't overflow when multiplied by itself\\n if (sqrtRatioX96 <= type(uint128).max) {\\n uint256 ratioX192 = uint256(sqrtRatioX96) * sqrtRatioX96;\\n quoteAmount = baseToken < quoteToken\\n ? FullMath.mulDiv(ratioX192, baseAmount, 1 << 192)\\n : FullMath.mulDiv(1 << 192, baseAmount, ratioX192);\\n } else {\\n uint256 ratioX128 = FullMath.mulDiv(sqrtRatioX96, sqrtRatioX96, 1 << 64);\\n quoteAmount = baseToken < quoteToken\\n ? FullMath.mulDiv(ratioX128, baseAmount, 1 << 128)\\n : FullMath.mulDiv(1 << 128, baseAmount, ratioX128);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x83858224ba4dc88b7ab7f26de42c32d2debfd48a59bd5d011afe7be5d7cbb24f\",\"license\":\"GPL-2.0-or-later\"},\"contracts/libs/Uint256Casting.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nlibrary Uint256Casting {\\n /**\\n * @notice cast a uint256 to a uint128, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint128\\n */\\n function toUint128(uint256 y) internal pure returns (uint128 z) {\\n require((z = uint128(y)) == y, \\\"OF128\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint96, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint96\\n */\\n function toUint96(uint256 y) internal pure returns (uint96 z) {\\n require((z = uint96(y)) == y, \\\"OF96\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint32, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint32\\n */\\n function toUint32(uint256 y) internal pure returns (uint32 z) {\\n require((z = uint32(y)) == y, \\\"OF32\\\");\\n }\\n}\\n\",\"keccak256\":\"0xcccbe82f8696be398d0d0f5a44988e9bab70e18dd40c9563620cdf160d8bcd7c\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50610edc806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80634a0a96eb146100515780634ac78d111461009a578063cce79bd5146100f6578063de5a6e2214610140575b600080fd5b6100836004803603604081101561006757600080fd5b5080356001600160a01b0316906020013563ffffffff1661017f565b6040805160029290920b8252519081900360200190f35b6100e4600480360360a08110156100b057600080fd5b506001600160a01b03813581169160208101358216916040820135169063ffffffff606082013581169160800135166101c3565b60408051918252519081900360200190f35b6100e4600480360360a081101561010c57600080fd5b506001600160a01b03813581169160208101358216916040820135169063ffffffff606082013516906080013515156101de565b6101666004803603602081101561015657600080fd5b50356001600160a01b031661023c565b6040805163ffffffff9092168252519081900360200190f35b60008061018b8461024f565b905060008163ffffffff168463ffffffff16116101a857836101aa565b815b90506101b8858260006103fb565b925050505b92915050565b60006101d28686868686610713565b90505b95945050505050565b6000816101f8576101f186868686610742565b90506101d5565b60006102038761024f565b905060008163ffffffff168563ffffffff16116102205784610222565b815b905061023088888884610742565b98975050505050505050565b60006102478261024f565b90505b919050565b600080829050600080826001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561029157600080fd5b505afa1580156102a5573d6000803e3d6000fd5b505050506040513d60e08110156102bb57600080fd5b5060408101516060909101519092509050600061ffff808316906001850116816102e157fe5b069050600080856001600160a01b031663252c09d7846040518263ffffffff1660e01b8152600401808261ffff16815260200191505060806040518083038186803b15801561032f57600080fd5b505afa158015610343573d6000803e3d6000fd5b505050506040513d608081101561035957600080fd5b5080516060909101519092509050801561037c57504203945061024a9350505050565b856001600160a01b031663252c09d760006040518263ffffffff1660e01b81526004018082815260200191505060806040518083038186803b1580156103c157600080fd5b505afa1580156103d5573d6000803e3d6000fd5b505050506040513d60808110156103eb57600080fd5b5051420398975050505050505050565b60008163ffffffff168363ffffffff1611610442576040805162461bcd60e51b8152602060048201526002602482015261042560f41b604482015290519081900360640190fd5b6040805160028082526060820183526000928392919060208301908036833701905050905060008486039050858260008151811061047c57fe5b602002602001019063ffffffff16908163ffffffff168152505084826001815181106104a457fe5b63ffffffff90921660209283029190910182015260405163883bdbfd60e01b8152600481018281528451602483015284516000936001600160a01b038c169363883bdbfd938893909283926044019185820191028083838b5b838110156105155781810151838201526020016104fd565b505050509050019250505060006040518083038186803b15801561053857600080fd5b505afa15801561054c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561057557600080fd5b810190808051604051939291908464010000000082111561059557600080fd5b9083019060208201858111156105aa57600080fd5b82518660208202830111640100000000821117156105c757600080fd5b82525081516020918201928201910280838360005b838110156105f45781810151838201526020016105dc565b505050509050016040526020018051604051939291908464010000000082111561061d57600080fd5b90830190602082018581111561063257600080fd5b825186602082028301116401000000008211171561064f57600080fd5b82525081516020918201928201910280838360005b8381101561067c578181015183820152602001610664565b5050505090500160405250505050905060008160008151811061069b57fe5b6020026020010151826001815181106106b057fe5b60200260200101510390508263ffffffff168160060b816106cd57fe5b05945060008160060b1280156106f757508263ffffffff168160060b816106f057fe5b0760060b15155b1561070457600019909401935b509293505050505b9392505050565b6000806107218785856103fb565b905061073781670de0b6b3a76400008888610891565b979650505050505050565b600080610751868686866109b5565b90506000856001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561078e57600080fd5b505afa1580156107a2573d6000803e3d6000fd5b505050506040513d60208110156107b857600080fd5b50516040805163313ce56760e01b815290519192506000916001600160a01b0388169163313ce567916004808301926020929190829003018186803b15801561080057600080fd5b505afa158015610814573d6000803e3d6000fd5b505050506040513d602081101561082a57600080fd5b5051905060ff828116908216141561084757829350505050610889565b8060ff168260ff161115610871576108678360ff83850316600a0a6109e4565b9350505050610889565b6108838360ff84840316600a0a610a3d565b93505050505b949350505050565b60008061089d86610aa4565b90506fffffffffffffffffffffffffffffffff6001600160a01b03821611610927576001600160a01b03808216800290848116908616106108fe576108f9600160c01b876fffffffffffffffffffffffffffffffff1683610dd6565b61091f565b61091f81876fffffffffffffffffffffffffffffffff16600160c01b610dd6565b9250506109ac565b60006109466001600160a01b0383168068010000000000000000610dd6565b9050836001600160a01b0316856001600160a01b03161061098757610982600160801b876fffffffffffffffffffffffffffffffff1683610dd6565b6109a8565b6109a881876fffffffffffffffffffffffffffffffff16600160801b610dd6565b9250505b50949350505050565b6000806109c4868460006103fb565b90506109da81670de0b6b3a76400008787610891565b9695505050505050565b6000826109f3575060006101bd565b82820282848281610a0057fe5b041461070c5760405162461bcd60e51b8152600401808060200182810382526021815260200180610e866021913960400191505060405180910390fd5b6000808211610a93576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381610a9c57fe5b049392505050565b60008060008360020b12610abb578260020b610ac3565b8260020b6000035b9050620d89e8811115610b01576040805162461bcd60e51b81526020600482015260016024820152601560fa1b604482015290519081900360640190fd5b600060018216610b1557600160801b610b27565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615610b5b576ffff97272373d413259a46990580e213a0260801c5b6004821615610b7a576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615610b99576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615610bb8576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615610bd7576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615610bf6576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615610c15576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615610c35576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615610c55576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615610c75576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615610c95576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615610cb5576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615610cd5576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615610cf5576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615610d15576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615610d36576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615610d56576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615610d75576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615610d92576b048a170391f7dc42444e8fa20260801c5b60008460020b1315610dad578060001981610da957fe5b0490505b640100000000810615610dc1576001610dc4565b60005b60ff16602082901c0192505050919050565b6000808060001985870986860292508281109083900303905080610e0c5760008411610e0157600080fd5b50829004905061070c565b808411610e1857600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a0290910302918190038190046001018684119095039490940291909403929092049190911791909102915050939250505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220b1a443112ea45879a00fbc518b3cc36f190c9940d1022cd43a38928e460276ce64736f6c63430007060033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80634a0a96eb146100515780634ac78d111461009a578063cce79bd5146100f6578063de5a6e2214610140575b600080fd5b6100836004803603604081101561006757600080fd5b5080356001600160a01b0316906020013563ffffffff1661017f565b6040805160029290920b8252519081900360200190f35b6100e4600480360360a08110156100b057600080fd5b506001600160a01b03813581169160208101358216916040820135169063ffffffff606082013581169160800135166101c3565b60408051918252519081900360200190f35b6100e4600480360360a081101561010c57600080fd5b506001600160a01b03813581169160208101358216916040820135169063ffffffff606082013516906080013515156101de565b6101666004803603602081101561015657600080fd5b50356001600160a01b031661023c565b6040805163ffffffff9092168252519081900360200190f35b60008061018b8461024f565b905060008163ffffffff168463ffffffff16116101a857836101aa565b815b90506101b8858260006103fb565b925050505b92915050565b60006101d28686868686610713565b90505b95945050505050565b6000816101f8576101f186868686610742565b90506101d5565b60006102038761024f565b905060008163ffffffff168563ffffffff16116102205784610222565b815b905061023088888884610742565b98975050505050505050565b60006102478261024f565b90505b919050565b600080829050600080826001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561029157600080fd5b505afa1580156102a5573d6000803e3d6000fd5b505050506040513d60e08110156102bb57600080fd5b5060408101516060909101519092509050600061ffff808316906001850116816102e157fe5b069050600080856001600160a01b031663252c09d7846040518263ffffffff1660e01b8152600401808261ffff16815260200191505060806040518083038186803b15801561032f57600080fd5b505afa158015610343573d6000803e3d6000fd5b505050506040513d608081101561035957600080fd5b5080516060909101519092509050801561037c57504203945061024a9350505050565b856001600160a01b031663252c09d760006040518263ffffffff1660e01b81526004018082815260200191505060806040518083038186803b1580156103c157600080fd5b505afa1580156103d5573d6000803e3d6000fd5b505050506040513d60808110156103eb57600080fd5b5051420398975050505050505050565b60008163ffffffff168363ffffffff1611610442576040805162461bcd60e51b8152602060048201526002602482015261042560f41b604482015290519081900360640190fd5b6040805160028082526060820183526000928392919060208301908036833701905050905060008486039050858260008151811061047c57fe5b602002602001019063ffffffff16908163ffffffff168152505084826001815181106104a457fe5b63ffffffff90921660209283029190910182015260405163883bdbfd60e01b8152600481018281528451602483015284516000936001600160a01b038c169363883bdbfd938893909283926044019185820191028083838b5b838110156105155781810151838201526020016104fd565b505050509050019250505060006040518083038186803b15801561053857600080fd5b505afa15801561054c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561057557600080fd5b810190808051604051939291908464010000000082111561059557600080fd5b9083019060208201858111156105aa57600080fd5b82518660208202830111640100000000821117156105c757600080fd5b82525081516020918201928201910280838360005b838110156105f45781810151838201526020016105dc565b505050509050016040526020018051604051939291908464010000000082111561061d57600080fd5b90830190602082018581111561063257600080fd5b825186602082028301116401000000008211171561064f57600080fd5b82525081516020918201928201910280838360005b8381101561067c578181015183820152602001610664565b5050505090500160405250505050905060008160008151811061069b57fe5b6020026020010151826001815181106106b057fe5b60200260200101510390508263ffffffff168160060b816106cd57fe5b05945060008160060b1280156106f757508263ffffffff168160060b816106f057fe5b0760060b15155b1561070457600019909401935b509293505050505b9392505050565b6000806107218785856103fb565b905061073781670de0b6b3a76400008888610891565b979650505050505050565b600080610751868686866109b5565b90506000856001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561078e57600080fd5b505afa1580156107a2573d6000803e3d6000fd5b505050506040513d60208110156107b857600080fd5b50516040805163313ce56760e01b815290519192506000916001600160a01b0388169163313ce567916004808301926020929190829003018186803b15801561080057600080fd5b505afa158015610814573d6000803e3d6000fd5b505050506040513d602081101561082a57600080fd5b5051905060ff828116908216141561084757829350505050610889565b8060ff168260ff161115610871576108678360ff83850316600a0a6109e4565b9350505050610889565b6108838360ff84840316600a0a610a3d565b93505050505b949350505050565b60008061089d86610aa4565b90506fffffffffffffffffffffffffffffffff6001600160a01b03821611610927576001600160a01b03808216800290848116908616106108fe576108f9600160c01b876fffffffffffffffffffffffffffffffff1683610dd6565b61091f565b61091f81876fffffffffffffffffffffffffffffffff16600160c01b610dd6565b9250506109ac565b60006109466001600160a01b0383168068010000000000000000610dd6565b9050836001600160a01b0316856001600160a01b03161061098757610982600160801b876fffffffffffffffffffffffffffffffff1683610dd6565b6109a8565b6109a881876fffffffffffffffffffffffffffffffff16600160801b610dd6565b9250505b50949350505050565b6000806109c4868460006103fb565b90506109da81670de0b6b3a76400008787610891565b9695505050505050565b6000826109f3575060006101bd565b82820282848281610a0057fe5b041461070c5760405162461bcd60e51b8152600401808060200182810382526021815260200180610e866021913960400191505060405180910390fd5b6000808211610a93576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381610a9c57fe5b049392505050565b60008060008360020b12610abb578260020b610ac3565b8260020b6000035b9050620d89e8811115610b01576040805162461bcd60e51b81526020600482015260016024820152601560fa1b604482015290519081900360640190fd5b600060018216610b1557600160801b610b27565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615610b5b576ffff97272373d413259a46990580e213a0260801c5b6004821615610b7a576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615610b99576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615610bb8576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615610bd7576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615610bf6576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615610c15576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615610c35576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615610c55576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615610c75576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615610c95576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615610cb5576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615610cd5576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615610cf5576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615610d15576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615610d36576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615610d56576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615610d75576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615610d92576b048a170391f7dc42444e8fa20260801c5b60008460020b1315610dad578060001981610da957fe5b0490505b640100000000810615610dc1576001610dc4565b60005b60ff16602082901c0192505050919050565b6000808060001985870986860292508281109083900303905080610e0c5760008411610e0157600080fd5b50829004905061070c565b808411610e1857600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a0290910302918190038190046001018684119095039490940291909403929092049190911791909102915050939250505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220b1a443112ea45879a00fbc518b3cc36f190c9940d1022cd43a38928e460276ce64736f6c63430007060033", "devdoc": { "details": "if ETH price is $3000, both ETH/USDC price and ETH/DAI price will be reported as 3000 * 1e18 by this oracle", "kind": "dev", diff --git a/packages/hardhat/deployments/mainnet/ShortHelper.json b/packages/hardhat/deployments/mainnet/ShortHelper.json index 0b1480736..977978fa0 100644 --- a/packages/hardhat/deployments/mainnet/ShortHelper.json +++ b/packages/hardhat/deployments/mainnet/ShortHelper.json @@ -1,5 +1,5 @@ { - "address": "0x9E9fd8A934107Cd0BABf3001981B90243dDe4E98", + "address": "0x3b4095D5ff0e629972CAAa50bd3004B09a1632C5", "abi": [ { "inputs": [ @@ -266,60 +266,60 @@ "type": "receive" } ], - "transactionHash": "0x785b467e47011f1ab417a50c98bd4dd82cbeb58f3c5c1b9540fa024f8c454aa7", + "transactionHash": "0xed01b8ac049e86818eb3195840f6bf167bb7d84916dd12d66d4287dbcc6f4a76", "receipt": { "to": null, - "from": "0x80010e7575b24f47097598474502F0fd0aDbF3a8", - "contractAddress": "0x9E9fd8A934107Cd0BABf3001981B90243dDe4E98", - "transactionIndex": 20, - "gasUsed": "1097949", - "logsBloom": "0x00000002000000000000000000000100000000000000000000000000000000000000000000000000000000000000000002000000080000000000000000200000000000000000000000000000000000000000000000000000000000000000010000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000020000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000010200000000020000000000000000000000000000000000000080000000000", - "blockHash": "0x498192d05edd585fa144dc96c505851e4a3082f3c12c2d17ffb281970392847b", - "transactionHash": "0x785b467e47011f1ab417a50c98bd4dd82cbeb58f3c5c1b9540fa024f8c454aa7", + "from": "0xa3cB04d8BD927EEC8826BD77b7C71abE3d29c081", + "contractAddress": "0x3b4095D5ff0e629972CAAa50bd3004B09a1632C5", + "transactionIndex": 131, + "gasUsed": "1067532", + "logsBloom": "0x00000002000000000000000000000000000000000000000000000100000000000000100000000000000000000000000002000000080000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000004100000100000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000020000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010200000000000000000000000000800000000000000000000000000000000", + "blockHash": "0x22e5959137a7afadb6ba777526b440f8a2d8840c13406f506a02924f765a064e", + "transactionHash": "0xed01b8ac049e86818eb3195840f6bf167bb7d84916dd12d66d4287dbcc6f4a76", "logs": [ { - "transactionIndex": 20, - "blockNumber": 13977505, - "transactionHash": "0x785b467e47011f1ab417a50c98bd4dd82cbeb58f3c5c1b9540fa024f8c454aa7", - "address": "0x4a49c7aC69de6cf23da5872b7A7c7D2f2D48fC87", + "transactionIndex": 131, + "blockNumber": 13982573, + "transactionHash": "0xed01b8ac049e86818eb3195840f6bf167bb7d84916dd12d66d4287dbcc6f4a76", + "address": "0xf1B99e3E573A1a9C5E6B2Ce818b617F0E664E86B", "topics": [ "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x0000000000000000000000009e9fd8a934107cd0babf3001981b90243dde4e98", + "0x0000000000000000000000003b4095d5ff0e629972caaa50bd3004b09a1632c5", "0x000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564" ], "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 10, - "blockHash": "0x498192d05edd585fa144dc96c505851e4a3082f3c12c2d17ffb281970392847b" + "logIndex": 178, + "blockHash": "0x22e5959137a7afadb6ba777526b440f8a2d8840c13406f506a02924f765a064e" }, { - "transactionIndex": 20, - "blockNumber": 13977505, - "transactionHash": "0x785b467e47011f1ab417a50c98bd4dd82cbeb58f3c5c1b9540fa024f8c454aa7", + "transactionIndex": 131, + "blockNumber": 13982573, + "transactionHash": "0xed01b8ac049e86818eb3195840f6bf167bb7d84916dd12d66d4287dbcc6f4a76", "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "topics": [ "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x0000000000000000000000009e9fd8a934107cd0babf3001981b90243dde4e98", + "0x0000000000000000000000003b4095d5ff0e629972caaa50bd3004b09a1632c5", "0x000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564" ], "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 11, - "blockHash": "0x498192d05edd585fa144dc96c505851e4a3082f3c12c2d17ffb281970392847b" + "logIndex": 179, + "blockHash": "0x22e5959137a7afadb6ba777526b440f8a2d8840c13406f506a02924f765a064e" } ], - "blockNumber": 13977505, - "cumulativeGasUsed": "1876146", + "blockNumber": 13982573, + "cumulativeGasUsed": "10719031", "status": 1, "byzantium": true }, "args": [ - "0x0344f8706947321FA87881D3DaD0EB1b8C65E732", + "0x64187ae08781B09368e6253F9E94951243A493D5", "0xE592427A0AEce92De3Edee1F18E0157C05861564", "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" ], - "solcInputHash": "56b4ec4ab07157f3d2fb7e1de805d93e", - "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_controllerAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_swapRouter\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_wethAddr\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_wPowerPerpAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_withdrawAmount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"tokenIn\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenOut\",\"type\":\"address\"},{\"internalType\":\"uint24\",\"name\":\"fee\",\"type\":\"uint24\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountInMaximum\",\"type\":\"uint256\"},{\"internalType\":\"uint160\",\"name\":\"sqrtPriceLimitX96\",\"type\":\"uint160\"}],\"internalType\":\"struct ISwapRouter.ExactOutputSingleParams\",\"name\":\"_exactOutputParams\",\"type\":\"tuple\"}],\"name\":\"closeShort\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controller\",\"outputs\":[{\"internalType\":\"contract IController\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC721Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_powerPerpAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_uniNftId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"tokenIn\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenOut\",\"type\":\"address\"},{\"internalType\":\"uint24\",\"name\":\"fee\",\"type\":\"uint24\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountOutMinimum\",\"type\":\"uint256\"},{\"internalType\":\"uint160\",\"name\":\"sqrtPriceLimitX96\",\"type\":\"uint160\"}],\"internalType\":\"struct ISwapRouter.ExactInputSingleParams\",\"name\":\"_exactInputParams\",\"type\":\"tuple\"}],\"name\":\"openShort\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"router\",\"outputs\":[{\"internalType\":\"contract ISwapRouter\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"shortPowerPerp\",\"outputs\":[{\"internalType\":\"contract IShortPowerPerp\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wPowerPerp\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"weth\",\"outputs\":[{\"internalType\":\"contract IWETH9\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"closeShort(uint256,uint256,uint256,(address,address,uint24,address,uint256,uint256,uint256,uint160))\":{\"params\":{\"_vaultId\":\"short wPowerPerp vault id\",\"_wPowerPerpAmount\":\"amount of wPowerPerp to burn\",\"_withdrawAmount\":\"amount to withdraw\"}},\"constructor\":{\"params\":{\"_controllerAddr\":\"controller address for wPowerPerp\",\"_swapRouter\":\"uniswap v3 swap router address\",\"_wethAddr\":\"weth address\"}},\"onERC721Received(address,address,uint256,bytes)\":{\"details\":\"accept erc721 from safeTransferFrom and safeMint after callback\",\"returns\":{\"_0\":\"returns received selector\"}},\"openShort(uint256,uint256,uint256,(address,address,uint24,address,uint256,uint256,uint256,uint160))\":{\"params\":{\"_powerPerpAmount\":\"amount of powerPerp to mint/sell\",\"_uniNftId\":\"uniswap v3 position token id\",\"_vaultId\":\"short wPowerPerp vault id\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"closeShort(uint256,uint256,uint256,(address,address,uint24,address,uint256,uint256,uint256,uint160))\":{\"notice\":\"buy back wPowerPerp with eth on uniswap v3 and close position\"},\"constructor\":{\"notice\":\"constructor for short helper\"},\"openShort(uint256,uint256,uint256,(address,address,uint24,address,uint256,uint256,uint256,uint160))\":{\"notice\":\"mint power perp, trade with uniswap v3 and send back premium in eth\"}},\"notice\":\"contract simplifies opening a short wPowerPerp position by selling wPowerPerp on uniswap v3 and returning eth to user\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/periphery/ShortHelper.sol\":\"ShortHelper\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":850},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd2f30fad5b24c4120f96dbac83aacdb7993ee610a9092bc23c44463da292bf8d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0xe22a1fc7400ae196eba2ad1562d0386462b00a6363b742d55a2fd2021a58586f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0xbd74f587ab9b9711801baf667db1426e4a03fd2d7f15af33e0e0d0394e7cef76\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"../../introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\\n}\\n\",\"keccak256\":\"0xb11597841d47f7a773bca63ca323c76f804cb5d944788de0327db5526319dc82\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Enumerable is IERC721 {\\n\\n /**\\n * @dev Returns the total amount of tokens stored by the contract.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\\n */\\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);\\n\\n /**\\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\\n * Use along with {totalSupply} to enumerate all tokens.\\n */\\n function tokenByIndex(uint256 index) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x2789dfea2d73182683d637db5729201f6730dae6113030a94c828f8688f38f2f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Metadata is IERC721 {\\n\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0xc82c7d1d732081d9bd23f1555ebdf8f3bc1738bc42c2bfc4b9aa7564d9fa3573\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\\n */\\n function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0x05604ffcf69e416b8a42728bb0e4fd75170d8fac70bf1a284afeb4752a9bc52f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf89f005a3d98f7768cdee2583707db0ac725cf567d455751af32ee68132f3db3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor () {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and make it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0x1153f6dd334c01566417b8c551122450542a2b75a2bbb379d59a8c320ed6da28\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/interfaces/callback/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\"},\"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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;\\n}\\n\",\"keccak256\":\"0x0ba8a9b95a956a4050749c0158e928398c447c91469682ca8a7cc7e77a7fe032\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/FullMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.4.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 // 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;\\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 /// @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 result = mulDiv(a, b, denominator);\\n if (mulmod(a, b, denominator) > 0) {\\n require(result < type(uint256).max);\\n result++;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe511530871deaef86692cea9adb6076d26d7b47fd4815ce51af52af981026057\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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\":\"0x86715eb960f18e01ac94e3bba4614ed51a887fa3c5bd1c43bf80aa98e019cf2d\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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\":\"0x4c12bf820c0b011f5490a209960ca34dd8af34660ef9e01de0438393d15e3fd8\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/SqrtPriceMath.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity >=0.5.0;\\n\\nimport './LowGasSafeMath.sol';\\nimport './SafeCast.sol';\\n\\nimport './FullMath.sol';\\nimport './UnsafeMath.sol';\\nimport './FixedPoint96.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 if (add) {\\n uint256 product;\\n if ((product = amount * sqrtPX96) / amount == sqrtPX96) {\\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 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 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 (\\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 (\\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\\n require(sqrtRatioAX96 > 0);\\n\\n return\\n roundUp\\n ? UnsafeMath.divRoundingUp(\\n FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96),\\n sqrtRatioAX96\\n )\\n : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96;\\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\":\"0x4f69701d331d364b69a1cda77cd7b983a0079d36ae0e06b0bb1d64ae56c3705e\",\"license\":\"BUSL-1.1\"},\"@uniswap/v3-core/contracts/libraries/TickMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.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 uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\\n require(absTick <= uint256(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 /// @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 // 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\",\"keccak256\":\"0x1f864a2bf61ba05f3173eaf2e3f94c5e1da4bec0554757527b6d1ef1fe439e4e\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/UnsafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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\":\"0x5f36d7d16348d8c37fe64fda932018d6e5e8acecd054f0f97d32db62d20c6c88\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IERC721Permit.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\n\\nimport '@openzeppelin/contracts/token/ERC721/IERC721.sol';\\n\\n/// @title ERC721 with permit\\n/// @notice Extension to ERC721 that includes a permit function for signature based approvals\\ninterface IERC721Permit is IERC721 {\\n /// @notice The permit typehash used in the permit signature\\n /// @return The typehash for the permit\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n\\n /// @notice The domain separator used in the permit signature\\n /// @return The domain seperator used in encoding of permit signature\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Approve of a specific token ID for spending by spender via signature\\n /// @param spender The account that is being approved\\n /// @param tokenId The ID of the token that is being approved for spending\\n /// @param deadline The deadline timestamp by which the call must be mined for the approve to work\\n /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`\\n /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`\\n /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`\\n function permit(\\n address spender,\\n uint256 tokenId,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable;\\n}\\n\",\"keccak256\":\"0x9e3c2a4ee65ddf95b2dfcb0815784eea3a295707e6f8b83e4c4f0f8fe2e3a1d4\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\nimport '@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol';\\nimport '@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol';\\n\\nimport './IPoolInitializer.sol';\\nimport './IERC721Permit.sol';\\nimport './IPeripheryPayments.sol';\\nimport './IPeripheryImmutableState.sol';\\nimport '../libraries/PoolAddress.sol';\\n\\n/// @title Non-fungible token for positions\\n/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred\\n/// and authorized.\\ninterface INonfungiblePositionManager is\\n IPoolInitializer,\\n IPeripheryPayments,\\n IPeripheryImmutableState,\\n IERC721Metadata,\\n IERC721Enumerable,\\n IERC721Permit\\n{\\n /// @notice Emitted when liquidity is increased for a position NFT\\n /// @dev Also emitted when a token is minted\\n /// @param tokenId The ID of the token for which liquidity was increased\\n /// @param liquidity The amount by which liquidity for the NFT position was increased\\n /// @param amount0 The amount of token0 that was paid for the increase in liquidity\\n /// @param amount1 The amount of token1 that was paid for the increase in liquidity\\n event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\\n /// @notice Emitted when liquidity is decreased for a position NFT\\n /// @param tokenId The ID of the token for which liquidity was decreased\\n /// @param liquidity The amount by which liquidity for the NFT position was decreased\\n /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity\\n /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity\\n event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\\n /// @notice Emitted when tokens are collected for a position NFT\\n /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior\\n /// @param tokenId The ID of the token for which underlying tokens were collected\\n /// @param recipient The address of the account that received the collected tokens\\n /// @param amount0 The amount of token0 owed to the position that was collected\\n /// @param amount1 The amount of token1 owed to the position that was collected\\n event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);\\n\\n /// @notice Returns the position information associated with a given token ID.\\n /// @dev Throws if the token ID is not valid.\\n /// @param tokenId The ID of the token that represents the position\\n /// @return nonce The nonce for permits\\n /// @return operator The address that is approved for spending\\n /// @return token0 The address of the token0 for a specific pool\\n /// @return token1 The address of the token1 for a specific pool\\n /// @return fee The fee associated with the pool\\n /// @return tickLower The lower end of the tick range for the position\\n /// @return tickUpper The higher end of the tick range for the position\\n /// @return liquidity The liquidity of the position\\n /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position\\n /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position\\n /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation\\n /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation\\n function positions(uint256 tokenId)\\n external\\n view\\n returns (\\n uint96 nonce,\\n address operator,\\n address token0,\\n address token1,\\n uint24 fee,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n uint256 feeGrowthInside0LastX128,\\n uint256 feeGrowthInside1LastX128,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n );\\n\\n struct MintParams {\\n address token0;\\n address token1;\\n uint24 fee;\\n int24 tickLower;\\n int24 tickUpper;\\n uint256 amount0Desired;\\n uint256 amount1Desired;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n address recipient;\\n uint256 deadline;\\n }\\n\\n /// @notice Creates a new position wrapped in a NFT\\n /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized\\n /// a method does not exist, i.e. the pool is assumed to be initialized.\\n /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata\\n /// @return tokenId The ID of the token that represents the minted position\\n /// @return liquidity The amount of liquidity for this position\\n /// @return amount0 The amount of token0\\n /// @return amount1 The amount of token1\\n function mint(MintParams calldata params)\\n external\\n payable\\n returns (\\n uint256 tokenId,\\n uint128 liquidity,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n struct IncreaseLiquidityParams {\\n uint256 tokenId;\\n uint256 amount0Desired;\\n uint256 amount1Desired;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n uint256 deadline;\\n }\\n\\n /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`\\n /// @param params tokenId The ID of the token for which liquidity is being increased,\\n /// amount0Desired The desired amount of token0 to be spent,\\n /// amount1Desired The desired amount of token1 to be spent,\\n /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,\\n /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,\\n /// deadline The time by which the transaction must be included to effect the change\\n /// @return liquidity The new liquidity amount as a result of the increase\\n /// @return amount0 The amount of token0 to acheive resulting liquidity\\n /// @return amount1 The amount of token1 to acheive resulting liquidity\\n function increaseLiquidity(IncreaseLiquidityParams calldata params)\\n external\\n payable\\n returns (\\n uint128 liquidity,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n struct DecreaseLiquidityParams {\\n uint256 tokenId;\\n uint128 liquidity;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n uint256 deadline;\\n }\\n\\n /// @notice Decreases the amount of liquidity in a position and accounts it to the position\\n /// @param params tokenId The ID of the token for which liquidity is being decreased,\\n /// amount The amount by which liquidity will be decreased,\\n /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,\\n /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,\\n /// deadline The time by which the transaction must be included to effect the change\\n /// @return amount0 The amount of token0 accounted to the position's tokens owed\\n /// @return amount1 The amount of token1 accounted to the position's tokens owed\\n function decreaseLiquidity(DecreaseLiquidityParams calldata params)\\n external\\n payable\\n returns (uint256 amount0, uint256 amount1);\\n\\n struct CollectParams {\\n uint256 tokenId;\\n address recipient;\\n uint128 amount0Max;\\n uint128 amount1Max;\\n }\\n\\n /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient\\n /// @param params tokenId The ID of the NFT for which tokens are being collected,\\n /// recipient The account that should receive the tokens,\\n /// amount0Max The maximum amount of token0 to collect,\\n /// amount1Max The maximum amount of token1 to collect\\n /// @return amount0 The amount of fees collected in token0\\n /// @return amount1 The amount of fees collected in token1\\n function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens\\n /// must be collected first.\\n /// @param tokenId The ID of the token that is being burned\\n function burn(uint256 tokenId) external payable;\\n}\\n\",\"keccak256\":\"0xe1dadc73e60bf05d0b4e0f05bd2847c5783e833cc10352c14763360b13495ee1\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPeripheryImmutableState.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Immutable state\\n/// @notice Functions that return immutable state of the router\\ninterface IPeripheryImmutableState {\\n /// @return Returns the address of the Uniswap V3 factory\\n function factory() external view returns (address);\\n\\n /// @return Returns the address of WETH9\\n function WETH9() external view returns (address);\\n}\\n\",\"keccak256\":\"0x7affcfeb5127c0925a71d6a65345e117c33537523aeca7bc98085ead8452519d\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPeripheryPayments.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\n\\n/// @title Periphery Payments\\n/// @notice Functions to ease deposits and withdrawals of ETH\\ninterface IPeripheryPayments {\\n /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.\\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.\\n /// @param amountMinimum The minimum amount of WETH9 to unwrap\\n /// @param recipient The address receiving ETH\\n function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;\\n\\n /// @notice Refunds any ETH balance held by this contract to the `msg.sender`\\n /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps\\n /// that use ether for the input amount\\n function refundETH() external payable;\\n\\n /// @notice Transfers the full amount of a token held by this contract to recipient\\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users\\n /// @param token The contract address of the token which will be transferred to `recipient`\\n /// @param amountMinimum The minimum amount of token required for a transfer\\n /// @param recipient The destination address of the token\\n function sweepToken(\\n address token,\\n uint256 amountMinimum,\\n address recipient\\n ) external payable;\\n}\\n\",\"keccak256\":\"0xb547e10f1e69bed03621a62b73a503e260643066c6b4054867a4d1fef47eb274\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPoolInitializer.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\n/// @title Creates and initializes V3 Pools\\n/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that\\n/// require the pool to exist.\\ninterface IPoolInitializer {\\n /// @notice Creates a new pool if it does not exist, then initializes if not initialized\\n /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool\\n /// @param token0 The contract address of token0 of the pool\\n /// @param token1 The contract address of token1 of the pool\\n /// @param fee The fee amount of the v3 pool for the specified token pair\\n /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value\\n /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary\\n function createAndInitializePoolIfNecessary(\\n address token0,\\n address token1,\\n uint24 fee,\\n uint160 sqrtPriceX96\\n ) external payable returns (address pool);\\n}\\n\",\"keccak256\":\"0x9d7695e8d94c22cc5fcced602017aabb988de89981ea7bee29ea629d5328a862\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\nimport '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';\\n\\n/// @title Router token swapping functionality\\n/// @notice Functions for swapping tokens via Uniswap V3\\ninterface ISwapRouter is IUniswapV3SwapCallback {\\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 /// @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 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\",\"keccak256\":\"0x9bfaf1feb32814623e627ab70f2409760b15d95f1f9b058e2b3399a8bb732975\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee\\nlibrary PoolAddress {\\n bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;\\n\\n /// @notice The identifying key of the pool\\n struct PoolKey {\\n address token0;\\n address token1;\\n uint24 fee;\\n }\\n\\n /// @notice Returns PoolKey: the ordered tokens with the matched fee levels\\n /// @param tokenA The first token of a pool, unsorted\\n /// @param tokenB The second token of a pool, unsorted\\n /// @param fee The fee level of the pool\\n /// @return Poolkey The pool details with ordered token0 and token1 assignments\\n function getPoolKey(\\n address tokenA,\\n address tokenB,\\n uint24 fee\\n ) internal pure returns (PoolKey memory) {\\n if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);\\n return PoolKey({token0: tokenA, token1: tokenB, fee: fee});\\n }\\n\\n /// @notice Deterministically computes the pool address given the factory and PoolKey\\n /// @param factory The Uniswap V3 factory contract address\\n /// @param key The PoolKey\\n /// @return pool The contract address of the V3 pool\\n function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {\\n require(key.token0 < key.token1);\\n pool = address(\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n hex'ff',\\n factory,\\n keccak256(abi.encode(key.token0, key.token1, key.fee)),\\n POOL_INIT_CODE_HASH\\n )\\n )\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x5edd84eb8ba7c12fd8cb6cffe52e1e9f3f6464514ee5f539c2283826209035a2\",\"license\":\"GPL-2.0-or-later\"},\"contracts/interfaces/IController.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\npragma abicoder v2;\\n\\nimport {VaultLib} from \\\"../libs/VaultLib.sol\\\";\\n\\ninterface IController {\\n function ethQuoteCurrencyPool() external view returns (address);\\n\\n function feeRate() external view returns (uint256);\\n\\n function getFee(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _collateralAmount\\n ) external view returns (uint256);\\n\\n function quoteCurrency() external view returns (address);\\n\\n function vaults(uint256 _vaultId) external view returns (VaultLib.Vault memory);\\n\\n function shortPowerPerp() external view returns (address);\\n\\n function wPowerPerp() external view returns (address);\\n\\n function getExpectedNormalizationFactor() external view returns (uint256);\\n\\n function mintPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _powerPerpAmount,\\n uint256 _uniTokenId\\n ) external payable returns (uint256 vaultId, uint256 wPowerPerpAmount);\\n\\n function mintWPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _uniTokenId\\n ) external payable returns (uint256 vaultId);\\n\\n /**\\n * Deposit collateral into a vault\\n */\\n function deposit(uint256 _vaultId) external payable;\\n\\n /**\\n * Withdraw collateral from a vault.\\n */\\n function withdraw(uint256 _vaultId, uint256 _amount) external payable;\\n\\n function burnWPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _withdrawAmount\\n ) external;\\n\\n function burnOnPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _powerPerpAmount,\\n uint256 _withdrawAmount\\n ) external returns (uint256 wPowerPerpAmount);\\n\\n function liquidate(uint256 _vaultId, uint256 _maxDebtAmount) external returns (uint256);\\n\\n function updateOperator(uint256 _vaultId, address _operator) external;\\n\\n /**\\n * External function to update the normalized factor as a way to pay funding.\\n */\\n function applyFunding() external;\\n\\n function reduceDebtShutdown(uint256 _vaultId) external;\\n}\\n\",\"keccak256\":\"0x1d37386781eb0935b9936e2dbc865b19607e33b1cbf98b056b6e60f50adf0063\",\"license\":\"MIT\"},\"contracts/interfaces/IShortPowerPerp.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\nimport {IERC721} from \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\n\\ninterface IShortPowerPerp is IERC721 {\\n function nextId() external view returns (uint256);\\n\\n function mintNFT(address recipient) external returns (uint256 _newId);\\n}\\n\",\"keccak256\":\"0xf2d2cb2decac32a199e63f0d5141e46a6e989620944ec5f0144e5aebd0c7989e\",\"license\":\"MIT\"},\"contracts/interfaces/IWETH9.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IWETH9 is IERC20 {\\n function deposit() external payable;\\n\\n function withdraw(uint256 wad) external;\\n}\\n\",\"keccak256\":\"0x8a9a4512f1fc29b14dcf97ca149f263f28de43191a3ee31336f2389e3f2f5f8e\",\"license\":\"MIT\"},\"contracts/interfaces/IWPowerPerp.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IWPowerPerp is IERC20 {\\n function mint(address _account, uint256 _amount) external;\\n\\n function burn(address _account, uint256 _amount) external;\\n}\\n\",\"keccak256\":\"0x873a337fcb47b96ed0714dbc2edbf1d200f529752efb7beb18109c9e6a9d7271\",\"license\":\"MIT\"},\"contracts/libs/Uint256Casting.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nlibrary Uint256Casting {\\n /**\\n * @notice cast a uint256 to a uint128, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint128\\n */\\n function toUint128(uint256 y) internal pure returns (uint128 z) {\\n require((z = uint128(y)) == y, \\\"OF128\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint96, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint96\\n */\\n function toUint96(uint256 y) internal pure returns (uint96 z) {\\n require((z = uint96(y)) == y, \\\"OF96\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint32, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint32\\n */\\n function toUint32(uint256 y) internal pure returns (uint32 z) {\\n require((z = uint32(y)) == y, \\\"OF32\\\");\\n }\\n}\\n\",\"keccak256\":\"0xcccbe82f8696be398d0d0f5a44988e9bab70e18dd40c9563620cdf160d8bcd7c\",\"license\":\"MIT\"},\"contracts/libs/VaultLib.sol\":{\"content\":\"//SPDX-License-Identifier: BUSL-1.1\\n\\npragma solidity =0.7.6;\\n\\n//interface\\nimport {INonfungiblePositionManager} from \\\"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\\\";\\n\\n//lib\\nimport {SafeMath} from \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/TickMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/SqrtPriceMath.sol\\\";\\nimport {Uint256Casting} from \\\"./Uint256Casting.sol\\\";\\n\\n/**\\n * Error code:\\n * V1: Vault already had nft\\n * V2: Vault has no NFT\\n */\\nlibrary VaultLib {\\n using SafeMath for uint256;\\n using Uint256Casting for uint256;\\n\\n uint256 constant ONE_ONE = 1e36;\\n\\n // the collateralization ratio (CR) is checked with the numerator and denominator separately\\n // a user is safe if - collateral value >= (COLLAT_RATIO_NUMER/COLLAT_RATIO_DENOM)* debt value\\n uint256 public constant CR_NUMERATOR = 3;\\n uint256 public constant CR_DENOMINATOR = 2;\\n\\n struct Vault {\\n // the address that can update the vault\\n address operator;\\n // uniswap position token id deposited into the vault as collateral\\n // 2^32 is 4,294,967,296, which means the vault structure will work with up to 4 billion positions\\n uint32 NftCollateralId;\\n // amount of eth (wei) used in the vault as collateral\\n // 2^96 / 1e18 = 79,228,162,514, which means a vault can store up to 79 billion eth\\n // when we need to do calculations, we always cast this number to uint256 to avoid overflow\\n uint96 collateralAmount;\\n // amount of wPowerPerp minted from the vault\\n uint128 shortAmount;\\n }\\n\\n /**\\n * @notice add eth collateral to a vault\\n * @param _vault in-memory vault\\n * @param _amount amount of eth to add\\n */\\n function addEthCollateral(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.collateralAmount = uint256(_vault.collateralAmount).add(_amount).toUint96();\\n }\\n\\n /**\\n * @notice add uniswap position token collateral to a vault\\n * @param _vault in-memory vault\\n * @param _tokenId uniswap position token id\\n */\\n function addUniNftCollateral(Vault memory _vault, uint256 _tokenId) internal pure {\\n require(_vault.NftCollateralId == 0, \\\"V1\\\");\\n require(_tokenId != 0, \\\"C23\\\");\\n _vault.NftCollateralId = _tokenId.toUint32();\\n }\\n\\n /**\\n * @notice remove eth collateral from a vault\\n * @param _vault in-memory vault\\n * @param _amount amount of eth to remove\\n */\\n function removeEthCollateral(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.collateralAmount = uint256(_vault.collateralAmount).sub(_amount).toUint96();\\n }\\n\\n /**\\n * @notice remove uniswap position token collateral from a vault\\n * @param _vault in-memory vault\\n */\\n function removeUniNftCollateral(Vault memory _vault) internal pure {\\n require(_vault.NftCollateralId != 0, \\\"V2\\\");\\n _vault.NftCollateralId = 0;\\n }\\n\\n /**\\n * @notice add debt to vault\\n * @param _vault in-memory vault\\n * @param _amount amount of debt to add\\n */\\n function addShort(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.shortAmount = uint256(_vault.shortAmount).add(_amount).toUint128();\\n }\\n\\n /**\\n * @notice remove debt from vault\\n * @param _vault in-memory vault\\n * @param _amount amount of debt to remove\\n */\\n function removeShort(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.shortAmount = uint256(_vault.shortAmount).sub(_amount).toUint128();\\n }\\n\\n /**\\n * @notice check if a vault is properly collateralized\\n * @param _vault the vault we want to check\\n * @param _positionManager address of the uniswap position manager\\n * @param _normalizationFactor current _normalizationFactor\\n * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18\\n * @param _minCollateral minimum collateral that needs to be in a vault\\n * @param _wsqueethPoolTick current price tick for wsqueeth pool\\n * @param _isWethToken0 whether weth is token0 in the wsqueeth pool\\n * @return true if the vault is sufficiently collateralized\\n * @return true if the vault is considered as a dust vault\\n */\\n function getVaultStatus(\\n Vault memory _vault,\\n address _positionManager,\\n uint256 _normalizationFactor,\\n uint256 _ethQuoteCurrencyPrice,\\n uint256 _minCollateral,\\n int24 _wsqueethPoolTick,\\n bool _isWethToken0\\n ) internal view returns (bool, bool) {\\n if (_vault.shortAmount == 0) return (true, false);\\n\\n uint256 debtValueInETH = uint256(_vault.shortAmount).mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div(\\n ONE_ONE\\n );\\n uint256 totalCollateral = _getEffectiveCollateral(\\n _vault,\\n _positionManager,\\n _normalizationFactor,\\n _ethQuoteCurrencyPrice,\\n _wsqueethPoolTick,\\n _isWethToken0\\n );\\n\\n bool isDust = totalCollateral < _minCollateral;\\n bool isAboveWater = totalCollateral.mul(CR_DENOMINATOR) >= debtValueInETH.mul(CR_NUMERATOR);\\n return (isAboveWater, isDust);\\n }\\n\\n /**\\n * @notice get the total effective collateral of a vault, which is:\\n * collateral amount + uniswap position token equivelent amount in eth\\n * @param _vault the vault we want to check\\n * @param _positionManager address of the uniswap position manager\\n * @param _normalizationFactor current _normalizationFactor\\n * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18\\n * @param _wsqueethPoolTick current price tick for wsqueeth pool\\n * @param _isWethToken0 whether weth is token0 in the wsqueeth pool\\n * @return the total worth of collateral in the vault\\n */\\n function _getEffectiveCollateral(\\n Vault memory _vault,\\n address _positionManager,\\n uint256 _normalizationFactor,\\n uint256 _ethQuoteCurrencyPrice,\\n int24 _wsqueethPoolTick,\\n bool _isWethToken0\\n ) internal view returns (uint256) {\\n if (_vault.NftCollateralId == 0) return _vault.collateralAmount;\\n\\n // the user has deposited uniswap position token as collateral, see how much eth / wSqueeth the uniswap position token has\\n (uint256 nftEthAmount, uint256 nftWsqueethAmount) = _getUniPositionBalances(\\n _positionManager,\\n _vault.NftCollateralId,\\n _wsqueethPoolTick,\\n _isWethToken0\\n );\\n // convert squeeth amount from uniswap position token as equivalent amount of collateral\\n uint256 wSqueethIndexValueInEth = nftWsqueethAmount.mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div(\\n ONE_ONE\\n );\\n // add eth value from uniswap position token as collateral\\n return nftEthAmount.add(wSqueethIndexValueInEth).add(_vault.collateralAmount);\\n }\\n\\n /**\\n * @notice determine how much eth / wPowerPerp the uniswap position contains\\n * @param _positionManager address of the uniswap position manager\\n * @param _tokenId uniswap position token id\\n * @param _wPowerPerpPoolTick current price tick\\n * @param _isWethToken0 whether weth is token0 in the pool\\n * @return ethAmount the eth amount this LP token contains\\n * @return wPowerPerpAmount the wPowerPerp amount this LP token contains\\n */\\n function _getUniPositionBalances(\\n address _positionManager,\\n uint256 _tokenId,\\n int24 _wPowerPerpPoolTick,\\n bool _isWethToken0\\n ) internal view returns (uint256 ethAmount, uint256 wPowerPerpAmount) {\\n (\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n ) = _getUniswapPositionInfo(_positionManager, _tokenId);\\n (uint256 amount0, uint256 amount1) = _getToken0Token1Balances(\\n tickLower,\\n tickUpper,\\n _wPowerPerpPoolTick,\\n liquidity\\n );\\n\\n return\\n _isWethToken0\\n ? (amount0 + tokensOwed0, amount1 + tokensOwed1)\\n : (amount1 + tokensOwed1, amount0 + tokensOwed0);\\n }\\n\\n /**\\n * @notice get uniswap position token info\\n * @param _positionManager address of the uniswap position position manager\\n * @param _tokenId uniswap position token id\\n * @return tickLower lower tick of the position\\n * @return tickUpper upper tick of the position\\n * @return liquidity raw liquidity amount of the position\\n * @return tokensOwed0 amount of token 0 can be collected as fee\\n * @return tokensOwed1 amount of token 1 can be collected as fee\\n */\\n function _getUniswapPositionInfo(address _positionManager, uint256 _tokenId)\\n internal\\n view\\n returns (\\n int24,\\n int24,\\n uint128,\\n uint128,\\n uint128\\n )\\n {\\n INonfungiblePositionManager positionManager = INonfungiblePositionManager(_positionManager);\\n (\\n ,\\n ,\\n ,\\n ,\\n ,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n ,\\n ,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n ) = positionManager.positions(_tokenId);\\n return (tickLower, tickUpper, liquidity, tokensOwed0, tokensOwed1);\\n }\\n\\n /**\\n * @notice get balances of token0 / token1 in a uniswap position\\n * @dev knowing liquidity, tick range, and current tick gives balances\\n * @param _tickLower address of the uniswap position manager\\n * @param _tickUpper uniswap position token id\\n * @param _tick current price tick used for calculation\\n * @return amount0 the amount of token0 in the uniswap position token\\n * @return amount1 the amount of token1 in the uniswap position token\\n */\\n function _getToken0Token1Balances(\\n int24 _tickLower,\\n int24 _tickUpper,\\n int24 _tick,\\n uint128 _liquidity\\n ) internal pure returns (uint256 amount0, uint256 amount1) {\\n // get the current price and tick from wPowerPerp pool\\n uint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(_tick);\\n\\n // the following line is copied from the _modifyPosition function implemented by Uniswap core\\n // we use the same logic to determine how much token0, token1 equals to given \\\"liquidity\\\"\\n // https://github.com/Uniswap/uniswap-v3-core/blob/b2c5555d696428c40c4b236069b3528b2317f3c1/contracts/UniswapV3Pool.sol#L306\\n\\n // use these 2 functions directly, because liquidity is always positive\\n // getAmount0Delta: https://github.com/Uniswap/uniswap-v3-core/blob/b2c5555d696428c40c4b236069b3528b2317f3c1/contracts/libraries/SqrtPriceMath.sol#L209\\n // getAmount1Delta: https://github.com/Uniswap/uniswap-v3-core/blob/b2c5555d696428c40c4b236069b3528b2317f3c1/contracts/libraries/SqrtPriceMath.sol#L225\\n\\n if (_tick < _tickLower) {\\n amount0 = SqrtPriceMath.getAmount0Delta(\\n TickMath.getSqrtRatioAtTick(_tickLower),\\n TickMath.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n } else if (_tick < _tickUpper) {\\n amount0 = SqrtPriceMath.getAmount0Delta(\\n sqrtPriceX96,\\n TickMath.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n amount1 = SqrtPriceMath.getAmount1Delta(\\n TickMath.getSqrtRatioAtTick(_tickLower),\\n sqrtPriceX96,\\n _liquidity,\\n true\\n );\\n } else {\\n amount1 = SqrtPriceMath.getAmount1Delta(\\n TickMath.getSqrtRatioAtTick(_tickLower),\\n TickMath.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n }\\n }\\n}\\n\",\"keccak256\":\"0x70e0be9051bbd93304ab5c934ab16066b39cedc1cc96d81c6f6f8570c62efdd0\",\"license\":\"BUSL-1.1\"},\"contracts/periphery/ShortHelper.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\n\\npragma solidity =0.7.6;\\npragma abicoder v2;\\n// Interfaces\\nimport {IERC721} from \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\nimport {IERC721Receiver} from \\\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\\\";\\nimport {ISwapRouter} from \\\"@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol\\\";\\n\\nimport {IWPowerPerp} from \\\"../interfaces/IWPowerPerp.sol\\\";\\nimport {IWETH9} from \\\"../interfaces/IWETH9.sol\\\";\\nimport {IShortPowerPerp} from \\\"../interfaces/IShortPowerPerp.sol\\\";\\nimport {IController} from \\\"../interfaces/IController.sol\\\";\\n\\n// Libraries\\nimport {Address} from \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport {ReentrancyGuard} from \\\"@openzeppelin/contracts/utils/ReentrancyGuard.sol\\\";\\nimport {SafeMath} from \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\n\\n/**\\n * @notice contract simplifies opening a short wPowerPerp position by selling wPowerPerp on uniswap v3 and returning eth to user\\n */\\ncontract ShortHelper is IERC721Receiver, ReentrancyGuard {\\n using SafeMath for uint256;\\n using Address for address payable;\\n\\n IController public immutable controller;\\n ISwapRouter public immutable router;\\n IWETH9 public immutable weth;\\n IShortPowerPerp public immutable shortPowerPerp;\\n address public immutable wPowerPerp;\\n\\n /**\\n * @notice constructor for short helper\\n * @param _controllerAddr controller address for wPowerPerp\\n * @param _swapRouter uniswap v3 swap router address\\n * @param _wethAddr weth address\\n */\\n constructor(\\n address _controllerAddr,\\n address _swapRouter,\\n address _wethAddr\\n ) {\\n require(_controllerAddr != address(0), \\\"Invalid controller address\\\");\\n require(_swapRouter != address(0), \\\"Invalid swap router address\\\");\\n require(_wethAddr != address(0), \\\"Invalid weth address\\\");\\n IController _controller = IController(_controllerAddr);\\n router = ISwapRouter(_swapRouter);\\n wPowerPerp = _controller.wPowerPerp();\\n IWPowerPerp _wPowerPerp = IWPowerPerp(_controller.wPowerPerp());\\n IWETH9 _weth = IWETH9(_wethAddr);\\n _wPowerPerp.approve(_swapRouter, type(uint256).max);\\n _weth.approve(_swapRouter, type(uint256).max);\\n\\n // assign immutable variables\\n shortPowerPerp = IShortPowerPerp(_controller.shortPowerPerp());\\n weth = _weth;\\n controller = _controller;\\n }\\n\\n /**\\n * @notice mint power perp, trade with uniswap v3 and send back premium in eth\\n * @param _vaultId short wPowerPerp vault id\\n * @param _powerPerpAmount amount of powerPerp to mint/sell\\n * @param _uniNftId uniswap v3 position token id\\n */\\n function openShort(\\n uint256 _vaultId,\\n uint256 _powerPerpAmount,\\n uint256 _uniNftId,\\n ISwapRouter.ExactInputSingleParams memory _exactInputParams\\n ) external payable nonReentrant {\\n if (_vaultId != 0) require(shortPowerPerp.ownerOf(_vaultId) == msg.sender, \\\"Not allowed\\\");\\n require(\\n _exactInputParams.tokenOut == address(weth) && _exactInputParams.tokenIn == wPowerPerp,\\n \\\"Wrong swap tokens\\\"\\n );\\n\\n (uint256 vaultId, uint256 wPowerPerpAmount) = controller.mintPowerPerpAmount{value: msg.value}(\\n _vaultId,\\n _powerPerpAmount,\\n _uniNftId\\n );\\n _exactInputParams.amountIn = wPowerPerpAmount;\\n\\n uint256 amountOut = router.exactInputSingle(_exactInputParams);\\n\\n // if the recipient is this address: unwrap eth and send back to msg.sender\\n if (_exactInputParams.recipient == address(this)) {\\n weth.withdraw(amountOut);\\n payable(msg.sender).sendValue(amountOut);\\n }\\n\\n // this is a newly open vault, transfer to the user.\\n if (_vaultId == 0) shortPowerPerp.safeTransferFrom(address(this), msg.sender, vaultId);\\n }\\n\\n /**\\n * @notice buy back wPowerPerp with eth on uniswap v3 and close position\\n * @param _vaultId short wPowerPerp vault id\\n * @param _wPowerPerpAmount amount of wPowerPerp to burn\\n * @param _withdrawAmount amount to withdraw\\n */\\n function closeShort(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _withdrawAmount,\\n ISwapRouter.ExactOutputSingleParams memory _exactOutputParams\\n ) external payable nonReentrant {\\n require(shortPowerPerp.ownerOf(_vaultId) == msg.sender, \\\"Not allowed\\\");\\n require(\\n _exactOutputParams.tokenOut == wPowerPerp && _exactOutputParams.tokenIn == address(weth),\\n \\\"Wrong swap tokens\\\"\\n );\\n\\n // wrap eth to weth\\n weth.deposit{value: msg.value}();\\n\\n // pay weth and get wPowerPerp in return.\\n uint256 amountIn = router.exactOutputSingle(_exactOutputParams);\\n\\n controller.burnWPowerPerpAmount(_vaultId, _wPowerPerpAmount, _withdrawAmount);\\n\\n // send back unused eth and withdrawn collateral\\n weth.withdraw(msg.value.sub(amountIn));\\n // no eth should be left in the contract, so we send it all back\\n payable(msg.sender).sendValue(address(this).balance);\\n }\\n\\n /**\\n * @dev only receive eth from weth contract and controller.\\n */\\n receive() external payable {\\n require(msg.sender == address(weth) || msg.sender == address(controller), \\\"can't receive eth\\\");\\n }\\n\\n /**\\n * @dev accept erc721 from safeTransferFrom and safeMint after callback\\n * @return returns received selector\\n */\\n function onERC721Received(\\n address,\\n address,\\n uint256,\\n bytes memory\\n ) public virtual override returns (bytes4) {\\n return this.onERC721Received.selector;\\n }\\n}\\n\",\"keccak256\":\"0x512bb00cb9e4a780ba460ef629f3c581feb8ca669373417beeefdcbc1233c4d1\",\"license\":\"GPL-2.0-or-later\"}},\"version\":1}", - "bytecode": "0x6101206040523480156200001257600080fd5b50604051620016d9380380620016d98339810160408190526200003591620003e6565b60016000556001600160a01b0383166200006c5760405162461bcd60e51b81526004016200006390620004a1565b60405180910390fd5b6001600160a01b038216620000955760405162461bcd60e51b81526004016200006390620004d8565b6001600160a01b038116620000be5760405162461bcd60e51b815260040162000063906200046a565b6000839050826001600160a01b031660a0816001600160a01b031660601b81525050806001600160a01b0316637f07b1306040518163ffffffff1660e01b815260040160206040518083038186803b1580156200011a57600080fd5b505afa1580156200012f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001559190620003c2565b6001600160a01b0316610100816001600160a01b031660601b815250506000816001600160a01b0316637f07b1306040518163ffffffff1660e01b815260040160206040518083038186803b158015620001ae57600080fd5b505afa158015620001c3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001e99190620003c2565b60405163095ea7b360e01b815290915083906001600160a01b0383169063095ea7b390620002209088906000199060040162000451565b602060405180830381600087803b1580156200023b57600080fd5b505af115801562000250573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200027691906200042f565b5060405163095ea7b360e01b81526001600160a01b0382169063095ea7b390620002a99088906000199060040162000451565b602060405180830381600087803b158015620002c457600080fd5b505af1158015620002d9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002ff91906200042f565b50826001600160a01b0316639d4c94426040518163ffffffff1660e01b815260040160206040518083038186803b1580156200033a57600080fd5b505afa1580156200034f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003759190620003c2565b6001600160601b0319606091821b811660e05291811b821660c0529290921b909116608052506200050f92505050565b80516001600160a01b0381168114620003bd57600080fd5b919050565b600060208284031215620003d4578081fd5b620003df82620003a5565b9392505050565b600080600060608486031215620003fb578182fd5b6200040684620003a5565b92506200041660208501620003a5565b91506200042660408501620003a5565b90509250925092565b60006020828403121562000441578081fd5b81518015158114620003df578182fd5b6001600160a01b03929092168252602082015260400190565b60208082526014908201527f496e76616c696420776574682061646472657373000000000000000000000000604082015260600190565b6020808252601a908201527f496e76616c696420636f6e74726f6c6c65722061646472657373000000000000604082015260600190565b6020808252601b908201527f496e76616c6964207377617020726f7574657220616464726573730000000000604082015260600190565b60805160601c60a05160601c60c05160601c60e05160601c6101005160601c61112d620005ac6000398061032d528061065552806108045250806102785280610679528061070f5280610ab4525080608f528061036d52806103c35280610595528061063152806107c45280610a0b525080610466528061093c5280610b5452508060c15280610522528061085d5280610b30525061112d6000f3fe60806040526004361061007f5760003560e01c80639d4c94421161004e5780639d4c94421461018f578063e56cfbbe146101a4578063f77c4791146101b7578063f887ea40146101cc5761010a565b8063150b7a021461010f57806317fd9e0e146101455780633fc8cef3146101585780637f07b1301461017a5761010a565b3661010a57336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614806100e35750336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016145b6101085760405162461bcd60e51b81526004016100ff9061101c565b60405180910390fd5b005b600080fd5b34801561011b57600080fd5b5061012f61012a366004610db4565b6101e1565b60405161013c9190610f81565b60405180910390f35b610108610153366004610ea5565b61020a565b34801561016457600080fd5b5061016d61062f565b60405161013c9190610f49565b34801561018657600080fd5b5061016d610653565b34801561019b57600080fd5b5061016d610677565b6101086101b2366004610ea5565b61069b565b3480156101c357600080fd5b5061016d610b2e565b3480156101d857600080fd5b5061016d610b52565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b60026000541415610262576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026000556040516331a9108f60e11b815233907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e906102b5908890600401611062565b60206040518083038186803b1580156102cd57600080fd5b505afa1580156102e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103059190610d91565b6001600160a01b03161461032b5760405162461bcd60e51b81526004016100ff90610fe5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681602001516001600160a01b03161480156103a557507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681600001516001600160a01b0316145b6103c15760405162461bcd60e51b81526004016100ff90610fae565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561041c57600080fd5b505af1158015610430573d6000803e3d6000fd5b50506040517fdb3e2198000000000000000000000000000000000000000000000000000000008152600093506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016925063db3e2198915061049d908590600401611053565b602060405180830381600087803b1580156104b757600080fd5b505af11580156104cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ef9190610e6a565b6040517f8632cb030000000000000000000000000000000000000000000000000000000081529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638632cb039061055b9088908890889060040161106b565b600060405180830381600087803b15801561057557600080fd5b505af1158015610589573d6000803e3d6000fd5b50506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169150632e1a7d4d90506105c83484610b76565b6040518263ffffffff1660e01b81526004016105e49190611062565b600060405180830381600087803b1580156105fe57600080fd5b505af1158015610612573d6000803e3d6000fd5b506106239250339150479050610bd8565b50506001600055505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600260005414156106f3576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260005583156107c2576040516331a9108f60e11b815233907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e9061074c908890600401611062565b60206040518083038186803b15801561076457600080fd5b505afa158015610778573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061079c9190610d91565b6001600160a01b0316146107c25760405162461bcd60e51b81526004016100ff90610fe5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681602001516001600160a01b031614801561083c57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681600001516001600160a01b0316145b6108585760405162461bcd60e51b81526004016100ff90610fae565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631bf7bf6c348888886040518563ffffffff1660e01b81526004016108ac9392919061106b565b60408051808303818588803b1580156108c457600080fd5b505af11580156108d8573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906108fd9190610e82565b60a085018190526040517f414bf38900000000000000000000000000000000000000000000000000000000815291935091506000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063414bf38990610971908790600401611053565b602060405180830381600087803b15801561098b57600080fd5b505af115801561099f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c39190610e6a565b60608501519091506001600160a01b0316301415610a7f576040517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690632e1a7d4d90610a40908490600401611062565b600060405180830381600087803b158015610a5a57600080fd5b505af1158015610a6e573d6000803e3d6000fd5b50610a7f9250339150839050610bd8565b86610b20576040517f42842e0e0000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906342842e0e90610aed90309033908890600401610f5d565b600060405180830381600087803b158015610b0757600080fd5b505af1158015610b1b573d6000803e3d6000fd5b505050505b505060016000555050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600082821115610bcd576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b80471015610c2d576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114610c78576040519150601f19603f3d011682016040523d82523d6000602084013e610c7d565b606091505b5050905080610cbd5760405162461bcd60e51b815260040180806020018281038252603a8152602001806110be603a913960400191505060405180910390fd5b505050565b8035610ccd816110a5565b919050565b6000610100808385031215610ce5578182fd5b6040519081019067ffffffffffffffff82118183101715610d0257fe5b81604052809250610d1284610cc2565b8152610d2060208501610cc2565b6020820152610d3160408501610d7e565b6040820152610d4260608501610cc2565b60608201526080840135608082015260a084013560a082015260c084013560c0820152610d7160e08501610cc2565b60e0820152505092915050565b803562ffffff81168114610ccd57600080fd5b600060208284031215610da2578081fd5b8151610dad816110a5565b9392505050565b60008060008060808587031215610dc9578283fd5b8435610dd4816110a5565b9350602085810135610de5816110a5565b935060408601359250606086013567ffffffffffffffff80821115610e08578384fd5b818801915088601f830112610e1b578384fd5b813581811115610e2757fe5b610e39601f8201601f19168501611081565b91508082528984828501011115610e4e578485fd5b8084840185840137810190920192909252939692955090935050565b600060208284031215610e7b578081fd5b5051919050565b60008060408385031215610e94578182fd5b505080516020909101519092909150565b6000806000806101608587031215610ebb578384fd5b843593506020850135925060408501359150610eda8660608701610cd2565b905092959194509250565b6001600160a01b0380825116835280602083015116602084015262ffffff60408301511660408401528060608301511660608401526080820151608084015260a082015160a084015260c082015160c08401528060e08301511660e0840152505050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b60208082526011908201527f57726f6e67207377617020746f6b656e73000000000000000000000000000000604082015260600190565b6020808252600b908201527f4e6f7420616c6c6f776564000000000000000000000000000000000000000000604082015260600190565b60208082526011908201527f63616e2774207265636569766520657468000000000000000000000000000000604082015260600190565b6101008101610bd28284610ee5565b90815260200190565b9283526020830191909152604082015260600190565b60405181810167ffffffffffffffff8111828210171561109d57fe5b604052919050565b6001600160a01b03811681146110ba57600080fd5b5056fe416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564a264697066735822122031d0323c331c7416fbb179d6fe827fa8f99618cdcac08929c861cbfb8342129764736f6c63430007060033", - "deployedBytecode": "0x60806040526004361061007f5760003560e01c80639d4c94421161004e5780639d4c94421461018f578063e56cfbbe146101a4578063f77c4791146101b7578063f887ea40146101cc5761010a565b8063150b7a021461010f57806317fd9e0e146101455780633fc8cef3146101585780637f07b1301461017a5761010a565b3661010a57336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614806100e35750336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016145b6101085760405162461bcd60e51b81526004016100ff9061101c565b60405180910390fd5b005b600080fd5b34801561011b57600080fd5b5061012f61012a366004610db4565b6101e1565b60405161013c9190610f81565b60405180910390f35b610108610153366004610ea5565b61020a565b34801561016457600080fd5b5061016d61062f565b60405161013c9190610f49565b34801561018657600080fd5b5061016d610653565b34801561019b57600080fd5b5061016d610677565b6101086101b2366004610ea5565b61069b565b3480156101c357600080fd5b5061016d610b2e565b3480156101d857600080fd5b5061016d610b52565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b60026000541415610262576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026000556040516331a9108f60e11b815233907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e906102b5908890600401611062565b60206040518083038186803b1580156102cd57600080fd5b505afa1580156102e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103059190610d91565b6001600160a01b03161461032b5760405162461bcd60e51b81526004016100ff90610fe5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681602001516001600160a01b03161480156103a557507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681600001516001600160a01b0316145b6103c15760405162461bcd60e51b81526004016100ff90610fae565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561041c57600080fd5b505af1158015610430573d6000803e3d6000fd5b50506040517fdb3e2198000000000000000000000000000000000000000000000000000000008152600093506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016925063db3e2198915061049d908590600401611053565b602060405180830381600087803b1580156104b757600080fd5b505af11580156104cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ef9190610e6a565b6040517f8632cb030000000000000000000000000000000000000000000000000000000081529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638632cb039061055b9088908890889060040161106b565b600060405180830381600087803b15801561057557600080fd5b505af1158015610589573d6000803e3d6000fd5b50506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169150632e1a7d4d90506105c83484610b76565b6040518263ffffffff1660e01b81526004016105e49190611062565b600060405180830381600087803b1580156105fe57600080fd5b505af1158015610612573d6000803e3d6000fd5b506106239250339150479050610bd8565b50506001600055505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600260005414156106f3576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260005583156107c2576040516331a9108f60e11b815233907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e9061074c908890600401611062565b60206040518083038186803b15801561076457600080fd5b505afa158015610778573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061079c9190610d91565b6001600160a01b0316146107c25760405162461bcd60e51b81526004016100ff90610fe5565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681602001516001600160a01b031614801561083c57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681600001516001600160a01b0316145b6108585760405162461bcd60e51b81526004016100ff90610fae565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631bf7bf6c348888886040518563ffffffff1660e01b81526004016108ac9392919061106b565b60408051808303818588803b1580156108c457600080fd5b505af11580156108d8573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906108fd9190610e82565b60a085018190526040517f414bf38900000000000000000000000000000000000000000000000000000000815291935091506000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063414bf38990610971908790600401611053565b602060405180830381600087803b15801561098b57600080fd5b505af115801561099f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c39190610e6a565b60608501519091506001600160a01b0316301415610a7f576040517f2e1a7d4d0000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690632e1a7d4d90610a40908490600401611062565b600060405180830381600087803b158015610a5a57600080fd5b505af1158015610a6e573d6000803e3d6000fd5b50610a7f9250339150839050610bd8565b86610b20576040517f42842e0e0000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906342842e0e90610aed90309033908890600401610f5d565b600060405180830381600087803b158015610b0757600080fd5b505af1158015610b1b573d6000803e3d6000fd5b505050505b505060016000555050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600082821115610bcd576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b80471015610c2d576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114610c78576040519150601f19603f3d011682016040523d82523d6000602084013e610c7d565b606091505b5050905080610cbd5760405162461bcd60e51b815260040180806020018281038252603a8152602001806110be603a913960400191505060405180910390fd5b505050565b8035610ccd816110a5565b919050565b6000610100808385031215610ce5578182fd5b6040519081019067ffffffffffffffff82118183101715610d0257fe5b81604052809250610d1284610cc2565b8152610d2060208501610cc2565b6020820152610d3160408501610d7e565b6040820152610d4260608501610cc2565b60608201526080840135608082015260a084013560a082015260c084013560c0820152610d7160e08501610cc2565b60e0820152505092915050565b803562ffffff81168114610ccd57600080fd5b600060208284031215610da2578081fd5b8151610dad816110a5565b9392505050565b60008060008060808587031215610dc9578283fd5b8435610dd4816110a5565b9350602085810135610de5816110a5565b935060408601359250606086013567ffffffffffffffff80821115610e08578384fd5b818801915088601f830112610e1b578384fd5b813581811115610e2757fe5b610e39601f8201601f19168501611081565b91508082528984828501011115610e4e578485fd5b8084840185840137810190920192909252939692955090935050565b600060208284031215610e7b578081fd5b5051919050565b60008060408385031215610e94578182fd5b505080516020909101519092909150565b6000806000806101608587031215610ebb578384fd5b843593506020850135925060408501359150610eda8660608701610cd2565b905092959194509250565b6001600160a01b0380825116835280602083015116602084015262ffffff60408301511660408401528060608301511660608401526080820151608084015260a082015160a084015260c082015160c08401528060e08301511660e0840152505050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b60208082526011908201527f57726f6e67207377617020746f6b656e73000000000000000000000000000000604082015260600190565b6020808252600b908201527f4e6f7420616c6c6f776564000000000000000000000000000000000000000000604082015260600190565b60208082526011908201527f63616e2774207265636569766520657468000000000000000000000000000000604082015260600190565b6101008101610bd28284610ee5565b90815260200190565b9283526020830191909152604082015260600190565b60405181810167ffffffffffffffff8111828210171561109d57fe5b604052919050565b6001600160a01b03811681146110ba57600080fd5b5056fe416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564a264697066735822122031d0323c331c7416fbb179d6fe827fa8f99618cdcac08929c861cbfb8342129764736f6c63430007060033", + "solcInputHash": "d97d3d4b09e0d70518330d405a7dd9ff", + "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_controllerAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_swapRouter\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_wethAddr\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_wPowerPerpAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_withdrawAmount\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"tokenIn\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenOut\",\"type\":\"address\"},{\"internalType\":\"uint24\",\"name\":\"fee\",\"type\":\"uint24\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountInMaximum\",\"type\":\"uint256\"},{\"internalType\":\"uint160\",\"name\":\"sqrtPriceLimitX96\",\"type\":\"uint160\"}],\"internalType\":\"struct ISwapRouter.ExactOutputSingleParams\",\"name\":\"_exactOutputParams\",\"type\":\"tuple\"}],\"name\":\"closeShort\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controller\",\"outputs\":[{\"internalType\":\"contract IController\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"onERC721Received\",\"outputs\":[{\"internalType\":\"bytes4\",\"name\":\"\",\"type\":\"bytes4\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_vaultId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_powerPerpAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_uniNftId\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"tokenIn\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenOut\",\"type\":\"address\"},{\"internalType\":\"uint24\",\"name\":\"fee\",\"type\":\"uint24\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountOutMinimum\",\"type\":\"uint256\"},{\"internalType\":\"uint160\",\"name\":\"sqrtPriceLimitX96\",\"type\":\"uint160\"}],\"internalType\":\"struct ISwapRouter.ExactInputSingleParams\",\"name\":\"_exactInputParams\",\"type\":\"tuple\"}],\"name\":\"openShort\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"router\",\"outputs\":[{\"internalType\":\"contract ISwapRouter\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"shortPowerPerp\",\"outputs\":[{\"internalType\":\"contract IShortPowerPerp\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wPowerPerp\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"weth\",\"outputs\":[{\"internalType\":\"contract IWETH9\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"closeShort(uint256,uint256,uint256,(address,address,uint24,address,uint256,uint256,uint256,uint160))\":{\"params\":{\"_vaultId\":\"short wPowerPerp vault id\",\"_wPowerPerpAmount\":\"amount of wPowerPerp to burn\",\"_withdrawAmount\":\"amount to withdraw\"}},\"constructor\":{\"params\":{\"_controllerAddr\":\"controller address for wPowerPerp\",\"_swapRouter\":\"uniswap v3 swap router address\",\"_wethAddr\":\"weth address\"}},\"onERC721Received(address,address,uint256,bytes)\":{\"details\":\"accept erc721 from safeTransferFrom and safeMint after callback\",\"returns\":{\"_0\":\"returns received selector\"}},\"openShort(uint256,uint256,uint256,(address,address,uint24,address,uint256,uint256,uint256,uint160))\":{\"params\":{\"_powerPerpAmount\":\"amount of powerPerp to mint/sell\",\"_uniNftId\":\"uniswap v3 position token id\",\"_vaultId\":\"short wPowerPerp vault id\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"closeShort(uint256,uint256,uint256,(address,address,uint24,address,uint256,uint256,uint256,uint160))\":{\"notice\":\"buy back wPowerPerp with eth on uniswap v3 and close position\"},\"constructor\":{\"notice\":\"constructor for short helper\"},\"openShort(uint256,uint256,uint256,(address,address,uint24,address,uint256,uint256,uint256,uint160))\":{\"notice\":\"mint power perp, trade with uniswap v3 and send back premium in eth\"}},\"notice\":\"contract simplifies opening a short wPowerPerp position by selling wPowerPerp on uniswap v3 and returning eth to user\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/periphery/ShortHelper.sol\":\"ShortHelper\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":825},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd2f30fad5b24c4120f96dbac83aacdb7993ee610a9092bc23c44463da292bf8d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0xe22a1fc7400ae196eba2ad1562d0386462b00a6363b742d55a2fd2021a58586f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0xbd74f587ab9b9711801baf667db1426e4a03fd2d7f15af33e0e0d0394e7cef76\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"../../introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\\n}\\n\",\"keccak256\":\"0xb11597841d47f7a773bca63ca323c76f804cb5d944788de0327db5526319dc82\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Enumerable is IERC721 {\\n\\n /**\\n * @dev Returns the total amount of tokens stored by the contract.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\\n */\\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);\\n\\n /**\\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\\n * Use along with {totalSupply} to enumerate all tokens.\\n */\\n function tokenByIndex(uint256 index) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x2789dfea2d73182683d637db5729201f6730dae6113030a94c828f8688f38f2f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Metadata is IERC721 {\\n\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0xc82c7d1d732081d9bd23f1555ebdf8f3bc1738bc42c2bfc4b9aa7564d9fa3573\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\\n */\\n function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0x05604ffcf69e416b8a42728bb0e4fd75170d8fac70bf1a284afeb4752a9bc52f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf89f005a3d98f7768cdee2583707db0ac725cf567d455751af32ee68132f3db3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor () {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and make it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0x1153f6dd334c01566417b8c551122450542a2b75a2bbb379d59a8c320ed6da28\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/interfaces/callback/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\"},\"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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;\\n}\\n\",\"keccak256\":\"0x0ba8a9b95a956a4050749c0158e928398c447c91469682ca8a7cc7e77a7fe032\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/FullMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.4.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 // 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;\\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 /// @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 result = mulDiv(a, b, denominator);\\n if (mulmod(a, b, denominator) > 0) {\\n require(result < type(uint256).max);\\n result++;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe511530871deaef86692cea9adb6076d26d7b47fd4815ce51af52af981026057\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/libraries/UnsafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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\":\"0x5f36d7d16348d8c37fe64fda932018d6e5e8acecd054f0f97d32db62d20c6c88\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IERC721Permit.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\n\\nimport '@openzeppelin/contracts/token/ERC721/IERC721.sol';\\n\\n/// @title ERC721 with permit\\n/// @notice Extension to ERC721 that includes a permit function for signature based approvals\\ninterface IERC721Permit is IERC721 {\\n /// @notice The permit typehash used in the permit signature\\n /// @return The typehash for the permit\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n\\n /// @notice The domain separator used in the permit signature\\n /// @return The domain seperator used in encoding of permit signature\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Approve of a specific token ID for spending by spender via signature\\n /// @param spender The account that is being approved\\n /// @param tokenId The ID of the token that is being approved for spending\\n /// @param deadline The deadline timestamp by which the call must be mined for the approve to work\\n /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`\\n /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`\\n /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`\\n function permit(\\n address spender,\\n uint256 tokenId,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable;\\n}\\n\",\"keccak256\":\"0x9e3c2a4ee65ddf95b2dfcb0815784eea3a295707e6f8b83e4c4f0f8fe2e3a1d4\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\nimport '@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol';\\nimport '@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol';\\n\\nimport './IPoolInitializer.sol';\\nimport './IERC721Permit.sol';\\nimport './IPeripheryPayments.sol';\\nimport './IPeripheryImmutableState.sol';\\nimport '../libraries/PoolAddress.sol';\\n\\n/// @title Non-fungible token for positions\\n/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred\\n/// and authorized.\\ninterface INonfungiblePositionManager is\\n IPoolInitializer,\\n IPeripheryPayments,\\n IPeripheryImmutableState,\\n IERC721Metadata,\\n IERC721Enumerable,\\n IERC721Permit\\n{\\n /// @notice Emitted when liquidity is increased for a position NFT\\n /// @dev Also emitted when a token is minted\\n /// @param tokenId The ID of the token for which liquidity was increased\\n /// @param liquidity The amount by which liquidity for the NFT position was increased\\n /// @param amount0 The amount of token0 that was paid for the increase in liquidity\\n /// @param amount1 The amount of token1 that was paid for the increase in liquidity\\n event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\\n /// @notice Emitted when liquidity is decreased for a position NFT\\n /// @param tokenId The ID of the token for which liquidity was decreased\\n /// @param liquidity The amount by which liquidity for the NFT position was decreased\\n /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity\\n /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity\\n event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\\n /// @notice Emitted when tokens are collected for a position NFT\\n /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior\\n /// @param tokenId The ID of the token for which underlying tokens were collected\\n /// @param recipient The address of the account that received the collected tokens\\n /// @param amount0 The amount of token0 owed to the position that was collected\\n /// @param amount1 The amount of token1 owed to the position that was collected\\n event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);\\n\\n /// @notice Returns the position information associated with a given token ID.\\n /// @dev Throws if the token ID is not valid.\\n /// @param tokenId The ID of the token that represents the position\\n /// @return nonce The nonce for permits\\n /// @return operator The address that is approved for spending\\n /// @return token0 The address of the token0 for a specific pool\\n /// @return token1 The address of the token1 for a specific pool\\n /// @return fee The fee associated with the pool\\n /// @return tickLower The lower end of the tick range for the position\\n /// @return tickUpper The higher end of the tick range for the position\\n /// @return liquidity The liquidity of the position\\n /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position\\n /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position\\n /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation\\n /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation\\n function positions(uint256 tokenId)\\n external\\n view\\n returns (\\n uint96 nonce,\\n address operator,\\n address token0,\\n address token1,\\n uint24 fee,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n uint256 feeGrowthInside0LastX128,\\n uint256 feeGrowthInside1LastX128,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n );\\n\\n struct MintParams {\\n address token0;\\n address token1;\\n uint24 fee;\\n int24 tickLower;\\n int24 tickUpper;\\n uint256 amount0Desired;\\n uint256 amount1Desired;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n address recipient;\\n uint256 deadline;\\n }\\n\\n /// @notice Creates a new position wrapped in a NFT\\n /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized\\n /// a method does not exist, i.e. the pool is assumed to be initialized.\\n /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata\\n /// @return tokenId The ID of the token that represents the minted position\\n /// @return liquidity The amount of liquidity for this position\\n /// @return amount0 The amount of token0\\n /// @return amount1 The amount of token1\\n function mint(MintParams calldata params)\\n external\\n payable\\n returns (\\n uint256 tokenId,\\n uint128 liquidity,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n struct IncreaseLiquidityParams {\\n uint256 tokenId;\\n uint256 amount0Desired;\\n uint256 amount1Desired;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n uint256 deadline;\\n }\\n\\n /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`\\n /// @param params tokenId The ID of the token for which liquidity is being increased,\\n /// amount0Desired The desired amount of token0 to be spent,\\n /// amount1Desired The desired amount of token1 to be spent,\\n /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,\\n /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,\\n /// deadline The time by which the transaction must be included to effect the change\\n /// @return liquidity The new liquidity amount as a result of the increase\\n /// @return amount0 The amount of token0 to acheive resulting liquidity\\n /// @return amount1 The amount of token1 to acheive resulting liquidity\\n function increaseLiquidity(IncreaseLiquidityParams calldata params)\\n external\\n payable\\n returns (\\n uint128 liquidity,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n struct DecreaseLiquidityParams {\\n uint256 tokenId;\\n uint128 liquidity;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n uint256 deadline;\\n }\\n\\n /// @notice Decreases the amount of liquidity in a position and accounts it to the position\\n /// @param params tokenId The ID of the token for which liquidity is being decreased,\\n /// amount The amount by which liquidity will be decreased,\\n /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,\\n /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,\\n /// deadline The time by which the transaction must be included to effect the change\\n /// @return amount0 The amount of token0 accounted to the position's tokens owed\\n /// @return amount1 The amount of token1 accounted to the position's tokens owed\\n function decreaseLiquidity(DecreaseLiquidityParams calldata params)\\n external\\n payable\\n returns (uint256 amount0, uint256 amount1);\\n\\n struct CollectParams {\\n uint256 tokenId;\\n address recipient;\\n uint128 amount0Max;\\n uint128 amount1Max;\\n }\\n\\n /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient\\n /// @param params tokenId The ID of the NFT for which tokens are being collected,\\n /// recipient The account that should receive the tokens,\\n /// amount0Max The maximum amount of token0 to collect,\\n /// amount1Max The maximum amount of token1 to collect\\n /// @return amount0 The amount of fees collected in token0\\n /// @return amount1 The amount of fees collected in token1\\n function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens\\n /// must be collected first.\\n /// @param tokenId The ID of the token that is being burned\\n function burn(uint256 tokenId) external payable;\\n}\\n\",\"keccak256\":\"0xe1dadc73e60bf05d0b4e0f05bd2847c5783e833cc10352c14763360b13495ee1\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPeripheryImmutableState.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Immutable state\\n/// @notice Functions that return immutable state of the router\\ninterface IPeripheryImmutableState {\\n /// @return Returns the address of the Uniswap V3 factory\\n function factory() external view returns (address);\\n\\n /// @return Returns the address of WETH9\\n function WETH9() external view returns (address);\\n}\\n\",\"keccak256\":\"0x7affcfeb5127c0925a71d6a65345e117c33537523aeca7bc98085ead8452519d\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPeripheryPayments.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\n\\n/// @title Periphery Payments\\n/// @notice Functions to ease deposits and withdrawals of ETH\\ninterface IPeripheryPayments {\\n /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.\\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.\\n /// @param amountMinimum The minimum amount of WETH9 to unwrap\\n /// @param recipient The address receiving ETH\\n function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;\\n\\n /// @notice Refunds any ETH balance held by this contract to the `msg.sender`\\n /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps\\n /// that use ether for the input amount\\n function refundETH() external payable;\\n\\n /// @notice Transfers the full amount of a token held by this contract to recipient\\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users\\n /// @param token The contract address of the token which will be transferred to `recipient`\\n /// @param amountMinimum The minimum amount of token required for a transfer\\n /// @param recipient The destination address of the token\\n function sweepToken(\\n address token,\\n uint256 amountMinimum,\\n address recipient\\n ) external payable;\\n}\\n\",\"keccak256\":\"0xb547e10f1e69bed03621a62b73a503e260643066c6b4054867a4d1fef47eb274\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPoolInitializer.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\n/// @title Creates and initializes V3 Pools\\n/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that\\n/// require the pool to exist.\\ninterface IPoolInitializer {\\n /// @notice Creates a new pool if it does not exist, then initializes if not initialized\\n /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool\\n /// @param token0 The contract address of token0 of the pool\\n /// @param token1 The contract address of token1 of the pool\\n /// @param fee The fee amount of the v3 pool for the specified token pair\\n /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value\\n /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary\\n function createAndInitializePoolIfNecessary(\\n address token0,\\n address token1,\\n uint24 fee,\\n uint160 sqrtPriceX96\\n ) external payable returns (address pool);\\n}\\n\",\"keccak256\":\"0x9d7695e8d94c22cc5fcced602017aabb988de89981ea7bee29ea629d5328a862\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\nimport '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';\\n\\n/// @title Router token swapping functionality\\n/// @notice Functions for swapping tokens via Uniswap V3\\ninterface ISwapRouter is IUniswapV3SwapCallback {\\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 /// @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 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\",\"keccak256\":\"0x9bfaf1feb32814623e627ab70f2409760b15d95f1f9b058e2b3399a8bb732975\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee\\nlibrary PoolAddress {\\n bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;\\n\\n /// @notice The identifying key of the pool\\n struct PoolKey {\\n address token0;\\n address token1;\\n uint24 fee;\\n }\\n\\n /// @notice Returns PoolKey: the ordered tokens with the matched fee levels\\n /// @param tokenA The first token of a pool, unsorted\\n /// @param tokenB The second token of a pool, unsorted\\n /// @param fee The fee level of the pool\\n /// @return Poolkey The pool details with ordered token0 and token1 assignments\\n function getPoolKey(\\n address tokenA,\\n address tokenB,\\n uint24 fee\\n ) internal pure returns (PoolKey memory) {\\n if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);\\n return PoolKey({token0: tokenA, token1: tokenB, fee: fee});\\n }\\n\\n /// @notice Deterministically computes the pool address given the factory and PoolKey\\n /// @param factory The Uniswap V3 factory contract address\\n /// @param key The PoolKey\\n /// @return pool The contract address of the V3 pool\\n function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {\\n require(key.token0 < key.token1);\\n pool = address(\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n hex'ff',\\n factory,\\n keccak256(abi.encode(key.token0, key.token1, key.fee)),\\n POOL_INIT_CODE_HASH\\n )\\n )\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x5edd84eb8ba7c12fd8cb6cffe52e1e9f3f6464514ee5f539c2283826209035a2\",\"license\":\"GPL-2.0-or-later\"},\"contracts/interfaces/IController.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\npragma abicoder v2;\\n\\nimport {VaultLib} from \\\"../libs/VaultLib.sol\\\";\\n\\ninterface IController {\\n function ethQuoteCurrencyPool() external view returns (address);\\n\\n function feeRate() external view returns (uint256);\\n\\n function getFee(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _collateralAmount\\n ) external view returns (uint256);\\n\\n function quoteCurrency() external view returns (address);\\n\\n function vaults(uint256 _vaultId) external view returns (VaultLib.Vault memory);\\n\\n function shortPowerPerp() external view returns (address);\\n\\n function wPowerPerp() external view returns (address);\\n\\n function getExpectedNormalizationFactor() external view returns (uint256);\\n\\n function mintPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _powerPerpAmount,\\n uint256 _uniTokenId\\n ) external payable returns (uint256 vaultId, uint256 wPowerPerpAmount);\\n\\n function mintWPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _uniTokenId\\n ) external payable returns (uint256 vaultId);\\n\\n /**\\n * Deposit collateral into a vault\\n */\\n function deposit(uint256 _vaultId) external payable;\\n\\n /**\\n * Withdraw collateral from a vault.\\n */\\n function withdraw(uint256 _vaultId, uint256 _amount) external payable;\\n\\n function burnWPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _withdrawAmount\\n ) external;\\n\\n function burnOnPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _powerPerpAmount,\\n uint256 _withdrawAmount\\n ) external returns (uint256 wPowerPerpAmount);\\n\\n function liquidate(uint256 _vaultId, uint256 _maxDebtAmount) external returns (uint256);\\n\\n function updateOperator(uint256 _vaultId, address _operator) external;\\n\\n /**\\n * External function to update the normalized factor as a way to pay funding.\\n */\\n function applyFunding() external;\\n\\n function redeemShort(uint256 _vaultId) external;\\n\\n function reduceDebtShutdown(uint256 _vaultId) external;\\n\\n function isShutDown() external returns (bool);\\n}\\n\",\"keccak256\":\"0xc5d6230c8bafcaf2ae7260efd68c45ab13e91819ed9e11881b29dc48386e4bc7\",\"license\":\"MIT\"},\"contracts/interfaces/IShortPowerPerp.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\nimport {IERC721} from \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\n\\ninterface IShortPowerPerp is IERC721 {\\n function nextId() external view returns (uint256);\\n\\n function mintNFT(address recipient) external returns (uint256 _newId);\\n}\\n\",\"keccak256\":\"0xf2d2cb2decac32a199e63f0d5141e46a6e989620944ec5f0144e5aebd0c7989e\",\"license\":\"MIT\"},\"contracts/interfaces/IWETH9.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IWETH9 is IERC20 {\\n function deposit() external payable;\\n\\n function withdraw(uint256 wad) external;\\n}\\n\",\"keccak256\":\"0x8a9a4512f1fc29b14dcf97ca149f263f28de43191a3ee31336f2389e3f2f5f8e\",\"license\":\"MIT\"},\"contracts/interfaces/IWPowerPerp.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IWPowerPerp is IERC20 {\\n function mint(address _account, uint256 _amount) external;\\n\\n function burn(address _account, uint256 _amount) external;\\n}\\n\",\"keccak256\":\"0x873a337fcb47b96ed0714dbc2edbf1d200f529752efb7beb18109c9e6a9d7271\",\"license\":\"MIT\"},\"contracts/libs/SqrtPriceMathPartial.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\nimport \\\"@uniswap/v3-core/contracts/libraries/FullMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/UnsafeMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\\\";\\n\\n/// @title Functions based on Q64.96 sqrt price and liquidity\\n/// @notice Exposes two functions from @uniswap/v3-core SqrtPriceMath\\n/// that use square root of price as a Q64.96 and liquidity to compute deltas\\nlibrary SqrtPriceMathPartial {\\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 ) external 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\\n require(sqrtRatioAX96 > 0);\\n\\n return\\n roundUp\\n ? UnsafeMath.divRoundingUp(\\n FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96),\\n sqrtRatioAX96\\n )\\n : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96;\\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 ) external 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\",\"keccak256\":\"0x34b98f373514d057151a41d35aa42031af3b1a47e910888ed73315f72520e429\",\"license\":\"GPL-2.0-or-later\"},\"contracts/libs/TickMathExternal.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.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 TickMathExternal {\\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) public pure returns (uint160 sqrtPriceX96) {\\n uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\\n require(absTick <= uint256(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 /// @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) external pure returns (int24 tick) {\\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\",\"keccak256\":\"0xfd917bc787958baa0b7fd6f526f88a63a5b98a32d3ff1c0f67665e7a1be86e10\",\"license\":\"GPL-2.0-or-later\"},\"contracts/libs/Uint256Casting.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nlibrary Uint256Casting {\\n /**\\n * @notice cast a uint256 to a uint128, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint128\\n */\\n function toUint128(uint256 y) internal pure returns (uint128 z) {\\n require((z = uint128(y)) == y, \\\"OF128\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint96, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint96\\n */\\n function toUint96(uint256 y) internal pure returns (uint96 z) {\\n require((z = uint96(y)) == y, \\\"OF96\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint32, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint32\\n */\\n function toUint32(uint256 y) internal pure returns (uint32 z) {\\n require((z = uint32(y)) == y, \\\"OF32\\\");\\n }\\n}\\n\",\"keccak256\":\"0xcccbe82f8696be398d0d0f5a44988e9bab70e18dd40c9563620cdf160d8bcd7c\",\"license\":\"MIT\"},\"contracts/libs/VaultLib.sol\":{\"content\":\"//SPDX-License-Identifier: GPL-2.0-or-later\\n\\npragma solidity =0.7.6;\\n\\n//interface\\nimport {INonfungiblePositionManager} from \\\"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\\\";\\n\\n//lib\\nimport {SafeMath} from \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport {TickMathExternal} from \\\"./TickMathExternal.sol\\\";\\nimport {SqrtPriceMathPartial} from \\\"./SqrtPriceMathPartial.sol\\\";\\nimport {Uint256Casting} from \\\"./Uint256Casting.sol\\\";\\n\\n/**\\n * Error code:\\n * V1: Vault already had nft\\n * V2: Vault has no NFT\\n */\\nlibrary VaultLib {\\n using SafeMath for uint256;\\n using Uint256Casting for uint256;\\n\\n uint256 constant ONE_ONE = 1e36;\\n\\n // the collateralization ratio (CR) is checked with the numerator and denominator separately\\n // a user is safe if - collateral value >= (COLLAT_RATIO_NUMER/COLLAT_RATIO_DENOM)* debt value\\n uint256 public constant CR_NUMERATOR = 3;\\n uint256 public constant CR_DENOMINATOR = 2;\\n\\n struct Vault {\\n // the address that can update the vault\\n address operator;\\n // uniswap position token id deposited into the vault as collateral\\n // 2^32 is 4,294,967,296, which means the vault structure will work with up to 4 billion positions\\n uint32 NftCollateralId;\\n // amount of eth (wei) used in the vault as collateral\\n // 2^96 / 1e18 = 79,228,162,514, which means a vault can store up to 79 billion eth\\n // when we need to do calculations, we always cast this number to uint256 to avoid overflow\\n uint96 collateralAmount;\\n // amount of wPowerPerp minted from the vault\\n uint128 shortAmount;\\n }\\n\\n /**\\n * @notice add eth collateral to a vault\\n * @param _vault in-memory vault\\n * @param _amount amount of eth to add\\n */\\n function addEthCollateral(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.collateralAmount = uint256(_vault.collateralAmount).add(_amount).toUint96();\\n }\\n\\n /**\\n * @notice add uniswap position token collateral to a vault\\n * @param _vault in-memory vault\\n * @param _tokenId uniswap position token id\\n */\\n function addUniNftCollateral(Vault memory _vault, uint256 _tokenId) internal pure {\\n require(_vault.NftCollateralId == 0, \\\"V1\\\");\\n require(_tokenId != 0, \\\"C23\\\");\\n _vault.NftCollateralId = _tokenId.toUint32();\\n }\\n\\n /**\\n * @notice remove eth collateral from a vault\\n * @param _vault in-memory vault\\n * @param _amount amount of eth to remove\\n */\\n function removeEthCollateral(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.collateralAmount = uint256(_vault.collateralAmount).sub(_amount).toUint96();\\n }\\n\\n /**\\n * @notice remove uniswap position token collateral from a vault\\n * @param _vault in-memory vault\\n */\\n function removeUniNftCollateral(Vault memory _vault) internal pure {\\n require(_vault.NftCollateralId != 0, \\\"V2\\\");\\n _vault.NftCollateralId = 0;\\n }\\n\\n /**\\n * @notice add debt to vault\\n * @param _vault in-memory vault\\n * @param _amount amount of debt to add\\n */\\n function addShort(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.shortAmount = uint256(_vault.shortAmount).add(_amount).toUint128();\\n }\\n\\n /**\\n * @notice remove debt from vault\\n * @param _vault in-memory vault\\n * @param _amount amount of debt to remove\\n */\\n function removeShort(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.shortAmount = uint256(_vault.shortAmount).sub(_amount).toUint128();\\n }\\n\\n /**\\n * @notice check if a vault is properly collateralized\\n * @param _vault the vault we want to check\\n * @param _positionManager address of the uniswap position manager\\n * @param _normalizationFactor current _normalizationFactor\\n * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18\\n * @param _minCollateral minimum collateral that needs to be in a vault\\n * @param _wsqueethPoolTick current price tick for wsqueeth pool\\n * @param _isWethToken0 whether weth is token0 in the wsqueeth pool\\n * @return true if the vault is sufficiently collateralized\\n * @return true if the vault is considered as a dust vault\\n */\\n function getVaultStatus(\\n Vault memory _vault,\\n address _positionManager,\\n uint256 _normalizationFactor,\\n uint256 _ethQuoteCurrencyPrice,\\n uint256 _minCollateral,\\n int24 _wsqueethPoolTick,\\n bool _isWethToken0\\n ) internal view returns (bool, bool) {\\n if (_vault.shortAmount == 0) return (true, false);\\n\\n uint256 debtValueInETH = uint256(_vault.shortAmount).mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div(\\n ONE_ONE\\n );\\n uint256 totalCollateral = _getEffectiveCollateral(\\n _vault,\\n _positionManager,\\n _normalizationFactor,\\n _ethQuoteCurrencyPrice,\\n _wsqueethPoolTick,\\n _isWethToken0\\n );\\n\\n bool isDust = totalCollateral < _minCollateral;\\n bool isAboveWater = totalCollateral.mul(CR_DENOMINATOR) >= debtValueInETH.mul(CR_NUMERATOR);\\n return (isAboveWater, isDust);\\n }\\n\\n /**\\n * @notice get the total effective collateral of a vault, which is:\\n * collateral amount + uniswap position token equivelent amount in eth\\n * @param _vault the vault we want to check\\n * @param _positionManager address of the uniswap position manager\\n * @param _normalizationFactor current _normalizationFactor\\n * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18\\n * @param _wsqueethPoolTick current price tick for wsqueeth pool\\n * @param _isWethToken0 whether weth is token0 in the wsqueeth pool\\n * @return the total worth of collateral in the vault\\n */\\n function _getEffectiveCollateral(\\n Vault memory _vault,\\n address _positionManager,\\n uint256 _normalizationFactor,\\n uint256 _ethQuoteCurrencyPrice,\\n int24 _wsqueethPoolTick,\\n bool _isWethToken0\\n ) internal view returns (uint256) {\\n if (_vault.NftCollateralId == 0) return _vault.collateralAmount;\\n\\n // the user has deposited uniswap position token as collateral, see how much eth / wSqueeth the uniswap position token has\\n (uint256 nftEthAmount, uint256 nftWsqueethAmount) = _getUniPositionBalances(\\n _positionManager,\\n _vault.NftCollateralId,\\n _wsqueethPoolTick,\\n _isWethToken0\\n );\\n // convert squeeth amount from uniswap position token as equivalent amount of collateral\\n uint256 wSqueethIndexValueInEth = nftWsqueethAmount.mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div(\\n ONE_ONE\\n );\\n // add eth value from uniswap position token as collateral\\n return nftEthAmount.add(wSqueethIndexValueInEth).add(_vault.collateralAmount);\\n }\\n\\n /**\\n * @notice determine how much eth / wPowerPerp the uniswap position contains\\n * @param _positionManager address of the uniswap position manager\\n * @param _tokenId uniswap position token id\\n * @param _wPowerPerpPoolTick current price tick\\n * @param _isWethToken0 whether weth is token0 in the pool\\n * @return ethAmount the eth amount this LP token contains\\n * @return wPowerPerpAmount the wPowerPerp amount this LP token contains\\n */\\n function _getUniPositionBalances(\\n address _positionManager,\\n uint256 _tokenId,\\n int24 _wPowerPerpPoolTick,\\n bool _isWethToken0\\n ) internal view returns (uint256 ethAmount, uint256 wPowerPerpAmount) {\\n (\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n ) = _getUniswapPositionInfo(_positionManager, _tokenId);\\n (uint256 amount0, uint256 amount1) = _getToken0Token1Balances(\\n tickLower,\\n tickUpper,\\n _wPowerPerpPoolTick,\\n liquidity\\n );\\n\\n return\\n _isWethToken0\\n ? (amount0 + tokensOwed0, amount1 + tokensOwed1)\\n : (amount1 + tokensOwed1, amount0 + tokensOwed0);\\n }\\n\\n /**\\n * @notice get uniswap position token info\\n * @param _positionManager address of the uniswap position position manager\\n * @param _tokenId uniswap position token id\\n * @return tickLower lower tick of the position\\n * @return tickUpper upper tick of the position\\n * @return liquidity raw liquidity amount of the position\\n * @return tokensOwed0 amount of token 0 can be collected as fee\\n * @return tokensOwed1 amount of token 1 can be collected as fee\\n */\\n function _getUniswapPositionInfo(address _positionManager, uint256 _tokenId)\\n internal\\n view\\n returns (\\n int24,\\n int24,\\n uint128,\\n uint128,\\n uint128\\n )\\n {\\n INonfungiblePositionManager positionManager = INonfungiblePositionManager(_positionManager);\\n (\\n ,\\n ,\\n ,\\n ,\\n ,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n ,\\n ,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n ) = positionManager.positions(_tokenId);\\n return (tickLower, tickUpper, liquidity, tokensOwed0, tokensOwed1);\\n }\\n\\n /**\\n * @notice get balances of token0 / token1 in a uniswap position\\n * @dev knowing liquidity, tick range, and current tick gives balances\\n * @param _tickLower address of the uniswap position manager\\n * @param _tickUpper uniswap position token id\\n * @param _tick current price tick used for calculation\\n * @return amount0 the amount of token0 in the uniswap position token\\n * @return amount1 the amount of token1 in the uniswap position token\\n */\\n function _getToken0Token1Balances(\\n int24 _tickLower,\\n int24 _tickUpper,\\n int24 _tick,\\n uint128 _liquidity\\n ) internal pure returns (uint256 amount0, uint256 amount1) {\\n // get the current price and tick from wPowerPerp pool\\n uint160 sqrtPriceX96 = TickMathExternal.getSqrtRatioAtTick(_tick);\\n\\n if (_tick < _tickLower) {\\n amount0 = SqrtPriceMathPartial.getAmount0Delta(\\n TickMathExternal.getSqrtRatioAtTick(_tickLower),\\n TickMathExternal.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n } else if (_tick < _tickUpper) {\\n amount0 = SqrtPriceMathPartial.getAmount0Delta(\\n sqrtPriceX96,\\n TickMathExternal.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n amount1 = SqrtPriceMathPartial.getAmount1Delta(\\n TickMathExternal.getSqrtRatioAtTick(_tickLower),\\n sqrtPriceX96,\\n _liquidity,\\n true\\n );\\n } else {\\n amount1 = SqrtPriceMathPartial.getAmount1Delta(\\n TickMathExternal.getSqrtRatioAtTick(_tickLower),\\n TickMathExternal.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n }\\n }\\n}\\n\",\"keccak256\":\"0x939175a827c8e9d8d09ee55957e8127a6a55bf42d6a0b3e48b0b59c895aa85af\",\"license\":\"GPL-2.0-or-later\"},\"contracts/periphery/ShortHelper.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\n\\npragma solidity =0.7.6;\\npragma abicoder v2;\\n// Interfaces\\nimport {IERC721} from \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\nimport {IERC721Receiver} from \\\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\\\";\\nimport {ISwapRouter} from \\\"@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol\\\";\\n\\nimport {IWPowerPerp} from \\\"../interfaces/IWPowerPerp.sol\\\";\\nimport {IWETH9} from \\\"../interfaces/IWETH9.sol\\\";\\nimport {IShortPowerPerp} from \\\"../interfaces/IShortPowerPerp.sol\\\";\\nimport {IController} from \\\"../interfaces/IController.sol\\\";\\n\\n// Libraries\\nimport {Address} from \\\"@openzeppelin/contracts/utils/Address.sol\\\";\\nimport {ReentrancyGuard} from \\\"@openzeppelin/contracts/utils/ReentrancyGuard.sol\\\";\\nimport {SafeMath} from \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\n\\n/**\\n * @notice contract simplifies opening a short wPowerPerp position by selling wPowerPerp on uniswap v3 and returning eth to user\\n */\\ncontract ShortHelper is IERC721Receiver, ReentrancyGuard {\\n using SafeMath for uint256;\\n using Address for address payable;\\n\\n IController public immutable controller;\\n ISwapRouter public immutable router;\\n IWETH9 public immutable weth;\\n IShortPowerPerp public immutable shortPowerPerp;\\n address public immutable wPowerPerp;\\n\\n /**\\n * @notice constructor for short helper\\n * @param _controllerAddr controller address for wPowerPerp\\n * @param _swapRouter uniswap v3 swap router address\\n * @param _wethAddr weth address\\n */\\n constructor(\\n address _controllerAddr,\\n address _swapRouter,\\n address _wethAddr\\n ) {\\n require(_controllerAddr != address(0), \\\"Invalid controller address\\\");\\n require(_swapRouter != address(0), \\\"Invalid swap router address\\\");\\n require(_wethAddr != address(0), \\\"Invalid weth address\\\");\\n IController _controller = IController(_controllerAddr);\\n router = ISwapRouter(_swapRouter);\\n wPowerPerp = _controller.wPowerPerp();\\n IWPowerPerp _wPowerPerp = IWPowerPerp(_controller.wPowerPerp());\\n IWETH9 _weth = IWETH9(_wethAddr);\\n _wPowerPerp.approve(_swapRouter, type(uint256).max);\\n _weth.approve(_swapRouter, type(uint256).max);\\n\\n // assign immutable variables\\n shortPowerPerp = IShortPowerPerp(_controller.shortPowerPerp());\\n weth = _weth;\\n controller = _controller;\\n }\\n\\n /**\\n * @notice mint power perp, trade with uniswap v3 and send back premium in eth\\n * @param _vaultId short wPowerPerp vault id\\n * @param _powerPerpAmount amount of powerPerp to mint/sell\\n * @param _uniNftId uniswap v3 position token id\\n */\\n function openShort(\\n uint256 _vaultId,\\n uint256 _powerPerpAmount,\\n uint256 _uniNftId,\\n ISwapRouter.ExactInputSingleParams memory _exactInputParams\\n ) external payable nonReentrant {\\n if (_vaultId != 0) require(shortPowerPerp.ownerOf(_vaultId) == msg.sender, \\\"Not allowed\\\");\\n require(\\n _exactInputParams.tokenOut == address(weth) && _exactInputParams.tokenIn == wPowerPerp,\\n \\\"Wrong swap tokens\\\"\\n );\\n\\n (uint256 vaultId, uint256 wPowerPerpAmount) = controller.mintPowerPerpAmount{value: msg.value}(\\n _vaultId,\\n _powerPerpAmount,\\n _uniNftId\\n );\\n _exactInputParams.amountIn = wPowerPerpAmount;\\n\\n uint256 amountOut = router.exactInputSingle(_exactInputParams);\\n\\n // if the recipient is this address: unwrap eth and send back to msg.sender\\n if (_exactInputParams.recipient == address(this)) {\\n weth.withdraw(amountOut);\\n payable(msg.sender).sendValue(amountOut);\\n }\\n\\n // this is a newly open vault, transfer to the user.\\n if (_vaultId == 0) shortPowerPerp.safeTransferFrom(address(this), msg.sender, vaultId);\\n }\\n\\n /**\\n * @notice buy back wPowerPerp with eth on uniswap v3 and close position\\n * @param _vaultId short wPowerPerp vault id\\n * @param _wPowerPerpAmount amount of wPowerPerp to burn\\n * @param _withdrawAmount amount to withdraw\\n */\\n function closeShort(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _withdrawAmount,\\n ISwapRouter.ExactOutputSingleParams memory _exactOutputParams\\n ) external payable nonReentrant {\\n require(shortPowerPerp.ownerOf(_vaultId) == msg.sender, \\\"Not allowed\\\");\\n require(\\n _exactOutputParams.tokenOut == wPowerPerp && _exactOutputParams.tokenIn == address(weth),\\n \\\"Wrong swap tokens\\\"\\n );\\n\\n // wrap eth to weth\\n weth.deposit{value: msg.value}();\\n\\n // pay weth and get wPowerPerp in return.\\n uint256 amountIn = router.exactOutputSingle(_exactOutputParams);\\n\\n controller.burnWPowerPerpAmount(_vaultId, _wPowerPerpAmount, _withdrawAmount);\\n\\n // send back unused eth and withdrawn collateral\\n weth.withdraw(msg.value.sub(amountIn));\\n // no eth should be left in the contract, so we send it all back\\n payable(msg.sender).sendValue(address(this).balance);\\n }\\n\\n /**\\n * @dev only receive eth from weth contract and controller.\\n */\\n receive() external payable {\\n require(msg.sender == address(weth) || msg.sender == address(controller), \\\"can't receive eth\\\");\\n }\\n\\n /**\\n * @dev accept erc721 from safeTransferFrom and safeMint after callback\\n * @return returns received selector\\n */\\n function onERC721Received(\\n address,\\n address,\\n uint256,\\n bytes memory\\n ) public virtual override returns (bytes4) {\\n return this.onERC721Received.selector;\\n }\\n}\\n\",\"keccak256\":\"0x512bb00cb9e4a780ba460ef629f3c581feb8ca669373417beeefdcbc1233c4d1\",\"license\":\"GPL-2.0-or-later\"}},\"version\":1}", + "bytecode": "0x6101206040523480156200001257600080fd5b5060405162001643380380620016438339810160408190526200003591620003e6565b60016000556001600160a01b0383166200006c5760405162461bcd60e51b81526004016200006390620004a1565b60405180910390fd5b6001600160a01b038216620000955760405162461bcd60e51b81526004016200006390620004d8565b6001600160a01b038116620000be5760405162461bcd60e51b815260040162000063906200046a565b6000839050826001600160a01b031660a0816001600160a01b031660601b81525050806001600160a01b0316637f07b1306040518163ffffffff1660e01b815260040160206040518083038186803b1580156200011a57600080fd5b505afa1580156200012f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001559190620003c2565b6001600160a01b0316610100816001600160a01b031660601b815250506000816001600160a01b0316637f07b1306040518163ffffffff1660e01b815260040160206040518083038186803b158015620001ae57600080fd5b505afa158015620001c3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001e99190620003c2565b60405163095ea7b360e01b815290915083906001600160a01b0383169063095ea7b390620002209088906000199060040162000451565b602060405180830381600087803b1580156200023b57600080fd5b505af115801562000250573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200027691906200042f565b5060405163095ea7b360e01b81526001600160a01b0382169063095ea7b390620002a99088906000199060040162000451565b602060405180830381600087803b158015620002c457600080fd5b505af1158015620002d9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002ff91906200042f565b50826001600160a01b0316639d4c94426040518163ffffffff1660e01b815260040160206040518083038186803b1580156200033a57600080fd5b505afa1580156200034f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003759190620003c2565b6001600160601b0319606091821b811660e05291811b821660c0529290921b909116608052506200050f92505050565b80516001600160a01b0381168114620003bd57600080fd5b919050565b600060208284031215620003d4578081fd5b620003df82620003a5565b9392505050565b600080600060608486031215620003fb578182fd5b6200040684620003a5565b92506200041660208501620003a5565b91506200042660408501620003a5565b90509250925092565b60006020828403121562000441578081fd5b81518015158114620003df578182fd5b6001600160a01b03929092168252602082015260400190565b60208082526014908201527f496e76616c696420776574682061646472657373000000000000000000000000604082015260600190565b6020808252601a908201527f496e76616c696420636f6e74726f6c6c65722061646472657373000000000000604082015260600190565b6020808252601b908201527f496e76616c6964207377617020726f7574657220616464726573730000000000604082015260600190565b60805160601c60a05160601c60c05160601c60e05160601c6101005160601c611097620005ac60003980610314528061060a52806107b952508061025f528061062e52806106c45280610a1e525080608f528061035452806103aa528061054a52806105e65280610779528061098e52508061043452806108d85280610abe52508060c152806104d752806108125280610a9a52506110976000f3fe60806040526004361061007f5760003560e01c80639d4c94421161004e5780639d4c94421461018f578063e56cfbbe146101a4578063f77c4791146101b7578063f887ea40146101cc5761010a565b8063150b7a021461010f57806317fd9e0e146101455780633fc8cef3146101585780637f07b1301461017a5761010a565b3661010a57336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614806100e35750336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016145b6101085760405162461bcd60e51b81526004016100ff90610f86565b60405180910390fd5b005b600080fd5b34801561011b57600080fd5b5061012f61012a366004610d1e565b6101e1565b60405161013c9190610eeb565b60405180910390f35b610108610153366004610e0f565b6101f1565b34801561016457600080fd5b5061016d6105e4565b60405161013c9190610eb3565b34801561018657600080fd5b5061016d610608565b34801561019b57600080fd5b5061016d61062c565b6101086101b2366004610e0f565b610650565b3480156101c357600080fd5b5061016d610a98565b3480156101d857600080fd5b5061016d610abc565b630a85bd0160e11b949350505050565b60026000541415610249576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026000556040516331a9108f60e11b815233907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e9061029c908890600401610fcc565b60206040518083038186803b1580156102b457600080fd5b505afa1580156102c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ec9190610cfb565b6001600160a01b0316146103125760405162461bcd60e51b81526004016100ff90610f4f565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681602001516001600160a01b031614801561038c57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681600001516001600160a01b0316145b6103a85760405162461bcd60e51b81526004016100ff90610f18565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561040357600080fd5b505af1158015610417573d6000803e3d6000fd5b5050604051631b67c43360e31b8152600093506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016925063db3e2198915061046b908590600401610fbd565b602060405180830381600087803b15801561048557600080fd5b505af1158015610499573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104bd9190610dd4565b604051638632cb0360e01b81529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638632cb039061051090889088908890600401610fd5565b600060405180830381600087803b15801561052a57600080fd5b505af115801561053e573d6000803e3d6000fd5b50506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169150632e1a7d4d905061057d3484610ae0565b6040518263ffffffff1660e01b81526004016105999190610fcc565b600060405180830381600087803b1580156105b357600080fd5b505af11580156105c7573d6000803e3d6000fd5b506105d89250339150479050610b42565b50506001600055505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600260005414156106a8576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026000558315610777576040516331a9108f60e11b815233907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90610701908890600401610fcc565b60206040518083038186803b15801561071957600080fd5b505afa15801561072d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107519190610cfb565b6001600160a01b0316146107775760405162461bcd60e51b81526004016100ff90610f4f565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681602001516001600160a01b03161480156107f157507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681600001516001600160a01b0316145b61080d5760405162461bcd60e51b81526004016100ff90610f18565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631bf7bf6c348888886040518563ffffffff1660e01b815260040161086193929190610fd5565b60408051808303818588803b15801561087957600080fd5b505af115801561088d573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906108b29190610dec565b60a0850181905260405163414bf38960e01b815291935091506000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063414bf3899061090d908790600401610fbd565b602060405180830381600087803b15801561092757600080fd5b505af115801561093b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095f9190610dd4565b60608501519091506001600160a01b0316301415610a0257604051632e1a7d4d60e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690632e1a7d4d906109c3908490600401610fcc565b600060405180830381600087803b1580156109dd57600080fd5b505af11580156109f1573d6000803e3d6000fd5b50610a029250339150839050610b42565b86610a8a57604051632142170760e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906342842e0e90610a5790309033908890600401610ec7565b600060405180830381600087803b158015610a7157600080fd5b505af1158015610a85573d6000803e3d6000fd5b505050505b505060016000555050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600082821115610b37576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b80471015610b97576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114610be2576040519150601f19603f3d011682016040523d82523d6000602084013e610be7565b606091505b5050905080610c275760405162461bcd60e51b815260040180806020018281038252603a815260200180611028603a913960400191505060405180910390fd5b505050565b8035610c378161100f565b919050565b6000610100808385031215610c4f578182fd5b6040519081019067ffffffffffffffff82118183101715610c6c57fe5b81604052809250610c7c84610c2c565b8152610c8a60208501610c2c565b6020820152610c9b60408501610ce8565b6040820152610cac60608501610c2c565b60608201526080840135608082015260a084013560a082015260c084013560c0820152610cdb60e08501610c2c565b60e0820152505092915050565b803562ffffff81168114610c3757600080fd5b600060208284031215610d0c578081fd5b8151610d178161100f565b9392505050565b60008060008060808587031215610d33578283fd5b8435610d3e8161100f565b9350602085810135610d4f8161100f565b935060408601359250606086013567ffffffffffffffff80821115610d72578384fd5b818801915088601f830112610d85578384fd5b813581811115610d9157fe5b610da3601f8201601f19168501610feb565b91508082528984828501011115610db8578485fd5b8084840185840137810190920192909252939692955090935050565b600060208284031215610de5578081fd5b5051919050565b60008060408385031215610dfe578182fd5b505080516020909101519092909150565b6000806000806101608587031215610e25578384fd5b843593506020850135925060408501359150610e448660608701610c3c565b905092959194509250565b6001600160a01b0380825116835280602083015116602084015262ffffff60408301511660408401528060608301511660608401526080820151608084015260a082015160a084015260c082015160c08401528060e08301511660e0840152505050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b60208082526011908201527f57726f6e67207377617020746f6b656e73000000000000000000000000000000604082015260600190565b6020808252600b908201527f4e6f7420616c6c6f776564000000000000000000000000000000000000000000604082015260600190565b60208082526011908201527f63616e2774207265636569766520657468000000000000000000000000000000604082015260600190565b6101008101610b3c8284610e4f565b90815260200190565b9283526020830191909152604082015260600190565b60405181810167ffffffffffffffff8111828210171561100757fe5b604052919050565b6001600160a01b038116811461102457600080fd5b5056fe416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564a2646970667358221220dca83f927accd8f5dd17b8c7ca8e2147659fcc484c1799c390e51729507a6b9f64736f6c63430007060033", + "deployedBytecode": "0x60806040526004361061007f5760003560e01c80639d4c94421161004e5780639d4c94421461018f578063e56cfbbe146101a4578063f77c4791146101b7578063f887ea40146101cc5761010a565b8063150b7a021461010f57806317fd9e0e146101455780633fc8cef3146101585780637f07b1301461017a5761010a565b3661010a57336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614806100e35750336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016145b6101085760405162461bcd60e51b81526004016100ff90610f86565b60405180910390fd5b005b600080fd5b34801561011b57600080fd5b5061012f61012a366004610d1e565b6101e1565b60405161013c9190610eeb565b60405180910390f35b610108610153366004610e0f565b6101f1565b34801561016457600080fd5b5061016d6105e4565b60405161013c9190610eb3565b34801561018657600080fd5b5061016d610608565b34801561019b57600080fd5b5061016d61062c565b6101086101b2366004610e0f565b610650565b3480156101c357600080fd5b5061016d610a98565b3480156101d857600080fd5b5061016d610abc565b630a85bd0160e11b949350505050565b60026000541415610249576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026000556040516331a9108f60e11b815233907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e9061029c908890600401610fcc565b60206040518083038186803b1580156102b457600080fd5b505afa1580156102c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ec9190610cfb565b6001600160a01b0316146103125760405162461bcd60e51b81526004016100ff90610f4f565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681602001516001600160a01b031614801561038c57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681600001516001600160a01b0316145b6103a85760405162461bcd60e51b81526004016100ff90610f18565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561040357600080fd5b505af1158015610417573d6000803e3d6000fd5b5050604051631b67c43360e31b8152600093506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016925063db3e2198915061046b908590600401610fbd565b602060405180830381600087803b15801561048557600080fd5b505af1158015610499573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104bd9190610dd4565b604051638632cb0360e01b81529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690638632cb039061051090889088908890600401610fd5565b600060405180830381600087803b15801561052a57600080fd5b505af115801561053e573d6000803e3d6000fd5b50506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169150632e1a7d4d905061057d3484610ae0565b6040518263ffffffff1660e01b81526004016105999190610fcc565b600060405180830381600087803b1580156105b357600080fd5b505af11580156105c7573d6000803e3d6000fd5b506105d89250339150479050610b42565b50506001600055505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600260005414156106a8576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026000558315610777576040516331a9108f60e11b815233907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90610701908890600401610fcc565b60206040518083038186803b15801561071957600080fd5b505afa15801561072d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107519190610cfb565b6001600160a01b0316146107775760405162461bcd60e51b81526004016100ff90610f4f565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681602001516001600160a01b03161480156107f157507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681600001516001600160a01b0316145b61080d5760405162461bcd60e51b81526004016100ff90610f18565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631bf7bf6c348888886040518563ffffffff1660e01b815260040161086193929190610fd5565b60408051808303818588803b15801561087957600080fd5b505af115801561088d573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906108b29190610dec565b60a0850181905260405163414bf38960e01b815291935091506000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063414bf3899061090d908790600401610fbd565b602060405180830381600087803b15801561092757600080fd5b505af115801561093b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095f9190610dd4565b60608501519091506001600160a01b0316301415610a0257604051632e1a7d4d60e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690632e1a7d4d906109c3908490600401610fcc565b600060405180830381600087803b1580156109dd57600080fd5b505af11580156109f1573d6000803e3d6000fd5b50610a029250339150839050610b42565b86610a8a57604051632142170760e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906342842e0e90610a5790309033908890600401610ec7565b600060405180830381600087803b158015610a7157600080fd5b505af1158015610a85573d6000803e3d6000fd5b505050505b505060016000555050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b600082821115610b37576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b80471015610b97576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114610be2576040519150601f19603f3d011682016040523d82523d6000602084013e610be7565b606091505b5050905080610c275760405162461bcd60e51b815260040180806020018281038252603a815260200180611028603a913960400191505060405180910390fd5b505050565b8035610c378161100f565b919050565b6000610100808385031215610c4f578182fd5b6040519081019067ffffffffffffffff82118183101715610c6c57fe5b81604052809250610c7c84610c2c565b8152610c8a60208501610c2c565b6020820152610c9b60408501610ce8565b6040820152610cac60608501610c2c565b60608201526080840135608082015260a084013560a082015260c084013560c0820152610cdb60e08501610c2c565b60e0820152505092915050565b803562ffffff81168114610c3757600080fd5b600060208284031215610d0c578081fd5b8151610d178161100f565b9392505050565b60008060008060808587031215610d33578283fd5b8435610d3e8161100f565b9350602085810135610d4f8161100f565b935060408601359250606086013567ffffffffffffffff80821115610d72578384fd5b818801915088601f830112610d85578384fd5b813581811115610d9157fe5b610da3601f8201601f19168501610feb565b91508082528984828501011115610db8578485fd5b8084840185840137810190920192909252939692955090935050565b600060208284031215610de5578081fd5b5051919050565b60008060408385031215610dfe578182fd5b505080516020909101519092909150565b6000806000806101608587031215610e25578384fd5b843593506020850135925060408501359150610e448660608701610c3c565b905092959194509250565b6001600160a01b0380825116835280602083015116602084015262ffffff60408301511660408401528060608301511660608401526080820151608084015260a082015160a084015260c082015160c08401528060e08301511660e0840152505050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b60208082526011908201527f57726f6e67207377617020746f6b656e73000000000000000000000000000000604082015260600190565b6020808252600b908201527f4e6f7420616c6c6f776564000000000000000000000000000000000000000000604082015260600190565b60208082526011908201527f63616e2774207265636569766520657468000000000000000000000000000000604082015260600190565b6101008101610b3c8284610e4f565b90815260200190565b9283526020830191909152604082015260600190565b60405181810167ffffffffffffffff8111828210171561100757fe5b604052919050565b6001600160a01b038116811461102457600080fd5b5056fe416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564a2646970667358221220dca83f927accd8f5dd17b8c7ca8e2147659fcc484c1799c390e51729507a6b9f64736f6c63430007060033", "devdoc": { "kind": "dev", "methods": { diff --git a/packages/hardhat/deployments/mainnet/ShortPowerPerp.json b/packages/hardhat/deployments/mainnet/ShortPowerPerp.json index 44f3fa911..536088a2b 100644 --- a/packages/hardhat/deployments/mainnet/ShortPowerPerp.json +++ b/packages/hardhat/deployments/mainnet/ShortPowerPerp.json @@ -1,5 +1,5 @@ { - "address": "0x4757F744ec0CF2e3500Dc655F55100C943a59cbb", + "address": "0xa653e22A963ff0026292Cc8B67941c0ba7863a38", "abi": [ { "inputs": [ @@ -475,19 +475,19 @@ "type": "function" } ], - "transactionHash": "0x5602a62ef3f18de643a9e3566867642276d94fea8786b2d2617fa7d8185e8d25", + "transactionHash": "0xb9d2a269993923dc908e89e1a02d9bc242df96a80503be150f5f31b186ab97d0", "receipt": { "to": null, - "from": "0x80010e7575b24f47097598474502F0fd0aDbF3a8", - "contractAddress": "0x4757F744ec0CF2e3500Dc655F55100C943a59cbb", - "transactionIndex": 44, - "gasUsed": "1949303", + "from": "0xa3cB04d8BD927EEC8826BD77b7C71abE3d29c081", + "contractAddress": "0xa653e22A963ff0026292Cc8B67941c0ba7863a38", + "transactionIndex": 23, + "gasUsed": "1944232", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x3fe13b6d41818cdd38b67ba598ded2b8284c1196dbd17a276bb4e441af142855", - "transactionHash": "0x5602a62ef3f18de643a9e3566867642276d94fea8786b2d2617fa7d8185e8d25", + "blockHash": "0xfb57ebbb216a9727f9003920d25985329d8f0ad0220a1d364294130d613df597", + "transactionHash": "0xb9d2a269993923dc908e89e1a02d9bc242df96a80503be150f5f31b186ab97d0", "logs": [], - "blockNumber": 13977443, - "cumulativeGasUsed": "5693277", + "blockNumber": 13982499, + "cumulativeGasUsed": "4596806", "status": 1, "byzantium": true }, @@ -495,10 +495,10 @@ "short Squeeth", "sSQU" ], - "solcInputHash": "56b4ec4ab07157f3d2fb7e1de805d93e", - "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_symbol\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"baseURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controller\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getApproved\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_controller\",\"type\":\"address\"}],\"name\":\"init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_recipient\",\"type\":\"address\"}],\"name\":\"mintNFT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nextId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenOfOwnerByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"approve(address,uint256)\":{\"details\":\"See {IERC721-approve}.\"},\"balanceOf(address)\":{\"details\":\"See {IERC721-balanceOf}.\"},\"baseURI()\":{\"details\":\"Returns the base URI set via {_setBaseURI}. This will be automatically added as a prefix in {tokenURI} to each token's URI, or to the token ID if no specific URI is set for that token ID.\"},\"constructor\":{\"params\":{\"_name\":\"token name for ERC721\",\"_symbol\":\"token symbol for ERC721\"}},\"getApproved(uint256)\":{\"details\":\"See {IERC721-getApproved}.\"},\"init(address)\":{\"params\":{\"_controller\":\"controller address\"}},\"isApprovedForAll(address,address)\":{\"details\":\"See {IERC721-isApprovedForAll}.\"},\"mintNFT(address)\":{\"details\":\"autoincrement tokenId starts at 1\",\"params\":{\"_recipient\":\"recipient address for NFT\"}},\"name()\":{\"details\":\"See {IERC721Metadata-name}.\"},\"ownerOf(uint256)\":{\"details\":\"See {IERC721-ownerOf}.\"},\"safeTransferFrom(address,address,uint256)\":{\"details\":\"See {IERC721-safeTransferFrom}.\"},\"safeTransferFrom(address,address,uint256,bytes)\":{\"details\":\"See {IERC721-safeTransferFrom}.\"},\"setApprovalForAll(address,bool)\":{\"details\":\"See {IERC721-setApprovalForAll}.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}. Time complexity O(1), guaranteed to always use less than 30 000 gas.\"},\"symbol()\":{\"details\":\"See {IERC721Metadata-symbol}.\"},\"tokenByIndex(uint256)\":{\"details\":\"See {IERC721Enumerable-tokenByIndex}.\"},\"tokenOfOwnerByIndex(address,uint256)\":{\"details\":\"See {IERC721Enumerable-tokenOfOwnerByIndex}.\"},\"tokenURI(uint256)\":{\"details\":\"See {IERC721Metadata-tokenURI}.\"},\"totalSupply()\":{\"details\":\"See {IERC721Enumerable-totalSupply}.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"See {IERC721-transferFrom}.\"}},\"stateVariables\":{\"nextId\":{\"details\":\"tokenId for the next vault opened\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"constructor\":{\"notice\":\"short power perpetual constructor\"},\"init(address)\":{\"notice\":\"initialize short contract\"},\"mintNFT(address)\":{\"notice\":\"mint new NFT\"}},\"notice\":\"ERC721 NFT representing ownership of a vault (short position)\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/core/ShortPowerPerp.sol\":\"ShortPowerPerp\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":850},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/introspection/ERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./IERC165.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC165} interface.\\n *\\n * Contracts may inherit from this and call {_registerInterface} to declare\\n * their support of an interface.\\n */\\nabstract contract ERC165 is IERC165 {\\n /*\\n * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7\\n */\\n bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;\\n\\n /**\\n * @dev Mapping of interface ids to whether or not it's supported.\\n */\\n mapping(bytes4 => bool) private _supportedInterfaces;\\n\\n constructor () {\\n // Derived contracts need only register support for their own interfaces,\\n // we register support for ERC165 itself here\\n _registerInterface(_INTERFACE_ID_ERC165);\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n *\\n * Time complexity O(1), guaranteed to always use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return _supportedInterfaces[interfaceId];\\n }\\n\\n /**\\n * @dev Registers the contract as an implementer of the interface defined by\\n * `interfaceId`. Support of the actual ERC165 interface is automatic and\\n * registering its interface id is not required.\\n *\\n * See {IERC165-supportsInterface}.\\n *\\n * Requirements:\\n *\\n * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).\\n */\\n function _registerInterface(bytes4 interfaceId) internal virtual {\\n require(interfaceId != 0xffffffff, \\\"ERC165: invalid interface id\\\");\\n _supportedInterfaces[interfaceId] = true;\\n }\\n}\\n\",\"keccak256\":\"0x234cdf2c3efd5f0dc17d32fe65d33c21674ca17de1e945eb60ac1076d7152d96\",\"license\":\"MIT\"},\"@openzeppelin/contracts/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd2f30fad5b24c4120f96dbac83aacdb7993ee610a9092bc23c44463da292bf8d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0xe22a1fc7400ae196eba2ad1562d0386462b00a6363b742d55a2fd2021a58586f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n// solhint-disable-next-line compiler-version\\npragma solidity >=0.4.24 <0.8.0;\\n\\nimport \\\"../utils/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 a proxied contract can't have a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n */\\nabstract contract Initializable {\\n\\n /**\\n * @dev Indicates that the contract has been initialized.\\n */\\n bool private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Modifier to protect an initializer function from being invoked twice.\\n */\\n modifier initializer() {\\n require(_initializing || _isConstructor() || !_initialized, \\\"Initializable: contract is already initialized\\\");\\n\\n bool isTopLevelCall = !_initializing;\\n if (isTopLevelCall) {\\n _initializing = true;\\n _initialized = true;\\n }\\n\\n _;\\n\\n if (isTopLevelCall) {\\n _initializing = false;\\n }\\n }\\n\\n /// @dev Returns true if and only if the function is running in the constructor\\n function _isConstructor() private view returns (bool) {\\n return !Address.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0x9abeffe138f098b16557187383ba0f9e8503602fa95cd668132986ee115237ed\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/ERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"../../utils/Context.sol\\\";\\nimport \\\"./IERC721.sol\\\";\\nimport \\\"./IERC721Metadata.sol\\\";\\nimport \\\"./IERC721Enumerable.sol\\\";\\nimport \\\"./IERC721Receiver.sol\\\";\\nimport \\\"../../introspection/ERC165.sol\\\";\\nimport \\\"../../math/SafeMath.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/EnumerableSet.sol\\\";\\nimport \\\"../../utils/EnumerableMap.sol\\\";\\nimport \\\"../../utils/Strings.sol\\\";\\n\\n/**\\n * @title ERC721 Non-Fungible Token Standard basic implementation\\n * @dev see https://eips.ethereum.org/EIPS/eip-721\\n */\\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {\\n using SafeMath for uint256;\\n using Address for address;\\n using EnumerableSet for EnumerableSet.UintSet;\\n using EnumerableMap for EnumerableMap.UintToAddressMap;\\n using Strings for uint256;\\n\\n // Equals to `bytes4(keccak256(\\\"onERC721Received(address,address,uint256,bytes)\\\"))`\\n // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`\\n bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;\\n\\n // Mapping from holder address to their (enumerable) set of owned tokens\\n mapping (address => EnumerableSet.UintSet) private _holderTokens;\\n\\n // Enumerable mapping from token ids to their owners\\n EnumerableMap.UintToAddressMap private _tokenOwners;\\n\\n // Mapping from token ID to approved address\\n mapping (uint256 => address) private _tokenApprovals;\\n\\n // Mapping from owner to operator approvals\\n mapping (address => mapping (address => bool)) private _operatorApprovals;\\n\\n // Token name\\n string private _name;\\n\\n // Token symbol\\n string private _symbol;\\n\\n // Optional mapping for token URIs\\n mapping (uint256 => string) private _tokenURIs;\\n\\n // Base URI\\n string private _baseURI;\\n\\n /*\\n * bytes4(keccak256('balanceOf(address)')) == 0x70a08231\\n * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e\\n * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3\\n * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc\\n * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465\\n * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5\\n * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd\\n * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e\\n * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde\\n *\\n * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^\\n * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd\\n */\\n bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;\\n\\n /*\\n * bytes4(keccak256('name()')) == 0x06fdde03\\n * bytes4(keccak256('symbol()')) == 0x95d89b41\\n * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd\\n *\\n * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f\\n */\\n bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;\\n\\n /*\\n * bytes4(keccak256('totalSupply()')) == 0x18160ddd\\n * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59\\n * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7\\n *\\n * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63\\n */\\n bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;\\n\\n /**\\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\\n */\\n constructor (string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n\\n // register the supported interfaces to conform to ERC721 via ERC165\\n _registerInterface(_INTERFACE_ID_ERC721);\\n _registerInterface(_INTERFACE_ID_ERC721_METADATA);\\n _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);\\n }\\n\\n /**\\n * @dev See {IERC721-balanceOf}.\\n */\\n function balanceOf(address owner) public view virtual override returns (uint256) {\\n require(owner != address(0), \\\"ERC721: balance query for the zero address\\\");\\n return _holderTokens[owner].length();\\n }\\n\\n /**\\n * @dev See {IERC721-ownerOf}.\\n */\\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\\n return _tokenOwners.get(tokenId, \\\"ERC721: owner query for nonexistent token\\\");\\n }\\n\\n /**\\n * @dev See {IERC721Metadata-name}.\\n */\\n function name() public view virtual override returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev See {IERC721Metadata-symbol}.\\n */\\n function symbol() public view virtual override returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev See {IERC721Metadata-tokenURI}.\\n */\\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\\n require(_exists(tokenId), \\\"ERC721Metadata: URI query for nonexistent token\\\");\\n\\n string memory _tokenURI = _tokenURIs[tokenId];\\n string memory base = baseURI();\\n\\n // If there is no base URI, return the token URI.\\n if (bytes(base).length == 0) {\\n return _tokenURI;\\n }\\n // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).\\n if (bytes(_tokenURI).length > 0) {\\n return string(abi.encodePacked(base, _tokenURI));\\n }\\n // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.\\n return string(abi.encodePacked(base, tokenId.toString()));\\n }\\n\\n /**\\n * @dev Returns the base URI set via {_setBaseURI}. This will be\\n * automatically added as a prefix in {tokenURI} to each token's URI, or\\n * to the token ID if no specific URI is set for that token ID.\\n */\\n function baseURI() public view virtual returns (string memory) {\\n return _baseURI;\\n }\\n\\n /**\\n * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.\\n */\\n function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {\\n return _holderTokens[owner].at(index);\\n }\\n\\n /**\\n * @dev See {IERC721Enumerable-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds\\n return _tokenOwners.length();\\n }\\n\\n /**\\n * @dev See {IERC721Enumerable-tokenByIndex}.\\n */\\n function tokenByIndex(uint256 index) public view virtual override returns (uint256) {\\n (uint256 tokenId, ) = _tokenOwners.at(index);\\n return tokenId;\\n }\\n\\n /**\\n * @dev See {IERC721-approve}.\\n */\\n function approve(address to, uint256 tokenId) public virtual override {\\n address owner = ERC721.ownerOf(tokenId);\\n require(to != owner, \\\"ERC721: approval to current owner\\\");\\n\\n require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()),\\n \\\"ERC721: approve caller is not owner nor approved for all\\\"\\n );\\n\\n _approve(to, tokenId);\\n }\\n\\n /**\\n * @dev See {IERC721-getApproved}.\\n */\\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\\n require(_exists(tokenId), \\\"ERC721: approved query for nonexistent token\\\");\\n\\n return _tokenApprovals[tokenId];\\n }\\n\\n /**\\n * @dev See {IERC721-setApprovalForAll}.\\n */\\n function setApprovalForAll(address operator, bool approved) public virtual override {\\n require(operator != _msgSender(), \\\"ERC721: approve to caller\\\");\\n\\n _operatorApprovals[_msgSender()][operator] = approved;\\n emit ApprovalForAll(_msgSender(), operator, approved);\\n }\\n\\n /**\\n * @dev See {IERC721-isApprovedForAll}.\\n */\\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\\n return _operatorApprovals[owner][operator];\\n }\\n\\n /**\\n * @dev See {IERC721-transferFrom}.\\n */\\n function transferFrom(address from, address to, uint256 tokenId) public virtual override {\\n //solhint-disable-next-line max-line-length\\n require(_isApprovedOrOwner(_msgSender(), tokenId), \\\"ERC721: transfer caller is not owner nor approved\\\");\\n\\n _transfer(from, to, tokenId);\\n }\\n\\n /**\\n * @dev See {IERC721-safeTransferFrom}.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {\\n safeTransferFrom(from, to, tokenId, \\\"\\\");\\n }\\n\\n /**\\n * @dev See {IERC721-safeTransferFrom}.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {\\n require(_isApprovedOrOwner(_msgSender(), tokenId), \\\"ERC721: transfer caller is not owner nor approved\\\");\\n _safeTransfer(from, to, tokenId, _data);\\n }\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * `_data` is additional data, it has no specified format and it is sent in call to `to`.\\n *\\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\\n * implement alternative mechanisms to perform token transfer, such as signature-based.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {\\n _transfer(from, to, tokenId);\\n require(_checkOnERC721Received(from, to, tokenId, _data), \\\"ERC721: transfer to non ERC721Receiver implementer\\\");\\n }\\n\\n /**\\n * @dev Returns whether `tokenId` exists.\\n *\\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\\n *\\n * Tokens start existing when they are minted (`_mint`),\\n * and stop existing when they are burned (`_burn`).\\n */\\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\\n return _tokenOwners.contains(tokenId);\\n }\\n\\n /**\\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\\n require(_exists(tokenId), \\\"ERC721: operator query for nonexistent token\\\");\\n address owner = ERC721.ownerOf(tokenId);\\n return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender));\\n }\\n\\n /**\\n * @dev Safely mints `tokenId` and transfers it to `to`.\\n *\\n * Requirements:\\n d*\\n * - `tokenId` must not exist.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _safeMint(address to, uint256 tokenId) internal virtual {\\n _safeMint(to, tokenId, \\\"\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\\n */\\n function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual {\\n _mint(to, tokenId);\\n require(_checkOnERC721Received(address(0), to, tokenId, _data), \\\"ERC721: transfer to non ERC721Receiver implementer\\\");\\n }\\n\\n /**\\n * @dev Mints `tokenId` and transfers it to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\\n *\\n * Requirements:\\n *\\n * - `tokenId` must not exist.\\n * - `to` cannot be the zero address.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _mint(address to, uint256 tokenId) internal virtual {\\n require(to != address(0), \\\"ERC721: mint to the zero address\\\");\\n require(!_exists(tokenId), \\\"ERC721: token already minted\\\");\\n\\n _beforeTokenTransfer(address(0), to, tokenId);\\n\\n _holderTokens[to].add(tokenId);\\n\\n _tokenOwners.set(tokenId, to);\\n\\n emit Transfer(address(0), to, tokenId);\\n }\\n\\n /**\\n * @dev Destroys `tokenId`.\\n * The approval is cleared when the token is burned.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _burn(uint256 tokenId) internal virtual {\\n address owner = ERC721.ownerOf(tokenId); // internal owner\\n\\n _beforeTokenTransfer(owner, address(0), tokenId);\\n\\n // Clear approvals\\n _approve(address(0), tokenId);\\n\\n // Clear metadata (if any)\\n if (bytes(_tokenURIs[tokenId]).length != 0) {\\n delete _tokenURIs[tokenId];\\n }\\n\\n _holderTokens[owner].remove(tokenId);\\n\\n _tokenOwners.remove(tokenId);\\n\\n emit Transfer(owner, address(0), tokenId);\\n }\\n\\n /**\\n * @dev Transfers `tokenId` from `from` to `to`.\\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _transfer(address from, address to, uint256 tokenId) internal virtual {\\n require(ERC721.ownerOf(tokenId) == from, \\\"ERC721: transfer of token that is not own\\\"); // internal owner\\n require(to != address(0), \\\"ERC721: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, tokenId);\\n\\n // Clear approvals from the previous owner\\n _approve(address(0), tokenId);\\n\\n _holderTokens[from].remove(tokenId);\\n _holderTokens[to].add(tokenId);\\n\\n _tokenOwners.set(tokenId, to);\\n\\n emit Transfer(from, to, tokenId);\\n }\\n\\n /**\\n * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {\\n require(_exists(tokenId), \\\"ERC721Metadata: URI set of nonexistent token\\\");\\n _tokenURIs[tokenId] = _tokenURI;\\n }\\n\\n /**\\n * @dev Internal function to set the base URI for all token IDs. It is\\n * automatically added as a prefix to the value returned in {tokenURI},\\n * or to the token ID if {tokenURI} is empty.\\n */\\n function _setBaseURI(string memory baseURI_) internal virtual {\\n _baseURI = baseURI_;\\n }\\n\\n /**\\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\\n * The call is not executed if the target address is not a contract.\\n *\\n * @param from address representing the previous owner of the given token ID\\n * @param to target address that will receive the tokens\\n * @param tokenId uint256 ID of the token to be transferred\\n * @param _data bytes optional data to send along with the call\\n * @return bool whether the call correctly returned the expected magic value\\n */\\n function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)\\n private returns (bool)\\n {\\n if (!to.isContract()) {\\n return true;\\n }\\n bytes memory returndata = to.functionCall(abi.encodeWithSelector(\\n IERC721Receiver(to).onERC721Received.selector,\\n _msgSender(),\\n from,\\n tokenId,\\n _data\\n ), \\\"ERC721: transfer to non ERC721Receiver implementer\\\");\\n bytes4 retval = abi.decode(returndata, (bytes4));\\n return (retval == _ERC721_RECEIVED);\\n }\\n\\n /**\\n * @dev Approve `to` to operate on `tokenId`\\n *\\n * Emits an {Approval} event.\\n */\\n function _approve(address to, uint256 tokenId) internal virtual {\\n _tokenApprovals[tokenId] = to;\\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner\\n }\\n\\n /**\\n * @dev Hook that is called before any token transfer. This includes minting\\n * and burning.\\n *\\n * Calling conditions:\\n *\\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\\n * transferred to `to`.\\n * - When `from` is zero, `tokenId` will be minted for `to`.\\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }\\n}\\n\",\"keccak256\":\"0x93e4f65a89c3c888afbaa3ee18c3fa4f51c422419bbcd9cca47676a0f8e507ea\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"../../introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\\n}\\n\",\"keccak256\":\"0xb11597841d47f7a773bca63ca323c76f804cb5d944788de0327db5526319dc82\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Enumerable is IERC721 {\\n\\n /**\\n * @dev Returns the total amount of tokens stored by the contract.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\\n */\\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);\\n\\n /**\\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\\n * Use along with {totalSupply} to enumerate all tokens.\\n */\\n function tokenByIndex(uint256 index) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x2789dfea2d73182683d637db5729201f6730dae6113030a94c828f8688f38f2f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Metadata is IERC721 {\\n\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0xc82c7d1d732081d9bd23f1555ebdf8f3bc1738bc42c2bfc4b9aa7564d9fa3573\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\\n */\\n function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0x05604ffcf69e416b8a42728bb0e4fd75170d8fac70bf1a284afeb4752a9bc52f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf89f005a3d98f7768cdee2583707db0ac725cf567d455751af32ee68132f3db3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/*\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with GSN meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x8d3cb350f04ff49cfb10aef08d87f19dcbaecc8027b0bed12f3275cd12f38cf0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/EnumerableMap.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Library for managing an enumerable variant of Solidity's\\n * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]\\n * type.\\n *\\n * Maps have the following properties:\\n *\\n * - Entries are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Entries are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableMap for EnumerableMap.UintToAddressMap;\\n *\\n * // Declare a set state variable\\n * EnumerableMap.UintToAddressMap private myMap;\\n * }\\n * ```\\n *\\n * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are\\n * supported.\\n */\\nlibrary EnumerableMap {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Map type with\\n // bytes32 keys and values.\\n // The Map implementation uses private functions, and user-facing\\n // implementations (such as Uint256ToAddressMap) are just wrappers around\\n // the underlying Map.\\n // This means that we can only create new EnumerableMaps for types that fit\\n // in bytes32.\\n\\n struct MapEntry {\\n bytes32 _key;\\n bytes32 _value;\\n }\\n\\n struct Map {\\n // Storage of map keys and values\\n MapEntry[] _entries;\\n\\n // Position of the entry defined by a key in the `entries` array, plus 1\\n // because index 0 means a key is not in the map.\\n mapping (bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Adds a key-value pair to a map, or updates the value for an existing\\n * key. O(1).\\n *\\n * Returns true if the key was added to the map, that is if it was not\\n * already present.\\n */\\n function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {\\n // We read and store the key's index to prevent multiple reads from the same storage slot\\n uint256 keyIndex = map._indexes[key];\\n\\n if (keyIndex == 0) { // Equivalent to !contains(map, key)\\n map._entries.push(MapEntry({ _key: key, _value: value }));\\n // The entry is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n map._indexes[key] = map._entries.length;\\n return true;\\n } else {\\n map._entries[keyIndex - 1]._value = value;\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a key-value pair from a map. O(1).\\n *\\n * Returns true if the key was removed from the map, that is if it was present.\\n */\\n function _remove(Map storage map, bytes32 key) private returns (bool) {\\n // We read and store the key's index to prevent multiple reads from the same storage slot\\n uint256 keyIndex = map._indexes[key];\\n\\n if (keyIndex != 0) { // Equivalent to contains(map, key)\\n // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one\\n // in the array, and then remove the last entry (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = keyIndex - 1;\\n uint256 lastIndex = map._entries.length - 1;\\n\\n // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs\\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\\n\\n MapEntry storage lastEntry = map._entries[lastIndex];\\n\\n // Move the last entry to the index where the entry to delete is\\n map._entries[toDeleteIndex] = lastEntry;\\n // Update the index for the moved entry\\n map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based\\n\\n // Delete the slot where the moved entry was stored\\n map._entries.pop();\\n\\n // Delete the index for the deleted slot\\n delete map._indexes[key];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the key is in the map. O(1).\\n */\\n function _contains(Map storage map, bytes32 key) private view returns (bool) {\\n return map._indexes[key] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of key-value pairs in the map. O(1).\\n */\\n function _length(Map storage map) private view returns (uint256) {\\n return map._entries.length;\\n }\\n\\n /**\\n * @dev Returns the key-value pair stored at position `index` in the map. O(1).\\n *\\n * Note that there are no guarantees on the ordering of entries inside the\\n * array, and it may change when more entries are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {\\n require(map._entries.length > index, \\\"EnumerableMap: index out of bounds\\\");\\n\\n MapEntry storage entry = map._entries[index];\\n return (entry._key, entry._value);\\n }\\n\\n /**\\n * @dev Tries to returns the value associated with `key`. O(1).\\n * Does not revert if `key` is not in the map.\\n */\\n function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {\\n uint256 keyIndex = map._indexes[key];\\n if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key)\\n return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based\\n }\\n\\n /**\\n * @dev Returns the value associated with `key`. O(1).\\n *\\n * Requirements:\\n *\\n * - `key` must be in the map.\\n */\\n function _get(Map storage map, bytes32 key) private view returns (bytes32) {\\n uint256 keyIndex = map._indexes[key];\\n require(keyIndex != 0, \\\"EnumerableMap: nonexistent key\\\"); // Equivalent to contains(map, key)\\n return map._entries[keyIndex - 1]._value; // All indexes are 1-based\\n }\\n\\n /**\\n * @dev Same as {_get}, with a custom error message when `key` is not in the map.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {_tryGet}.\\n */\\n function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {\\n uint256 keyIndex = map._indexes[key];\\n require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)\\n return map._entries[keyIndex - 1]._value; // All indexes are 1-based\\n }\\n\\n // UintToAddressMap\\n\\n struct UintToAddressMap {\\n Map _inner;\\n }\\n\\n /**\\n * @dev Adds a key-value pair to a map, or updates the value for an existing\\n * key. O(1).\\n *\\n * Returns true if the key was added to the map, that is if it was not\\n * already present.\\n */\\n function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {\\n return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the key was removed from the map, that is if it was present.\\n */\\n function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {\\n return _remove(map._inner, bytes32(key));\\n }\\n\\n /**\\n * @dev Returns true if the key is in the map. O(1).\\n */\\n function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {\\n return _contains(map._inner, bytes32(key));\\n }\\n\\n /**\\n * @dev Returns the number of elements in the map. O(1).\\n */\\n function length(UintToAddressMap storage map) internal view returns (uint256) {\\n return _length(map._inner);\\n }\\n\\n /**\\n * @dev Returns the element stored at position `index` in the set. O(1).\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {\\n (bytes32 key, bytes32 value) = _at(map._inner, index);\\n return (uint256(key), address(uint160(uint256(value))));\\n }\\n\\n /**\\n * @dev Tries to returns the value associated with `key`. O(1).\\n * Does not revert if `key` is not in the map.\\n *\\n * _Available since v3.4._\\n */\\n function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {\\n (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));\\n return (success, address(uint160(uint256(value))));\\n }\\n\\n /**\\n * @dev Returns the value associated with `key`. O(1).\\n *\\n * Requirements:\\n *\\n * - `key` must be in the map.\\n */\\n function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {\\n return address(uint160(uint256(_get(map._inner, bytes32(key)))));\\n }\\n\\n /**\\n * @dev Same as {get}, with a custom error message when `key` is not in the map.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryGet}.\\n */\\n function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {\\n return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));\\n }\\n}\\n\",\"keccak256\":\"0x2114555153edb5f273008b3d34205f511db9af06b88f752e4c280dd612c4c549\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping (bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) { // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\\n\\n bytes32 lastvalue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastvalue;\\n // Update the index for the moved value\\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n require(set._values.length > index, \\\"EnumerableSet: index out of bounds\\\");\\n return set._values[index];\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n}\\n\",\"keccak256\":\"0x9a2c1eebb65250f0e11882237038600f22a62376f0547db4acc0dfe0a3d8d34f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n uint256 index = digits - 1;\\n temp = value;\\n while (temp != 0) {\\n buffer[index--] = bytes1(uint8(48 + temp % 10));\\n temp /= 10;\\n }\\n return string(buffer);\\n }\\n}\\n\",\"keccak256\":\"0x08e38e034333372aea8cb1b8846085b7fbab42c6b77a0af464d2c6827827c4f0\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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;\\n}\\n\",\"keccak256\":\"0x0ba8a9b95a956a4050749c0158e928398c447c91469682ca8a7cc7e77a7fe032\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/FullMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.4.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 // 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;\\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 /// @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 result = mulDiv(a, b, denominator);\\n if (mulmod(a, b, denominator) > 0) {\\n require(result < type(uint256).max);\\n result++;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe511530871deaef86692cea9adb6076d26d7b47fd4815ce51af52af981026057\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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\":\"0x86715eb960f18e01ac94e3bba4614ed51a887fa3c5bd1c43bf80aa98e019cf2d\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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\":\"0x4c12bf820c0b011f5490a209960ca34dd8af34660ef9e01de0438393d15e3fd8\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/SqrtPriceMath.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity >=0.5.0;\\n\\nimport './LowGasSafeMath.sol';\\nimport './SafeCast.sol';\\n\\nimport './FullMath.sol';\\nimport './UnsafeMath.sol';\\nimport './FixedPoint96.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 if (add) {\\n uint256 product;\\n if ((product = amount * sqrtPX96) / amount == sqrtPX96) {\\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 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 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 (\\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 (\\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\\n require(sqrtRatioAX96 > 0);\\n\\n return\\n roundUp\\n ? UnsafeMath.divRoundingUp(\\n FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96),\\n sqrtRatioAX96\\n )\\n : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96;\\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\":\"0x4f69701d331d364b69a1cda77cd7b983a0079d36ae0e06b0bb1d64ae56c3705e\",\"license\":\"BUSL-1.1\"},\"@uniswap/v3-core/contracts/libraries/TickMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.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 uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\\n require(absTick <= uint256(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 /// @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 // 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\",\"keccak256\":\"0x1f864a2bf61ba05f3173eaf2e3f94c5e1da4bec0554757527b6d1ef1fe439e4e\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/UnsafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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\":\"0x5f36d7d16348d8c37fe64fda932018d6e5e8acecd054f0f97d32db62d20c6c88\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IERC721Permit.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\n\\nimport '@openzeppelin/contracts/token/ERC721/IERC721.sol';\\n\\n/// @title ERC721 with permit\\n/// @notice Extension to ERC721 that includes a permit function for signature based approvals\\ninterface IERC721Permit is IERC721 {\\n /// @notice The permit typehash used in the permit signature\\n /// @return The typehash for the permit\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n\\n /// @notice The domain separator used in the permit signature\\n /// @return The domain seperator used in encoding of permit signature\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Approve of a specific token ID for spending by spender via signature\\n /// @param spender The account that is being approved\\n /// @param tokenId The ID of the token that is being approved for spending\\n /// @param deadline The deadline timestamp by which the call must be mined for the approve to work\\n /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`\\n /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`\\n /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`\\n function permit(\\n address spender,\\n uint256 tokenId,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable;\\n}\\n\",\"keccak256\":\"0x9e3c2a4ee65ddf95b2dfcb0815784eea3a295707e6f8b83e4c4f0f8fe2e3a1d4\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\nimport '@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol';\\nimport '@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol';\\n\\nimport './IPoolInitializer.sol';\\nimport './IERC721Permit.sol';\\nimport './IPeripheryPayments.sol';\\nimport './IPeripheryImmutableState.sol';\\nimport '../libraries/PoolAddress.sol';\\n\\n/// @title Non-fungible token for positions\\n/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred\\n/// and authorized.\\ninterface INonfungiblePositionManager is\\n IPoolInitializer,\\n IPeripheryPayments,\\n IPeripheryImmutableState,\\n IERC721Metadata,\\n IERC721Enumerable,\\n IERC721Permit\\n{\\n /// @notice Emitted when liquidity is increased for a position NFT\\n /// @dev Also emitted when a token is minted\\n /// @param tokenId The ID of the token for which liquidity was increased\\n /// @param liquidity The amount by which liquidity for the NFT position was increased\\n /// @param amount0 The amount of token0 that was paid for the increase in liquidity\\n /// @param amount1 The amount of token1 that was paid for the increase in liquidity\\n event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\\n /// @notice Emitted when liquidity is decreased for a position NFT\\n /// @param tokenId The ID of the token for which liquidity was decreased\\n /// @param liquidity The amount by which liquidity for the NFT position was decreased\\n /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity\\n /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity\\n event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\\n /// @notice Emitted when tokens are collected for a position NFT\\n /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior\\n /// @param tokenId The ID of the token for which underlying tokens were collected\\n /// @param recipient The address of the account that received the collected tokens\\n /// @param amount0 The amount of token0 owed to the position that was collected\\n /// @param amount1 The amount of token1 owed to the position that was collected\\n event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);\\n\\n /// @notice Returns the position information associated with a given token ID.\\n /// @dev Throws if the token ID is not valid.\\n /// @param tokenId The ID of the token that represents the position\\n /// @return nonce The nonce for permits\\n /// @return operator The address that is approved for spending\\n /// @return token0 The address of the token0 for a specific pool\\n /// @return token1 The address of the token1 for a specific pool\\n /// @return fee The fee associated with the pool\\n /// @return tickLower The lower end of the tick range for the position\\n /// @return tickUpper The higher end of the tick range for the position\\n /// @return liquidity The liquidity of the position\\n /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position\\n /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position\\n /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation\\n /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation\\n function positions(uint256 tokenId)\\n external\\n view\\n returns (\\n uint96 nonce,\\n address operator,\\n address token0,\\n address token1,\\n uint24 fee,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n uint256 feeGrowthInside0LastX128,\\n uint256 feeGrowthInside1LastX128,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n );\\n\\n struct MintParams {\\n address token0;\\n address token1;\\n uint24 fee;\\n int24 tickLower;\\n int24 tickUpper;\\n uint256 amount0Desired;\\n uint256 amount1Desired;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n address recipient;\\n uint256 deadline;\\n }\\n\\n /// @notice Creates a new position wrapped in a NFT\\n /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized\\n /// a method does not exist, i.e. the pool is assumed to be initialized.\\n /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata\\n /// @return tokenId The ID of the token that represents the minted position\\n /// @return liquidity The amount of liquidity for this position\\n /// @return amount0 The amount of token0\\n /// @return amount1 The amount of token1\\n function mint(MintParams calldata params)\\n external\\n payable\\n returns (\\n uint256 tokenId,\\n uint128 liquidity,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n struct IncreaseLiquidityParams {\\n uint256 tokenId;\\n uint256 amount0Desired;\\n uint256 amount1Desired;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n uint256 deadline;\\n }\\n\\n /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`\\n /// @param params tokenId The ID of the token for which liquidity is being increased,\\n /// amount0Desired The desired amount of token0 to be spent,\\n /// amount1Desired The desired amount of token1 to be spent,\\n /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,\\n /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,\\n /// deadline The time by which the transaction must be included to effect the change\\n /// @return liquidity The new liquidity amount as a result of the increase\\n /// @return amount0 The amount of token0 to acheive resulting liquidity\\n /// @return amount1 The amount of token1 to acheive resulting liquidity\\n function increaseLiquidity(IncreaseLiquidityParams calldata params)\\n external\\n payable\\n returns (\\n uint128 liquidity,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n struct DecreaseLiquidityParams {\\n uint256 tokenId;\\n uint128 liquidity;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n uint256 deadline;\\n }\\n\\n /// @notice Decreases the amount of liquidity in a position and accounts it to the position\\n /// @param params tokenId The ID of the token for which liquidity is being decreased,\\n /// amount The amount by which liquidity will be decreased,\\n /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,\\n /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,\\n /// deadline The time by which the transaction must be included to effect the change\\n /// @return amount0 The amount of token0 accounted to the position's tokens owed\\n /// @return amount1 The amount of token1 accounted to the position's tokens owed\\n function decreaseLiquidity(DecreaseLiquidityParams calldata params)\\n external\\n payable\\n returns (uint256 amount0, uint256 amount1);\\n\\n struct CollectParams {\\n uint256 tokenId;\\n address recipient;\\n uint128 amount0Max;\\n uint128 amount1Max;\\n }\\n\\n /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient\\n /// @param params tokenId The ID of the NFT for which tokens are being collected,\\n /// recipient The account that should receive the tokens,\\n /// amount0Max The maximum amount of token0 to collect,\\n /// amount1Max The maximum amount of token1 to collect\\n /// @return amount0 The amount of fees collected in token0\\n /// @return amount1 The amount of fees collected in token1\\n function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens\\n /// must be collected first.\\n /// @param tokenId The ID of the token that is being burned\\n function burn(uint256 tokenId) external payable;\\n}\\n\",\"keccak256\":\"0xe1dadc73e60bf05d0b4e0f05bd2847c5783e833cc10352c14763360b13495ee1\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPeripheryImmutableState.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Immutable state\\n/// @notice Functions that return immutable state of the router\\ninterface IPeripheryImmutableState {\\n /// @return Returns the address of the Uniswap V3 factory\\n function factory() external view returns (address);\\n\\n /// @return Returns the address of WETH9\\n function WETH9() external view returns (address);\\n}\\n\",\"keccak256\":\"0x7affcfeb5127c0925a71d6a65345e117c33537523aeca7bc98085ead8452519d\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPeripheryPayments.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\n\\n/// @title Periphery Payments\\n/// @notice Functions to ease deposits and withdrawals of ETH\\ninterface IPeripheryPayments {\\n /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.\\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.\\n /// @param amountMinimum The minimum amount of WETH9 to unwrap\\n /// @param recipient The address receiving ETH\\n function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;\\n\\n /// @notice Refunds any ETH balance held by this contract to the `msg.sender`\\n /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps\\n /// that use ether for the input amount\\n function refundETH() external payable;\\n\\n /// @notice Transfers the full amount of a token held by this contract to recipient\\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users\\n /// @param token The contract address of the token which will be transferred to `recipient`\\n /// @param amountMinimum The minimum amount of token required for a transfer\\n /// @param recipient The destination address of the token\\n function sweepToken(\\n address token,\\n uint256 amountMinimum,\\n address recipient\\n ) external payable;\\n}\\n\",\"keccak256\":\"0xb547e10f1e69bed03621a62b73a503e260643066c6b4054867a4d1fef47eb274\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPoolInitializer.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\n/// @title Creates and initializes V3 Pools\\n/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that\\n/// require the pool to exist.\\ninterface IPoolInitializer {\\n /// @notice Creates a new pool if it does not exist, then initializes if not initialized\\n /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool\\n /// @param token0 The contract address of token0 of the pool\\n /// @param token1 The contract address of token1 of the pool\\n /// @param fee The fee amount of the v3 pool for the specified token pair\\n /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value\\n /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary\\n function createAndInitializePoolIfNecessary(\\n address token0,\\n address token1,\\n uint24 fee,\\n uint160 sqrtPriceX96\\n ) external payable returns (address pool);\\n}\\n\",\"keccak256\":\"0x9d7695e8d94c22cc5fcced602017aabb988de89981ea7bee29ea629d5328a862\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee\\nlibrary PoolAddress {\\n bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;\\n\\n /// @notice The identifying key of the pool\\n struct PoolKey {\\n address token0;\\n address token1;\\n uint24 fee;\\n }\\n\\n /// @notice Returns PoolKey: the ordered tokens with the matched fee levels\\n /// @param tokenA The first token of a pool, unsorted\\n /// @param tokenB The second token of a pool, unsorted\\n /// @param fee The fee level of the pool\\n /// @return Poolkey The pool details with ordered token0 and token1 assignments\\n function getPoolKey(\\n address tokenA,\\n address tokenB,\\n uint24 fee\\n ) internal pure returns (PoolKey memory) {\\n if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);\\n return PoolKey({token0: tokenA, token1: tokenB, fee: fee});\\n }\\n\\n /// @notice Deterministically computes the pool address given the factory and PoolKey\\n /// @param factory The Uniswap V3 factory contract address\\n /// @param key The PoolKey\\n /// @return pool The contract address of the V3 pool\\n function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {\\n require(key.token0 < key.token1);\\n pool = address(\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n hex'ff',\\n factory,\\n keccak256(abi.encode(key.token0, key.token1, key.fee)),\\n POOL_INIT_CODE_HASH\\n )\\n )\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x5edd84eb8ba7c12fd8cb6cffe52e1e9f3f6464514ee5f539c2283826209035a2\",\"license\":\"GPL-2.0-or-later\"},\"contracts/core/ShortPowerPerp.sol\":{\"content\":\"//SPDX-License-Identifier: BUSL-1.1\\n\\npragma solidity =0.7.6;\\n\\n//contract\\nimport {ERC721} from \\\"@openzeppelin/contracts/token/ERC721/ERC721.sol\\\";\\nimport {Initializable} from \\\"@openzeppelin/contracts/proxy/Initializable.sol\\\";\\nimport {IController} from \\\"../interfaces/IController.sol\\\";\\n\\n/**\\n * @notice ERC721 NFT representing ownership of a vault (short position)\\n */\\ncontract ShortPowerPerp is ERC721, Initializable {\\n /// @dev tokenId for the next vault opened\\n uint256 public nextId = 1;\\n\\n address public controller;\\n address private immutable deployer;\\n\\n modifier onlyController() {\\n require(msg.sender == controller, \\\"Not controller\\\");\\n _;\\n }\\n\\n /**\\n * @notice short power perpetual constructor\\n * @param _name token name for ERC721\\n * @param _symbol token symbol for ERC721\\n */\\n constructor(string memory _name, string memory _symbol) ERC721(_name, _symbol) {\\n deployer = msg.sender;\\n }\\n\\n /**\\n * @notice initialize short contract\\n * @param _controller controller address\\n */\\n function init(address _controller) public initializer {\\n require(msg.sender == deployer, \\\"Invalid caller of init\\\");\\n require(_controller != address(0), \\\"Invalid controller address\\\");\\n controller = _controller;\\n }\\n\\n /**\\n * @notice mint new NFT\\n * @dev autoincrement tokenId starts at 1\\n * @param _recipient recipient address for NFT\\n */\\n function mintNFT(address _recipient) external onlyController returns (uint256 tokenId) {\\n // mint NFT\\n _safeMint(_recipient, (tokenId = nextId++));\\n }\\n\\n function _beforeTokenTransfer(\\n address, /* from */\\n address, /* to */\\n uint256 tokenId\\n ) internal override {\\n IController(controller).updateOperator(tokenId, address(0));\\n }\\n}\\n\",\"keccak256\":\"0x5597686c00b4341803c9119e8402e9207b0d13ca722e724fa9d2c85e8ea6dbf5\",\"license\":\"BUSL-1.1\"},\"contracts/interfaces/IController.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\npragma abicoder v2;\\n\\nimport {VaultLib} from \\\"../libs/VaultLib.sol\\\";\\n\\ninterface IController {\\n function ethQuoteCurrencyPool() external view returns (address);\\n\\n function feeRate() external view returns (uint256);\\n\\n function getFee(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _collateralAmount\\n ) external view returns (uint256);\\n\\n function quoteCurrency() external view returns (address);\\n\\n function vaults(uint256 _vaultId) external view returns (VaultLib.Vault memory);\\n\\n function shortPowerPerp() external view returns (address);\\n\\n function wPowerPerp() external view returns (address);\\n\\n function getExpectedNormalizationFactor() external view returns (uint256);\\n\\n function mintPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _powerPerpAmount,\\n uint256 _uniTokenId\\n ) external payable returns (uint256 vaultId, uint256 wPowerPerpAmount);\\n\\n function mintWPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _uniTokenId\\n ) external payable returns (uint256 vaultId);\\n\\n /**\\n * Deposit collateral into a vault\\n */\\n function deposit(uint256 _vaultId) external payable;\\n\\n /**\\n * Withdraw collateral from a vault.\\n */\\n function withdraw(uint256 _vaultId, uint256 _amount) external payable;\\n\\n function burnWPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _withdrawAmount\\n ) external;\\n\\n function burnOnPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _powerPerpAmount,\\n uint256 _withdrawAmount\\n ) external returns (uint256 wPowerPerpAmount);\\n\\n function liquidate(uint256 _vaultId, uint256 _maxDebtAmount) external returns (uint256);\\n\\n function updateOperator(uint256 _vaultId, address _operator) external;\\n\\n /**\\n * External function to update the normalized factor as a way to pay funding.\\n */\\n function applyFunding() external;\\n\\n function reduceDebtShutdown(uint256 _vaultId) external;\\n}\\n\",\"keccak256\":\"0x1d37386781eb0935b9936e2dbc865b19607e33b1cbf98b056b6e60f50adf0063\",\"license\":\"MIT\"},\"contracts/libs/Uint256Casting.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nlibrary Uint256Casting {\\n /**\\n * @notice cast a uint256 to a uint128, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint128\\n */\\n function toUint128(uint256 y) internal pure returns (uint128 z) {\\n require((z = uint128(y)) == y, \\\"OF128\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint96, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint96\\n */\\n function toUint96(uint256 y) internal pure returns (uint96 z) {\\n require((z = uint96(y)) == y, \\\"OF96\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint32, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint32\\n */\\n function toUint32(uint256 y) internal pure returns (uint32 z) {\\n require((z = uint32(y)) == y, \\\"OF32\\\");\\n }\\n}\\n\",\"keccak256\":\"0xcccbe82f8696be398d0d0f5a44988e9bab70e18dd40c9563620cdf160d8bcd7c\",\"license\":\"MIT\"},\"contracts/libs/VaultLib.sol\":{\"content\":\"//SPDX-License-Identifier: BUSL-1.1\\n\\npragma solidity =0.7.6;\\n\\n//interface\\nimport {INonfungiblePositionManager} from \\\"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\\\";\\n\\n//lib\\nimport {SafeMath} from \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/TickMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/SqrtPriceMath.sol\\\";\\nimport {Uint256Casting} from \\\"./Uint256Casting.sol\\\";\\n\\n/**\\n * Error code:\\n * V1: Vault already had nft\\n * V2: Vault has no NFT\\n */\\nlibrary VaultLib {\\n using SafeMath for uint256;\\n using Uint256Casting for uint256;\\n\\n uint256 constant ONE_ONE = 1e36;\\n\\n // the collateralization ratio (CR) is checked with the numerator and denominator separately\\n // a user is safe if - collateral value >= (COLLAT_RATIO_NUMER/COLLAT_RATIO_DENOM)* debt value\\n uint256 public constant CR_NUMERATOR = 3;\\n uint256 public constant CR_DENOMINATOR = 2;\\n\\n struct Vault {\\n // the address that can update the vault\\n address operator;\\n // uniswap position token id deposited into the vault as collateral\\n // 2^32 is 4,294,967,296, which means the vault structure will work with up to 4 billion positions\\n uint32 NftCollateralId;\\n // amount of eth (wei) used in the vault as collateral\\n // 2^96 / 1e18 = 79,228,162,514, which means a vault can store up to 79 billion eth\\n // when we need to do calculations, we always cast this number to uint256 to avoid overflow\\n uint96 collateralAmount;\\n // amount of wPowerPerp minted from the vault\\n uint128 shortAmount;\\n }\\n\\n /**\\n * @notice add eth collateral to a vault\\n * @param _vault in-memory vault\\n * @param _amount amount of eth to add\\n */\\n function addEthCollateral(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.collateralAmount = uint256(_vault.collateralAmount).add(_amount).toUint96();\\n }\\n\\n /**\\n * @notice add uniswap position token collateral to a vault\\n * @param _vault in-memory vault\\n * @param _tokenId uniswap position token id\\n */\\n function addUniNftCollateral(Vault memory _vault, uint256 _tokenId) internal pure {\\n require(_vault.NftCollateralId == 0, \\\"V1\\\");\\n require(_tokenId != 0, \\\"C23\\\");\\n _vault.NftCollateralId = _tokenId.toUint32();\\n }\\n\\n /**\\n * @notice remove eth collateral from a vault\\n * @param _vault in-memory vault\\n * @param _amount amount of eth to remove\\n */\\n function removeEthCollateral(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.collateralAmount = uint256(_vault.collateralAmount).sub(_amount).toUint96();\\n }\\n\\n /**\\n * @notice remove uniswap position token collateral from a vault\\n * @param _vault in-memory vault\\n */\\n function removeUniNftCollateral(Vault memory _vault) internal pure {\\n require(_vault.NftCollateralId != 0, \\\"V2\\\");\\n _vault.NftCollateralId = 0;\\n }\\n\\n /**\\n * @notice add debt to vault\\n * @param _vault in-memory vault\\n * @param _amount amount of debt to add\\n */\\n function addShort(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.shortAmount = uint256(_vault.shortAmount).add(_amount).toUint128();\\n }\\n\\n /**\\n * @notice remove debt from vault\\n * @param _vault in-memory vault\\n * @param _amount amount of debt to remove\\n */\\n function removeShort(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.shortAmount = uint256(_vault.shortAmount).sub(_amount).toUint128();\\n }\\n\\n /**\\n * @notice check if a vault is properly collateralized\\n * @param _vault the vault we want to check\\n * @param _positionManager address of the uniswap position manager\\n * @param _normalizationFactor current _normalizationFactor\\n * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18\\n * @param _minCollateral minimum collateral that needs to be in a vault\\n * @param _wsqueethPoolTick current price tick for wsqueeth pool\\n * @param _isWethToken0 whether weth is token0 in the wsqueeth pool\\n * @return true if the vault is sufficiently collateralized\\n * @return true if the vault is considered as a dust vault\\n */\\n function getVaultStatus(\\n Vault memory _vault,\\n address _positionManager,\\n uint256 _normalizationFactor,\\n uint256 _ethQuoteCurrencyPrice,\\n uint256 _minCollateral,\\n int24 _wsqueethPoolTick,\\n bool _isWethToken0\\n ) internal view returns (bool, bool) {\\n if (_vault.shortAmount == 0) return (true, false);\\n\\n uint256 debtValueInETH = uint256(_vault.shortAmount).mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div(\\n ONE_ONE\\n );\\n uint256 totalCollateral = _getEffectiveCollateral(\\n _vault,\\n _positionManager,\\n _normalizationFactor,\\n _ethQuoteCurrencyPrice,\\n _wsqueethPoolTick,\\n _isWethToken0\\n );\\n\\n bool isDust = totalCollateral < _minCollateral;\\n bool isAboveWater = totalCollateral.mul(CR_DENOMINATOR) >= debtValueInETH.mul(CR_NUMERATOR);\\n return (isAboveWater, isDust);\\n }\\n\\n /**\\n * @notice get the total effective collateral of a vault, which is:\\n * collateral amount + uniswap position token equivelent amount in eth\\n * @param _vault the vault we want to check\\n * @param _positionManager address of the uniswap position manager\\n * @param _normalizationFactor current _normalizationFactor\\n * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18\\n * @param _wsqueethPoolTick current price tick for wsqueeth pool\\n * @param _isWethToken0 whether weth is token0 in the wsqueeth pool\\n * @return the total worth of collateral in the vault\\n */\\n function _getEffectiveCollateral(\\n Vault memory _vault,\\n address _positionManager,\\n uint256 _normalizationFactor,\\n uint256 _ethQuoteCurrencyPrice,\\n int24 _wsqueethPoolTick,\\n bool _isWethToken0\\n ) internal view returns (uint256) {\\n if (_vault.NftCollateralId == 0) return _vault.collateralAmount;\\n\\n // the user has deposited uniswap position token as collateral, see how much eth / wSqueeth the uniswap position token has\\n (uint256 nftEthAmount, uint256 nftWsqueethAmount) = _getUniPositionBalances(\\n _positionManager,\\n _vault.NftCollateralId,\\n _wsqueethPoolTick,\\n _isWethToken0\\n );\\n // convert squeeth amount from uniswap position token as equivalent amount of collateral\\n uint256 wSqueethIndexValueInEth = nftWsqueethAmount.mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div(\\n ONE_ONE\\n );\\n // add eth value from uniswap position token as collateral\\n return nftEthAmount.add(wSqueethIndexValueInEth).add(_vault.collateralAmount);\\n }\\n\\n /**\\n * @notice determine how much eth / wPowerPerp the uniswap position contains\\n * @param _positionManager address of the uniswap position manager\\n * @param _tokenId uniswap position token id\\n * @param _wPowerPerpPoolTick current price tick\\n * @param _isWethToken0 whether weth is token0 in the pool\\n * @return ethAmount the eth amount this LP token contains\\n * @return wPowerPerpAmount the wPowerPerp amount this LP token contains\\n */\\n function _getUniPositionBalances(\\n address _positionManager,\\n uint256 _tokenId,\\n int24 _wPowerPerpPoolTick,\\n bool _isWethToken0\\n ) internal view returns (uint256 ethAmount, uint256 wPowerPerpAmount) {\\n (\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n ) = _getUniswapPositionInfo(_positionManager, _tokenId);\\n (uint256 amount0, uint256 amount1) = _getToken0Token1Balances(\\n tickLower,\\n tickUpper,\\n _wPowerPerpPoolTick,\\n liquidity\\n );\\n\\n return\\n _isWethToken0\\n ? (amount0 + tokensOwed0, amount1 + tokensOwed1)\\n : (amount1 + tokensOwed1, amount0 + tokensOwed0);\\n }\\n\\n /**\\n * @notice get uniswap position token info\\n * @param _positionManager address of the uniswap position position manager\\n * @param _tokenId uniswap position token id\\n * @return tickLower lower tick of the position\\n * @return tickUpper upper tick of the position\\n * @return liquidity raw liquidity amount of the position\\n * @return tokensOwed0 amount of token 0 can be collected as fee\\n * @return tokensOwed1 amount of token 1 can be collected as fee\\n */\\n function _getUniswapPositionInfo(address _positionManager, uint256 _tokenId)\\n internal\\n view\\n returns (\\n int24,\\n int24,\\n uint128,\\n uint128,\\n uint128\\n )\\n {\\n INonfungiblePositionManager positionManager = INonfungiblePositionManager(_positionManager);\\n (\\n ,\\n ,\\n ,\\n ,\\n ,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n ,\\n ,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n ) = positionManager.positions(_tokenId);\\n return (tickLower, tickUpper, liquidity, tokensOwed0, tokensOwed1);\\n }\\n\\n /**\\n * @notice get balances of token0 / token1 in a uniswap position\\n * @dev knowing liquidity, tick range, and current tick gives balances\\n * @param _tickLower address of the uniswap position manager\\n * @param _tickUpper uniswap position token id\\n * @param _tick current price tick used for calculation\\n * @return amount0 the amount of token0 in the uniswap position token\\n * @return amount1 the amount of token1 in the uniswap position token\\n */\\n function _getToken0Token1Balances(\\n int24 _tickLower,\\n int24 _tickUpper,\\n int24 _tick,\\n uint128 _liquidity\\n ) internal pure returns (uint256 amount0, uint256 amount1) {\\n // get the current price and tick from wPowerPerp pool\\n uint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(_tick);\\n\\n // the following line is copied from the _modifyPosition function implemented by Uniswap core\\n // we use the same logic to determine how much token0, token1 equals to given \\\"liquidity\\\"\\n // https://github.com/Uniswap/uniswap-v3-core/blob/b2c5555d696428c40c4b236069b3528b2317f3c1/contracts/UniswapV3Pool.sol#L306\\n\\n // use these 2 functions directly, because liquidity is always positive\\n // getAmount0Delta: https://github.com/Uniswap/uniswap-v3-core/blob/b2c5555d696428c40c4b236069b3528b2317f3c1/contracts/libraries/SqrtPriceMath.sol#L209\\n // getAmount1Delta: https://github.com/Uniswap/uniswap-v3-core/blob/b2c5555d696428c40c4b236069b3528b2317f3c1/contracts/libraries/SqrtPriceMath.sol#L225\\n\\n if (_tick < _tickLower) {\\n amount0 = SqrtPriceMath.getAmount0Delta(\\n TickMath.getSqrtRatioAtTick(_tickLower),\\n TickMath.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n } else if (_tick < _tickUpper) {\\n amount0 = SqrtPriceMath.getAmount0Delta(\\n sqrtPriceX96,\\n TickMath.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n amount1 = SqrtPriceMath.getAmount1Delta(\\n TickMath.getSqrtRatioAtTick(_tickLower),\\n sqrtPriceX96,\\n _liquidity,\\n true\\n );\\n } else {\\n amount1 = SqrtPriceMath.getAmount1Delta(\\n TickMath.getSqrtRatioAtTick(_tickLower),\\n TickMath.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n }\\n }\\n}\\n\",\"keccak256\":\"0x70e0be9051bbd93304ab5c934ab16066b39cedc1cc96d81c6f6f8570c62efdd0\",\"license\":\"BUSL-1.1\"}},\"version\":1}", - "bytecode": "0x60a06040526001600b553480156200001657600080fd5b50604051620022b5380380620022b5833981810160405260408110156200003c57600080fd5b81019080805160405193929190846401000000008211156200005d57600080fd5b9083019060208201858111156200007357600080fd5b82516401000000008111828201881017156200008e57600080fd5b82525081516020918201929091019080838360005b83811015620000bd578181015183820152602001620000a3565b50505050905090810190601f168015620000eb5780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200010f57600080fd5b9083019060208201858111156200012557600080fd5b82516401000000008111828201881017156200014057600080fd5b82525081516020918201929091019080838360005b838110156200016f57818101518382015260200162000155565b50505050905090810190601f1680156200019d5780820380516001836020036101000a031916815260200191505b5060405250839150829050620001ba6301ffc9a760e01b6200022d565b8151620001cf906006906020850190620002b2565b508051620001e5906007906020840190620002b2565b50620001f86380ac58cd60e01b6200022d565b6200020a635b5e139f60e01b6200022d565b6200021c63780e9d6360e01b6200022d565b5050503360601b608052506200035e565b6001600160e01b031980821614156200028d576040805162461bcd60e51b815260206004820152601c60248201527f4552433136353a20696e76616c696420696e7465726661636520696400000000604482015290519081900360640190fd5b6001600160e01b0319166000908152602081905260409020805460ff19166001179055565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282620002ea576000855562000335565b82601f106200030557805160ff191683800117855562000335565b8280016001018555821562000335579182015b828111156200033557825182559160200191906001019062000318565b506200034392915062000347565b5090565b5b8082111562000343576000815560010162000348565b60805160601c611f396200037c600039806107f75250611f396000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806354ba0f27116100d857806395d89b411161008c578063c87b56dd11610066578063c87b56dd14610505578063e985e9c514610522578063f77c47911461055057610177565b806395d89b4114610409578063a22cb46514610411578063b88d4fde1461043f57610177565b80636352211e116100bd5780636352211e146103be5780636c0360eb146103db57806370a08231146103e357610177565b806354ba0f271461039057806361b8ce8c146103b657610177565b806319ab453c1161012f5780632f745c59116101145780632f745c591461031157806342842e0e1461033d5780634f6ccce71461037357610177565b806319ab453c146102b557806323b872dd146102db57610177565b8063081812fc11610160578063081812fc14610234578063095ea7b31461026d57806318160ddd1461029b57610177565b806301ffc9a71461017c57806306fdde03146101b7575b600080fd5b6101a36004803603602081101561019257600080fd5b50356001600160e01b031916610558565b604080519115158252519081900360200190f35b6101bf61057b565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101f95781810151838201526020016101e1565b50505050905090810190601f1680156102265780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102516004803603602081101561024a57600080fd5b5035610611565b604080516001600160a01b039092168252519081900360200190f35b6102996004803603604081101561028357600080fd5b506001600160a01b038135169060200135610673565b005b6102a361074e565b60408051918252519081900360200190f35b610299600480360360208110156102cb57600080fd5b50356001600160a01b031661075f565b610299600480360360608110156102f157600080fd5b506001600160a01b03813581169160208101359091169060400135610902565b6102a36004803603604081101561032757600080fd5b506001600160a01b038135169060200135610959565b6102996004803603606081101561035357600080fd5b506001600160a01b03813581169160208101359091169060400135610984565b6102a36004803603602081101561038957600080fd5b503561099f565b6102a3600480360360208110156103a657600080fd5b50356001600160a01b03166109b5565b6102a3610a2d565b610251600480360360208110156103d457600080fd5b5035610a33565b6101bf610a5b565b6102a3600480360360208110156103f957600080fd5b50356001600160a01b0316610abc565b6101bf610b24565b6102996004803603604081101561042757600080fd5b506001600160a01b0381351690602001351515610b85565b6102996004803603608081101561045557600080fd5b6001600160a01b0382358116926020810135909116916040820135919081019060808101606082013564010000000081111561049057600080fd5b8201836020820111156104a257600080fd5b803590602001918460018302840111640100000000831117156104c457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610c8a945050505050565b6101bf6004803603602081101561051b57600080fd5b5035610ce8565b6101a36004803603604081101561053857600080fd5b506001600160a01b0381358116916020013516610f69565b610251610f97565b6001600160e01b0319811660009081526020819052604090205460ff165b919050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106075780601f106105dc57610100808354040283529160200191610607565b820191906000526020600020905b8154815290600101906020018083116105ea57829003601f168201915b5050505050905090565b600061061c82610fa6565b6106575760405162461bcd60e51b815260040180806020018281038252602c815260200180611e2e602c913960400191505060405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061067e82610a33565b9050806001600160a01b0316836001600160a01b031614156106d15760405162461bcd60e51b8152600401808060200182810382526021815260200180611eb26021913960400191505060405180910390fd5b806001600160a01b03166106e3610fb3565b6001600160a01b031614806107045750610704816106ff610fb3565b610f69565b61073f5760405162461bcd60e51b8152600401808060200182810382526038815260200180611d536038913960400191505060405180910390fd5b6107498383610fb7565b505050565b600061075a6002611032565b905090565b600a54610100900460ff1680610778575061077861103d565b806107865750600a5460ff16155b6107c15760405162461bcd60e51b815260040180806020018281038252602e815260200180611dde602e913960400191505060405180910390fd5b600a54610100900460ff161580156107ec57600a805460ff1961ff0019909116610100171660011790555b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610869576040805162461bcd60e51b815260206004820152601660248201527f496e76616c69642063616c6c6572206f6620696e697400000000000000000000604482015290519081900360640190fd5b6001600160a01b0382166108c4576040805162461bcd60e51b815260206004820152601a60248201527f496e76616c696420636f6e74726f6c6c65722061646472657373000000000000604482015290519081900360640190fd5b600c805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03841617905580156108fe57600a805461ff00191690555b5050565b61091361090d610fb3565b8261104e565b61094e5760405162461bcd60e51b8152600401808060200182810382526031815260200180611ed36031913960400191505060405180910390fd5b6107498383836110f2565b6001600160a01b038216600090815260016020526040812061097b908361123e565b90505b92915050565b61074983838360405180602001604052806000815250610c8a565b6000806109ad60028461124a565b509392505050565b600c546000906001600160a01b03163314610a17576040805162461bcd60e51b815260206004820152600e60248201527f4e6f7420636f6e74726f6c6c6572000000000000000000000000000000000000604482015290519081900360640190fd5b50600b8054600181019091556105768282611266565b600b5481565b600061097e82604051806060016040528060298152602001611db56029913960029190611280565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106075780601f106105dc57610100808354040283529160200191610607565b60006001600160a01b038216610b035760405162461bcd60e51b815260040180806020018281038252602a815260200180611d8b602a913960400191505060405180910390fd5b6001600160a01b038216600090815260016020526040902061097e90611032565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106075780601f106105dc57610100808354040283529160200191610607565b610b8d610fb3565b6001600160a01b0316826001600160a01b03161415610bf3576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b8060056000610c00610fb3565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610c44610fb3565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b610c9b610c95610fb3565b8361104e565b610cd65760405162461bcd60e51b8152600401808060200182810382526031815260200180611ed36031913960400191505060405180910390fd5b610ce284848484611297565b50505050565b6060610cf382610fa6565b610d2e5760405162461bcd60e51b815260040180806020018281038252602f815260200180611e83602f913960400191505060405180910390fd5b60008281526008602090815260408083208054825160026001831615610100026000190190921691909104601f810185900485028201850190935282815292909190830182828015610dc15780601f10610d9657610100808354040283529160200191610dc1565b820191906000526020600020905b815481529060010190602001808311610da457829003601f168201915b505050505090506000610dd2610a5b565b9050805160001415610de657509050610576565b815115610ea75780826040516020018083805190602001908083835b60208310610e215780518252601f199092019160209182019101610e02565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310610e695780518252601f199092019160209182019101610e4a565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050610576565b80610eb1856112e9565b6040516020018083805190602001908083835b60208310610ee35780518252601f199092019160209182019101610ec4565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310610f2b5780518252601f199092019160209182019101610f0c565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600c546001600160a01b031681565b600061097e6002836113dc565b3390565b6000818152600460205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0384169081179091558190610ff982610a33565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061097e826113e8565b6000611048306113ec565b15905090565b600061105982610fa6565b6110945760405162461bcd60e51b815260040180806020018281038252602c815260200180611d27602c913960400191505060405180910390fd5b600061109f83610a33565b9050806001600160a01b0316846001600160a01b031614806110da5750836001600160a01b03166110cf84610611565b6001600160a01b0316145b806110ea57506110ea8185610f69565b949350505050565b826001600160a01b031661110582610a33565b6001600160a01b03161461114a5760405162461bcd60e51b8152600401808060200182810382526029815260200180611e5a6029913960400191505060405180910390fd5b6001600160a01b03821661118f5760405162461bcd60e51b8152600401808060200182810382526024815260200180611d036024913960400191505060405180910390fd5b61119a8383836113f2565b6111a5600082610fb7565b6001600160a01b03831660009081526001602052604090206111c7908261147b565b506001600160a01b03821660009081526001602052604090206111ea9082611487565b506111f760028284611493565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061097b83836114a9565b6000808080611259868661150d565b9097909650945050505050565b6108fe828260405180602001604052806000815250611588565b600061128d8484846115da565b90505b9392505050565b6112a28484846110f2565b6112ae848484846116a4565b610ce25760405162461bcd60e51b8152600401808060200182810382526032815260200180611cd16032913960400191505060405180910390fd5b60608161130e57506040805180820190915260018152600360fc1b6020820152610576565b8160005b811561132657600101600a82049150611312565b60008167ffffffffffffffff8111801561133f57600080fd5b506040519080825280601f01601f19166020018201604052801561136a576020820181803683370190505b50859350905060001982015b83156113d357600a840660300160f81b8282806001900393508151811061139957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a84049350611376565b50949350505050565b600061097b8383611836565b5490565b3b151590565b600c54604080517fc65a391d0000000000000000000000000000000000000000000000000000000081526004810184905260006024820181905291516001600160a01b039093169263c65a391d9260448084019391929182900301818387803b15801561145e57600080fd5b505af1158015611472573d6000803e3d6000fd5b50505050505050565b600061097b838361184e565b600061097b8383611914565b600061128d84846001600160a01b03851661195e565b815460009082106114eb5760405162461bcd60e51b8152600401808060200182810382526022815260200180611caf6022913960400191505060405180910390fd5b8260000182815481106114fa57fe5b9060005260206000200154905092915050565b8154600090819083106115515760405162461bcd60e51b8152600401808060200182810382526022815260200180611e0c6022913960400191505060405180910390fd5b600084600001848154811061156257fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b61159283836119f5565b61159f60008484846116a4565b6107495760405162461bcd60e51b8152600401808060200182810382526032815260200180611cd16032913960400191505060405180910390fd5b600082815260018401602052604081205482816116755760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561163a578181015183820152602001611622565b50505050905090810190601f1680156116675780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061168857fe5b9060005260206000209060020201600101549150509392505050565b60006116b8846001600160a01b03166113ec565b6116c4575060016110ea565b60006117fc630a85bd0160e11b6116d9610fb3565b88878760405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611740578181015183820152602001611728565b50505050905090810190601f16801561176d5780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001611cd1603291396001600160a01b0388169190611b23565b9050600081806020019051602081101561181557600080fd5b50516001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b6000818152600183016020526040812054801561190a578354600019808301919081019060009087908390811061188157fe5b906000526020600020015490508087600001848154811061189e57fe5b6000918252602080832090910192909255828152600189810190925260409020908401905586548790806118ce57fe5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505061097e565b600091505061097e565b60006119208383611836565b6119565750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561097e565b50600061097e565b6000828152600184016020526040812054806119c3575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055611290565b828560000160018303815481106119d657fe5b9060005260206000209060020201600101819055506000915050611290565b6001600160a01b038216611a50576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b611a5981610fa6565b15611aab576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b611ab7600083836113f2565b6001600160a01b0382166000908152600160205260409020611ad99082611487565b50611ae660028284611493565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b606061128d848460008585611b37856113ec565b611b88576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310611bc65780518252601f199092019160209182019101611ba7565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611c28576040519150601f19603f3d011682016040523d82523d6000602084013e611c2d565b606091505b5091509150611c3d828286611c48565b979650505050505050565b60608315611c57575081611290565b825115611c675782518084602001fd5b60405162461bcd60e51b815260206004820181815284516024840152845185939192839260440191908501908083836000831561163a57818101518382015260200161162256fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a207472616e7366657220746f20746865207a65726f20616464726573734552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a2646970667358221220b79c1ef92cb8f2f98408b280bb125fd93cbbd6ab42057e81e542f3d9c8499a7964736f6c63430007060033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101775760003560e01c806354ba0f27116100d857806395d89b411161008c578063c87b56dd11610066578063c87b56dd14610505578063e985e9c514610522578063f77c47911461055057610177565b806395d89b4114610409578063a22cb46514610411578063b88d4fde1461043f57610177565b80636352211e116100bd5780636352211e146103be5780636c0360eb146103db57806370a08231146103e357610177565b806354ba0f271461039057806361b8ce8c146103b657610177565b806319ab453c1161012f5780632f745c59116101145780632f745c591461031157806342842e0e1461033d5780634f6ccce71461037357610177565b806319ab453c146102b557806323b872dd146102db57610177565b8063081812fc11610160578063081812fc14610234578063095ea7b31461026d57806318160ddd1461029b57610177565b806301ffc9a71461017c57806306fdde03146101b7575b600080fd5b6101a36004803603602081101561019257600080fd5b50356001600160e01b031916610558565b604080519115158252519081900360200190f35b6101bf61057b565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101f95781810151838201526020016101e1565b50505050905090810190601f1680156102265780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102516004803603602081101561024a57600080fd5b5035610611565b604080516001600160a01b039092168252519081900360200190f35b6102996004803603604081101561028357600080fd5b506001600160a01b038135169060200135610673565b005b6102a361074e565b60408051918252519081900360200190f35b610299600480360360208110156102cb57600080fd5b50356001600160a01b031661075f565b610299600480360360608110156102f157600080fd5b506001600160a01b03813581169160208101359091169060400135610902565b6102a36004803603604081101561032757600080fd5b506001600160a01b038135169060200135610959565b6102996004803603606081101561035357600080fd5b506001600160a01b03813581169160208101359091169060400135610984565b6102a36004803603602081101561038957600080fd5b503561099f565b6102a3600480360360208110156103a657600080fd5b50356001600160a01b03166109b5565b6102a3610a2d565b610251600480360360208110156103d457600080fd5b5035610a33565b6101bf610a5b565b6102a3600480360360208110156103f957600080fd5b50356001600160a01b0316610abc565b6101bf610b24565b6102996004803603604081101561042757600080fd5b506001600160a01b0381351690602001351515610b85565b6102996004803603608081101561045557600080fd5b6001600160a01b0382358116926020810135909116916040820135919081019060808101606082013564010000000081111561049057600080fd5b8201836020820111156104a257600080fd5b803590602001918460018302840111640100000000831117156104c457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610c8a945050505050565b6101bf6004803603602081101561051b57600080fd5b5035610ce8565b6101a36004803603604081101561053857600080fd5b506001600160a01b0381358116916020013516610f69565b610251610f97565b6001600160e01b0319811660009081526020819052604090205460ff165b919050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106075780601f106105dc57610100808354040283529160200191610607565b820191906000526020600020905b8154815290600101906020018083116105ea57829003601f168201915b5050505050905090565b600061061c82610fa6565b6106575760405162461bcd60e51b815260040180806020018281038252602c815260200180611e2e602c913960400191505060405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061067e82610a33565b9050806001600160a01b0316836001600160a01b031614156106d15760405162461bcd60e51b8152600401808060200182810382526021815260200180611eb26021913960400191505060405180910390fd5b806001600160a01b03166106e3610fb3565b6001600160a01b031614806107045750610704816106ff610fb3565b610f69565b61073f5760405162461bcd60e51b8152600401808060200182810382526038815260200180611d536038913960400191505060405180910390fd5b6107498383610fb7565b505050565b600061075a6002611032565b905090565b600a54610100900460ff1680610778575061077861103d565b806107865750600a5460ff16155b6107c15760405162461bcd60e51b815260040180806020018281038252602e815260200180611dde602e913960400191505060405180910390fd5b600a54610100900460ff161580156107ec57600a805460ff1961ff0019909116610100171660011790555b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610869576040805162461bcd60e51b815260206004820152601660248201527f496e76616c69642063616c6c6572206f6620696e697400000000000000000000604482015290519081900360640190fd5b6001600160a01b0382166108c4576040805162461bcd60e51b815260206004820152601a60248201527f496e76616c696420636f6e74726f6c6c65722061646472657373000000000000604482015290519081900360640190fd5b600c805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03841617905580156108fe57600a805461ff00191690555b5050565b61091361090d610fb3565b8261104e565b61094e5760405162461bcd60e51b8152600401808060200182810382526031815260200180611ed36031913960400191505060405180910390fd5b6107498383836110f2565b6001600160a01b038216600090815260016020526040812061097b908361123e565b90505b92915050565b61074983838360405180602001604052806000815250610c8a565b6000806109ad60028461124a565b509392505050565b600c546000906001600160a01b03163314610a17576040805162461bcd60e51b815260206004820152600e60248201527f4e6f7420636f6e74726f6c6c6572000000000000000000000000000000000000604482015290519081900360640190fd5b50600b8054600181019091556105768282611266565b600b5481565b600061097e82604051806060016040528060298152602001611db56029913960029190611280565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106075780601f106105dc57610100808354040283529160200191610607565b60006001600160a01b038216610b035760405162461bcd60e51b815260040180806020018281038252602a815260200180611d8b602a913960400191505060405180910390fd5b6001600160a01b038216600090815260016020526040902061097e90611032565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106075780601f106105dc57610100808354040283529160200191610607565b610b8d610fb3565b6001600160a01b0316826001600160a01b03161415610bf3576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b8060056000610c00610fb3565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610c44610fb3565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b610c9b610c95610fb3565b8361104e565b610cd65760405162461bcd60e51b8152600401808060200182810382526031815260200180611ed36031913960400191505060405180910390fd5b610ce284848484611297565b50505050565b6060610cf382610fa6565b610d2e5760405162461bcd60e51b815260040180806020018281038252602f815260200180611e83602f913960400191505060405180910390fd5b60008281526008602090815260408083208054825160026001831615610100026000190190921691909104601f810185900485028201850190935282815292909190830182828015610dc15780601f10610d9657610100808354040283529160200191610dc1565b820191906000526020600020905b815481529060010190602001808311610da457829003601f168201915b505050505090506000610dd2610a5b565b9050805160001415610de657509050610576565b815115610ea75780826040516020018083805190602001908083835b60208310610e215780518252601f199092019160209182019101610e02565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310610e695780518252601f199092019160209182019101610e4a565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050610576565b80610eb1856112e9565b6040516020018083805190602001908083835b60208310610ee35780518252601f199092019160209182019101610ec4565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310610f2b5780518252601f199092019160209182019101610f0c565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600c546001600160a01b031681565b600061097e6002836113dc565b3390565b6000818152600460205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0384169081179091558190610ff982610a33565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061097e826113e8565b6000611048306113ec565b15905090565b600061105982610fa6565b6110945760405162461bcd60e51b815260040180806020018281038252602c815260200180611d27602c913960400191505060405180910390fd5b600061109f83610a33565b9050806001600160a01b0316846001600160a01b031614806110da5750836001600160a01b03166110cf84610611565b6001600160a01b0316145b806110ea57506110ea8185610f69565b949350505050565b826001600160a01b031661110582610a33565b6001600160a01b03161461114a5760405162461bcd60e51b8152600401808060200182810382526029815260200180611e5a6029913960400191505060405180910390fd5b6001600160a01b03821661118f5760405162461bcd60e51b8152600401808060200182810382526024815260200180611d036024913960400191505060405180910390fd5b61119a8383836113f2565b6111a5600082610fb7565b6001600160a01b03831660009081526001602052604090206111c7908261147b565b506001600160a01b03821660009081526001602052604090206111ea9082611487565b506111f760028284611493565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061097b83836114a9565b6000808080611259868661150d565b9097909650945050505050565b6108fe828260405180602001604052806000815250611588565b600061128d8484846115da565b90505b9392505050565b6112a28484846110f2565b6112ae848484846116a4565b610ce25760405162461bcd60e51b8152600401808060200182810382526032815260200180611cd16032913960400191505060405180910390fd5b60608161130e57506040805180820190915260018152600360fc1b6020820152610576565b8160005b811561132657600101600a82049150611312565b60008167ffffffffffffffff8111801561133f57600080fd5b506040519080825280601f01601f19166020018201604052801561136a576020820181803683370190505b50859350905060001982015b83156113d357600a840660300160f81b8282806001900393508151811061139957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a84049350611376565b50949350505050565b600061097b8383611836565b5490565b3b151590565b600c54604080517fc65a391d0000000000000000000000000000000000000000000000000000000081526004810184905260006024820181905291516001600160a01b039093169263c65a391d9260448084019391929182900301818387803b15801561145e57600080fd5b505af1158015611472573d6000803e3d6000fd5b50505050505050565b600061097b838361184e565b600061097b8383611914565b600061128d84846001600160a01b03851661195e565b815460009082106114eb5760405162461bcd60e51b8152600401808060200182810382526022815260200180611caf6022913960400191505060405180910390fd5b8260000182815481106114fa57fe5b9060005260206000200154905092915050565b8154600090819083106115515760405162461bcd60e51b8152600401808060200182810382526022815260200180611e0c6022913960400191505060405180910390fd5b600084600001848154811061156257fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b61159283836119f5565b61159f60008484846116a4565b6107495760405162461bcd60e51b8152600401808060200182810382526032815260200180611cd16032913960400191505060405180910390fd5b600082815260018401602052604081205482816116755760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561163a578181015183820152602001611622565b50505050905090810190601f1680156116675780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061168857fe5b9060005260206000209060020201600101549150509392505050565b60006116b8846001600160a01b03166113ec565b6116c4575060016110ea565b60006117fc630a85bd0160e11b6116d9610fb3565b88878760405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611740578181015183820152602001611728565b50505050905090810190601f16801561176d5780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001611cd1603291396001600160a01b0388169190611b23565b9050600081806020019051602081101561181557600080fd5b50516001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b6000818152600183016020526040812054801561190a578354600019808301919081019060009087908390811061188157fe5b906000526020600020015490508087600001848154811061189e57fe5b6000918252602080832090910192909255828152600189810190925260409020908401905586548790806118ce57fe5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505061097e565b600091505061097e565b60006119208383611836565b6119565750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561097e565b50600061097e565b6000828152600184016020526040812054806119c3575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055611290565b828560000160018303815481106119d657fe5b9060005260206000209060020201600101819055506000915050611290565b6001600160a01b038216611a50576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b611a5981610fa6565b15611aab576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b611ab7600083836113f2565b6001600160a01b0382166000908152600160205260409020611ad99082611487565b50611ae660028284611493565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b606061128d848460008585611b37856113ec565b611b88576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310611bc65780518252601f199092019160209182019101611ba7565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611c28576040519150601f19603f3d011682016040523d82523d6000602084013e611c2d565b606091505b5091509150611c3d828286611c48565b979650505050505050565b60608315611c57575081611290565b825115611c675782518084602001fd5b60405162461bcd60e51b815260206004820181815284516024840152845185939192839260440191908501908083836000831561163a57818101518382015260200161162256fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a207472616e7366657220746f20746865207a65726f20616464726573734552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a2646970667358221220b79c1ef92cb8f2f98408b280bb125fd93cbbd6ab42057e81e542f3d9c8499a7964736f6c63430007060033", + "solcInputHash": "d97d3d4b09e0d70518330d405a7dd9ff", + "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_symbol\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"baseURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controller\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getApproved\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_controller\",\"type\":\"address\"}],\"name\":\"init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_recipient\",\"type\":\"address\"}],\"name\":\"mintNFT\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nextId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"tokenOfOwnerByIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"approve(address,uint256)\":{\"details\":\"See {IERC721-approve}.\"},\"balanceOf(address)\":{\"details\":\"See {IERC721-balanceOf}.\"},\"baseURI()\":{\"details\":\"Returns the base URI set via {_setBaseURI}. This will be automatically added as a prefix in {tokenURI} to each token's URI, or to the token ID if no specific URI is set for that token ID.\"},\"constructor\":{\"params\":{\"_name\":\"token name for ERC721\",\"_symbol\":\"token symbol for ERC721\"}},\"getApproved(uint256)\":{\"details\":\"See {IERC721-getApproved}.\"},\"init(address)\":{\"params\":{\"_controller\":\"controller address\"}},\"isApprovedForAll(address,address)\":{\"details\":\"See {IERC721-isApprovedForAll}.\"},\"mintNFT(address)\":{\"details\":\"autoincrement tokenId starts at 1\",\"params\":{\"_recipient\":\"recipient address for NFT\"}},\"name()\":{\"details\":\"See {IERC721Metadata-name}.\"},\"ownerOf(uint256)\":{\"details\":\"See {IERC721-ownerOf}.\"},\"safeTransferFrom(address,address,uint256)\":{\"details\":\"See {IERC721-safeTransferFrom}.\"},\"safeTransferFrom(address,address,uint256,bytes)\":{\"details\":\"See {IERC721-safeTransferFrom}.\"},\"setApprovalForAll(address,bool)\":{\"details\":\"See {IERC721-setApprovalForAll}.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}. Time complexity O(1), guaranteed to always use less than 30 000 gas.\"},\"symbol()\":{\"details\":\"See {IERC721Metadata-symbol}.\"},\"tokenByIndex(uint256)\":{\"details\":\"See {IERC721Enumerable-tokenByIndex}.\"},\"tokenOfOwnerByIndex(address,uint256)\":{\"details\":\"See {IERC721Enumerable-tokenOfOwnerByIndex}.\"},\"tokenURI(uint256)\":{\"details\":\"See {IERC721Metadata-tokenURI}.\"},\"totalSupply()\":{\"details\":\"See {IERC721Enumerable-totalSupply}.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"See {IERC721-transferFrom}.\"}},\"stateVariables\":{\"nextId\":{\"details\":\"tokenId for the next vault opened\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"constructor\":{\"notice\":\"short power perpetual constructor\"},\"init(address)\":{\"notice\":\"initialize short contract\"},\"mintNFT(address)\":{\"notice\":\"mint new NFT\"}},\"notice\":\"ERC721 NFT representing ownership of a vault (short position)\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/core/ShortPowerPerp.sol\":\"ShortPowerPerp\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":825},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/introspection/ERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./IERC165.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC165} interface.\\n *\\n * Contracts may inherit from this and call {_registerInterface} to declare\\n * their support of an interface.\\n */\\nabstract contract ERC165 is IERC165 {\\n /*\\n * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7\\n */\\n bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;\\n\\n /**\\n * @dev Mapping of interface ids to whether or not it's supported.\\n */\\n mapping(bytes4 => bool) private _supportedInterfaces;\\n\\n constructor () {\\n // Derived contracts need only register support for their own interfaces,\\n // we register support for ERC165 itself here\\n _registerInterface(_INTERFACE_ID_ERC165);\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n *\\n * Time complexity O(1), guaranteed to always use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return _supportedInterfaces[interfaceId];\\n }\\n\\n /**\\n * @dev Registers the contract as an implementer of the interface defined by\\n * `interfaceId`. Support of the actual ERC165 interface is automatic and\\n * registering its interface id is not required.\\n *\\n * See {IERC165-supportsInterface}.\\n *\\n * Requirements:\\n *\\n * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).\\n */\\n function _registerInterface(bytes4 interfaceId) internal virtual {\\n require(interfaceId != 0xffffffff, \\\"ERC165: invalid interface id\\\");\\n _supportedInterfaces[interfaceId] = true;\\n }\\n}\\n\",\"keccak256\":\"0x234cdf2c3efd5f0dc17d32fe65d33c21674ca17de1e945eb60ac1076d7152d96\",\"license\":\"MIT\"},\"@openzeppelin/contracts/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xd2f30fad5b24c4120f96dbac83aacdb7993ee610a9092bc23c44463da292bf8d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0xe22a1fc7400ae196eba2ad1562d0386462b00a6363b742d55a2fd2021a58586f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n// solhint-disable-next-line compiler-version\\npragma solidity >=0.4.24 <0.8.0;\\n\\nimport \\\"../utils/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 a proxied contract can't have a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n */\\nabstract contract Initializable {\\n\\n /**\\n * @dev Indicates that the contract has been initialized.\\n */\\n bool private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Modifier to protect an initializer function from being invoked twice.\\n */\\n modifier initializer() {\\n require(_initializing || _isConstructor() || !_initialized, \\\"Initializable: contract is already initialized\\\");\\n\\n bool isTopLevelCall = !_initializing;\\n if (isTopLevelCall) {\\n _initializing = true;\\n _initialized = true;\\n }\\n\\n _;\\n\\n if (isTopLevelCall) {\\n _initializing = false;\\n }\\n }\\n\\n /// @dev Returns true if and only if the function is running in the constructor\\n function _isConstructor() private view returns (bool) {\\n return !Address.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0x9abeffe138f098b16557187383ba0f9e8503602fa95cd668132986ee115237ed\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/ERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"../../utils/Context.sol\\\";\\nimport \\\"./IERC721.sol\\\";\\nimport \\\"./IERC721Metadata.sol\\\";\\nimport \\\"./IERC721Enumerable.sol\\\";\\nimport \\\"./IERC721Receiver.sol\\\";\\nimport \\\"../../introspection/ERC165.sol\\\";\\nimport \\\"../../math/SafeMath.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/EnumerableSet.sol\\\";\\nimport \\\"../../utils/EnumerableMap.sol\\\";\\nimport \\\"../../utils/Strings.sol\\\";\\n\\n/**\\n * @title ERC721 Non-Fungible Token Standard basic implementation\\n * @dev see https://eips.ethereum.org/EIPS/eip-721\\n */\\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {\\n using SafeMath for uint256;\\n using Address for address;\\n using EnumerableSet for EnumerableSet.UintSet;\\n using EnumerableMap for EnumerableMap.UintToAddressMap;\\n using Strings for uint256;\\n\\n // Equals to `bytes4(keccak256(\\\"onERC721Received(address,address,uint256,bytes)\\\"))`\\n // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`\\n bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;\\n\\n // Mapping from holder address to their (enumerable) set of owned tokens\\n mapping (address => EnumerableSet.UintSet) private _holderTokens;\\n\\n // Enumerable mapping from token ids to their owners\\n EnumerableMap.UintToAddressMap private _tokenOwners;\\n\\n // Mapping from token ID to approved address\\n mapping (uint256 => address) private _tokenApprovals;\\n\\n // Mapping from owner to operator approvals\\n mapping (address => mapping (address => bool)) private _operatorApprovals;\\n\\n // Token name\\n string private _name;\\n\\n // Token symbol\\n string private _symbol;\\n\\n // Optional mapping for token URIs\\n mapping (uint256 => string) private _tokenURIs;\\n\\n // Base URI\\n string private _baseURI;\\n\\n /*\\n * bytes4(keccak256('balanceOf(address)')) == 0x70a08231\\n * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e\\n * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3\\n * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc\\n * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465\\n * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5\\n * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd\\n * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e\\n * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde\\n *\\n * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^\\n * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd\\n */\\n bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;\\n\\n /*\\n * bytes4(keccak256('name()')) == 0x06fdde03\\n * bytes4(keccak256('symbol()')) == 0x95d89b41\\n * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd\\n *\\n * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f\\n */\\n bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;\\n\\n /*\\n * bytes4(keccak256('totalSupply()')) == 0x18160ddd\\n * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59\\n * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7\\n *\\n * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63\\n */\\n bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;\\n\\n /**\\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\\n */\\n constructor (string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n\\n // register the supported interfaces to conform to ERC721 via ERC165\\n _registerInterface(_INTERFACE_ID_ERC721);\\n _registerInterface(_INTERFACE_ID_ERC721_METADATA);\\n _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);\\n }\\n\\n /**\\n * @dev See {IERC721-balanceOf}.\\n */\\n function balanceOf(address owner) public view virtual override returns (uint256) {\\n require(owner != address(0), \\\"ERC721: balance query for the zero address\\\");\\n return _holderTokens[owner].length();\\n }\\n\\n /**\\n * @dev See {IERC721-ownerOf}.\\n */\\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\\n return _tokenOwners.get(tokenId, \\\"ERC721: owner query for nonexistent token\\\");\\n }\\n\\n /**\\n * @dev See {IERC721Metadata-name}.\\n */\\n function name() public view virtual override returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev See {IERC721Metadata-symbol}.\\n */\\n function symbol() public view virtual override returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev See {IERC721Metadata-tokenURI}.\\n */\\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\\n require(_exists(tokenId), \\\"ERC721Metadata: URI query for nonexistent token\\\");\\n\\n string memory _tokenURI = _tokenURIs[tokenId];\\n string memory base = baseURI();\\n\\n // If there is no base URI, return the token URI.\\n if (bytes(base).length == 0) {\\n return _tokenURI;\\n }\\n // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).\\n if (bytes(_tokenURI).length > 0) {\\n return string(abi.encodePacked(base, _tokenURI));\\n }\\n // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.\\n return string(abi.encodePacked(base, tokenId.toString()));\\n }\\n\\n /**\\n * @dev Returns the base URI set via {_setBaseURI}. This will be\\n * automatically added as a prefix in {tokenURI} to each token's URI, or\\n * to the token ID if no specific URI is set for that token ID.\\n */\\n function baseURI() public view virtual returns (string memory) {\\n return _baseURI;\\n }\\n\\n /**\\n * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.\\n */\\n function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {\\n return _holderTokens[owner].at(index);\\n }\\n\\n /**\\n * @dev See {IERC721Enumerable-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds\\n return _tokenOwners.length();\\n }\\n\\n /**\\n * @dev See {IERC721Enumerable-tokenByIndex}.\\n */\\n function tokenByIndex(uint256 index) public view virtual override returns (uint256) {\\n (uint256 tokenId, ) = _tokenOwners.at(index);\\n return tokenId;\\n }\\n\\n /**\\n * @dev See {IERC721-approve}.\\n */\\n function approve(address to, uint256 tokenId) public virtual override {\\n address owner = ERC721.ownerOf(tokenId);\\n require(to != owner, \\\"ERC721: approval to current owner\\\");\\n\\n require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()),\\n \\\"ERC721: approve caller is not owner nor approved for all\\\"\\n );\\n\\n _approve(to, tokenId);\\n }\\n\\n /**\\n * @dev See {IERC721-getApproved}.\\n */\\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\\n require(_exists(tokenId), \\\"ERC721: approved query for nonexistent token\\\");\\n\\n return _tokenApprovals[tokenId];\\n }\\n\\n /**\\n * @dev See {IERC721-setApprovalForAll}.\\n */\\n function setApprovalForAll(address operator, bool approved) public virtual override {\\n require(operator != _msgSender(), \\\"ERC721: approve to caller\\\");\\n\\n _operatorApprovals[_msgSender()][operator] = approved;\\n emit ApprovalForAll(_msgSender(), operator, approved);\\n }\\n\\n /**\\n * @dev See {IERC721-isApprovedForAll}.\\n */\\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\\n return _operatorApprovals[owner][operator];\\n }\\n\\n /**\\n * @dev See {IERC721-transferFrom}.\\n */\\n function transferFrom(address from, address to, uint256 tokenId) public virtual override {\\n //solhint-disable-next-line max-line-length\\n require(_isApprovedOrOwner(_msgSender(), tokenId), \\\"ERC721: transfer caller is not owner nor approved\\\");\\n\\n _transfer(from, to, tokenId);\\n }\\n\\n /**\\n * @dev See {IERC721-safeTransferFrom}.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {\\n safeTransferFrom(from, to, tokenId, \\\"\\\");\\n }\\n\\n /**\\n * @dev See {IERC721-safeTransferFrom}.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {\\n require(_isApprovedOrOwner(_msgSender(), tokenId), \\\"ERC721: transfer caller is not owner nor approved\\\");\\n _safeTransfer(from, to, tokenId, _data);\\n }\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * `_data` is additional data, it has no specified format and it is sent in call to `to`.\\n *\\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\\n * implement alternative mechanisms to perform token transfer, such as signature-based.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {\\n _transfer(from, to, tokenId);\\n require(_checkOnERC721Received(from, to, tokenId, _data), \\\"ERC721: transfer to non ERC721Receiver implementer\\\");\\n }\\n\\n /**\\n * @dev Returns whether `tokenId` exists.\\n *\\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\\n *\\n * Tokens start existing when they are minted (`_mint`),\\n * and stop existing when they are burned (`_burn`).\\n */\\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\\n return _tokenOwners.contains(tokenId);\\n }\\n\\n /**\\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\\n require(_exists(tokenId), \\\"ERC721: operator query for nonexistent token\\\");\\n address owner = ERC721.ownerOf(tokenId);\\n return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender));\\n }\\n\\n /**\\n * @dev Safely mints `tokenId` and transfers it to `to`.\\n *\\n * Requirements:\\n d*\\n * - `tokenId` must not exist.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _safeMint(address to, uint256 tokenId) internal virtual {\\n _safeMint(to, tokenId, \\\"\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\\n */\\n function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual {\\n _mint(to, tokenId);\\n require(_checkOnERC721Received(address(0), to, tokenId, _data), \\\"ERC721: transfer to non ERC721Receiver implementer\\\");\\n }\\n\\n /**\\n * @dev Mints `tokenId` and transfers it to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\\n *\\n * Requirements:\\n *\\n * - `tokenId` must not exist.\\n * - `to` cannot be the zero address.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _mint(address to, uint256 tokenId) internal virtual {\\n require(to != address(0), \\\"ERC721: mint to the zero address\\\");\\n require(!_exists(tokenId), \\\"ERC721: token already minted\\\");\\n\\n _beforeTokenTransfer(address(0), to, tokenId);\\n\\n _holderTokens[to].add(tokenId);\\n\\n _tokenOwners.set(tokenId, to);\\n\\n emit Transfer(address(0), to, tokenId);\\n }\\n\\n /**\\n * @dev Destroys `tokenId`.\\n * The approval is cleared when the token is burned.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _burn(uint256 tokenId) internal virtual {\\n address owner = ERC721.ownerOf(tokenId); // internal owner\\n\\n _beforeTokenTransfer(owner, address(0), tokenId);\\n\\n // Clear approvals\\n _approve(address(0), tokenId);\\n\\n // Clear metadata (if any)\\n if (bytes(_tokenURIs[tokenId]).length != 0) {\\n delete _tokenURIs[tokenId];\\n }\\n\\n _holderTokens[owner].remove(tokenId);\\n\\n _tokenOwners.remove(tokenId);\\n\\n emit Transfer(owner, address(0), tokenId);\\n }\\n\\n /**\\n * @dev Transfers `tokenId` from `from` to `to`.\\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _transfer(address from, address to, uint256 tokenId) internal virtual {\\n require(ERC721.ownerOf(tokenId) == from, \\\"ERC721: transfer of token that is not own\\\"); // internal owner\\n require(to != address(0), \\\"ERC721: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, tokenId);\\n\\n // Clear approvals from the previous owner\\n _approve(address(0), tokenId);\\n\\n _holderTokens[from].remove(tokenId);\\n _holderTokens[to].add(tokenId);\\n\\n _tokenOwners.set(tokenId, to);\\n\\n emit Transfer(from, to, tokenId);\\n }\\n\\n /**\\n * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {\\n require(_exists(tokenId), \\\"ERC721Metadata: URI set of nonexistent token\\\");\\n _tokenURIs[tokenId] = _tokenURI;\\n }\\n\\n /**\\n * @dev Internal function to set the base URI for all token IDs. It is\\n * automatically added as a prefix to the value returned in {tokenURI},\\n * or to the token ID if {tokenURI} is empty.\\n */\\n function _setBaseURI(string memory baseURI_) internal virtual {\\n _baseURI = baseURI_;\\n }\\n\\n /**\\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\\n * The call is not executed if the target address is not a contract.\\n *\\n * @param from address representing the previous owner of the given token ID\\n * @param to target address that will receive the tokens\\n * @param tokenId uint256 ID of the token to be transferred\\n * @param _data bytes optional data to send along with the call\\n * @return bool whether the call correctly returned the expected magic value\\n */\\n function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)\\n private returns (bool)\\n {\\n if (!to.isContract()) {\\n return true;\\n }\\n bytes memory returndata = to.functionCall(abi.encodeWithSelector(\\n IERC721Receiver(to).onERC721Received.selector,\\n _msgSender(),\\n from,\\n tokenId,\\n _data\\n ), \\\"ERC721: transfer to non ERC721Receiver implementer\\\");\\n bytes4 retval = abi.decode(returndata, (bytes4));\\n return (retval == _ERC721_RECEIVED);\\n }\\n\\n /**\\n * @dev Approve `to` to operate on `tokenId`\\n *\\n * Emits an {Approval} event.\\n */\\n function _approve(address to, uint256 tokenId) internal virtual {\\n _tokenApprovals[tokenId] = to;\\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner\\n }\\n\\n /**\\n * @dev Hook that is called before any token transfer. This includes minting\\n * and burning.\\n *\\n * Calling conditions:\\n *\\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\\n * transferred to `to`.\\n * - When `from` is zero, `tokenId` will be minted for `to`.\\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }\\n}\\n\",\"keccak256\":\"0x93e4f65a89c3c888afbaa3ee18c3fa4f51c422419bbcd9cca47676a0f8e507ea\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"../../introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\\n}\\n\",\"keccak256\":\"0xb11597841d47f7a773bca63ca323c76f804cb5d944788de0327db5526319dc82\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Enumerable is IERC721 {\\n\\n /**\\n * @dev Returns the total amount of tokens stored by the contract.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\\n */\\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);\\n\\n /**\\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\\n * Use along with {totalSupply} to enumerate all tokens.\\n */\\n function tokenByIndex(uint256 index) external view returns (uint256);\\n}\\n\",\"keccak256\":\"0x2789dfea2d73182683d637db5729201f6730dae6113030a94c828f8688f38f2f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./IERC721.sol\\\";\\n\\n/**\\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\\n * @dev See https://eips.ethereum.org/EIPS/eip-721\\n */\\ninterface IERC721Metadata is IERC721 {\\n\\n /**\\n * @dev Returns the token collection name.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the token collection symbol.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\\n */\\n function tokenURI(uint256 tokenId) external view returns (string memory);\\n}\\n\",\"keccak256\":\"0xc82c7d1d732081d9bd23f1555ebdf8f3bc1738bc42c2bfc4b9aa7564d9fa3573\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @title ERC721 token receiver interface\\n * @dev Interface for any contract that wants to support safeTransfers\\n * from ERC721 asset contracts.\\n */\\ninterface IERC721Receiver {\\n /**\\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\\n * by `operator` from `from`, this function is called.\\n *\\n * It must return its Solidity selector to confirm the token transfer.\\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\\n *\\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\\n */\\n function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);\\n}\\n\",\"keccak256\":\"0x05604ffcf69e416b8a42728bb0e4fd75170d8fac70bf1a284afeb4752a9bc52f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf89f005a3d98f7768cdee2583707db0ac725cf567d455751af32ee68132f3db3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/*\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with GSN meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x8d3cb350f04ff49cfb10aef08d87f19dcbaecc8027b0bed12f3275cd12f38cf0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/EnumerableMap.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Library for managing an enumerable variant of Solidity's\\n * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]\\n * type.\\n *\\n * Maps have the following properties:\\n *\\n * - Entries are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Entries are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableMap for EnumerableMap.UintToAddressMap;\\n *\\n * // Declare a set state variable\\n * EnumerableMap.UintToAddressMap private myMap;\\n * }\\n * ```\\n *\\n * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are\\n * supported.\\n */\\nlibrary EnumerableMap {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Map type with\\n // bytes32 keys and values.\\n // The Map implementation uses private functions, and user-facing\\n // implementations (such as Uint256ToAddressMap) are just wrappers around\\n // the underlying Map.\\n // This means that we can only create new EnumerableMaps for types that fit\\n // in bytes32.\\n\\n struct MapEntry {\\n bytes32 _key;\\n bytes32 _value;\\n }\\n\\n struct Map {\\n // Storage of map keys and values\\n MapEntry[] _entries;\\n\\n // Position of the entry defined by a key in the `entries` array, plus 1\\n // because index 0 means a key is not in the map.\\n mapping (bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Adds a key-value pair to a map, or updates the value for an existing\\n * key. O(1).\\n *\\n * Returns true if the key was added to the map, that is if it was not\\n * already present.\\n */\\n function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {\\n // We read and store the key's index to prevent multiple reads from the same storage slot\\n uint256 keyIndex = map._indexes[key];\\n\\n if (keyIndex == 0) { // Equivalent to !contains(map, key)\\n map._entries.push(MapEntry({ _key: key, _value: value }));\\n // The entry is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n map._indexes[key] = map._entries.length;\\n return true;\\n } else {\\n map._entries[keyIndex - 1]._value = value;\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a key-value pair from a map. O(1).\\n *\\n * Returns true if the key was removed from the map, that is if it was present.\\n */\\n function _remove(Map storage map, bytes32 key) private returns (bool) {\\n // We read and store the key's index to prevent multiple reads from the same storage slot\\n uint256 keyIndex = map._indexes[key];\\n\\n if (keyIndex != 0) { // Equivalent to contains(map, key)\\n // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one\\n // in the array, and then remove the last entry (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = keyIndex - 1;\\n uint256 lastIndex = map._entries.length - 1;\\n\\n // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs\\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\\n\\n MapEntry storage lastEntry = map._entries[lastIndex];\\n\\n // Move the last entry to the index where the entry to delete is\\n map._entries[toDeleteIndex] = lastEntry;\\n // Update the index for the moved entry\\n map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based\\n\\n // Delete the slot where the moved entry was stored\\n map._entries.pop();\\n\\n // Delete the index for the deleted slot\\n delete map._indexes[key];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the key is in the map. O(1).\\n */\\n function _contains(Map storage map, bytes32 key) private view returns (bool) {\\n return map._indexes[key] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of key-value pairs in the map. O(1).\\n */\\n function _length(Map storage map) private view returns (uint256) {\\n return map._entries.length;\\n }\\n\\n /**\\n * @dev Returns the key-value pair stored at position `index` in the map. O(1).\\n *\\n * Note that there are no guarantees on the ordering of entries inside the\\n * array, and it may change when more entries are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {\\n require(map._entries.length > index, \\\"EnumerableMap: index out of bounds\\\");\\n\\n MapEntry storage entry = map._entries[index];\\n return (entry._key, entry._value);\\n }\\n\\n /**\\n * @dev Tries to returns the value associated with `key`. O(1).\\n * Does not revert if `key` is not in the map.\\n */\\n function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {\\n uint256 keyIndex = map._indexes[key];\\n if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key)\\n return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based\\n }\\n\\n /**\\n * @dev Returns the value associated with `key`. O(1).\\n *\\n * Requirements:\\n *\\n * - `key` must be in the map.\\n */\\n function _get(Map storage map, bytes32 key) private view returns (bytes32) {\\n uint256 keyIndex = map._indexes[key];\\n require(keyIndex != 0, \\\"EnumerableMap: nonexistent key\\\"); // Equivalent to contains(map, key)\\n return map._entries[keyIndex - 1]._value; // All indexes are 1-based\\n }\\n\\n /**\\n * @dev Same as {_get}, with a custom error message when `key` is not in the map.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {_tryGet}.\\n */\\n function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {\\n uint256 keyIndex = map._indexes[key];\\n require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)\\n return map._entries[keyIndex - 1]._value; // All indexes are 1-based\\n }\\n\\n // UintToAddressMap\\n\\n struct UintToAddressMap {\\n Map _inner;\\n }\\n\\n /**\\n * @dev Adds a key-value pair to a map, or updates the value for an existing\\n * key. O(1).\\n *\\n * Returns true if the key was added to the map, that is if it was not\\n * already present.\\n */\\n function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {\\n return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the key was removed from the map, that is if it was present.\\n */\\n function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {\\n return _remove(map._inner, bytes32(key));\\n }\\n\\n /**\\n * @dev Returns true if the key is in the map. O(1).\\n */\\n function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {\\n return _contains(map._inner, bytes32(key));\\n }\\n\\n /**\\n * @dev Returns the number of elements in the map. O(1).\\n */\\n function length(UintToAddressMap storage map) internal view returns (uint256) {\\n return _length(map._inner);\\n }\\n\\n /**\\n * @dev Returns the element stored at position `index` in the set. O(1).\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {\\n (bytes32 key, bytes32 value) = _at(map._inner, index);\\n return (uint256(key), address(uint160(uint256(value))));\\n }\\n\\n /**\\n * @dev Tries to returns the value associated with `key`. O(1).\\n * Does not revert if `key` is not in the map.\\n *\\n * _Available since v3.4._\\n */\\n function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {\\n (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));\\n return (success, address(uint160(uint256(value))));\\n }\\n\\n /**\\n * @dev Returns the value associated with `key`. O(1).\\n *\\n * Requirements:\\n *\\n * - `key` must be in the map.\\n */\\n function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {\\n return address(uint160(uint256(_get(map._inner, bytes32(key)))));\\n }\\n\\n /**\\n * @dev Same as {get}, with a custom error message when `key` is not in the map.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryGet}.\\n */\\n function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {\\n return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));\\n }\\n}\\n\",\"keccak256\":\"0x2114555153edb5f273008b3d34205f511db9af06b88f752e4c280dd612c4c549\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/EnumerableSet.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Library for managing\\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\\n * types.\\n *\\n * Sets have the following properties:\\n *\\n * - Elements are added, removed, and checked for existence in constant time\\n * (O(1)).\\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\\n *\\n * ```\\n * contract Example {\\n * // Add the library methods\\n * using EnumerableSet for EnumerableSet.AddressSet;\\n *\\n * // Declare a set state variable\\n * EnumerableSet.AddressSet private mySet;\\n * }\\n * ```\\n *\\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\\n * and `uint256` (`UintSet`) are supported.\\n */\\nlibrary EnumerableSet {\\n // To implement this library for multiple types with as little code\\n // repetition as possible, we write it in terms of a generic Set type with\\n // bytes32 values.\\n // The Set implementation uses private functions, and user-facing\\n // implementations (such as AddressSet) are just wrappers around the\\n // underlying Set.\\n // This means that we can only create new EnumerableSets for types that fit\\n // in bytes32.\\n\\n struct Set {\\n // Storage of set values\\n bytes32[] _values;\\n\\n // Position of the value in the `values` array, plus 1 because index 0\\n // means a value is not in the set.\\n mapping (bytes32 => uint256) _indexes;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function _add(Set storage set, bytes32 value) private returns (bool) {\\n if (!_contains(set, value)) {\\n set._values.push(value);\\n // The value is stored at length-1, but we add 1 to all indexes\\n // and use 0 as a sentinel value\\n set._indexes[value] = set._values.length;\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function _remove(Set storage set, bytes32 value) private returns (bool) {\\n // We read and store the value's index to prevent multiple reads from the same storage slot\\n uint256 valueIndex = set._indexes[value];\\n\\n if (valueIndex != 0) { // Equivalent to contains(set, value)\\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\\n // the array, and then remove the last element (sometimes called as 'swap and pop').\\n // This modifies the order of the array, as noted in {at}.\\n\\n uint256 toDeleteIndex = valueIndex - 1;\\n uint256 lastIndex = set._values.length - 1;\\n\\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\\n\\n bytes32 lastvalue = set._values[lastIndex];\\n\\n // Move the last value to the index where the value to delete is\\n set._values[toDeleteIndex] = lastvalue;\\n // Update the index for the moved value\\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\\n\\n // Delete the slot where the moved value was stored\\n set._values.pop();\\n\\n // Delete the index for the deleted slot\\n delete set._indexes[value];\\n\\n return true;\\n } else {\\n return false;\\n }\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\\n return set._indexes[value] != 0;\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function _length(Set storage set) private view returns (uint256) {\\n return set._values.length;\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\\n require(set._values.length > index, \\\"EnumerableSet: index out of bounds\\\");\\n return set._values[index];\\n }\\n\\n // Bytes32Set\\n\\n struct Bytes32Set {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _add(set._inner, value);\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\\n return _remove(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\\n return _contains(set._inner, value);\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(Bytes32Set storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\\n return _at(set._inner, index);\\n }\\n\\n // AddressSet\\n\\n struct AddressSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(AddressSet storage set, address value) internal returns (bool) {\\n return _add(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(AddressSet storage set, address value) internal returns (bool) {\\n return _remove(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(AddressSet storage set, address value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(uint256(uint160(value))));\\n }\\n\\n /**\\n * @dev Returns the number of values in the set. O(1).\\n */\\n function length(AddressSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\\n return address(uint160(uint256(_at(set._inner, index))));\\n }\\n\\n\\n // UintSet\\n\\n struct UintSet {\\n Set _inner;\\n }\\n\\n /**\\n * @dev Add a value to a set. O(1).\\n *\\n * Returns true if the value was added to the set, that is if it was not\\n * already present.\\n */\\n function add(UintSet storage set, uint256 value) internal returns (bool) {\\n return _add(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Removes a value from a set. O(1).\\n *\\n * Returns true if the value was removed from the set, that is if it was\\n * present.\\n */\\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\\n return _remove(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns true if the value is in the set. O(1).\\n */\\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\\n return _contains(set._inner, bytes32(value));\\n }\\n\\n /**\\n * @dev Returns the number of values on the set. O(1).\\n */\\n function length(UintSet storage set) internal view returns (uint256) {\\n return _length(set._inner);\\n }\\n\\n /**\\n * @dev Returns the value stored at position `index` in the set. O(1).\\n *\\n * Note that there are no guarantees on the ordering of values inside the\\n * array, and it may change when more values are added or removed.\\n *\\n * Requirements:\\n *\\n * - `index` must be strictly less than {length}.\\n */\\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\\n return uint256(_at(set._inner, index));\\n }\\n}\\n\",\"keccak256\":\"0x9a2c1eebb65250f0e11882237038600f22a62376f0547db4acc0dfe0a3d8d34f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n uint256 index = digits - 1;\\n temp = value;\\n while (temp != 0) {\\n buffer[index--] = bytes1(uint8(48 + temp % 10));\\n temp /= 10;\\n }\\n return string(buffer);\\n }\\n}\\n\",\"keccak256\":\"0x08e38e034333372aea8cb1b8846085b7fbab42c6b77a0af464d2c6827827c4f0\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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;\\n}\\n\",\"keccak256\":\"0x0ba8a9b95a956a4050749c0158e928398c447c91469682ca8a7cc7e77a7fe032\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/FullMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.4.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 // 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;\\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 /// @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 result = mulDiv(a, b, denominator);\\n if (mulmod(a, b, denominator) > 0) {\\n require(result < type(uint256).max);\\n result++;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe511530871deaef86692cea9adb6076d26d7b47fd4815ce51af52af981026057\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/libraries/UnsafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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\":\"0x5f36d7d16348d8c37fe64fda932018d6e5e8acecd054f0f97d32db62d20c6c88\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IERC721Permit.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\n\\nimport '@openzeppelin/contracts/token/ERC721/IERC721.sol';\\n\\n/// @title ERC721 with permit\\n/// @notice Extension to ERC721 that includes a permit function for signature based approvals\\ninterface IERC721Permit is IERC721 {\\n /// @notice The permit typehash used in the permit signature\\n /// @return The typehash for the permit\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n\\n /// @notice The domain separator used in the permit signature\\n /// @return The domain seperator used in encoding of permit signature\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Approve of a specific token ID for spending by spender via signature\\n /// @param spender The account that is being approved\\n /// @param tokenId The ID of the token that is being approved for spending\\n /// @param deadline The deadline timestamp by which the call must be mined for the approve to work\\n /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`\\n /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`\\n /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`\\n function permit(\\n address spender,\\n uint256 tokenId,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external payable;\\n}\\n\",\"keccak256\":\"0x9e3c2a4ee65ddf95b2dfcb0815784eea3a295707e6f8b83e4c4f0f8fe2e3a1d4\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\nimport '@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol';\\nimport '@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol';\\n\\nimport './IPoolInitializer.sol';\\nimport './IERC721Permit.sol';\\nimport './IPeripheryPayments.sol';\\nimport './IPeripheryImmutableState.sol';\\nimport '../libraries/PoolAddress.sol';\\n\\n/// @title Non-fungible token for positions\\n/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred\\n/// and authorized.\\ninterface INonfungiblePositionManager is\\n IPoolInitializer,\\n IPeripheryPayments,\\n IPeripheryImmutableState,\\n IERC721Metadata,\\n IERC721Enumerable,\\n IERC721Permit\\n{\\n /// @notice Emitted when liquidity is increased for a position NFT\\n /// @dev Also emitted when a token is minted\\n /// @param tokenId The ID of the token for which liquidity was increased\\n /// @param liquidity The amount by which liquidity for the NFT position was increased\\n /// @param amount0 The amount of token0 that was paid for the increase in liquidity\\n /// @param amount1 The amount of token1 that was paid for the increase in liquidity\\n event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\\n /// @notice Emitted when liquidity is decreased for a position NFT\\n /// @param tokenId The ID of the token for which liquidity was decreased\\n /// @param liquidity The amount by which liquidity for the NFT position was decreased\\n /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity\\n /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity\\n event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\\n /// @notice Emitted when tokens are collected for a position NFT\\n /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior\\n /// @param tokenId The ID of the token for which underlying tokens were collected\\n /// @param recipient The address of the account that received the collected tokens\\n /// @param amount0 The amount of token0 owed to the position that was collected\\n /// @param amount1 The amount of token1 owed to the position that was collected\\n event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);\\n\\n /// @notice Returns the position information associated with a given token ID.\\n /// @dev Throws if the token ID is not valid.\\n /// @param tokenId The ID of the token that represents the position\\n /// @return nonce The nonce for permits\\n /// @return operator The address that is approved for spending\\n /// @return token0 The address of the token0 for a specific pool\\n /// @return token1 The address of the token1 for a specific pool\\n /// @return fee The fee associated with the pool\\n /// @return tickLower The lower end of the tick range for the position\\n /// @return tickUpper The higher end of the tick range for the position\\n /// @return liquidity The liquidity of the position\\n /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position\\n /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position\\n /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation\\n /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation\\n function positions(uint256 tokenId)\\n external\\n view\\n returns (\\n uint96 nonce,\\n address operator,\\n address token0,\\n address token1,\\n uint24 fee,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n uint256 feeGrowthInside0LastX128,\\n uint256 feeGrowthInside1LastX128,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n );\\n\\n struct MintParams {\\n address token0;\\n address token1;\\n uint24 fee;\\n int24 tickLower;\\n int24 tickUpper;\\n uint256 amount0Desired;\\n uint256 amount1Desired;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n address recipient;\\n uint256 deadline;\\n }\\n\\n /// @notice Creates a new position wrapped in a NFT\\n /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized\\n /// a method does not exist, i.e. the pool is assumed to be initialized.\\n /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata\\n /// @return tokenId The ID of the token that represents the minted position\\n /// @return liquidity The amount of liquidity for this position\\n /// @return amount0 The amount of token0\\n /// @return amount1 The amount of token1\\n function mint(MintParams calldata params)\\n external\\n payable\\n returns (\\n uint256 tokenId,\\n uint128 liquidity,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n struct IncreaseLiquidityParams {\\n uint256 tokenId;\\n uint256 amount0Desired;\\n uint256 amount1Desired;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n uint256 deadline;\\n }\\n\\n /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`\\n /// @param params tokenId The ID of the token for which liquidity is being increased,\\n /// amount0Desired The desired amount of token0 to be spent,\\n /// amount1Desired The desired amount of token1 to be spent,\\n /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,\\n /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,\\n /// deadline The time by which the transaction must be included to effect the change\\n /// @return liquidity The new liquidity amount as a result of the increase\\n /// @return amount0 The amount of token0 to acheive resulting liquidity\\n /// @return amount1 The amount of token1 to acheive resulting liquidity\\n function increaseLiquidity(IncreaseLiquidityParams calldata params)\\n external\\n payable\\n returns (\\n uint128 liquidity,\\n uint256 amount0,\\n uint256 amount1\\n );\\n\\n struct DecreaseLiquidityParams {\\n uint256 tokenId;\\n uint128 liquidity;\\n uint256 amount0Min;\\n uint256 amount1Min;\\n uint256 deadline;\\n }\\n\\n /// @notice Decreases the amount of liquidity in a position and accounts it to the position\\n /// @param params tokenId The ID of the token for which liquidity is being decreased,\\n /// amount The amount by which liquidity will be decreased,\\n /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,\\n /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,\\n /// deadline The time by which the transaction must be included to effect the change\\n /// @return amount0 The amount of token0 accounted to the position's tokens owed\\n /// @return amount1 The amount of token1 accounted to the position's tokens owed\\n function decreaseLiquidity(DecreaseLiquidityParams calldata params)\\n external\\n payable\\n returns (uint256 amount0, uint256 amount1);\\n\\n struct CollectParams {\\n uint256 tokenId;\\n address recipient;\\n uint128 amount0Max;\\n uint128 amount1Max;\\n }\\n\\n /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient\\n /// @param params tokenId The ID of the NFT for which tokens are being collected,\\n /// recipient The account that should receive the tokens,\\n /// amount0Max The maximum amount of token0 to collect,\\n /// amount1Max The maximum amount of token1 to collect\\n /// @return amount0 The amount of fees collected in token0\\n /// @return amount1 The amount of fees collected in token1\\n function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);\\n\\n /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens\\n /// must be collected first.\\n /// @param tokenId The ID of the token that is being burned\\n function burn(uint256 tokenId) external payable;\\n}\\n\",\"keccak256\":\"0xe1dadc73e60bf05d0b4e0f05bd2847c5783e833cc10352c14763360b13495ee1\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPeripheryImmutableState.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Immutable state\\n/// @notice Functions that return immutable state of the router\\ninterface IPeripheryImmutableState {\\n /// @return Returns the address of the Uniswap V3 factory\\n function factory() external view returns (address);\\n\\n /// @return Returns the address of WETH9\\n function WETH9() external view returns (address);\\n}\\n\",\"keccak256\":\"0x7affcfeb5127c0925a71d6a65345e117c33537523aeca7bc98085ead8452519d\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPeripheryPayments.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\n\\n/// @title Periphery Payments\\n/// @notice Functions to ease deposits and withdrawals of ETH\\ninterface IPeripheryPayments {\\n /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.\\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.\\n /// @param amountMinimum The minimum amount of WETH9 to unwrap\\n /// @param recipient The address receiving ETH\\n function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;\\n\\n /// @notice Refunds any ETH balance held by this contract to the `msg.sender`\\n /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps\\n /// that use ether for the input amount\\n function refundETH() external payable;\\n\\n /// @notice Transfers the full amount of a token held by this contract to recipient\\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users\\n /// @param token The contract address of the token which will be transferred to `recipient`\\n /// @param amountMinimum The minimum amount of token required for a transfer\\n /// @param recipient The destination address of the token\\n function sweepToken(\\n address token,\\n uint256 amountMinimum,\\n address recipient\\n ) external payable;\\n}\\n\",\"keccak256\":\"0xb547e10f1e69bed03621a62b73a503e260643066c6b4054867a4d1fef47eb274\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/interfaces/IPoolInitializer.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\n/// @title Creates and initializes V3 Pools\\n/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that\\n/// require the pool to exist.\\ninterface IPoolInitializer {\\n /// @notice Creates a new pool if it does not exist, then initializes if not initialized\\n /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool\\n /// @param token0 The contract address of token0 of the pool\\n /// @param token1 The contract address of token1 of the pool\\n /// @param fee The fee amount of the v3 pool for the specified token pair\\n /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value\\n /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary\\n function createAndInitializePoolIfNecessary(\\n address token0,\\n address token1,\\n uint24 fee,\\n uint160 sqrtPriceX96\\n ) external payable returns (address pool);\\n}\\n\",\"keccak256\":\"0x9d7695e8d94c22cc5fcced602017aabb988de89981ea7bee29ea629d5328a862\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee\\nlibrary PoolAddress {\\n bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;\\n\\n /// @notice The identifying key of the pool\\n struct PoolKey {\\n address token0;\\n address token1;\\n uint24 fee;\\n }\\n\\n /// @notice Returns PoolKey: the ordered tokens with the matched fee levels\\n /// @param tokenA The first token of a pool, unsorted\\n /// @param tokenB The second token of a pool, unsorted\\n /// @param fee The fee level of the pool\\n /// @return Poolkey The pool details with ordered token0 and token1 assignments\\n function getPoolKey(\\n address tokenA,\\n address tokenB,\\n uint24 fee\\n ) internal pure returns (PoolKey memory) {\\n if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);\\n return PoolKey({token0: tokenA, token1: tokenB, fee: fee});\\n }\\n\\n /// @notice Deterministically computes the pool address given the factory and PoolKey\\n /// @param factory The Uniswap V3 factory contract address\\n /// @param key The PoolKey\\n /// @return pool The contract address of the V3 pool\\n function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {\\n require(key.token0 < key.token1);\\n pool = address(\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n hex'ff',\\n factory,\\n keccak256(abi.encode(key.token0, key.token1, key.fee)),\\n POOL_INIT_CODE_HASH\\n )\\n )\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x5edd84eb8ba7c12fd8cb6cffe52e1e9f3f6464514ee5f539c2283826209035a2\",\"license\":\"GPL-2.0-or-later\"},\"contracts/core/ShortPowerPerp.sol\":{\"content\":\"//SPDX-License-Identifier: BUSL-1.1\\n\\npragma solidity =0.7.6;\\n\\n//contract\\nimport {ERC721} from \\\"@openzeppelin/contracts/token/ERC721/ERC721.sol\\\";\\nimport {Initializable} from \\\"@openzeppelin/contracts/proxy/Initializable.sol\\\";\\nimport {IController} from \\\"../interfaces/IController.sol\\\";\\n\\n/**\\n * @notice ERC721 NFT representing ownership of a vault (short position)\\n */\\ncontract ShortPowerPerp is ERC721, Initializable {\\n /// @dev tokenId for the next vault opened\\n uint256 public nextId = 1;\\n\\n address public controller;\\n address private immutable deployer;\\n\\n modifier onlyController() {\\n require(msg.sender == controller, \\\"Not controller\\\");\\n _;\\n }\\n\\n /**\\n * @notice short power perpetual constructor\\n * @param _name token name for ERC721\\n * @param _symbol token symbol for ERC721\\n */\\n constructor(string memory _name, string memory _symbol) ERC721(_name, _symbol) {\\n deployer = msg.sender;\\n }\\n\\n /**\\n * @notice initialize short contract\\n * @param _controller controller address\\n */\\n function init(address _controller) public initializer {\\n require(msg.sender == deployer, \\\"Invalid caller of init\\\");\\n require(_controller != address(0), \\\"Invalid controller address\\\");\\n controller = _controller;\\n }\\n\\n /**\\n * @notice mint new NFT\\n * @dev autoincrement tokenId starts at 1\\n * @param _recipient recipient address for NFT\\n */\\n function mintNFT(address _recipient) external onlyController returns (uint256 tokenId) {\\n // mint NFT\\n _safeMint(_recipient, (tokenId = nextId++));\\n }\\n\\n function _beforeTokenTransfer(\\n address, /* from */\\n address, /* to */\\n uint256 tokenId\\n ) internal override {\\n IController(controller).updateOperator(tokenId, address(0));\\n }\\n}\\n\",\"keccak256\":\"0x5597686c00b4341803c9119e8402e9207b0d13ca722e724fa9d2c85e8ea6dbf5\",\"license\":\"BUSL-1.1\"},\"contracts/interfaces/IController.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\npragma abicoder v2;\\n\\nimport {VaultLib} from \\\"../libs/VaultLib.sol\\\";\\n\\ninterface IController {\\n function ethQuoteCurrencyPool() external view returns (address);\\n\\n function feeRate() external view returns (uint256);\\n\\n function getFee(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _collateralAmount\\n ) external view returns (uint256);\\n\\n function quoteCurrency() external view returns (address);\\n\\n function vaults(uint256 _vaultId) external view returns (VaultLib.Vault memory);\\n\\n function shortPowerPerp() external view returns (address);\\n\\n function wPowerPerp() external view returns (address);\\n\\n function getExpectedNormalizationFactor() external view returns (uint256);\\n\\n function mintPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _powerPerpAmount,\\n uint256 _uniTokenId\\n ) external payable returns (uint256 vaultId, uint256 wPowerPerpAmount);\\n\\n function mintWPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _uniTokenId\\n ) external payable returns (uint256 vaultId);\\n\\n /**\\n * Deposit collateral into a vault\\n */\\n function deposit(uint256 _vaultId) external payable;\\n\\n /**\\n * Withdraw collateral from a vault.\\n */\\n function withdraw(uint256 _vaultId, uint256 _amount) external payable;\\n\\n function burnWPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _wPowerPerpAmount,\\n uint256 _withdrawAmount\\n ) external;\\n\\n function burnOnPowerPerpAmount(\\n uint256 _vaultId,\\n uint256 _powerPerpAmount,\\n uint256 _withdrawAmount\\n ) external returns (uint256 wPowerPerpAmount);\\n\\n function liquidate(uint256 _vaultId, uint256 _maxDebtAmount) external returns (uint256);\\n\\n function updateOperator(uint256 _vaultId, address _operator) external;\\n\\n /**\\n * External function to update the normalized factor as a way to pay funding.\\n */\\n function applyFunding() external;\\n\\n function redeemShort(uint256 _vaultId) external;\\n\\n function reduceDebtShutdown(uint256 _vaultId) external;\\n\\n function isShutDown() external returns (bool);\\n}\\n\",\"keccak256\":\"0xc5d6230c8bafcaf2ae7260efd68c45ab13e91819ed9e11881b29dc48386e4bc7\",\"license\":\"MIT\"},\"contracts/libs/SqrtPriceMathPartial.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\nimport \\\"@uniswap/v3-core/contracts/libraries/FullMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/UnsafeMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\\\";\\n\\n/// @title Functions based on Q64.96 sqrt price and liquidity\\n/// @notice Exposes two functions from @uniswap/v3-core SqrtPriceMath\\n/// that use square root of price as a Q64.96 and liquidity to compute deltas\\nlibrary SqrtPriceMathPartial {\\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 ) external 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\\n require(sqrtRatioAX96 > 0);\\n\\n return\\n roundUp\\n ? UnsafeMath.divRoundingUp(\\n FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96),\\n sqrtRatioAX96\\n )\\n : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96;\\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 ) external 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\",\"keccak256\":\"0x34b98f373514d057151a41d35aa42031af3b1a47e910888ed73315f72520e429\",\"license\":\"GPL-2.0-or-later\"},\"contracts/libs/TickMathExternal.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.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 TickMathExternal {\\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) public pure returns (uint160 sqrtPriceX96) {\\n uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\\n require(absTick <= uint256(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 /// @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) external pure returns (int24 tick) {\\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\",\"keccak256\":\"0xfd917bc787958baa0b7fd6f526f88a63a5b98a32d3ff1c0f67665e7a1be86e10\",\"license\":\"GPL-2.0-or-later\"},\"contracts/libs/Uint256Casting.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nlibrary Uint256Casting {\\n /**\\n * @notice cast a uint256 to a uint128, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint128\\n */\\n function toUint128(uint256 y) internal pure returns (uint128 z) {\\n require((z = uint128(y)) == y, \\\"OF128\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint96, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint96\\n */\\n function toUint96(uint256 y) internal pure returns (uint96 z) {\\n require((z = uint96(y)) == y, \\\"OF96\\\");\\n }\\n\\n /**\\n * @notice cast a uint256 to a uint32, revert on overflow\\n * @param y the uint256 to be downcasted\\n * @return z the downcasted integer, now type uint32\\n */\\n function toUint32(uint256 y) internal pure returns (uint32 z) {\\n require((z = uint32(y)) == y, \\\"OF32\\\");\\n }\\n}\\n\",\"keccak256\":\"0xcccbe82f8696be398d0d0f5a44988e9bab70e18dd40c9563620cdf160d8bcd7c\",\"license\":\"MIT\"},\"contracts/libs/VaultLib.sol\":{\"content\":\"//SPDX-License-Identifier: GPL-2.0-or-later\\n\\npragma solidity =0.7.6;\\n\\n//interface\\nimport {INonfungiblePositionManager} from \\\"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\\\";\\n\\n//lib\\nimport {SafeMath} from \\\"@openzeppelin/contracts/math/SafeMath.sol\\\";\\nimport {TickMathExternal} from \\\"./TickMathExternal.sol\\\";\\nimport {SqrtPriceMathPartial} from \\\"./SqrtPriceMathPartial.sol\\\";\\nimport {Uint256Casting} from \\\"./Uint256Casting.sol\\\";\\n\\n/**\\n * Error code:\\n * V1: Vault already had nft\\n * V2: Vault has no NFT\\n */\\nlibrary VaultLib {\\n using SafeMath for uint256;\\n using Uint256Casting for uint256;\\n\\n uint256 constant ONE_ONE = 1e36;\\n\\n // the collateralization ratio (CR) is checked with the numerator and denominator separately\\n // a user is safe if - collateral value >= (COLLAT_RATIO_NUMER/COLLAT_RATIO_DENOM)* debt value\\n uint256 public constant CR_NUMERATOR = 3;\\n uint256 public constant CR_DENOMINATOR = 2;\\n\\n struct Vault {\\n // the address that can update the vault\\n address operator;\\n // uniswap position token id deposited into the vault as collateral\\n // 2^32 is 4,294,967,296, which means the vault structure will work with up to 4 billion positions\\n uint32 NftCollateralId;\\n // amount of eth (wei) used in the vault as collateral\\n // 2^96 / 1e18 = 79,228,162,514, which means a vault can store up to 79 billion eth\\n // when we need to do calculations, we always cast this number to uint256 to avoid overflow\\n uint96 collateralAmount;\\n // amount of wPowerPerp minted from the vault\\n uint128 shortAmount;\\n }\\n\\n /**\\n * @notice add eth collateral to a vault\\n * @param _vault in-memory vault\\n * @param _amount amount of eth to add\\n */\\n function addEthCollateral(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.collateralAmount = uint256(_vault.collateralAmount).add(_amount).toUint96();\\n }\\n\\n /**\\n * @notice add uniswap position token collateral to a vault\\n * @param _vault in-memory vault\\n * @param _tokenId uniswap position token id\\n */\\n function addUniNftCollateral(Vault memory _vault, uint256 _tokenId) internal pure {\\n require(_vault.NftCollateralId == 0, \\\"V1\\\");\\n require(_tokenId != 0, \\\"C23\\\");\\n _vault.NftCollateralId = _tokenId.toUint32();\\n }\\n\\n /**\\n * @notice remove eth collateral from a vault\\n * @param _vault in-memory vault\\n * @param _amount amount of eth to remove\\n */\\n function removeEthCollateral(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.collateralAmount = uint256(_vault.collateralAmount).sub(_amount).toUint96();\\n }\\n\\n /**\\n * @notice remove uniswap position token collateral from a vault\\n * @param _vault in-memory vault\\n */\\n function removeUniNftCollateral(Vault memory _vault) internal pure {\\n require(_vault.NftCollateralId != 0, \\\"V2\\\");\\n _vault.NftCollateralId = 0;\\n }\\n\\n /**\\n * @notice add debt to vault\\n * @param _vault in-memory vault\\n * @param _amount amount of debt to add\\n */\\n function addShort(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.shortAmount = uint256(_vault.shortAmount).add(_amount).toUint128();\\n }\\n\\n /**\\n * @notice remove debt from vault\\n * @param _vault in-memory vault\\n * @param _amount amount of debt to remove\\n */\\n function removeShort(Vault memory _vault, uint256 _amount) internal pure {\\n _vault.shortAmount = uint256(_vault.shortAmount).sub(_amount).toUint128();\\n }\\n\\n /**\\n * @notice check if a vault is properly collateralized\\n * @param _vault the vault we want to check\\n * @param _positionManager address of the uniswap position manager\\n * @param _normalizationFactor current _normalizationFactor\\n * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18\\n * @param _minCollateral minimum collateral that needs to be in a vault\\n * @param _wsqueethPoolTick current price tick for wsqueeth pool\\n * @param _isWethToken0 whether weth is token0 in the wsqueeth pool\\n * @return true if the vault is sufficiently collateralized\\n * @return true if the vault is considered as a dust vault\\n */\\n function getVaultStatus(\\n Vault memory _vault,\\n address _positionManager,\\n uint256 _normalizationFactor,\\n uint256 _ethQuoteCurrencyPrice,\\n uint256 _minCollateral,\\n int24 _wsqueethPoolTick,\\n bool _isWethToken0\\n ) internal view returns (bool, bool) {\\n if (_vault.shortAmount == 0) return (true, false);\\n\\n uint256 debtValueInETH = uint256(_vault.shortAmount).mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div(\\n ONE_ONE\\n );\\n uint256 totalCollateral = _getEffectiveCollateral(\\n _vault,\\n _positionManager,\\n _normalizationFactor,\\n _ethQuoteCurrencyPrice,\\n _wsqueethPoolTick,\\n _isWethToken0\\n );\\n\\n bool isDust = totalCollateral < _minCollateral;\\n bool isAboveWater = totalCollateral.mul(CR_DENOMINATOR) >= debtValueInETH.mul(CR_NUMERATOR);\\n return (isAboveWater, isDust);\\n }\\n\\n /**\\n * @notice get the total effective collateral of a vault, which is:\\n * collateral amount + uniswap position token equivelent amount in eth\\n * @param _vault the vault we want to check\\n * @param _positionManager address of the uniswap position manager\\n * @param _normalizationFactor current _normalizationFactor\\n * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18\\n * @param _wsqueethPoolTick current price tick for wsqueeth pool\\n * @param _isWethToken0 whether weth is token0 in the wsqueeth pool\\n * @return the total worth of collateral in the vault\\n */\\n function _getEffectiveCollateral(\\n Vault memory _vault,\\n address _positionManager,\\n uint256 _normalizationFactor,\\n uint256 _ethQuoteCurrencyPrice,\\n int24 _wsqueethPoolTick,\\n bool _isWethToken0\\n ) internal view returns (uint256) {\\n if (_vault.NftCollateralId == 0) return _vault.collateralAmount;\\n\\n // the user has deposited uniswap position token as collateral, see how much eth / wSqueeth the uniswap position token has\\n (uint256 nftEthAmount, uint256 nftWsqueethAmount) = _getUniPositionBalances(\\n _positionManager,\\n _vault.NftCollateralId,\\n _wsqueethPoolTick,\\n _isWethToken0\\n );\\n // convert squeeth amount from uniswap position token as equivalent amount of collateral\\n uint256 wSqueethIndexValueInEth = nftWsqueethAmount.mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div(\\n ONE_ONE\\n );\\n // add eth value from uniswap position token as collateral\\n return nftEthAmount.add(wSqueethIndexValueInEth).add(_vault.collateralAmount);\\n }\\n\\n /**\\n * @notice determine how much eth / wPowerPerp the uniswap position contains\\n * @param _positionManager address of the uniswap position manager\\n * @param _tokenId uniswap position token id\\n * @param _wPowerPerpPoolTick current price tick\\n * @param _isWethToken0 whether weth is token0 in the pool\\n * @return ethAmount the eth amount this LP token contains\\n * @return wPowerPerpAmount the wPowerPerp amount this LP token contains\\n */\\n function _getUniPositionBalances(\\n address _positionManager,\\n uint256 _tokenId,\\n int24 _wPowerPerpPoolTick,\\n bool _isWethToken0\\n ) internal view returns (uint256 ethAmount, uint256 wPowerPerpAmount) {\\n (\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n ) = _getUniswapPositionInfo(_positionManager, _tokenId);\\n (uint256 amount0, uint256 amount1) = _getToken0Token1Balances(\\n tickLower,\\n tickUpper,\\n _wPowerPerpPoolTick,\\n liquidity\\n );\\n\\n return\\n _isWethToken0\\n ? (amount0 + tokensOwed0, amount1 + tokensOwed1)\\n : (amount1 + tokensOwed1, amount0 + tokensOwed0);\\n }\\n\\n /**\\n * @notice get uniswap position token info\\n * @param _positionManager address of the uniswap position position manager\\n * @param _tokenId uniswap position token id\\n * @return tickLower lower tick of the position\\n * @return tickUpper upper tick of the position\\n * @return liquidity raw liquidity amount of the position\\n * @return tokensOwed0 amount of token 0 can be collected as fee\\n * @return tokensOwed1 amount of token 1 can be collected as fee\\n */\\n function _getUniswapPositionInfo(address _positionManager, uint256 _tokenId)\\n internal\\n view\\n returns (\\n int24,\\n int24,\\n uint128,\\n uint128,\\n uint128\\n )\\n {\\n INonfungiblePositionManager positionManager = INonfungiblePositionManager(_positionManager);\\n (\\n ,\\n ,\\n ,\\n ,\\n ,\\n int24 tickLower,\\n int24 tickUpper,\\n uint128 liquidity,\\n ,\\n ,\\n uint128 tokensOwed0,\\n uint128 tokensOwed1\\n ) = positionManager.positions(_tokenId);\\n return (tickLower, tickUpper, liquidity, tokensOwed0, tokensOwed1);\\n }\\n\\n /**\\n * @notice get balances of token0 / token1 in a uniswap position\\n * @dev knowing liquidity, tick range, and current tick gives balances\\n * @param _tickLower address of the uniswap position manager\\n * @param _tickUpper uniswap position token id\\n * @param _tick current price tick used for calculation\\n * @return amount0 the amount of token0 in the uniswap position token\\n * @return amount1 the amount of token1 in the uniswap position token\\n */\\n function _getToken0Token1Balances(\\n int24 _tickLower,\\n int24 _tickUpper,\\n int24 _tick,\\n uint128 _liquidity\\n ) internal pure returns (uint256 amount0, uint256 amount1) {\\n // get the current price and tick from wPowerPerp pool\\n uint160 sqrtPriceX96 = TickMathExternal.getSqrtRatioAtTick(_tick);\\n\\n if (_tick < _tickLower) {\\n amount0 = SqrtPriceMathPartial.getAmount0Delta(\\n TickMathExternal.getSqrtRatioAtTick(_tickLower),\\n TickMathExternal.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n } else if (_tick < _tickUpper) {\\n amount0 = SqrtPriceMathPartial.getAmount0Delta(\\n sqrtPriceX96,\\n TickMathExternal.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n amount1 = SqrtPriceMathPartial.getAmount1Delta(\\n TickMathExternal.getSqrtRatioAtTick(_tickLower),\\n sqrtPriceX96,\\n _liquidity,\\n true\\n );\\n } else {\\n amount1 = SqrtPriceMathPartial.getAmount1Delta(\\n TickMathExternal.getSqrtRatioAtTick(_tickLower),\\n TickMathExternal.getSqrtRatioAtTick(_tickUpper),\\n _liquidity,\\n true\\n );\\n }\\n }\\n}\\n\",\"keccak256\":\"0x939175a827c8e9d8d09ee55957e8127a6a55bf42d6a0b3e48b0b59c895aa85af\",\"license\":\"GPL-2.0-or-later\"}},\"version\":1}", + "bytecode": "0x60a06040526001600b553480156200001657600080fd5b506040516200229c3803806200229c833981810160405260408110156200003c57600080fd5b81019080805160405193929190846401000000008211156200005d57600080fd5b9083019060208201858111156200007357600080fd5b82516401000000008111828201881017156200008e57600080fd5b82525081516020918201929091019080838360005b83811015620000bd578181015183820152602001620000a3565b50505050905090810190601f168015620000eb5780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200010f57600080fd5b9083019060208201858111156200012557600080fd5b82516401000000008111828201881017156200014057600080fd5b82525081516020918201929091019080838360005b838110156200016f57818101518382015260200162000155565b50505050905090810190601f1680156200019d5780820380516001836020036101000a031916815260200191505b5060405250839150829050620001ba6301ffc9a760e01b6200022d565b8151620001cf906006906020850190620002b2565b508051620001e5906007906020840190620002b2565b50620001f86380ac58cd60e01b6200022d565b6200020a635b5e139f60e01b6200022d565b6200021c63780e9d6360e01b6200022d565b5050503360601b608052506200035e565b6001600160e01b031980821614156200028d576040805162461bcd60e51b815260206004820152601c60248201527f4552433136353a20696e76616c696420696e7465726661636520696400000000604482015290519081900360640190fd5b6001600160e01b0319166000908152602081905260409020805460ff19166001179055565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282620002ea576000855562000335565b82601f106200030557805160ff191683800117855562000335565b8280016001018555821562000335579182015b828111156200033557825182559160200191906001019062000318565b506200034392915062000347565b5090565b5b8082111562000343576000815560010162000348565b60805160601c611f206200037c600039806107f75250611f206000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806354ba0f27116100d857806395d89b411161008c578063c87b56dd11610066578063c87b56dd14610505578063e985e9c514610522578063f77c47911461055057610177565b806395d89b4114610409578063a22cb46514610411578063b88d4fde1461043f57610177565b80636352211e116100bd5780636352211e146103be5780636c0360eb146103db57806370a08231146103e357610177565b806354ba0f271461039057806361b8ce8c146103b657610177565b806319ab453c1161012f5780632f745c59116101145780632f745c591461031157806342842e0e1461033d5780634f6ccce71461037357610177565b806319ab453c146102b557806323b872dd146102db57610177565b8063081812fc11610160578063081812fc14610234578063095ea7b31461026d57806318160ddd1461029b57610177565b806301ffc9a71461017c57806306fdde03146101b7575b600080fd5b6101a36004803603602081101561019257600080fd5b50356001600160e01b031916610558565b604080519115158252519081900360200190f35b6101bf61057b565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101f95781810151838201526020016101e1565b50505050905090810190601f1680156102265780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102516004803603602081101561024a57600080fd5b5035610611565b604080516001600160a01b039092168252519081900360200190f35b6102996004803603604081101561028357600080fd5b506001600160a01b038135169060200135610673565b005b6102a361074e565b60408051918252519081900360200190f35b610299600480360360208110156102cb57600080fd5b50356001600160a01b031661075f565b610299600480360360608110156102f157600080fd5b506001600160a01b03813581169160208101359091169060400135610902565b6102a36004803603604081101561032757600080fd5b506001600160a01b038135169060200135610959565b6102996004803603606081101561035357600080fd5b506001600160a01b03813581169160208101359091169060400135610984565b6102a36004803603602081101561038957600080fd5b503561099f565b6102a3600480360360208110156103a657600080fd5b50356001600160a01b03166109b5565b6102a3610a2d565b610251600480360360208110156103d457600080fd5b5035610a33565b6101bf610a5b565b6102a3600480360360208110156103f957600080fd5b50356001600160a01b0316610abc565b6101bf610b24565b6102996004803603604081101561042757600080fd5b506001600160a01b0381351690602001351515610b85565b6102996004803603608081101561045557600080fd5b6001600160a01b0382358116926020810135909116916040820135919081019060808101606082013564010000000081111561049057600080fd5b8201836020820111156104a257600080fd5b803590602001918460018302840111640100000000831117156104c457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610c8a945050505050565b6101bf6004803603602081101561051b57600080fd5b5035610ce8565b6101a36004803603604081101561053857600080fd5b506001600160a01b0381358116916020013516610f69565b610251610f97565b6001600160e01b0319811660009081526020819052604090205460ff165b919050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106075780601f106105dc57610100808354040283529160200191610607565b820191906000526020600020905b8154815290600101906020018083116105ea57829003601f168201915b5050505050905090565b600061061c82610fa6565b6106575760405162461bcd60e51b815260040180806020018281038252602c815260200180611e15602c913960400191505060405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061067e82610a33565b9050806001600160a01b0316836001600160a01b031614156106d15760405162461bcd60e51b8152600401808060200182810382526021815260200180611e996021913960400191505060405180910390fd5b806001600160a01b03166106e3610fb3565b6001600160a01b031614806107045750610704816106ff610fb3565b610f69565b61073f5760405162461bcd60e51b8152600401808060200182810382526038815260200180611d3a6038913960400191505060405180910390fd5b6107498383610fb7565b505050565b600061075a6002611032565b905090565b600a54610100900460ff1680610778575061077861103d565b806107865750600a5460ff16155b6107c15760405162461bcd60e51b815260040180806020018281038252602e815260200180611dc5602e913960400191505060405180910390fd5b600a54610100900460ff161580156107ec57600a805460ff1961ff0019909116610100171660011790555b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610869576040805162461bcd60e51b815260206004820152601660248201527f496e76616c69642063616c6c6572206f6620696e697400000000000000000000604482015290519081900360640190fd5b6001600160a01b0382166108c4576040805162461bcd60e51b815260206004820152601a60248201527f496e76616c696420636f6e74726f6c6c65722061646472657373000000000000604482015290519081900360640190fd5b600c805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03841617905580156108fe57600a805461ff00191690555b5050565b61091361090d610fb3565b8261104e565b61094e5760405162461bcd60e51b8152600401808060200182810382526031815260200180611eba6031913960400191505060405180910390fd5b6107498383836110f2565b6001600160a01b038216600090815260016020526040812061097b908361123e565b90505b92915050565b61074983838360405180602001604052806000815250610c8a565b6000806109ad60028461124a565b509392505050565b600c546000906001600160a01b03163314610a17576040805162461bcd60e51b815260206004820152600e60248201527f4e6f7420636f6e74726f6c6c6572000000000000000000000000000000000000604482015290519081900360640190fd5b50600b8054600181019091556105768282611266565b600b5481565b600061097e82604051806060016040528060298152602001611d9c6029913960029190611280565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106075780601f106105dc57610100808354040283529160200191610607565b60006001600160a01b038216610b035760405162461bcd60e51b815260040180806020018281038252602a815260200180611d72602a913960400191505060405180910390fd5b6001600160a01b038216600090815260016020526040902061097e90611032565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106075780601f106105dc57610100808354040283529160200191610607565b610b8d610fb3565b6001600160a01b0316826001600160a01b03161415610bf3576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b8060056000610c00610fb3565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610c44610fb3565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b610c9b610c95610fb3565b8361104e565b610cd65760405162461bcd60e51b8152600401808060200182810382526031815260200180611eba6031913960400191505060405180910390fd5b610ce284848484611297565b50505050565b6060610cf382610fa6565b610d2e5760405162461bcd60e51b815260040180806020018281038252602f815260200180611e6a602f913960400191505060405180910390fd5b60008281526008602090815260408083208054825160026001831615610100026000190190921691909104601f810185900485028201850190935282815292909190830182828015610dc15780601f10610d9657610100808354040283529160200191610dc1565b820191906000526020600020905b815481529060010190602001808311610da457829003601f168201915b505050505090506000610dd2610a5b565b9050805160001415610de657509050610576565b815115610ea75780826040516020018083805190602001908083835b60208310610e215780518252601f199092019160209182019101610e02565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310610e695780518252601f199092019160209182019101610e4a565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050610576565b80610eb1856112e9565b6040516020018083805190602001908083835b60208310610ee35780518252601f199092019160209182019101610ec4565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310610f2b5780518252601f199092019160209182019101610f0c565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600c546001600160a01b031681565b600061097e6002836113dc565b3390565b6000818152600460205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0384169081179091558190610ff982610a33565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061097e826113e8565b6000611048306113ec565b15905090565b600061105982610fa6565b6110945760405162461bcd60e51b815260040180806020018281038252602c815260200180611d0e602c913960400191505060405180910390fd5b600061109f83610a33565b9050806001600160a01b0316846001600160a01b031614806110da5750836001600160a01b03166110cf84610611565b6001600160a01b0316145b806110ea57506110ea8185610f69565b949350505050565b826001600160a01b031661110582610a33565b6001600160a01b03161461114a5760405162461bcd60e51b8152600401808060200182810382526029815260200180611e416029913960400191505060405180910390fd5b6001600160a01b03821661118f5760405162461bcd60e51b8152600401808060200182810382526024815260200180611cea6024913960400191505060405180910390fd5b61119a8383836113f2565b6111a5600082610fb7565b6001600160a01b03831660009081526001602052604090206111c79082611462565b506001600160a01b03821660009081526001602052604090206111ea908261146e565b506111f76002828461147a565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061097b8383611490565b600080808061125986866114f4565b9097909650945050505050565b6108fe82826040518060200160405280600081525061156f565b600061128d8484846115c1565b90505b9392505050565b6112a28484846110f2565b6112ae8484848461168b565b610ce25760405162461bcd60e51b8152600401808060200182810382526032815260200180611cb86032913960400191505060405180910390fd5b60608161130e57506040805180820190915260018152600360fc1b6020820152610576565b8160005b811561132657600101600a82049150611312565b60008167ffffffffffffffff8111801561133f57600080fd5b506040519080825280601f01601f19166020018201604052801561136a576020820181803683370190505b50859350905060001982015b83156113d357600a840660300160f81b8282806001900393508151811061139957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a84049350611376565b50949350505050565b600061097b838361181d565b5490565b3b151590565b600c546040805163c65a391d60e01b81526004810184905260006024820181905291516001600160a01b039093169263c65a391d9260448084019391929182900301818387803b15801561144557600080fd5b505af1158015611459573d6000803e3d6000fd5b50505050505050565b600061097b8383611835565b600061097b83836118fb565b600061128d84846001600160a01b038516611945565b815460009082106114d25760405162461bcd60e51b8152600401808060200182810382526022815260200180611c966022913960400191505060405180910390fd5b8260000182815481106114e157fe5b9060005260206000200154905092915050565b8154600090819083106115385760405162461bcd60e51b8152600401808060200182810382526022815260200180611df36022913960400191505060405180910390fd5b600084600001848154811061154957fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b61157983836119dc565b611586600084848461168b565b6107495760405162461bcd60e51b8152600401808060200182810382526032815260200180611cb86032913960400191505060405180910390fd5b6000828152600184016020526040812054828161165c5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611621578181015183820152602001611609565b50505050905090810190601f16801561164e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061166f57fe5b9060005260206000209060020201600101549150509392505050565b600061169f846001600160a01b03166113ec565b6116ab575060016110ea565b60006117e3630a85bd0160e11b6116c0610fb3565b88878760405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561172757818101518382015260200161170f565b50505050905090810190601f1680156117545780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001611cb8603291396001600160a01b0388169190611b0a565b905060008180602001905160208110156117fc57600080fd5b50516001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b600081815260018301602052604081205480156118f1578354600019808301919081019060009087908390811061186857fe5b906000526020600020015490508087600001848154811061188557fe5b6000918252602080832090910192909255828152600189810190925260409020908401905586548790806118b557fe5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505061097e565b600091505061097e565b6000611907838361181d565b61193d5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561097e565b50600061097e565b6000828152600184016020526040812054806119aa575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055611290565b828560000160018303815481106119bd57fe5b9060005260206000209060020201600101819055506000915050611290565b6001600160a01b038216611a37576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b611a4081610fa6565b15611a92576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b611a9e600083836113f2565b6001600160a01b0382166000908152600160205260409020611ac0908261146e565b50611acd6002828461147a565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b606061128d848460008585611b1e856113ec565b611b6f576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310611bad5780518252601f199092019160209182019101611b8e565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611c0f576040519150601f19603f3d011682016040523d82523d6000602084013e611c14565b606091505b5091509150611c24828286611c2f565b979650505050505050565b60608315611c3e575081611290565b825115611c4e5782518084602001fd5b60405162461bcd60e51b815260206004820181815284516024840152845185939192839260440191908501908083836000831561162157818101518382015260200161160956fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a207472616e7366657220746f20746865207a65726f20616464726573734552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a2646970667358221220d3f1a23837994f40417509b4bc6ecf5c3e0a993c2a5fa9467490d40d7655c57964736f6c63430007060033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101775760003560e01c806354ba0f27116100d857806395d89b411161008c578063c87b56dd11610066578063c87b56dd14610505578063e985e9c514610522578063f77c47911461055057610177565b806395d89b4114610409578063a22cb46514610411578063b88d4fde1461043f57610177565b80636352211e116100bd5780636352211e146103be5780636c0360eb146103db57806370a08231146103e357610177565b806354ba0f271461039057806361b8ce8c146103b657610177565b806319ab453c1161012f5780632f745c59116101145780632f745c591461031157806342842e0e1461033d5780634f6ccce71461037357610177565b806319ab453c146102b557806323b872dd146102db57610177565b8063081812fc11610160578063081812fc14610234578063095ea7b31461026d57806318160ddd1461029b57610177565b806301ffc9a71461017c57806306fdde03146101b7575b600080fd5b6101a36004803603602081101561019257600080fd5b50356001600160e01b031916610558565b604080519115158252519081900360200190f35b6101bf61057b565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101f95781810151838201526020016101e1565b50505050905090810190601f1680156102265780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102516004803603602081101561024a57600080fd5b5035610611565b604080516001600160a01b039092168252519081900360200190f35b6102996004803603604081101561028357600080fd5b506001600160a01b038135169060200135610673565b005b6102a361074e565b60408051918252519081900360200190f35b610299600480360360208110156102cb57600080fd5b50356001600160a01b031661075f565b610299600480360360608110156102f157600080fd5b506001600160a01b03813581169160208101359091169060400135610902565b6102a36004803603604081101561032757600080fd5b506001600160a01b038135169060200135610959565b6102996004803603606081101561035357600080fd5b506001600160a01b03813581169160208101359091169060400135610984565b6102a36004803603602081101561038957600080fd5b503561099f565b6102a3600480360360208110156103a657600080fd5b50356001600160a01b03166109b5565b6102a3610a2d565b610251600480360360208110156103d457600080fd5b5035610a33565b6101bf610a5b565b6102a3600480360360208110156103f957600080fd5b50356001600160a01b0316610abc565b6101bf610b24565b6102996004803603604081101561042757600080fd5b506001600160a01b0381351690602001351515610b85565b6102996004803603608081101561045557600080fd5b6001600160a01b0382358116926020810135909116916040820135919081019060808101606082013564010000000081111561049057600080fd5b8201836020820111156104a257600080fd5b803590602001918460018302840111640100000000831117156104c457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610c8a945050505050565b6101bf6004803603602081101561051b57600080fd5b5035610ce8565b6101a36004803603604081101561053857600080fd5b506001600160a01b0381358116916020013516610f69565b610251610f97565b6001600160e01b0319811660009081526020819052604090205460ff165b919050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106075780601f106105dc57610100808354040283529160200191610607565b820191906000526020600020905b8154815290600101906020018083116105ea57829003601f168201915b5050505050905090565b600061061c82610fa6565b6106575760405162461bcd60e51b815260040180806020018281038252602c815260200180611e15602c913960400191505060405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061067e82610a33565b9050806001600160a01b0316836001600160a01b031614156106d15760405162461bcd60e51b8152600401808060200182810382526021815260200180611e996021913960400191505060405180910390fd5b806001600160a01b03166106e3610fb3565b6001600160a01b031614806107045750610704816106ff610fb3565b610f69565b61073f5760405162461bcd60e51b8152600401808060200182810382526038815260200180611d3a6038913960400191505060405180910390fd5b6107498383610fb7565b505050565b600061075a6002611032565b905090565b600a54610100900460ff1680610778575061077861103d565b806107865750600a5460ff16155b6107c15760405162461bcd60e51b815260040180806020018281038252602e815260200180611dc5602e913960400191505060405180910390fd5b600a54610100900460ff161580156107ec57600a805460ff1961ff0019909116610100171660011790555b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610869576040805162461bcd60e51b815260206004820152601660248201527f496e76616c69642063616c6c6572206f6620696e697400000000000000000000604482015290519081900360640190fd5b6001600160a01b0382166108c4576040805162461bcd60e51b815260206004820152601a60248201527f496e76616c696420636f6e74726f6c6c65722061646472657373000000000000604482015290519081900360640190fd5b600c805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03841617905580156108fe57600a805461ff00191690555b5050565b61091361090d610fb3565b8261104e565b61094e5760405162461bcd60e51b8152600401808060200182810382526031815260200180611eba6031913960400191505060405180910390fd5b6107498383836110f2565b6001600160a01b038216600090815260016020526040812061097b908361123e565b90505b92915050565b61074983838360405180602001604052806000815250610c8a565b6000806109ad60028461124a565b509392505050565b600c546000906001600160a01b03163314610a17576040805162461bcd60e51b815260206004820152600e60248201527f4e6f7420636f6e74726f6c6c6572000000000000000000000000000000000000604482015290519081900360640190fd5b50600b8054600181019091556105768282611266565b600b5481565b600061097e82604051806060016040528060298152602001611d9c6029913960029190611280565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106075780601f106105dc57610100808354040283529160200191610607565b60006001600160a01b038216610b035760405162461bcd60e51b815260040180806020018281038252602a815260200180611d72602a913960400191505060405180910390fd5b6001600160a01b038216600090815260016020526040902061097e90611032565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106075780601f106105dc57610100808354040283529160200191610607565b610b8d610fb3565b6001600160a01b0316826001600160a01b03161415610bf3576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b8060056000610c00610fb3565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610c44610fb3565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b610c9b610c95610fb3565b8361104e565b610cd65760405162461bcd60e51b8152600401808060200182810382526031815260200180611eba6031913960400191505060405180910390fd5b610ce284848484611297565b50505050565b6060610cf382610fa6565b610d2e5760405162461bcd60e51b815260040180806020018281038252602f815260200180611e6a602f913960400191505060405180910390fd5b60008281526008602090815260408083208054825160026001831615610100026000190190921691909104601f810185900485028201850190935282815292909190830182828015610dc15780601f10610d9657610100808354040283529160200191610dc1565b820191906000526020600020905b815481529060010190602001808311610da457829003601f168201915b505050505090506000610dd2610a5b565b9050805160001415610de657509050610576565b815115610ea75780826040516020018083805190602001908083835b60208310610e215780518252601f199092019160209182019101610e02565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310610e695780518252601f199092019160209182019101610e4a565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050610576565b80610eb1856112e9565b6040516020018083805190602001908083835b60208310610ee35780518252601f199092019160209182019101610ec4565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310610f2b5780518252601f199092019160209182019101610f0c565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600c546001600160a01b031681565b600061097e6002836113dc565b3390565b6000818152600460205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0384169081179091558190610ff982610a33565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061097e826113e8565b6000611048306113ec565b15905090565b600061105982610fa6565b6110945760405162461bcd60e51b815260040180806020018281038252602c815260200180611d0e602c913960400191505060405180910390fd5b600061109f83610a33565b9050806001600160a01b0316846001600160a01b031614806110da5750836001600160a01b03166110cf84610611565b6001600160a01b0316145b806110ea57506110ea8185610f69565b949350505050565b826001600160a01b031661110582610a33565b6001600160a01b03161461114a5760405162461bcd60e51b8152600401808060200182810382526029815260200180611e416029913960400191505060405180910390fd5b6001600160a01b03821661118f5760405162461bcd60e51b8152600401808060200182810382526024815260200180611cea6024913960400191505060405180910390fd5b61119a8383836113f2565b6111a5600082610fb7565b6001600160a01b03831660009081526001602052604090206111c79082611462565b506001600160a01b03821660009081526001602052604090206111ea908261146e565b506111f76002828461147a565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061097b8383611490565b600080808061125986866114f4565b9097909650945050505050565b6108fe82826040518060200160405280600081525061156f565b600061128d8484846115c1565b90505b9392505050565b6112a28484846110f2565b6112ae8484848461168b565b610ce25760405162461bcd60e51b8152600401808060200182810382526032815260200180611cb86032913960400191505060405180910390fd5b60608161130e57506040805180820190915260018152600360fc1b6020820152610576565b8160005b811561132657600101600a82049150611312565b60008167ffffffffffffffff8111801561133f57600080fd5b506040519080825280601f01601f19166020018201604052801561136a576020820181803683370190505b50859350905060001982015b83156113d357600a840660300160f81b8282806001900393508151811061139957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a84049350611376565b50949350505050565b600061097b838361181d565b5490565b3b151590565b600c546040805163c65a391d60e01b81526004810184905260006024820181905291516001600160a01b039093169263c65a391d9260448084019391929182900301818387803b15801561144557600080fd5b505af1158015611459573d6000803e3d6000fd5b50505050505050565b600061097b8383611835565b600061097b83836118fb565b600061128d84846001600160a01b038516611945565b815460009082106114d25760405162461bcd60e51b8152600401808060200182810382526022815260200180611c966022913960400191505060405180910390fd5b8260000182815481106114e157fe5b9060005260206000200154905092915050565b8154600090819083106115385760405162461bcd60e51b8152600401808060200182810382526022815260200180611df36022913960400191505060405180910390fd5b600084600001848154811061154957fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b61157983836119dc565b611586600084848461168b565b6107495760405162461bcd60e51b8152600401808060200182810382526032815260200180611cb86032913960400191505060405180910390fd5b6000828152600184016020526040812054828161165c5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611621578181015183820152602001611609565b50505050905090810190601f16801561164e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061166f57fe5b9060005260206000209060020201600101549150509392505050565b600061169f846001600160a01b03166113ec565b6116ab575060016110ea565b60006117e3630a85bd0160e11b6116c0610fb3565b88878760405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561172757818101518382015260200161170f565b50505050905090810190601f1680156117545780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001611cb8603291396001600160a01b0388169190611b0a565b905060008180602001905160208110156117fc57600080fd5b50516001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b600081815260018301602052604081205480156118f1578354600019808301919081019060009087908390811061186857fe5b906000526020600020015490508087600001848154811061188557fe5b6000918252602080832090910192909255828152600189810190925260409020908401905586548790806118b557fe5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505061097e565b600091505061097e565b6000611907838361181d565b61193d5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561097e565b50600061097e565b6000828152600184016020526040812054806119aa575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055611290565b828560000160018303815481106119bd57fe5b9060005260206000209060020201600101819055506000915050611290565b6001600160a01b038216611a37576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b611a4081610fa6565b15611a92576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b611a9e600083836113f2565b6001600160a01b0382166000908152600160205260409020611ac0908261146e565b50611acd6002828461147a565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b606061128d848460008585611b1e856113ec565b611b6f576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310611bad5780518252601f199092019160209182019101611b8e565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611c0f576040519150601f19603f3d011682016040523d82523d6000602084013e611c14565b606091505b5091509150611c24828286611c2f565b979650505050505050565b60608315611c3e575081611290565b825115611c4e5782518084602001fd5b60405162461bcd60e51b815260206004820181815284516024840152845185939192839260440191908501908083836000831561162157818101518382015260200161160956fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a207472616e7366657220746f20746865207a65726f20616464726573734552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a2646970667358221220d3f1a23837994f40417509b4bc6ecf5c3e0a993c2a5fa9467490d40d7655c57964736f6c63430007060033", "devdoc": { "kind": "dev", "methods": { @@ -685,7 +685,7 @@ "type": "t_bool" }, { - "astId": 10981, + "astId": 10465, "contract": "contracts/core/ShortPowerPerp.sol:ShortPowerPerp", "label": "nextId", "offset": 0, @@ -693,7 +693,7 @@ "type": "t_uint256" }, { - "astId": 10983, + "astId": 10467, "contract": "contracts/core/ShortPowerPerp.sol:ShortPowerPerp", "label": "controller", "offset": 0, diff --git a/packages/hardhat/deployments/mainnet/SqrtPriceMathPartial.json b/packages/hardhat/deployments/mainnet/SqrtPriceMathPartial.json new file mode 100644 index 000000000..b776e159b --- /dev/null +++ b/packages/hardhat/deployments/mainnet/SqrtPriceMathPartial.json @@ -0,0 +1,142 @@ +{ + "address": "0x9cf8dcbCf115B06d8f577E73Cb9EdFdb27828460", + "abi": [ + { + "inputs": [ + { + "internalType": "uint160", + "name": "sqrtRatioAX96", + "type": "uint160" + }, + { + "internalType": "uint160", + "name": "sqrtRatioBX96", + "type": "uint160" + }, + { + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "internalType": "bool", + "name": "roundUp", + "type": "bool" + } + ], + "name": "getAmount0Delta", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint160", + "name": "sqrtRatioAX96", + "type": "uint160" + }, + { + "internalType": "uint160", + "name": "sqrtRatioBX96", + "type": "uint160" + }, + { + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "internalType": "bool", + "name": "roundUp", + "type": "bool" + } + ], + "name": "getAmount1Delta", + "outputs": [ + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + } + ], + "transactionHash": "0xcc8f5cf0caf5162496847f590af7330820b9552fec9ab8d4618fc947fc0abf36", + "receipt": { + "to": null, + "from": "0xa3cB04d8BD927EEC8826BD77b7C71abE3d29c081", + "contractAddress": "0x9cf8dcbCf115B06d8f577E73Cb9EdFdb27828460", + "transactionIndex": 138, + "gasUsed": "245460", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xbc0e2739d884b3d4798c7e4aa1757ccf5ab0c1afa8284955c8608abab932871c", + "transactionHash": "0xcc8f5cf0caf5162496847f590af7330820b9552fec9ab8d4618fc947fc0abf36", + "logs": [], + "blockNumber": 13982540, + "cumulativeGasUsed": "7107029", + "status": 1, + "byzantium": true + }, + "args": [], + "solcInputHash": "d97d3d4b09e0d70518330d405a7dd9ff", + "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint160\",\"name\":\"sqrtRatioAX96\",\"type\":\"uint160\"},{\"internalType\":\"uint160\",\"name\":\"sqrtRatioBX96\",\"type\":\"uint160\"},{\"internalType\":\"uint128\",\"name\":\"liquidity\",\"type\":\"uint128\"},{\"internalType\":\"bool\",\"name\":\"roundUp\",\"type\":\"bool\"}],\"name\":\"getAmount0Delta\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amount0\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint160\",\"name\":\"sqrtRatioAX96\",\"type\":\"uint160\"},{\"internalType\":\"uint160\",\"name\":\"sqrtRatioBX96\",\"type\":\"uint160\"},{\"internalType\":\"uint128\",\"name\":\"liquidity\",\"type\":\"uint128\"},{\"internalType\":\"bool\",\"name\":\"roundUp\",\"type\":\"bool\"}],\"name\":\"getAmount1Delta\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amount1\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getAmount0Delta(uint160,uint160,uint128,bool)\":{\"details\":\"Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper), i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower))\",\"params\":{\"liquidity\":\"The amount of usable liquidity\",\"roundUp\":\"Whether to round the amount up or down\",\"sqrtRatioAX96\":\"A sqrt price\",\"sqrtRatioBX96\":\"Another sqrt price\"},\"returns\":{\"amount0\":\"Amount of token0 required to cover a position of size liquidity between the two passed prices\"}},\"getAmount1Delta(uint160,uint160,uint128,bool)\":{\"details\":\"Calculates liquidity * (sqrt(upper) - sqrt(lower))\",\"params\":{\"liquidity\":\"The amount of usable liquidity\",\"roundUp\":\"Whether to round the amount up, or down\",\"sqrtRatioAX96\":\"A sqrt price\",\"sqrtRatioBX96\":\"Another sqrt price\"},\"returns\":{\"amount1\":\"Amount of token1 required to cover a position of size liquidity between the two passed prices\"}}},\"title\":\"Functions based on Q64.96 sqrt price and liquidity\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getAmount0Delta(uint160,uint160,uint128,bool)\":{\"notice\":\"Gets the amount0 delta between two prices\"},\"getAmount1Delta(uint160,uint160,uint128,bool)\":{\"notice\":\"Gets the amount1 delta between two prices\"}},\"notice\":\"Exposes two functions from @uniswap/v3-core SqrtPriceMath that use square root of price as a Q64.96 and liquidity to compute deltas\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/libs/SqrtPriceMathPartial.sol\":\"SqrtPriceMathPartial\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":825},\"remappings\":[]},\"sources\":{\"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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;\\n}\\n\",\"keccak256\":\"0x0ba8a9b95a956a4050749c0158e928398c447c91469682ca8a7cc7e77a7fe032\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/FullMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.4.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 // 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;\\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 /// @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 result = mulDiv(a, b, denominator);\\n if (mulmod(a, b, denominator) > 0) {\\n require(result < type(uint256).max);\\n result++;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe511530871deaef86692cea9adb6076d26d7b47fd4815ce51af52af981026057\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/libraries/UnsafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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\":\"0x5f36d7d16348d8c37fe64fda932018d6e5e8acecd054f0f97d32db62d20c6c88\",\"license\":\"GPL-2.0-or-later\"},\"contracts/libs/SqrtPriceMathPartial.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\nimport \\\"@uniswap/v3-core/contracts/libraries/FullMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/UnsafeMath.sol\\\";\\nimport \\\"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\\\";\\n\\n/// @title Functions based on Q64.96 sqrt price and liquidity\\n/// @notice Exposes two functions from @uniswap/v3-core SqrtPriceMath\\n/// that use square root of price as a Q64.96 and liquidity to compute deltas\\nlibrary SqrtPriceMathPartial {\\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 ) external 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\\n require(sqrtRatioAX96 > 0);\\n\\n return\\n roundUp\\n ? UnsafeMath.divRoundingUp(\\n FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96),\\n sqrtRatioAX96\\n )\\n : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96;\\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 ) external 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\",\"keccak256\":\"0x34b98f373514d057151a41d35aa42031af3b1a47e910888ed73315f72520e429\",\"license\":\"GPL-2.0-or-later\"}},\"version\":1}", + "bytecode": "0x61037c610026600b82828239805160001a60731461001957fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100405760003560e01c80632c32d4b61461004557806348a0c5bd146100a7575b600080fd5b6100956004803603608081101561005b57600080fd5b506001600160a01b0381358116916020810135909116906fffffffffffffffffffffffffffffffff604082013516906060013515156100f7565b60408051918252519081900360200190f35b610095600480360360808110156100bd57600080fd5b506001600160a01b0381358116916020810135909116906fffffffffffffffffffffffffffffffff604082013516906060013515156101b4565b6000836001600160a01b0316856001600160a01b03161115610117579293925b7bffffffffffffffffffffffffffffffff000000000000000000000000606084901b166001600160a01b03868603811690871661015357600080fd5b8361018357866001600160a01b03166101768383896001600160a01b0316610251565b8161017d57fe5b046101a9565b6101a961019a8383896001600160a01b0316610301565b886001600160a01b031661033b565b979650505050505050565b6000836001600160a01b0316856001600160a01b031611156101d4579293925b816102135761020e836fffffffffffffffffffffffffffffffff168686036001600160a01b03166c01000000000000000000000000610251565b610248565b610248836fffffffffffffffffffffffffffffffff168686036001600160a01b03166c01000000000000000000000000610301565b95945050505050565b6000808060001985870986860292508281109083900303905080610287576000841161027c57600080fd5b5082900490506102fa565b80841161029357600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b600061030e848484610251565b90506000828061031a57fe5b84860911156102fa57600019811061033157600080fd5b6001019392505050565b80820491061515019056fea2646970667358221220e32a27e160f1e100d379265eea59cd512b33af807bc5362bfed6c725eae3727964736f6c63430007060033", + "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600436106100405760003560e01c80632c32d4b61461004557806348a0c5bd146100a7575b600080fd5b6100956004803603608081101561005b57600080fd5b506001600160a01b0381358116916020810135909116906fffffffffffffffffffffffffffffffff604082013516906060013515156100f7565b60408051918252519081900360200190f35b610095600480360360808110156100bd57600080fd5b506001600160a01b0381358116916020810135909116906fffffffffffffffffffffffffffffffff604082013516906060013515156101b4565b6000836001600160a01b0316856001600160a01b03161115610117579293925b7bffffffffffffffffffffffffffffffff000000000000000000000000606084901b166001600160a01b03868603811690871661015357600080fd5b8361018357866001600160a01b03166101768383896001600160a01b0316610251565b8161017d57fe5b046101a9565b6101a961019a8383896001600160a01b0316610301565b886001600160a01b031661033b565b979650505050505050565b6000836001600160a01b0316856001600160a01b031611156101d4579293925b816102135761020e836fffffffffffffffffffffffffffffffff168686036001600160a01b03166c01000000000000000000000000610251565b610248565b610248836fffffffffffffffffffffffffffffffff168686036001600160a01b03166c01000000000000000000000000610301565b95945050505050565b6000808060001985870986860292508281109083900303905080610287576000841161027c57600080fd5b5082900490506102fa565b80841161029357600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b600061030e848484610251565b90506000828061031a57fe5b84860911156102fa57600019811061033157600080fd5b6001019392505050565b80820491061515019056fea2646970667358221220e32a27e160f1e100d379265eea59cd512b33af807bc5362bfed6c725eae3727964736f6c63430007060033", + "devdoc": { + "kind": "dev", + "methods": { + "getAmount0Delta(uint160,uint160,uint128,bool)": { + "details": "Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper), i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower))", + "params": { + "liquidity": "The amount of usable liquidity", + "roundUp": "Whether to round the amount up or down", + "sqrtRatioAX96": "A sqrt price", + "sqrtRatioBX96": "Another sqrt price" + }, + "returns": { + "amount0": "Amount of token0 required to cover a position of size liquidity between the two passed prices" + } + }, + "getAmount1Delta(uint160,uint160,uint128,bool)": { + "details": "Calculates liquidity * (sqrt(upper) - sqrt(lower))", + "params": { + "liquidity": "The amount of usable liquidity", + "roundUp": "Whether to round the amount up, or down", + "sqrtRatioAX96": "A sqrt price", + "sqrtRatioBX96": "Another sqrt price" + }, + "returns": { + "amount1": "Amount of token1 required to cover a position of size liquidity between the two passed prices" + } + } + }, + "title": "Functions based on Q64.96 sqrt price and liquidity", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "getAmount0Delta(uint160,uint160,uint128,bool)": { + "notice": "Gets the amount0 delta between two prices" + }, + "getAmount1Delta(uint160,uint160,uint128,bool)": { + "notice": "Gets the amount1 delta between two prices" + } + }, + "notice": "Exposes two functions from @uniswap/v3-core SqrtPriceMath that use square root of price as a Q64.96 and liquidity to compute deltas", + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/hardhat/deployments/mainnet/TickMathExternal.json b/packages/hardhat/deployments/mainnet/TickMathExternal.json new file mode 100644 index 000000000..bc062ee01 --- /dev/null +++ b/packages/hardhat/deployments/mainnet/TickMathExternal.json @@ -0,0 +1,120 @@ +{ + "address": "0x4d9d7F7aE80d51628Aa56eF37720718C99E6FDfC", + "abi": [ + { + "inputs": [ + { + "internalType": "int24", + "name": "tick", + "type": "int24" + } + ], + "name": "getSqrtRatioAtTick", + "outputs": [ + { + "internalType": "uint160", + "name": "sqrtPriceX96", + "type": "uint160" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint160", + "name": "sqrtPriceX96", + "type": "uint160" + } + ], + "name": "getTickAtSqrtRatio", + "outputs": [ + { + "internalType": "int24", + "name": "tick", + "type": "int24" + } + ], + "stateMutability": "pure", + "type": "function" + } + ], + "transactionHash": "0xc6e050a7c1817af0e9aac95aaa2fd9b6f60203e66347be83be582b7df4d486dd", + "receipt": { + "to": null, + "from": "0xa3cB04d8BD927EEC8826BD77b7C71abE3d29c081", + "contractAddress": "0x4d9d7F7aE80d51628Aa56eF37720718C99E6FDfC", + "transactionIndex": 134, + "gasUsed": "461391", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xc570b6483d86d2f995db11190088571aef14ade5baf357ec0a149b57f498f629", + "transactionHash": "0xc6e050a7c1817af0e9aac95aaa2fd9b6f60203e66347be83be582b7df4d486dd", + "logs": [], + "blockNumber": 13982535, + "cumulativeGasUsed": "10795107", + "status": 1, + "byzantium": true + }, + "args": [], + "solcInputHash": "d97d3d4b09e0d70518330d405a7dd9ff", + "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"int24\",\"name\":\"tick\",\"type\":\"int24\"}],\"name\":\"getSqrtRatioAtTick\",\"outputs\":[{\"internalType\":\"uint160\",\"name\":\"sqrtPriceX96\",\"type\":\"uint160\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint160\",\"name\":\"sqrtPriceX96\",\"type\":\"uint160\"}],\"name\":\"getTickAtSqrtRatio\",\"outputs\":[{\"internalType\":\"int24\",\"name\":\"tick\",\"type\":\"int24\"}],\"stateMutability\":\"pure\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getSqrtRatioAtTick(int24)\":{\"details\":\"Throws if |tick| > max tick\",\"params\":{\"tick\":\"The input tick for the above formula\"},\"returns\":{\"sqrtPriceX96\":\"A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) at the given tick\"}},\"getTickAtSqrtRatio(uint160)\":{\"details\":\"Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may ever return.\",\"params\":{\"sqrtPriceX96\":\"The sqrt ratio for which to compute the tick as a Q64.96\"},\"returns\":{\"tick\":\"The greatest tick for which the ratio is less than or equal to the input ratio\"}}},\"stateVariables\":{\"MAX_SQRT_RATIO\":{\"details\":\"The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\"},\"MAX_TICK\":{\"details\":\"The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128\"},\"MIN_SQRT_RATIO\":{\"details\":\"The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\"},\"MIN_TICK\":{\"details\":\"The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128\"}},\"title\":\"Math library for computing sqrt prices from ticks and vice versa\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getSqrtRatioAtTick(int24)\":{\"notice\":\"Calculates sqrt(1.0001^tick) * 2^96\"},\"getTickAtSqrtRatio(uint160)\":{\"notice\":\"Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio\"}},\"notice\":\"Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports prices between 2**-128 and 2**128\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/libs/TickMathExternal.sol\":\"TickMathExternal\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":825},\"remappings\":[]},\"sources\":{\"contracts/libs/TickMathExternal.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.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 TickMathExternal {\\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) public pure returns (uint160 sqrtPriceX96) {\\n uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\\n require(absTick <= uint256(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 /// @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) external pure returns (int24 tick) {\\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\",\"keccak256\":\"0xfd917bc787958baa0b7fd6f526f88a63a5b98a32d3ff1c0f67665e7a1be86e10\",\"license\":\"GPL-2.0-or-later\"}},\"version\":1}", + "bytecode": "0x610768610026600b82828239805160001a60731461001957fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100405760003560e01c80634f76c05814610045578063986cfba314610082575b600080fd5b61006b6004803603602081101561005b57600080fd5b50356001600160a01b03166100be565b6040805160029290920b8252519081900360200190f35b6100a26004803603602081101561009857600080fd5b503560020b6103f3565b604080516001600160a01b039092168252519081900360200190f35b60006401000276a36001600160a01b038316108015906100fa575073fffd8963efd1fc6a506488495d951d5263988d266001600160a01b038316105b61012f576040805162461bcd60e51b81526020600482015260016024820152602960f91b604482015290519081900360640190fd5b77ffffffffffffffffffffffffffffffffffffffff00000000602083901b166fffffffffffffffffffffffffffffffff811160071b81811c67ffffffffffffffff811160061b90811c63ffffffff811160051b90811c61ffff811160041b90811c60ff8111600390811b91821c600f811160021b90811c918211600190811b92831c979088119617909417909217179091171717608081106101d957607f810383901c91506101e3565b80607f0383901b91505b908002607f81811c60ff83811c9190911c800280831c81831c1c800280841c81841c1c800280851c81851c1c800280861c81861c1c800280871c81871c1c800280881c81881c1c800280891c81891c1c8002808a1c818a1c1c8002808b1c818b1c1c8002808c1c818c1c1c8002808d1c818d1c1c8002808e1c9c81901c9c909c1c80029c8d901c9e9d607f198f0160401b60c09190911c678000000000000000161760c19b909b1c674000000000000000169a909a1760c29990991c672000000000000000169890981760c39790971c671000000000000000169690961760c49590951c670800000000000000169490941760c59390931c670400000000000000169290921760c69190911c670200000000000000161760c79190911c670100000000000000161760c89190911c6680000000000000161760c99190911c6640000000000000161760ca9190911c6620000000000000161760cb9190911c6610000000000000161760cc9190911c6608000000000000161760cd9190911c66040000000000001617693627a301d71055774c8581026f028f6481ab7f045a5af012a19d003aa9198101608090811d906fdb2df09e81959a81455e260799a0632f8301901d600281810b9083900b146103e457886001600160a01b03166103c8826103f3565b6001600160a01b031611156103dd57816103df565b805b6103e6565b815b9998505050505050505050565b60008060008360020b1261040a578260020b610412565b8260020b6000035b9050620d89e8811115610450576040805162461bcd60e51b81526020600482015260016024820152601560fa1b604482015290519081900360640190fd5b60006001821661047157700100000000000000000000000000000000610483565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156104b7576ffff97272373d413259a46990580e213a0260801c5b60048216156104d6576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b60088216156104f5576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615610514576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615610533576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615610552576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615610571576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615610591576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b6102008216156105b1576ff987a7253ac413176f2b074cf7815e540260801c5b6104008216156105d1576ff3392b0822b70005940c7a398e4b70f30260801c5b6108008216156105f1576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615610611576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615610631576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615610651576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615610671576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615610692576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b620200008216156106b2576e5d6af8dedb81196699c329225ee6040260801c5b620400008216156106d1576d2216e584f5fa1ea926041bedfe980260801c5b620800008216156106ee576b048a170391f7dc42444e8fa20260801c5b60008460020b131561070957806000198161070557fe5b0490505b64010000000081061561071d576001610720565b60005b60ff16602082901c019250505091905056fea26469706673582212206dc5711c8d674b1e879100ebd61c20e86a23e1c2a1903ee0a40e90c57b2721f464736f6c63430007060033", + "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600436106100405760003560e01c80634f76c05814610045578063986cfba314610082575b600080fd5b61006b6004803603602081101561005b57600080fd5b50356001600160a01b03166100be565b6040805160029290920b8252519081900360200190f35b6100a26004803603602081101561009857600080fd5b503560020b6103f3565b604080516001600160a01b039092168252519081900360200190f35b60006401000276a36001600160a01b038316108015906100fa575073fffd8963efd1fc6a506488495d951d5263988d266001600160a01b038316105b61012f576040805162461bcd60e51b81526020600482015260016024820152602960f91b604482015290519081900360640190fd5b77ffffffffffffffffffffffffffffffffffffffff00000000602083901b166fffffffffffffffffffffffffffffffff811160071b81811c67ffffffffffffffff811160061b90811c63ffffffff811160051b90811c61ffff811160041b90811c60ff8111600390811b91821c600f811160021b90811c918211600190811b92831c979088119617909417909217179091171717608081106101d957607f810383901c91506101e3565b80607f0383901b91505b908002607f81811c60ff83811c9190911c800280831c81831c1c800280841c81841c1c800280851c81851c1c800280861c81861c1c800280871c81871c1c800280881c81881c1c800280891c81891c1c8002808a1c818a1c1c8002808b1c818b1c1c8002808c1c818c1c1c8002808d1c818d1c1c8002808e1c9c81901c9c909c1c80029c8d901c9e9d607f198f0160401b60c09190911c678000000000000000161760c19b909b1c674000000000000000169a909a1760c29990991c672000000000000000169890981760c39790971c671000000000000000169690961760c49590951c670800000000000000169490941760c59390931c670400000000000000169290921760c69190911c670200000000000000161760c79190911c670100000000000000161760c89190911c6680000000000000161760c99190911c6640000000000000161760ca9190911c6620000000000000161760cb9190911c6610000000000000161760cc9190911c6608000000000000161760cd9190911c66040000000000001617693627a301d71055774c8581026f028f6481ab7f045a5af012a19d003aa9198101608090811d906fdb2df09e81959a81455e260799a0632f8301901d600281810b9083900b146103e457886001600160a01b03166103c8826103f3565b6001600160a01b031611156103dd57816103df565b805b6103e6565b815b9998505050505050505050565b60008060008360020b1261040a578260020b610412565b8260020b6000035b9050620d89e8811115610450576040805162461bcd60e51b81526020600482015260016024820152601560fa1b604482015290519081900360640190fd5b60006001821661047157700100000000000000000000000000000000610483565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156104b7576ffff97272373d413259a46990580e213a0260801c5b60048216156104d6576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b60088216156104f5576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615610514576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615610533576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615610552576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615610571576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615610591576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b6102008216156105b1576ff987a7253ac413176f2b074cf7815e540260801c5b6104008216156105d1576ff3392b0822b70005940c7a398e4b70f30260801c5b6108008216156105f1576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615610611576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615610631576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615610651576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615610671576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615610692576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b620200008216156106b2576e5d6af8dedb81196699c329225ee6040260801c5b620400008216156106d1576d2216e584f5fa1ea926041bedfe980260801c5b620800008216156106ee576b048a170391f7dc42444e8fa20260801c5b60008460020b131561070957806000198161070557fe5b0490505b64010000000081061561071d576001610720565b60005b60ff16602082901c019250505091905056fea26469706673582212206dc5711c8d674b1e879100ebd61c20e86a23e1c2a1903ee0a40e90c57b2721f464736f6c63430007060033", + "devdoc": { + "kind": "dev", + "methods": { + "getSqrtRatioAtTick(int24)": { + "details": "Throws if |tick| > max tick", + "params": { + "tick": "The input tick for the above formula" + }, + "returns": { + "sqrtPriceX96": "A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) at the given tick" + } + }, + "getTickAtSqrtRatio(uint160)": { + "details": "Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may ever return.", + "params": { + "sqrtPriceX96": "The sqrt ratio for which to compute the tick as a Q64.96" + }, + "returns": { + "tick": "The greatest tick for which the ratio is less than or equal to the input ratio" + } + } + }, + "stateVariables": { + "MAX_SQRT_RATIO": { + "details": "The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)" + }, + "MAX_TICK": { + "details": "The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128" + }, + "MIN_SQRT_RATIO": { + "details": "The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)" + }, + "MIN_TICK": { + "details": "The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128" + } + }, + "title": "Math library for computing sqrt prices from ticks and vice versa", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "getSqrtRatioAtTick(int24)": { + "notice": "Calculates sqrt(1.0001^tick) * 2^96" + }, + "getTickAtSqrtRatio(uint160)": { + "notice": "Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio" + } + }, + "notice": "Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports prices between 2**-128 and 2**128", + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/packages/hardhat/deployments/mainnet/WPowerPerp.json b/packages/hardhat/deployments/mainnet/WPowerPerp.json index 76d166c29..1c3a33cee 100644 --- a/packages/hardhat/deployments/mainnet/WPowerPerp.json +++ b/packages/hardhat/deployments/mainnet/WPowerPerp.json @@ -1,5 +1,5 @@ { - "address": "0x4a49c7aC69de6cf23da5872b7A7c7D2f2D48fC87", + "address": "0xf1B99e3E573A1a9C5E6B2Ce818b617F0E664E86B", "abi": [ { "inputs": [ @@ -350,19 +350,19 @@ "type": "function" } ], - "transactionHash": "0x914bbc659af1b92882b39c9bb45fb0137a7d9c2eb459136d96d3566326a99f05", + "transactionHash": "0x7d501bc3f3cd097745d659b62c111d88f4202e5935c64087010dffea8d0c3475", "receipt": { "to": null, - "from": "0x80010e7575b24f47097598474502F0fd0aDbF3a8", - "contractAddress": "0x4a49c7aC69de6cf23da5872b7A7c7D2f2D48fC87", - "transactionIndex": 127, - "gasUsed": "1032126", + "from": "0xa3cB04d8BD927EEC8826BD77b7C71abE3d29c081", + "contractAddress": "0xf1B99e3E573A1a9C5E6B2Ce818b617F0E664E86B", + "transactionIndex": 62, + "gasUsed": "1032138", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x8b3083f6dc22e74ddc0ceea96f3f3ab117ec3963acc9f68683555865c2108679", - "transactionHash": "0x914bbc659af1b92882b39c9bb45fb0137a7d9c2eb459136d96d3566326a99f05", + "blockHash": "0x28dfd89b3b42928d994cf6839a1f8d29ed4abd1493677bd95d2e01fe6af8643c", + "transactionHash": "0x7d501bc3f3cd097745d659b62c111d88f4202e5935c64087010dffea8d0c3475", "logs": [], - "blockNumber": 13977444, - "cumulativeGasUsed": "8640076", + "blockNumber": 13982500, + "cumulativeGasUsed": "4521902", "status": 1, "byzantium": true }, @@ -370,10 +370,10 @@ "Opyn Squeeth", "oSQTH" ], - "solcInputHash": "56b4ec4ab07157f3d2fb7e1de805d93e", - "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_symbol\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controller\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_controller\",\"type\":\"address\"}],\"name\":\"init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"value of power perpetual is expected to go down over time through the impact of funding\",\"kind\":\"dev\",\"methods\":{\"allowance(address,address)\":{\"details\":\"See {IERC20-allowance}.\"},\"approve(address,uint256)\":{\"details\":\"See {IERC20-approve}. Requirements: - `spender` cannot be the zero address.\"},\"balanceOf(address)\":{\"details\":\"See {IERC20-balanceOf}.\"},\"burn(address,uint256)\":{\"params\":{\"_account\":\"account to burn from\",\"_amount\":\"amount to burn\"}},\"constructor\":{\"params\":{\"_name\":\"token name for ERC20\",\"_symbol\":\"token symbol for ERC20\"}},\"decimals()\":{\"details\":\"Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5,05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is called. NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.\"},\"decreaseAllowance(address,uint256)\":{\"details\":\"Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`.\"},\"increaseAllowance(address,uint256)\":{\"details\":\"Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.\"},\"init(address)\":{\"params\":{\"_controller\":\"controller address\"}},\"mint(address,uint256)\":{\"params\":{\"_account\":\"account to mint to\",\"_amount\":\"amount to mint\"}},\"name()\":{\"details\":\"Returns the name of the token.\"},\"symbol()\":{\"details\":\"Returns the symbol of the token, usually a shorter version of the name.\"},\"totalSupply()\":{\"details\":\"See {IERC20-totalSupply}.\"},\"transfer(address,uint256)\":{\"details\":\"See {IERC20-transfer}. Requirements: - `recipient` cannot be the zero address. - the caller must have a balance of at least `amount`.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. Requirements: - `sender` and `recipient` cannot be the zero address. - `sender` must have a balance of at least `amount`. - the caller must have allowance for ``sender``'s tokens of at least `amount`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"burn(address,uint256)\":{\"notice\":\"burn wPowerPerp\"},\"constructor\":{\"notice\":\"long power perpetual constructor\"},\"init(address)\":{\"notice\":\"init wPowerPerp contract\"},\"mint(address,uint256)\":{\"notice\":\"mint wPowerPerp\"}},\"notice\":\"ERC20 Token representing wrapped long power perpetual position\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/core/WPowerPerp.sol\":\"WPowerPerp\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":850},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0xe22a1fc7400ae196eba2ad1562d0386462b00a6363b742d55a2fd2021a58586f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n// solhint-disable-next-line compiler-version\\npragma solidity >=0.4.24 <0.8.0;\\n\\nimport \\\"../utils/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 a proxied contract can't have a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n */\\nabstract contract Initializable {\\n\\n /**\\n * @dev Indicates that the contract has been initialized.\\n */\\n bool private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Modifier to protect an initializer function from being invoked twice.\\n */\\n modifier initializer() {\\n require(_initializing || _isConstructor() || !_initialized, \\\"Initializable: contract is already initialized\\\");\\n\\n bool isTopLevelCall = !_initializing;\\n if (isTopLevelCall) {\\n _initializing = true;\\n _initialized = true;\\n }\\n\\n _;\\n\\n if (isTopLevelCall) {\\n _initializing = false;\\n }\\n }\\n\\n /// @dev Returns true if and only if the function is running in the constructor\\n function _isConstructor() private view returns (bool) {\\n return !Address.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0x9abeffe138f098b16557187383ba0f9e8503602fa95cd668132986ee115237ed\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"../../utils/Context.sol\\\";\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"../../math/SafeMath.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin guidelines: functions revert instead\\n * of returning `false` on failure. This behavior is nonetheless conventional\\n * and does not conflict with the expectations of ERC20 applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract ERC20 is Context, IERC20 {\\n using SafeMath for uint256;\\n\\n mapping (address => uint256) private _balances;\\n\\n mapping (address => mapping (address => uint256)) private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n uint8 private _decimals;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\\n * a default value of 18.\\n *\\n * To select a different value for {decimals}, use {_setupDecimals}.\\n *\\n * All three of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor (string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n _decimals = 18;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\\n * called.\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual returns (uint8) {\\n return _decimals;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual override returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `recipient` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(_msgSender(), recipient, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\\n _approve(_msgSender(), spender, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * Requirements:\\n *\\n * - `sender` and `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``sender``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(sender, recipient, amount);\\n _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \\\"ERC20: transfer amount exceeds allowance\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically increases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `spender` must have allowance for the caller of at least\\n * `subtractedValue`.\\n */\\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \\\"ERC20: decreased allowance below zero\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Moves tokens `amount` from `sender` to `recipient`.\\n *\\n * This is internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * Requirements:\\n *\\n * - `sender` cannot be the zero address.\\n * - `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n */\\n function _transfer(address sender, address recipient, uint256 amount) internal virtual {\\n require(sender != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(recipient != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(sender, recipient, amount);\\n\\n _balances[sender] = _balances[sender].sub(amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n _balances[recipient] = _balances[recipient].add(amount);\\n emit Transfer(sender, recipient, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply = _totalSupply.add(amount);\\n _balances[account] = _balances[account].add(amount);\\n emit Transfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n _balances[account] = _balances[account].sub(amount, \\\"ERC20: burn amount exceeds balance\\\");\\n _totalSupply = _totalSupply.sub(amount);\\n emit Transfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(address owner, address spender, uint256 amount) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Sets {decimals} to a value other than the default one of 18.\\n *\\n * WARNING: This function should only be called from the constructor. Most\\n * applications that interact with token contracts will not expect\\n * {decimals} to ever change, and may work incorrectly if it does.\\n */\\n function _setupDecimals(uint8 decimals_) internal virtual {\\n _decimals = decimals_;\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be to transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }\\n}\\n\",\"keccak256\":\"0x36b5ca4eabe888b39b10973621ca0dcc9b1508f8d06db9ddf045d7aa7c867d4a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0xbd74f587ab9b9711801baf667db1426e4a03fd2d7f15af33e0e0d0394e7cef76\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf89f005a3d98f7768cdee2583707db0ac725cf567d455751af32ee68132f3db3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/*\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with GSN meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x8d3cb350f04ff49cfb10aef08d87f19dcbaecc8027b0bed12f3275cd12f38cf0\",\"license\":\"MIT\"},\"contracts/core/WPowerPerp.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\n\\npragma solidity =0.7.6;\\n\\n//interface\\nimport {IWPowerPerp} from \\\"../interfaces/IWPowerPerp.sol\\\";\\n\\n//contract\\nimport {ERC20} from \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport {Initializable} from \\\"@openzeppelin/contracts/proxy/Initializable.sol\\\";\\n\\n/**\\n * @notice ERC20 Token representing wrapped long power perpetual position\\n * @dev value of power perpetual is expected to go down over time through the impact of funding\\n */\\ncontract WPowerPerp is ERC20, Initializable, IWPowerPerp {\\n address public controller;\\n address private immutable deployer;\\n\\n /**\\n * @notice long power perpetual constructor\\n * @param _name token name for ERC20\\n * @param _symbol token symbol for ERC20\\n */\\n constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) {\\n deployer = msg.sender;\\n }\\n\\n modifier onlyController() {\\n require(msg.sender == controller, \\\"Not controller\\\");\\n _;\\n }\\n\\n /**\\n * @notice init wPowerPerp contract\\n * @param _controller controller address\\n */\\n function init(address _controller) external initializer {\\n require(msg.sender == deployer, \\\"Invalid caller of init\\\");\\n require(_controller != address(0), \\\"Invalid controller address\\\");\\n controller = _controller;\\n }\\n\\n /**\\n * @notice mint wPowerPerp\\n * @param _account account to mint to\\n * @param _amount amount to mint\\n */\\n function mint(address _account, uint256 _amount) external override onlyController {\\n _mint(_account, _amount);\\n }\\n\\n /**\\n * @notice burn wPowerPerp\\n * @param _account account to burn from\\n * @param _amount amount to burn\\n */\\n function burn(address _account, uint256 _amount) external override onlyController {\\n _burn(_account, _amount);\\n }\\n}\\n\",\"keccak256\":\"0x46a9dd6652f902a62c5e538d99c4566bcd23cbe21247621c2f17b67250c334c5\",\"license\":\"BUSL-1.1\"},\"contracts/interfaces/IWPowerPerp.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IWPowerPerp is IERC20 {\\n function mint(address _account, uint256 _amount) external;\\n\\n function burn(address _account, uint256 _amount) external;\\n}\\n\",\"keccak256\":\"0x873a337fcb47b96ed0714dbc2edbf1d200f529752efb7beb18109c9e6a9d7271\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60a06040523480156200001157600080fd5b506040516200130238038062001302833981810160405260408110156200003757600080fd5b81019080805160405193929190846401000000008211156200005857600080fd5b9083019060208201858111156200006e57600080fd5b82516401000000008111828201881017156200008957600080fd5b82525081516020918201929091019080838360005b83811015620000b85781810151838201526020016200009e565b50505050905090810190601f168015620000e65780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200010a57600080fd5b9083019060208201858111156200012057600080fd5b82516401000000008111828201881017156200013b57600080fd5b82525081516020918201929091019080838360005b838110156200016a57818101518382015260200162000150565b50505050905090810190601f168015620001985780820380516001836020036101000a031916815260200191505b50604052505082518391508290620001b8906003906020850190620001ed565b508051620001ce906004906020840190620001ed565b50506005805460ff191660121790555050503360601b60805262000299565b828054600181600116156101000203166002900490600052602060002090601f01602090048101928262000225576000855562000270565b82601f106200024057805160ff191683800117855562000270565b8280016001018555821562000270579182015b828111156200027057825182559160200191906001019062000253565b506200027e92915062000282565b5090565b5b808211156200027e576000815560010162000283565b60805160601c61104b620002b760003980610505525061104b6000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c806340c10f1911610097578063a457c2d711610066578063a457c2d7146102ff578063a9059cbb1461032b578063dd62ed3e14610357578063f77c479114610385576100f5565b806340c10f191461027957806370a08231146102a557806395d89b41146102cb5780639dc29fac146102d3576100f5565b806319ab453c116100d357806319ab453c146101d157806323b872dd146101f9578063313ce5671461022f578063395093511461024d576100f5565b806306fdde03146100fa578063095ea7b31461017757806318160ddd146101b7575b600080fd5b6101026103a9565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561013c578181015183820152602001610124565b50505050905090810190601f1680156101695780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561018d57600080fd5b506001600160a01b03813516906020013561043f565b604080519115158252519081900360200190f35b6101bf61045c565b60408051918252519081900360200190f35b6101f7600480360360208110156101e757600080fd5b50356001600160a01b0316610462565b005b6101a36004803603606081101561020f57600080fd5b506001600160a01b03813581169160208101359091169060400135610622565b6102376106a9565b6040805160ff9092168252519081900360200190f35b6101a36004803603604081101561026357600080fd5b506001600160a01b0381351690602001356106b2565b6101f76004803603604081101561028f57600080fd5b506001600160a01b038135169060200135610700565b6101bf600480360360208110156102bb57600080fd5b50356001600160a01b0316610761565b61010261077c565b6101f7600480360360408110156102e957600080fd5b506001600160a01b0381351690602001356107dd565b6101a36004803603604081101561031557600080fd5b506001600160a01b03813516906020013561083e565b6101a36004803603604081101561034157600080fd5b506001600160a01b0381351690602001356108a6565b6101bf6004803603604081101561036d57600080fd5b506001600160a01b03813581169160200135166108ba565b61038d6108e5565b604080516001600160a01b039092168252519081900360200190f35b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104355780601f1061040a57610100808354040283529160200191610435565b820191906000526020600020905b81548152906001019060200180831161041857829003601f168201915b5050505050905090565b600061045361044c6108fb565b84846108ff565b50600192915050565b60025490565b60055462010000900460ff168061047c575061047c6109eb565b8061048f5750600554610100900460ff16155b6104ca5760405162461bcd60e51b815260040180806020018281038252602e815260200180610f31602e913960400191505060405180910390fd5b60055462010000900460ff161580156104fa576005805461ff001962ff0000199091166201000017166101001790555b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610577576040805162461bcd60e51b815260206004820152601660248201527f496e76616c69642063616c6c6572206f6620696e697400000000000000000000604482015290519081900360640190fd5b6001600160a01b0382166105d2576040805162461bcd60e51b815260206004820152601a60248201527f496e76616c696420636f6e74726f6c6c65722061646472657373000000000000604482015290519081900360640190fd5b600580547fffffffffffffffffff0000000000000000000000000000000000000000ffffff1663010000006001600160a01b03851602179055801561061e576005805462ff0000191690555b5050565b600061062f8484846109fc565b61069f8461063b6108fb565b61069a85604051806060016040528060288152602001610f5f602891396001600160a01b038a166000908152600160205260408120906106796108fb565b6001600160a01b031681526020810191909152604001600020549190610b57565b6108ff565b5060019392505050565b60055460ff1690565b60006104536106bf6108fb565b8461069a85600160006106d06108fb565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610bee565b600554630100000090046001600160a01b03163314610757576040805162461bcd60e51b815260206004820152600e60248201526d2737ba1031b7b73a3937b63632b960911b604482015290519081900360640190fd5b61061e8282610c4f565b6001600160a01b031660009081526020819052604090205490565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104355780601f1061040a57610100808354040283529160200191610435565b600554630100000090046001600160a01b03163314610834576040805162461bcd60e51b815260206004820152600e60248201526d2737ba1031b7b73a3937b63632b960911b604482015290519081900360640190fd5b61061e8282610d3f565b600061045361084b6108fb565b8461069a85604051806060016040528060258152602001610ff160259139600160006108756108fb565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190610b57565b60006104536108b36108fb565b84846109fc565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600554630100000090046001600160a01b031681565b3390565b6001600160a01b0383166109445760405162461bcd60e51b8152600401808060200182810382526024815260200180610fcd6024913960400191505060405180910390fd5b6001600160a01b0382166109895760405162461bcd60e51b8152600401808060200182810382526022815260200180610ee96022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b60006109f630610e3b565b15905090565b6001600160a01b038316610a415760405162461bcd60e51b8152600401808060200182810382526025815260200180610fa86025913960400191505060405180910390fd5b6001600160a01b038216610a865760405162461bcd60e51b8152600401808060200182810382526023815260200180610ea46023913960400191505060405180910390fd5b610a91838383610e41565b610ace81604051806060016040528060268152602001610f0b602691396001600160a01b0386166000908152602081905260409020549190610b57565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610afd9082610bee565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008184841115610be65760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610bab578181015183820152602001610b93565b50505050905090810190601f168015610bd85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610c48576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b038216610caa576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b610cb660008383610e41565b600254610cc39082610bee565b6002556001600160a01b038216600090815260208190526040902054610ce99082610bee565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b038216610d845760405162461bcd60e51b8152600401808060200182810382526021815260200180610f876021913960400191505060405180910390fd5b610d9082600083610e41565b610dcd81604051806060016040528060228152602001610ec7602291396001600160a01b0385166000908152602081905260409020549190610b57565b6001600160a01b038316600090815260208190526040902055600254610df39082610e46565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b3b151590565b505050565b600082821115610e9d576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b5090039056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a656445524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220d301629690fe537b9e28910ee4b6e293752fb5f311c10228929a95e3d700dcdf64736f6c63430007060033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806340c10f1911610097578063a457c2d711610066578063a457c2d7146102ff578063a9059cbb1461032b578063dd62ed3e14610357578063f77c479114610385576100f5565b806340c10f191461027957806370a08231146102a557806395d89b41146102cb5780639dc29fac146102d3576100f5565b806319ab453c116100d357806319ab453c146101d157806323b872dd146101f9578063313ce5671461022f578063395093511461024d576100f5565b806306fdde03146100fa578063095ea7b31461017757806318160ddd146101b7575b600080fd5b6101026103a9565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561013c578181015183820152602001610124565b50505050905090810190601f1680156101695780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561018d57600080fd5b506001600160a01b03813516906020013561043f565b604080519115158252519081900360200190f35b6101bf61045c565b60408051918252519081900360200190f35b6101f7600480360360208110156101e757600080fd5b50356001600160a01b0316610462565b005b6101a36004803603606081101561020f57600080fd5b506001600160a01b03813581169160208101359091169060400135610622565b6102376106a9565b6040805160ff9092168252519081900360200190f35b6101a36004803603604081101561026357600080fd5b506001600160a01b0381351690602001356106b2565b6101f76004803603604081101561028f57600080fd5b506001600160a01b038135169060200135610700565b6101bf600480360360208110156102bb57600080fd5b50356001600160a01b0316610761565b61010261077c565b6101f7600480360360408110156102e957600080fd5b506001600160a01b0381351690602001356107dd565b6101a36004803603604081101561031557600080fd5b506001600160a01b03813516906020013561083e565b6101a36004803603604081101561034157600080fd5b506001600160a01b0381351690602001356108a6565b6101bf6004803603604081101561036d57600080fd5b506001600160a01b03813581169160200135166108ba565b61038d6108e5565b604080516001600160a01b039092168252519081900360200190f35b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104355780601f1061040a57610100808354040283529160200191610435565b820191906000526020600020905b81548152906001019060200180831161041857829003601f168201915b5050505050905090565b600061045361044c6108fb565b84846108ff565b50600192915050565b60025490565b60055462010000900460ff168061047c575061047c6109eb565b8061048f5750600554610100900460ff16155b6104ca5760405162461bcd60e51b815260040180806020018281038252602e815260200180610f31602e913960400191505060405180910390fd5b60055462010000900460ff161580156104fa576005805461ff001962ff0000199091166201000017166101001790555b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610577576040805162461bcd60e51b815260206004820152601660248201527f496e76616c69642063616c6c6572206f6620696e697400000000000000000000604482015290519081900360640190fd5b6001600160a01b0382166105d2576040805162461bcd60e51b815260206004820152601a60248201527f496e76616c696420636f6e74726f6c6c65722061646472657373000000000000604482015290519081900360640190fd5b600580547fffffffffffffffffff0000000000000000000000000000000000000000ffffff1663010000006001600160a01b03851602179055801561061e576005805462ff0000191690555b5050565b600061062f8484846109fc565b61069f8461063b6108fb565b61069a85604051806060016040528060288152602001610f5f602891396001600160a01b038a166000908152600160205260408120906106796108fb565b6001600160a01b031681526020810191909152604001600020549190610b57565b6108ff565b5060019392505050565b60055460ff1690565b60006104536106bf6108fb565b8461069a85600160006106d06108fb565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610bee565b600554630100000090046001600160a01b03163314610757576040805162461bcd60e51b815260206004820152600e60248201526d2737ba1031b7b73a3937b63632b960911b604482015290519081900360640190fd5b61061e8282610c4f565b6001600160a01b031660009081526020819052604090205490565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104355780601f1061040a57610100808354040283529160200191610435565b600554630100000090046001600160a01b03163314610834576040805162461bcd60e51b815260206004820152600e60248201526d2737ba1031b7b73a3937b63632b960911b604482015290519081900360640190fd5b61061e8282610d3f565b600061045361084b6108fb565b8461069a85604051806060016040528060258152602001610ff160259139600160006108756108fb565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190610b57565b60006104536108b36108fb565b84846109fc565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600554630100000090046001600160a01b031681565b3390565b6001600160a01b0383166109445760405162461bcd60e51b8152600401808060200182810382526024815260200180610fcd6024913960400191505060405180910390fd5b6001600160a01b0382166109895760405162461bcd60e51b8152600401808060200182810382526022815260200180610ee96022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b60006109f630610e3b565b15905090565b6001600160a01b038316610a415760405162461bcd60e51b8152600401808060200182810382526025815260200180610fa86025913960400191505060405180910390fd5b6001600160a01b038216610a865760405162461bcd60e51b8152600401808060200182810382526023815260200180610ea46023913960400191505060405180910390fd5b610a91838383610e41565b610ace81604051806060016040528060268152602001610f0b602691396001600160a01b0386166000908152602081905260409020549190610b57565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610afd9082610bee565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008184841115610be65760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610bab578181015183820152602001610b93565b50505050905090810190601f168015610bd85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610c48576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b038216610caa576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b610cb660008383610e41565b600254610cc39082610bee565b6002556001600160a01b038216600090815260208190526040902054610ce99082610bee565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b038216610d845760405162461bcd60e51b8152600401808060200182810382526021815260200180610f876021913960400191505060405180910390fd5b610d9082600083610e41565b610dcd81604051806060016040528060228152602001610ec7602291396001600160a01b0385166000908152602081905260409020549190610b57565b6001600160a01b038316600090815260208190526040902055600254610df39082610e46565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b3b151590565b505050565b600082821115610e9d576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b5090039056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a656445524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220d301629690fe537b9e28910ee4b6e293752fb5f311c10228929a95e3d700dcdf64736f6c63430007060033", + "solcInputHash": "d97d3d4b09e0d70518330d405a7dd9ff", + "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_symbol\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"controller\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_controller\",\"type\":\"address\"}],\"name\":\"init\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"value of power perpetual is expected to go down over time through the impact of funding\",\"kind\":\"dev\",\"methods\":{\"allowance(address,address)\":{\"details\":\"See {IERC20-allowance}.\"},\"approve(address,uint256)\":{\"details\":\"See {IERC20-approve}. Requirements: - `spender` cannot be the zero address.\"},\"balanceOf(address)\":{\"details\":\"See {IERC20-balanceOf}.\"},\"burn(address,uint256)\":{\"params\":{\"_account\":\"account to burn from\",\"_amount\":\"amount to burn\"}},\"constructor\":{\"params\":{\"_name\":\"token name for ERC20\",\"_symbol\":\"token symbol for ERC20\"}},\"decimals()\":{\"details\":\"Returns the number of decimals used to get its user representation. For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5,05` (`505 / 10 ** 2`). Tokens usually opt for a value of 18, imitating the relationship between Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is called. NOTE: This information is only used for _display_ purposes: it in no way affects any of the arithmetic of the contract, including {IERC20-balanceOf} and {IERC20-transfer}.\"},\"decreaseAllowance(address,uint256)\":{\"details\":\"Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`.\"},\"increaseAllowance(address,uint256)\":{\"details\":\"Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.\"},\"init(address)\":{\"params\":{\"_controller\":\"controller address\"}},\"mint(address,uint256)\":{\"params\":{\"_account\":\"account to mint to\",\"_amount\":\"amount to mint\"}},\"name()\":{\"details\":\"Returns the name of the token.\"},\"symbol()\":{\"details\":\"Returns the symbol of the token, usually a shorter version of the name.\"},\"totalSupply()\":{\"details\":\"See {IERC20-totalSupply}.\"},\"transfer(address,uint256)\":{\"details\":\"See {IERC20-transfer}. Requirements: - `recipient` cannot be the zero address. - the caller must have a balance of at least `amount`.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. Requirements: - `sender` and `recipient` cannot be the zero address. - `sender` must have a balance of at least `amount`. - the caller must have allowance for ``sender``'s tokens of at least `amount`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"burn(address,uint256)\":{\"notice\":\"burn wPowerPerp\"},\"constructor\":{\"notice\":\"long power perpetual constructor\"},\"init(address)\":{\"notice\":\"init wPowerPerp contract\"},\"mint(address,uint256)\":{\"notice\":\"mint wPowerPerp\"}},\"notice\":\"ERC20 Token representing wrapped long power perpetual position\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/core/WPowerPerp.sol\":\"WPowerPerp\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":825},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/math/SafeMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\\n * checks.\\n *\\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\\n * in bugs, because programmers usually assume that an overflow raises an\\n * error, which is the standard behavior in high level programming languages.\\n * `SafeMath` restores this intuition by reverting the transaction when an\\n * operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeMath {\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n *\\n * _Available since v3.4._\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `+` operator.\\n *\\n * Requirements:\\n *\\n * - Addition cannot overflow.\\n */\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n uint256 c = a + b;\\n require(c >= a, \\\"SafeMath: addition overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting on\\n * overflow (when the result is negative).\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b <= a, \\\"SafeMath: subtraction overflow\\\");\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, reverting on\\n * overflow.\\n *\\n * Counterpart to Solidity's `*` operator.\\n *\\n * Requirements:\\n *\\n * - Multiplication cannot overflow.\\n */\\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (a == 0) return 0;\\n uint256 c = a * b;\\n require(c / a == b, \\\"SafeMath: multiplication overflow\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting on\\n * division by zero. The result is rounded towards zero.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: division by zero\\\");\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting when dividing by zero.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\\n require(b > 0, \\\"SafeMath: modulo by zero\\\");\\n return a % b;\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\\n * overflow (when the result is negative).\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {trySub}.\\n *\\n * Counterpart to Solidity's `-` operator.\\n *\\n * Requirements:\\n *\\n * - Subtraction cannot overflow.\\n */\\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b <= a, errorMessage);\\n return a - b;\\n }\\n\\n /**\\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\\n * division by zero. The result is rounded towards zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryDiv}.\\n *\\n * Counterpart to Solidity's `/` operator. Note: this function uses a\\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\\n * uses an invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a / b;\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\\n * reverting with custom message when dividing by zero.\\n *\\n * CAUTION: This function is deprecated because it requires allocating memory for the error\\n * message unnecessarily. For custom revert reasons use {tryMod}.\\n *\\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\\n * opcode (which leaves remaining gas untouched) while Solidity uses an\\n * invalid opcode to revert (consuming all remaining gas).\\n *\\n * Requirements:\\n *\\n * - The divisor cannot be zero.\\n */\\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\\n require(b > 0, errorMessage);\\n return a % b;\\n }\\n}\\n\",\"keccak256\":\"0xe22a1fc7400ae196eba2ad1562d0386462b00a6363b742d55a2fd2021a58586f\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n// solhint-disable-next-line compiler-version\\npragma solidity >=0.4.24 <0.8.0;\\n\\nimport \\\"../utils/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 a proxied contract can't have a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n */\\nabstract contract Initializable {\\n\\n /**\\n * @dev Indicates that the contract has been initialized.\\n */\\n bool private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Modifier to protect an initializer function from being invoked twice.\\n */\\n modifier initializer() {\\n require(_initializing || _isConstructor() || !_initialized, \\\"Initializable: contract is already initialized\\\");\\n\\n bool isTopLevelCall = !_initializing;\\n if (isTopLevelCall) {\\n _initializing = true;\\n _initialized = true;\\n }\\n\\n _;\\n\\n if (isTopLevelCall) {\\n _initializing = false;\\n }\\n }\\n\\n /// @dev Returns true if and only if the function is running in the constructor\\n function _isConstructor() private view returns (bool) {\\n return !Address.isContract(address(this));\\n }\\n}\\n\",\"keccak256\":\"0x9abeffe138f098b16557187383ba0f9e8503602fa95cd668132986ee115237ed\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"../../utils/Context.sol\\\";\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"../../math/SafeMath.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * We have followed general OpenZeppelin guidelines: functions revert instead\\n * of returning `false` on failure. This behavior is nonetheless conventional\\n * and does not conflict with the expectations of ERC20 applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract ERC20 is Context, IERC20 {\\n using SafeMath for uint256;\\n\\n mapping (address => uint256) private _balances;\\n\\n mapping (address => mapping (address => uint256)) private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n uint8 private _decimals;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\\n * a default value of 18.\\n *\\n * To select a different value for {decimals}, use {_setupDecimals}.\\n *\\n * All three of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor (string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n _decimals = 18;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\\n * called.\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual returns (uint8) {\\n return _decimals;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual override returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `recipient` cannot be the zero address.\\n * - the caller must have a balance of at least `amount`.\\n */\\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(_msgSender(), recipient, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\\n _approve(_msgSender(), spender, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * Requirements:\\n *\\n * - `sender` and `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n * - the caller must have allowance for ``sender``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\\n _transfer(sender, recipient, amount);\\n _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \\\"ERC20: transfer amount exceeds allowance\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically increases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));\\n return true;\\n }\\n\\n /**\\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `spender` must have allowance for the caller of at least\\n * `subtractedValue`.\\n */\\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \\\"ERC20: decreased allowance below zero\\\"));\\n return true;\\n }\\n\\n /**\\n * @dev Moves tokens `amount` from `sender` to `recipient`.\\n *\\n * This is internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * Requirements:\\n *\\n * - `sender` cannot be the zero address.\\n * - `recipient` cannot be the zero address.\\n * - `sender` must have a balance of at least `amount`.\\n */\\n function _transfer(address sender, address recipient, uint256 amount) internal virtual {\\n require(sender != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(recipient != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(sender, recipient, amount);\\n\\n _balances[sender] = _balances[sender].sub(amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n _balances[recipient] = _balances[recipient].add(amount);\\n emit Transfer(sender, recipient, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply = _totalSupply.add(amount);\\n _balances[account] = _balances[account].add(amount);\\n emit Transfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n _balances[account] = _balances[account].sub(amount, \\\"ERC20: burn amount exceeds balance\\\");\\n _totalSupply = _totalSupply.sub(amount);\\n emit Transfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n */\\n function _approve(address owner, address spender, uint256 amount) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Sets {decimals} to a value other than the default one of 18.\\n *\\n * WARNING: This function should only be called from the constructor. Most\\n * applications that interact with token contracts will not expect\\n * {decimals} to ever change, and may work incorrectly if it does.\\n */\\n function _setupDecimals(uint8 decimals_) internal virtual {\\n _decimals = decimals_;\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be to transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }\\n}\\n\",\"keccak256\":\"0x36b5ca4eabe888b39b10973621ca0dcc9b1508f8d06db9ddf045d7aa7c867d4a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0xbd74f587ab9b9711801baf667db1426e4a03fd2d7f15af33e0e0d0394e7cef76\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { size := extcodesize(account) }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf89f005a3d98f7768cdee2583707db0ac725cf567d455751af32ee68132f3db3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity >=0.6.0 <0.8.0;\\n\\n/*\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with GSN meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x8d3cb350f04ff49cfb10aef08d87f19dcbaecc8027b0bed12f3275cd12f38cf0\",\"license\":\"MIT\"},\"contracts/core/WPowerPerp.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\n\\npragma solidity =0.7.6;\\n\\n//interface\\nimport {IWPowerPerp} from \\\"../interfaces/IWPowerPerp.sol\\\";\\n\\n//contract\\nimport {ERC20} from \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport {Initializable} from \\\"@openzeppelin/contracts/proxy/Initializable.sol\\\";\\n\\n/**\\n * @notice ERC20 Token representing wrapped long power perpetual position\\n * @dev value of power perpetual is expected to go down over time through the impact of funding\\n */\\ncontract WPowerPerp is ERC20, Initializable, IWPowerPerp {\\n address public controller;\\n address private immutable deployer;\\n\\n /**\\n * @notice long power perpetual constructor\\n * @param _name token name for ERC20\\n * @param _symbol token symbol for ERC20\\n */\\n constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) {\\n deployer = msg.sender;\\n }\\n\\n modifier onlyController() {\\n require(msg.sender == controller, \\\"Not controller\\\");\\n _;\\n }\\n\\n /**\\n * @notice init wPowerPerp contract\\n * @param _controller controller address\\n */\\n function init(address _controller) external initializer {\\n require(msg.sender == deployer, \\\"Invalid caller of init\\\");\\n require(_controller != address(0), \\\"Invalid controller address\\\");\\n controller = _controller;\\n }\\n\\n /**\\n * @notice mint wPowerPerp\\n * @param _account account to mint to\\n * @param _amount amount to mint\\n */\\n function mint(address _account, uint256 _amount) external override onlyController {\\n _mint(_account, _amount);\\n }\\n\\n /**\\n * @notice burn wPowerPerp\\n * @param _account account to burn from\\n * @param _amount amount to burn\\n */\\n function burn(address _account, uint256 _amount) external override onlyController {\\n _burn(_account, _amount);\\n }\\n}\\n\",\"keccak256\":\"0x46a9dd6652f902a62c5e538d99c4566bcd23cbe21247621c2f17b67250c334c5\",\"license\":\"BUSL-1.1\"},\"contracts/interfaces/IWPowerPerp.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity =0.7.6;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\ninterface IWPowerPerp is IERC20 {\\n function mint(address _account, uint256 _amount) external;\\n\\n function burn(address _account, uint256 _amount) external;\\n}\\n\",\"keccak256\":\"0x873a337fcb47b96ed0714dbc2edbf1d200f529752efb7beb18109c9e6a9d7271\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60a06040523480156200001157600080fd5b506040516200130238038062001302833981810160405260408110156200003757600080fd5b81019080805160405193929190846401000000008211156200005857600080fd5b9083019060208201858111156200006e57600080fd5b82516401000000008111828201881017156200008957600080fd5b82525081516020918201929091019080838360005b83811015620000b85781810151838201526020016200009e565b50505050905090810190601f168015620000e65780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200010a57600080fd5b9083019060208201858111156200012057600080fd5b82516401000000008111828201881017156200013b57600080fd5b82525081516020918201929091019080838360005b838110156200016a57818101518382015260200162000150565b50505050905090810190601f168015620001985780820380516001836020036101000a031916815260200191505b50604052505082518391508290620001b8906003906020850190620001ed565b508051620001ce906004906020840190620001ed565b50506005805460ff191660121790555050503360601b60805262000299565b828054600181600116156101000203166002900490600052602060002090601f01602090048101928262000225576000855562000270565b82601f106200024057805160ff191683800117855562000270565b8280016001018555821562000270579182015b828111156200027057825182559160200191906001019062000253565b506200027e92915062000282565b5090565b5b808211156200027e576000815560010162000283565b60805160601c61104b620002b760003980610505525061104b6000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c806340c10f1911610097578063a457c2d711610066578063a457c2d7146102ff578063a9059cbb1461032b578063dd62ed3e14610357578063f77c479114610385576100f5565b806340c10f191461027957806370a08231146102a557806395d89b41146102cb5780639dc29fac146102d3576100f5565b806319ab453c116100d357806319ab453c146101d157806323b872dd146101f9578063313ce5671461022f578063395093511461024d576100f5565b806306fdde03146100fa578063095ea7b31461017757806318160ddd146101b7575b600080fd5b6101026103a9565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561013c578181015183820152602001610124565b50505050905090810190601f1680156101695780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561018d57600080fd5b506001600160a01b03813516906020013561043f565b604080519115158252519081900360200190f35b6101bf61045c565b60408051918252519081900360200190f35b6101f7600480360360208110156101e757600080fd5b50356001600160a01b0316610462565b005b6101a36004803603606081101561020f57600080fd5b506001600160a01b03813581169160208101359091169060400135610622565b6102376106a9565b6040805160ff9092168252519081900360200190f35b6101a36004803603604081101561026357600080fd5b506001600160a01b0381351690602001356106b2565b6101f76004803603604081101561028f57600080fd5b506001600160a01b038135169060200135610700565b6101bf600480360360208110156102bb57600080fd5b50356001600160a01b0316610761565b61010261077c565b6101f7600480360360408110156102e957600080fd5b506001600160a01b0381351690602001356107dd565b6101a36004803603604081101561031557600080fd5b506001600160a01b03813516906020013561083e565b6101a36004803603604081101561034157600080fd5b506001600160a01b0381351690602001356108a6565b6101bf6004803603604081101561036d57600080fd5b506001600160a01b03813581169160200135166108ba565b61038d6108e5565b604080516001600160a01b039092168252519081900360200190f35b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104355780601f1061040a57610100808354040283529160200191610435565b820191906000526020600020905b81548152906001019060200180831161041857829003601f168201915b5050505050905090565b600061045361044c6108fb565b84846108ff565b50600192915050565b60025490565b60055462010000900460ff168061047c575061047c6109eb565b8061048f5750600554610100900460ff16155b6104ca5760405162461bcd60e51b815260040180806020018281038252602e815260200180610f31602e913960400191505060405180910390fd5b60055462010000900460ff161580156104fa576005805461ff001962ff0000199091166201000017166101001790555b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610577576040805162461bcd60e51b815260206004820152601660248201527f496e76616c69642063616c6c6572206f6620696e697400000000000000000000604482015290519081900360640190fd5b6001600160a01b0382166105d2576040805162461bcd60e51b815260206004820152601a60248201527f496e76616c696420636f6e74726f6c6c65722061646472657373000000000000604482015290519081900360640190fd5b600580547fffffffffffffffffff0000000000000000000000000000000000000000ffffff1663010000006001600160a01b03851602179055801561061e576005805462ff0000191690555b5050565b600061062f8484846109fc565b61069f8461063b6108fb565b61069a85604051806060016040528060288152602001610f5f602891396001600160a01b038a166000908152600160205260408120906106796108fb565b6001600160a01b031681526020810191909152604001600020549190610b57565b6108ff565b5060019392505050565b60055460ff1690565b60006104536106bf6108fb565b8461069a85600160006106d06108fb565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610bee565b600554630100000090046001600160a01b03163314610757576040805162461bcd60e51b815260206004820152600e60248201526d2737ba1031b7b73a3937b63632b960911b604482015290519081900360640190fd5b61061e8282610c4f565b6001600160a01b031660009081526020819052604090205490565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104355780601f1061040a57610100808354040283529160200191610435565b600554630100000090046001600160a01b03163314610834576040805162461bcd60e51b815260206004820152600e60248201526d2737ba1031b7b73a3937b63632b960911b604482015290519081900360640190fd5b61061e8282610d3f565b600061045361084b6108fb565b8461069a85604051806060016040528060258152602001610ff160259139600160006108756108fb565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190610b57565b60006104536108b36108fb565b84846109fc565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600554630100000090046001600160a01b031681565b3390565b6001600160a01b0383166109445760405162461bcd60e51b8152600401808060200182810382526024815260200180610fcd6024913960400191505060405180910390fd5b6001600160a01b0382166109895760405162461bcd60e51b8152600401808060200182810382526022815260200180610ee96022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b60006109f630610e3b565b15905090565b6001600160a01b038316610a415760405162461bcd60e51b8152600401808060200182810382526025815260200180610fa86025913960400191505060405180910390fd5b6001600160a01b038216610a865760405162461bcd60e51b8152600401808060200182810382526023815260200180610ea46023913960400191505060405180910390fd5b610a91838383610e41565b610ace81604051806060016040528060268152602001610f0b602691396001600160a01b0386166000908152602081905260409020549190610b57565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610afd9082610bee565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008184841115610be65760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610bab578181015183820152602001610b93565b50505050905090810190601f168015610bd85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610c48576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b038216610caa576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b610cb660008383610e41565b600254610cc39082610bee565b6002556001600160a01b038216600090815260208190526040902054610ce99082610bee565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b038216610d845760405162461bcd60e51b8152600401808060200182810382526021815260200180610f876021913960400191505060405180910390fd5b610d9082600083610e41565b610dcd81604051806060016040528060228152602001610ec7602291396001600160a01b0385166000908152602081905260409020549190610b57565b6001600160a01b038316600090815260208190526040902055600254610df39082610e46565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b3b151590565b505050565b600082821115610e9d576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b5090039056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a656445524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220b212f681aae3a839369df006b7b5ca6280b5bb82909bb3e14edfc182234e45d164736f6c63430007060033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806340c10f1911610097578063a457c2d711610066578063a457c2d7146102ff578063a9059cbb1461032b578063dd62ed3e14610357578063f77c479114610385576100f5565b806340c10f191461027957806370a08231146102a557806395d89b41146102cb5780639dc29fac146102d3576100f5565b806319ab453c116100d357806319ab453c146101d157806323b872dd146101f9578063313ce5671461022f578063395093511461024d576100f5565b806306fdde03146100fa578063095ea7b31461017757806318160ddd146101b7575b600080fd5b6101026103a9565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561013c578181015183820152602001610124565b50505050905090810190601f1680156101695780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561018d57600080fd5b506001600160a01b03813516906020013561043f565b604080519115158252519081900360200190f35b6101bf61045c565b60408051918252519081900360200190f35b6101f7600480360360208110156101e757600080fd5b50356001600160a01b0316610462565b005b6101a36004803603606081101561020f57600080fd5b506001600160a01b03813581169160208101359091169060400135610622565b6102376106a9565b6040805160ff9092168252519081900360200190f35b6101a36004803603604081101561026357600080fd5b506001600160a01b0381351690602001356106b2565b6101f76004803603604081101561028f57600080fd5b506001600160a01b038135169060200135610700565b6101bf600480360360208110156102bb57600080fd5b50356001600160a01b0316610761565b61010261077c565b6101f7600480360360408110156102e957600080fd5b506001600160a01b0381351690602001356107dd565b6101a36004803603604081101561031557600080fd5b506001600160a01b03813516906020013561083e565b6101a36004803603604081101561034157600080fd5b506001600160a01b0381351690602001356108a6565b6101bf6004803603604081101561036d57600080fd5b506001600160a01b03813581169160200135166108ba565b61038d6108e5565b604080516001600160a01b039092168252519081900360200190f35b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104355780601f1061040a57610100808354040283529160200191610435565b820191906000526020600020905b81548152906001019060200180831161041857829003601f168201915b5050505050905090565b600061045361044c6108fb565b84846108ff565b50600192915050565b60025490565b60055462010000900460ff168061047c575061047c6109eb565b8061048f5750600554610100900460ff16155b6104ca5760405162461bcd60e51b815260040180806020018281038252602e815260200180610f31602e913960400191505060405180910390fd5b60055462010000900460ff161580156104fa576005805461ff001962ff0000199091166201000017166101001790555b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610577576040805162461bcd60e51b815260206004820152601660248201527f496e76616c69642063616c6c6572206f6620696e697400000000000000000000604482015290519081900360640190fd5b6001600160a01b0382166105d2576040805162461bcd60e51b815260206004820152601a60248201527f496e76616c696420636f6e74726f6c6c65722061646472657373000000000000604482015290519081900360640190fd5b600580547fffffffffffffffffff0000000000000000000000000000000000000000ffffff1663010000006001600160a01b03851602179055801561061e576005805462ff0000191690555b5050565b600061062f8484846109fc565b61069f8461063b6108fb565b61069a85604051806060016040528060288152602001610f5f602891396001600160a01b038a166000908152600160205260408120906106796108fb565b6001600160a01b031681526020810191909152604001600020549190610b57565b6108ff565b5060019392505050565b60055460ff1690565b60006104536106bf6108fb565b8461069a85600160006106d06108fb565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610bee565b600554630100000090046001600160a01b03163314610757576040805162461bcd60e51b815260206004820152600e60248201526d2737ba1031b7b73a3937b63632b960911b604482015290519081900360640190fd5b61061e8282610c4f565b6001600160a01b031660009081526020819052604090205490565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104355780601f1061040a57610100808354040283529160200191610435565b600554630100000090046001600160a01b03163314610834576040805162461bcd60e51b815260206004820152600e60248201526d2737ba1031b7b73a3937b63632b960911b604482015290519081900360640190fd5b61061e8282610d3f565b600061045361084b6108fb565b8461069a85604051806060016040528060258152602001610ff160259139600160006108756108fb565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190610b57565b60006104536108b36108fb565b84846109fc565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600554630100000090046001600160a01b031681565b3390565b6001600160a01b0383166109445760405162461bcd60e51b8152600401808060200182810382526024815260200180610fcd6024913960400191505060405180910390fd5b6001600160a01b0382166109895760405162461bcd60e51b8152600401808060200182810382526022815260200180610ee96022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b60006109f630610e3b565b15905090565b6001600160a01b038316610a415760405162461bcd60e51b8152600401808060200182810382526025815260200180610fa86025913960400191505060405180910390fd5b6001600160a01b038216610a865760405162461bcd60e51b8152600401808060200182810382526023815260200180610ea46023913960400191505060405180910390fd5b610a91838383610e41565b610ace81604051806060016040528060268152602001610f0b602691396001600160a01b0386166000908152602081905260409020549190610b57565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610afd9082610bee565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008184841115610be65760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610bab578181015183820152602001610b93565b50505050905090810190601f168015610bd85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610c48576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b038216610caa576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b610cb660008383610e41565b600254610cc39082610bee565b6002556001600160a01b038216600090815260208190526040902054610ce99082610bee565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b038216610d845760405162461bcd60e51b8152600401808060200182810382526021815260200180610f876021913960400191505060405180910390fd5b610d9082600083610e41565b610dcd81604051806060016040528060228152602001610ec7602291396001600160a01b0385166000908152602081905260409020549190610b57565b6001600160a01b038316600090815260208190526040902055600254610df39082610e46565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b3b151590565b505050565b600082821115610e9d576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b5090039056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a656445524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220b212f681aae3a839369df006b7b5ca6280b5bb82909bb3e14edfc182234e45d164736f6c63430007060033", "devdoc": { "details": "value of power perpetual is expected to go down over time through the impact of funding", "kind": "dev", @@ -523,7 +523,7 @@ "type": "t_bool" }, { - "astId": 11106, + "astId": 10590, "contract": "contracts/core/WPowerPerp.sol:WPowerPerp", "label": "controller", "offset": 3, diff --git a/packages/hardhat/deployments/mainnet/solcInputs/d97d3d4b09e0d70518330d405a7dd9ff.json b/packages/hardhat/deployments/mainnet/solcInputs/d97d3d4b09e0d70518330d405a7dd9ff.json new file mode 100644 index 000000000..583865191 --- /dev/null +++ b/packages/hardhat/deployments/mainnet/solcInputs/d97d3d4b09e0d70518330d405a7dd9ff.json @@ -0,0 +1,290 @@ +{ + "language": "Solidity", + "sources": { + "contracts/core/Controller.sol": { + "content": "//SPDX-License-Identifier: BUSL-1.1\n\npragma solidity =0.7.6;\npragma abicoder v2;\n\n// interface\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport {INonfungiblePositionManager} from \"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\";\nimport {IWETH9} from \"../interfaces/IWETH9.sol\";\nimport {IWPowerPerp} from \"../interfaces/IWPowerPerp.sol\";\nimport {IShortPowerPerp} from \"../interfaces/IShortPowerPerp.sol\";\nimport {IOracle} from \"../interfaces/IOracle.sol\";\nimport {IERC721Receiver} from \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\n\n//contract\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {ReentrancyGuard} from \"@openzeppelin/contracts/utils/ReentrancyGuard.sol\";\n\n//lib\nimport {SafeMath} from \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {ABDKMath64x64} from \"../libs/ABDKMath64x64.sol\";\nimport {VaultLib} from \"../libs/VaultLib.sol\";\nimport {Uint256Casting} from \"../libs/Uint256Casting.sol\";\nimport {Power2Base} from \"../libs/Power2Base.sol\";\n\n/**\n *\n * Error\n * C0: Paused\n * C1: Not paused\n * C2: Shutdown\n * C3: Not shutdown\n * C4: Invalid oracle address\n * C5: Invalid shortPowerPerp address\n * C6: Invalid wPowerPerp address\n * C7: Invalid weth address\n * C8: Invalid quote currency address\n * C9: Invalid eth:quoteCurrency pool address\n * C10: Invalid wPowerPerp:eth pool address\n * C11: Invalid Uniswap position manager\n * C12: Can not liquidate safe vault\n * C13: Invalid address\n * C14: Set fee recipient first\n * C15: Fee too high\n * C16: Paused too many times\n * C17: Pause time limit exceeded\n * C18: Not enough paused time has passed\n * C19: Cannot receive eth\n * C20: Not allowed\n * C21: Need full liquidation\n * C22: Dust vault left\n * C23: Invalid nft\n * C24: Invalid state\n * C25: 0 liquidity Uniswap position token\n * C26: Wrong fee tier for NFT deposit\n */\ncontract Controller is Ownable, ReentrancyGuard, IERC721Receiver {\n using SafeMath for uint256;\n using Uint256Casting for uint256;\n using ABDKMath64x64 for int128;\n using VaultLib for VaultLib.Vault;\n using Address for address payable;\n\n uint256 internal constant MIN_COLLATERAL = 6.9 ether;\n /// @dev system can only be paused for 182 days from deployment\n uint256 internal constant PAUSE_TIME_LIMIT = 182 days;\n\n uint256 public constant FUNDING_PERIOD = 420 hours;\n uint24 public immutable feeTier;\n uint32 public constant TWAP_PERIOD = 420 seconds;\n\n //80% of index\n uint256 internal constant LOWER_MARK_RATIO = 8e17;\n //140% of index\n uint256 internal constant UPPER_MARK_RATIO = 140e16;\n // 10%\n uint256 internal constant LIQUIDATION_BOUNTY = 1e17;\n // 2%\n uint256 internal constant REDUCE_DEBT_BOUNTY = 2e16;\n\n /// @dev basic unit used for calculation\n uint256 private constant ONE = 1e18;\n\n address public immutable weth;\n address public immutable quoteCurrency;\n address public immutable ethQuoteCurrencyPool;\n /// @dev address of the powerPerp/weth pool\n address public immutable wPowerPerpPool;\n address internal immutable uniswapPositionManager;\n address public immutable shortPowerPerp;\n address public immutable wPowerPerp;\n address public immutable oracle;\n address public feeRecipient;\n\n uint256 internal immutable deployTimestamp;\n /// @dev fee rate in basis point. feeRate of 1 = 0.01%\n uint256 public feeRate;\n /// @dev the settlement price for each wPowerPerp for settlement\n uint256 public indexForSettlement;\n\n uint256 public pausesLeft = 4;\n uint256 public lastPauseTime;\n\n // these 2 parameters are always updated together. Use uint128 to batch read and write.\n uint128 public normalizationFactor;\n uint128 public lastFundingUpdateTimestamp;\n\n bool internal immutable isWethToken0;\n bool public isShutDown;\n bool public isSystemPaused;\n\n /// @dev vault data storage\n mapping(uint256 => VaultLib.Vault) public vaults;\n\n /// Events\n event OpenVault(address sender, uint256 vaultId);\n event DepositCollateral(address sender, uint256 vaultId, uint256 amount);\n event DepositUniPositionToken(address sender, uint256 vaultId, uint256 tokenId);\n event WithdrawCollateral(address sender, uint256 vaultId, uint256 amount);\n event WithdrawUniPositionToken(address sender, uint256 vaultId, uint256 tokenId);\n event MintShort(address sender, uint256 amount, uint256 vaultId);\n event BurnShort(address sender, uint256 amount, uint256 vaultId);\n event ReduceDebt(\n address sender,\n uint256 vaultId,\n uint256 ethRedeemed,\n uint256 wPowerPerpRedeemed,\n uint256 wPowerPerpBurned,\n uint256 wPowerPerpExcess,\n uint256 bounty\n );\n event UpdateOperator(address sender, uint256 vaultId, address operator);\n event FeeRateUpdated(uint256 oldFee, uint256 newFee);\n event FeeRecipientUpdated(address oldFeeRecipient, address newFeeRecipient);\n event Liquidate(address liquidator, uint256 vaultId, uint256 debtAmount, uint256 collateralPaid);\n event NormalizationFactorUpdated(\n uint256 oldNormFactor,\n uint256 newNormFactor,\n uint256 lastModificationTimestamp,\n uint256 timestamp\n );\n event Paused(uint256 pausesLeft);\n event UnPaused(address unpauser);\n event Shutdown(uint256 indexForSettlement);\n event RedeemLong(address sender, uint256 wPowerPerpAmount, uint256 payoutAmount);\n event RedeemShort(address sender, uint256 vauldId, uint256 collateralAmount);\n\n modifier notPaused() {\n require(!isSystemPaused, \"C0\");\n _;\n }\n\n modifier isPaused() {\n require(isSystemPaused, \"C1\");\n _;\n }\n\n modifier notShutdown() {\n require(!isShutDown, \"C2\");\n _;\n }\n\n modifier isShutdown() {\n require(isShutDown, \"C3\");\n _;\n }\n\n /**\n * @notice constructor\n * @param _oracle oracle address\n * @param _shortPowerPerp ERC721 token address representing the short position\n * @param _wPowerPerp ERC20 token address representing the long position\n * @param _weth weth address\n * @param _quoteCurrency quoteCurrency address\n * @param _ethQuoteCurrencyPool uniswap v3 pool for weth / quoteCurrency\n * @param _wPowerPerpPool uniswap v3 pool for wPowerPerp / weth\n * @param _uniPositionManager uniswap v3 position manager address\n */\n constructor(\n address _oracle,\n address _shortPowerPerp,\n address _wPowerPerp,\n address _weth,\n address _quoteCurrency,\n address _ethQuoteCurrencyPool,\n address _wPowerPerpPool,\n address _uniPositionManager,\n uint24 _feeTier\n ) {\n require(_oracle != address(0), \"C4\");\n require(_shortPowerPerp != address(0), \"C5\");\n require(_wPowerPerp != address(0), \"C6\");\n require(_weth != address(0), \"C7\");\n require(_quoteCurrency != address(0), \"C8\");\n require(_ethQuoteCurrencyPool != address(0), \"C9\");\n require(_wPowerPerpPool != address(0), \"C10\");\n require(_uniPositionManager != address(0), \"C11\");\n\n oracle = _oracle;\n shortPowerPerp = _shortPowerPerp;\n wPowerPerp = _wPowerPerp;\n weth = _weth;\n quoteCurrency = _quoteCurrency;\n ethQuoteCurrencyPool = _ethQuoteCurrencyPool;\n wPowerPerpPool = _wPowerPerpPool;\n uniswapPositionManager = _uniPositionManager;\n feeTier = _feeTier;\n isWethToken0 = _weth < _wPowerPerp;\n\n normalizationFactor = 1e18;\n deployTimestamp = block.timestamp;\n lastFundingUpdateTimestamp = block.timestamp.toUint128();\n }\n\n /**\n * ======================\n * | External Functions |\n * ======================\n */\n\n /**\n * @notice returns the expected normalization factor, if the funding is paid right now\n * @dev can be used for on-chain and off-chain calculations\n */\n function getExpectedNormalizationFactor() external view returns (uint256) {\n return _getNewNormalizationFactor();\n }\n\n /**\n * @notice get the index price of the powerPerp, scaled down\n * @dev the index price is scaled down by INDEX_SCALE in the associated PowerXBase library\n * @dev this is the index price used when calculating funding and for collateralization\n * @param _period period which you want to calculate twap with\n * @return index price denominated in $USD, scaled by 1e18\n */\n function getIndex(uint32 _period) external view returns (uint256) {\n return Power2Base._getIndex(_period, oracle, ethQuoteCurrencyPool, weth, quoteCurrency);\n }\n\n /**\n * @notice the unscaled index of the power perp in USD, scaled by 18 decimals\n * @dev this is the mark that would be be used for future funding after a new normalization factor is applied\n * @param _period period which you want to calculate twap with\n * @return index price denominated in $USD, scaled by 1e18\n */\n function getUnscaledIndex(uint32 _period) external view returns (uint256) {\n return Power2Base._getUnscaledIndex(_period, oracle, ethQuoteCurrencyPool, weth, quoteCurrency);\n }\n\n /**\n * @notice get the expected mark price of powerPerp after funding has been applied\n * @param _period period of time for the twap in seconds\n * @return mark price denominated in $USD, scaled by 1e18\n */\n function getDenormalizedMark(uint32 _period) external view returns (uint256) {\n return\n Power2Base._getDenormalizedMark(\n _period,\n oracle,\n wPowerPerpPool,\n ethQuoteCurrencyPool,\n weth,\n quoteCurrency,\n wPowerPerp,\n _getNewNormalizationFactor()\n );\n }\n\n /**\n * @notice get the mark price of powerPerp before funding has been applied\n * @dev this is the mark that would be used to calculate a new normalization factor if funding was calculated now\n * @param _period period which you want to calculate twap with\n * @return mark price denominated in $USD, scaled by 1e18\n */\n function getDenormalizedMarkForFunding(uint32 _period) external view returns (uint256) {\n return\n Power2Base._getDenormalizedMark(\n _period,\n oracle,\n wPowerPerpPool,\n ethQuoteCurrencyPool,\n weth,\n quoteCurrency,\n wPowerPerp,\n normalizationFactor\n );\n }\n\n /**\n * @dev return if the vault is properly collateralized\n * @param _vaultId id of the vault\n * @return true if the vault is properly collateralized\n */\n function isVaultSafe(uint256 _vaultId) external view returns (bool) {\n VaultLib.Vault memory vault = vaults[_vaultId];\n uint256 expectedNormalizationFactor = _getNewNormalizationFactor();\n return _isVaultSafe(vault, expectedNormalizationFactor);\n }\n\n /**\n * @notice deposit collateral and mint wPowerPerp (non-rebasing) for specified powerPerp (rebasing) amount\n * @param _vaultId vault to mint wPowerPerp in\n * @param _powerPerpAmount amount of powerPerp to mint\n * @param _uniTokenId uniswap v3 position token id (additional collateral)\n * @return vaultId\n * @return amount of wPowerPerp minted\n */\n function mintPowerPerpAmount(\n uint256 _vaultId,\n uint256 _powerPerpAmount,\n uint256 _uniTokenId\n ) external payable notPaused nonReentrant returns (uint256, uint256) {\n return _openDepositMint(msg.sender, _vaultId, _powerPerpAmount, msg.value, _uniTokenId, false);\n }\n\n /**\n * @notice deposit collateral and mint wPowerPerp\n * @param _vaultId vault to mint wPowerPerp in\n * @param _wPowerPerpAmount amount of wPowerPerp to mint\n * @param _uniTokenId uniswap v3 position token id (additional collateral)\n * @return vaultId\n */\n function mintWPowerPerpAmount(\n uint256 _vaultId,\n uint256 _wPowerPerpAmount,\n uint256 _uniTokenId\n ) external payable notPaused nonReentrant returns (uint256) {\n (uint256 vaultId, ) = _openDepositMint(msg.sender, _vaultId, _wPowerPerpAmount, msg.value, _uniTokenId, true);\n return vaultId;\n }\n\n /**\n * @dev deposit collateral into a vault\n * @param _vaultId id of the vault\n */\n function deposit(uint256 _vaultId) external payable notPaused nonReentrant {\n _checkCanModifyVault(_vaultId, msg.sender);\n\n _applyFunding();\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\n _addEthCollateral(cachedVault, _vaultId, msg.value);\n\n _writeVault(_vaultId, cachedVault);\n }\n\n /**\n * @notice deposit uniswap position token into a vault to increase collateral ratio\n * @param _vaultId id of the vault\n * @param _uniTokenId uniswap position token id\n */\n function depositUniPositionToken(uint256 _vaultId, uint256 _uniTokenId) external notPaused nonReentrant {\n _checkCanModifyVault(_vaultId, msg.sender);\n\n _applyFunding();\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\n\n _depositUniPositionToken(cachedVault, msg.sender, _vaultId, _uniTokenId);\n _writeVault(_vaultId, cachedVault);\n }\n\n /**\n * @notice withdraw collateral from a vault\n * @param _vaultId id of the vault\n * @param _amount amount of eth to withdraw\n */\n function withdraw(uint256 _vaultId, uint256 _amount) external notPaused nonReentrant {\n _checkCanModifyVault(_vaultId, msg.sender);\n\n uint256 cachedNormFactor = _applyFunding();\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\n\n _withdrawCollateral(cachedVault, _vaultId, _amount);\n _checkVault(cachedVault, cachedNormFactor);\n _writeVault(_vaultId, cachedVault);\n payable(msg.sender).sendValue(_amount);\n }\n\n /**\n * @notice withdraw uniswap v3 position token from a vault\n * @param _vaultId id of the vault\n */\n function withdrawUniPositionToken(uint256 _vaultId) external notPaused nonReentrant {\n _checkCanModifyVault(_vaultId, msg.sender);\n\n uint256 cachedNormFactor = _applyFunding();\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\n _withdrawUniPositionToken(cachedVault, msg.sender, _vaultId);\n _checkVault(cachedVault, cachedNormFactor);\n _writeVault(_vaultId, cachedVault);\n }\n\n /**\n * @notice burn wPowerPerp and remove collateral from a vault\n * @param _vaultId id of the vault\n * @param _wPowerPerpAmount amount of wPowerPerp to burn\n * @param _withdrawAmount amount of eth to withdraw\n */\n function burnWPowerPerpAmount(\n uint256 _vaultId,\n uint256 _wPowerPerpAmount,\n uint256 _withdrawAmount\n ) external notPaused nonReentrant {\n _checkCanModifyVault(_vaultId, msg.sender);\n\n _burnAndWithdraw(msg.sender, _vaultId, _wPowerPerpAmount, _withdrawAmount, true);\n }\n\n /**\n * @notice burn powerPerp and remove collateral from a vault\n * @param _vaultId id of the vault\n * @param _powerPerpAmount amount of powerPerp to burn\n * @param _withdrawAmount amount of eth to withdraw\n * @return amount of wPowerPerp burned\n */\n function burnPowerPerpAmount(\n uint256 _vaultId,\n uint256 _powerPerpAmount,\n uint256 _withdrawAmount\n ) external notPaused nonReentrant returns (uint256) {\n _checkCanModifyVault(_vaultId, msg.sender);\n\n return _burnAndWithdraw(msg.sender, _vaultId, _powerPerpAmount, _withdrawAmount, false);\n }\n\n /**\n * @notice after the system is shutdown, insolvent vaults need to be have their uniswap v3 token assets withdrawn by force\n * @notice if a vault has a uniswap v3 position in it, anyone can call to withdraw uniswap v3 token assets, reducing debt and increasing collateral in the vault\n * @dev the caller won't get any bounty. this is expected to be used for insolvent vaults in shutdown\n * @param _vaultId vault containing uniswap v3 position to liquidate\n */\n function reduceDebtShutdown(uint256 _vaultId) external isShutdown nonReentrant {\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\n _reduceDebt(cachedVault, IShortPowerPerp(shortPowerPerp).ownerOf(_vaultId), _vaultId, false);\n _writeVault(_vaultId, cachedVault);\n }\n\n /**\n * @notice withdraw assets from uniswap v3 position, reducing debt and increasing collateral in the vault\n * @dev the caller won't get any bounty. this is expected to be used by vault owner\n * @param _vaultId target vault\n */\n function reduceDebt(uint256 _vaultId) external notPaused nonReentrant {\n _checkCanModifyVault(_vaultId, msg.sender);\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\n\n _reduceDebt(cachedVault, IShortPowerPerp(shortPowerPerp).ownerOf(_vaultId), _vaultId, false);\n\n _writeVault(_vaultId, cachedVault);\n }\n\n /**\n * @notice if a vault is under the 150% collateral ratio, anyone can liquidate the vault by burning wPowerPerp\n * @dev liquidator can get back (wPowerPerp burned) * (index price) * (normalizationFactor) * 110% in collateral\n * @dev normally can only liquidate 50% of a vault's debt\n * @dev if a vault is under dust limit after a liquidation can fully liquidate\n * @dev will attempt to reduceDebt first, and can earn a bounty if sucessful\n * @param _vaultId vault to liquidate\n * @param _maxDebtAmount max amount of wPowerPerpetual to repay\n * @return amount of wPowerPerp repaid\n */\n function liquidate(uint256 _vaultId, uint256 _maxDebtAmount) external notPaused nonReentrant returns (uint256) {\n uint256 cachedNormFactor = _applyFunding();\n\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\n\n require(!_isVaultSafe(cachedVault, cachedNormFactor), \"C12\");\n\n // try to save target vault before liquidation by reducing debt\n uint256 bounty = _reduceDebt(cachedVault, IShortPowerPerp(shortPowerPerp).ownerOf(_vaultId), _vaultId, true);\n\n // if vault is safe after saving, pay bounty and return early\n if (_isVaultSafe(cachedVault, cachedNormFactor)) {\n _writeVault(_vaultId, cachedVault);\n payable(msg.sender).sendValue(bounty);\n return 0;\n }\n\n // add back the bounty amount, liquidators onlly get reward from liquidation\n cachedVault.addEthCollateral(bounty);\n\n // if the vault is still not safe after saving, liquidate it\n (uint256 debtAmount, uint256 collateralPaid) = _liquidate(\n cachedVault,\n _maxDebtAmount,\n cachedNormFactor,\n msg.sender\n );\n\n emit Liquidate(msg.sender, _vaultId, debtAmount, collateralPaid);\n\n _writeVault(_vaultId, cachedVault);\n\n // pay the liquidator\n payable(msg.sender).sendValue(collateralPaid);\n\n return debtAmount;\n }\n\n /**\n * @notice authorize an address to modify the vault\n * @dev can be revoke by setting address to 0\n * @param _vaultId id of the vault\n * @param _operator new operator address\n */\n function updateOperator(uint256 _vaultId, address _operator) external {\n require(\n (shortPowerPerp == msg.sender) || (IShortPowerPerp(shortPowerPerp).ownerOf(_vaultId) == msg.sender),\n \"C20\"\n );\n vaults[_vaultId].operator = _operator;\n emit UpdateOperator(msg.sender, _vaultId, _operator);\n }\n\n /**\n * @notice set the recipient who will receive the fee\n * @dev this should be a contract handling insurance\n * @param _newFeeRecipient new fee recipient\n */\n function setFeeRecipient(address _newFeeRecipient) external onlyOwner {\n require(_newFeeRecipient != address(0), \"C13\");\n emit FeeRecipientUpdated(feeRecipient, _newFeeRecipient);\n feeRecipient = _newFeeRecipient;\n }\n\n /**\n * @notice set the fee rate when user mints\n * @dev this function cannot be called if the feeRecipient is still un-set\n * @param _newFeeRate new fee rate in basis points. can't be higher than 1%\n */\n function setFeeRate(uint256 _newFeeRate) external onlyOwner {\n require(feeRecipient != address(0), \"C14\");\n require(_newFeeRate <= 100, \"C15\");\n emit FeeRateUpdated(feeRate, _newFeeRate);\n feeRate = _newFeeRate;\n }\n\n /**\n * @notice shutting down the system allows all long wPowerPerp to be settled at index * normalizationFactor\n * @notice short positions can be redeemed for vault collateral minus value of debt\n * @notice pause (if not paused) and then immediately shutdown the system, can be called when paused already\n * @dev this bypasses the check on number of pauses or time based checks, but is irreversible and enables emergency settlement\n */\n function shutDown() external onlyOwner notShutdown {\n isSystemPaused = true;\n isShutDown = true;\n indexForSettlement = Power2Base._getScaledTwap(\n oracle,\n ethQuoteCurrencyPool,\n weth,\n quoteCurrency,\n TWAP_PERIOD,\n false\n );\n emit Shutdown(indexForSettlement);\n }\n\n /**\n * @notice pause the system for up to 24 hours after which any one can unpause\n * @dev can only be called for 365 days since the contract was launched or 4 times\n */\n function pause() external onlyOwner notShutdown notPaused {\n require(pausesLeft > 0, \"C16\");\n uint256 timeSinceDeploy = block.timestamp.sub(deployTimestamp);\n require(timeSinceDeploy < PAUSE_TIME_LIMIT, \"C17\");\n isSystemPaused = true;\n pausesLeft -= 1;\n lastPauseTime = block.timestamp;\n\n emit Paused(pausesLeft);\n }\n\n /**\n * @notice unpause the contract\n * @dev anyone can unpause the contract after 24 hours\n */\n function unPauseAnyone() external isPaused notShutdown {\n require(block.timestamp > (lastPauseTime + 1 days), \"C18\");\n isSystemPaused = false;\n emit UnPaused(msg.sender);\n }\n\n /**\n * @notice unpause the contract\n * @dev owner can unpause at any time\n */\n function unPauseOwner() external onlyOwner isPaused notShutdown {\n isSystemPaused = false;\n emit UnPaused(msg.sender);\n }\n\n /**\n * @notice redeem wPowerPerp for (settlement index value) * normalizationFactor when the system is shutdown\n * @param _wPerpAmount amount of wPowerPerp to burn\n */\n function redeemLong(uint256 _wPerpAmount) external isShutdown nonReentrant {\n IWPowerPerp(wPowerPerp).burn(msg.sender, _wPerpAmount);\n\n uint256 longValue = Power2Base._getLongSettlementValue(_wPerpAmount, indexForSettlement, normalizationFactor);\n payable(msg.sender).sendValue(longValue);\n\n emit RedeemLong(msg.sender, _wPerpAmount, longValue);\n }\n\n /**\n * @notice redeem short position when the system is shutdown\n * @dev short position is redeemed by valuing the debt at the (settlement index value) * normalizationFactor\n * @param _vaultId vault id\n */\n function redeemShort(uint256 _vaultId) external isShutdown nonReentrant {\n _checkCanModifyVault(_vaultId, msg.sender);\n\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\n uint256 cachedNormFactor = normalizationFactor;\n\n _reduceDebt(cachedVault, msg.sender, _vaultId, false);\n\n uint256 debt = Power2Base._getLongSettlementValue(\n cachedVault.shortAmount,\n indexForSettlement,\n cachedNormFactor\n );\n // if the debt is more than collateral, this line will revert\n uint256 excess = uint256(cachedVault.collateralAmount).sub(debt);\n\n // reset the vault but don't burn the nft, just because people may want to keep it\n cachedVault.shortAmount = 0;\n cachedVault.collateralAmount = 0;\n _writeVault(_vaultId, cachedVault);\n\n payable(msg.sender).sendValue(excess);\n\n emit RedeemShort(msg.sender, _vaultId, excess);\n }\n\n /**\n * @notice update the normalization factor as a way to pay funding\n */\n function applyFunding() external notPaused {\n _applyFunding();\n }\n\n /**\n * @notice add eth into a contract. used in case contract has insufficient eth to pay for settlement transactions\n */\n function donate() external payable isShutdown {}\n\n /**\n * @notice fallback function to accept eth\n */\n receive() external payable {\n require(msg.sender == weth, \"C19\");\n }\n\n /**\n * @dev accept erc721 from safeTransferFrom and safeMint after callback\n * @return returns received selector\n */\n function onERC721Received(\n address,\n address,\n uint256,\n bytes memory\n ) public virtual override returns (bytes4) {\n return this.onERC721Received.selector;\n }\n\n /*\n * ======================\n * | Internal Functions |\n * ======================\n */\n\n /**\n * @notice check if an address can modify a vault\n * @param _vaultId the id of the vault to check if can be modified by _account\n * @param _account the address to check if can modify the vault\n */\n function _checkCanModifyVault(uint256 _vaultId, address _account) internal view {\n require(\n IShortPowerPerp(shortPowerPerp).ownerOf(_vaultId) == _account || vaults[_vaultId].operator == _account,\n \"C20\"\n );\n }\n\n /**\n * @notice wrapper function which opens a vault, adds collateral and mints wPowerPerp\n * @param _account account to receive wPowerPerp\n * @param _vaultId id of the vault\n * @param _mintAmount amount to mint\n * @param _depositAmount amount of eth as collateral\n * @param _uniTokenId id of uniswap v3 position token\n * @param _isWAmount if the input amount is a wPowerPerp amount (as opposed to rebasing powerPerp)\n * @return the vaultId that was acted on or for a new vault the newly created vaultId\n * @return the minted wPowerPerp amount\n */\n function _openDepositMint(\n address _account,\n uint256 _vaultId,\n uint256 _mintAmount,\n uint256 _depositAmount,\n uint256 _uniTokenId,\n bool _isWAmount\n ) internal returns (uint256, uint256) {\n uint256 cachedNormFactor = _applyFunding();\n uint256 depositAmountWithFee = _depositAmount;\n uint256 wPowerPerpAmount = _isWAmount ? _mintAmount : _mintAmount.mul(ONE).div(cachedNormFactor);\n uint256 feeAmount;\n VaultLib.Vault memory cachedVault;\n\n // load vault or create new a new one\n if (_vaultId == 0) {\n (_vaultId, cachedVault) = _openVault(_account);\n } else {\n // make sure we're not accessing an unexistent vault.\n _checkCanModifyVault(_vaultId, msg.sender);\n cachedVault = vaults[_vaultId];\n }\n\n if (wPowerPerpAmount > 0) {\n (feeAmount, depositAmountWithFee) = _getFee(cachedVault, wPowerPerpAmount, _depositAmount);\n _mintWPowerPerp(cachedVault, _account, _vaultId, wPowerPerpAmount);\n }\n if (_depositAmount > 0) _addEthCollateral(cachedVault, _vaultId, depositAmountWithFee);\n if (_uniTokenId != 0) _depositUniPositionToken(cachedVault, _account, _vaultId, _uniTokenId);\n\n _checkVault(cachedVault, cachedNormFactor);\n _writeVault(_vaultId, cachedVault);\n\n // pay insurance fee\n if (feeAmount > 0) payable(feeRecipient).sendValue(feeAmount);\n\n return (_vaultId, wPowerPerpAmount);\n }\n\n /**\n * @notice wrapper function to burn wPowerPerp and redeem collateral\n * @param _account who should receive collateral\n * @param _vaultId id of the vault\n * @param _burnAmount amount of wPowerPerp to burn\n * @param _withdrawAmount amount of eth collateral to withdraw\n * @param _isWAmount true if the amount is wPowerPerp (as opposed to rebasing powerPerp)\n * @return total burned wPowerPower amount\n */\n function _burnAndWithdraw(\n address _account,\n uint256 _vaultId,\n uint256 _burnAmount,\n uint256 _withdrawAmount,\n bool _isWAmount\n ) internal returns (uint256) {\n uint256 cachedNormFactor = _applyFunding();\n uint256 wBurnAmount = _isWAmount ? _burnAmount : _burnAmount.mul(ONE).div(cachedNormFactor);\n\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\n if (wBurnAmount > 0) _burnWPowerPerp(cachedVault, _account, _vaultId, wBurnAmount);\n if (_withdrawAmount > 0) _withdrawCollateral(cachedVault, _vaultId, _withdrawAmount);\n _checkVault(cachedVault, cachedNormFactor);\n _writeVault(_vaultId, cachedVault);\n\n if (_withdrawAmount > 0) payable(msg.sender).sendValue(_withdrawAmount);\n\n return wBurnAmount;\n }\n\n /**\n * @notice open a new vault\n * @dev create a new vault and bind it with a new short vault id\n * @param _recipient owner of new vault\n * @return id of the new vault\n * @return new in-memory vault\n */\n function _openVault(address _recipient) internal returns (uint256, VaultLib.Vault memory) {\n uint256 vaultId = IShortPowerPerp(shortPowerPerp).mintNFT(_recipient);\n\n VaultLib.Vault memory vault = VaultLib.Vault({\n NftCollateralId: 0,\n collateralAmount: 0,\n shortAmount: 0,\n operator: address(0)\n });\n emit OpenVault(msg.sender, vaultId);\n return (vaultId, vault);\n }\n\n /**\n * @notice deposit uniswap v3 position token into a vault\n * @dev this function will update the vault memory in-place\n * @param _vault the Vault memory to update\n * @param _account account to transfer the uniswap v3 position from\n * @param _vaultId id of the vault\n * @param _uniTokenId uniswap position token id\n */\n function _depositUniPositionToken(\n VaultLib.Vault memory _vault,\n address _account,\n uint256 _vaultId,\n uint256 _uniTokenId\n ) internal {\n //get tokens for uniswap NFT\n (, , address token0, address token1, uint24 fee, , , uint128 liquidity, , , , ) = INonfungiblePositionManager(\n uniswapPositionManager\n ).positions(_uniTokenId);\n\n // require that liquidity is above 0\n require(liquidity > 0, \"C25\");\n // accept NFTs from only the wPowerPerp pool\n require(fee == feeTier, \"C26\");\n // check token0 and token1\n require((token0 == wPowerPerp && token1 == weth) || (token1 == wPowerPerp && token0 == weth), \"C23\");\n\n _vault.addUniNftCollateral(_uniTokenId);\n INonfungiblePositionManager(uniswapPositionManager).safeTransferFrom(_account, address(this), _uniTokenId);\n emit DepositUniPositionToken(msg.sender, _vaultId, _uniTokenId);\n }\n\n /**\n * @notice add eth collateral into a vault\n * @dev this function will update the vault memory in-place\n * @param _vault the Vault memory to update.\n * @param _vaultId id of the vault\n * @param _amount amount of eth adding to the vault\n */\n function _addEthCollateral(\n VaultLib.Vault memory _vault,\n uint256 _vaultId,\n uint256 _amount\n ) internal {\n _vault.addEthCollateral(_amount);\n emit DepositCollateral(msg.sender, _vaultId, _amount);\n }\n\n /**\n * @notice remove uniswap v3 position token from the vault\n * @dev this function will update the vault memory in-place\n * @param _vault the Vault memory to update\n * @param _account where to send the uni position token to\n * @param _vaultId id of the vault\n */\n function _withdrawUniPositionToken(\n VaultLib.Vault memory _vault,\n address _account,\n uint256 _vaultId\n ) internal {\n uint256 tokenId = _vault.NftCollateralId;\n _vault.removeUniNftCollateral();\n INonfungiblePositionManager(uniswapPositionManager).safeTransferFrom(address(this), _account, tokenId);\n emit WithdrawUniPositionToken(msg.sender, _vaultId, tokenId);\n }\n\n /**\n * @notice remove eth collateral from the vault\n * @dev this function will update the vault memory in-place\n * @param _vault the Vault memory to update\n * @param _vaultId id of the vault\n * @param _amount amount of eth to withdraw\n */\n function _withdrawCollateral(\n VaultLib.Vault memory _vault,\n uint256 _vaultId,\n uint256 _amount\n ) internal {\n _vault.removeEthCollateral(_amount);\n\n emit WithdrawCollateral(msg.sender, _vaultId, _amount);\n }\n\n /**\n * @notice mint wPowerPerp (ERC20) to an account\n * @dev this function will update the vault memory in-place\n * @param _vault the Vault memory to update\n * @param _account account to receive wPowerPerp\n * @param _vaultId id of the vault\n * @param _wPowerPerpAmount wPowerPerp amount to mint\n */\n function _mintWPowerPerp(\n VaultLib.Vault memory _vault,\n address _account,\n uint256 _vaultId,\n uint256 _wPowerPerpAmount\n ) internal {\n _vault.addShort(_wPowerPerpAmount);\n IWPowerPerp(wPowerPerp).mint(_account, _wPowerPerpAmount);\n\n emit MintShort(msg.sender, _wPowerPerpAmount, _vaultId);\n }\n\n /**\n * @notice burn wPowerPerp (ERC20) from an account\n * @dev this function will update the vault memory in-place\n * @param _vault the Vault memory to update\n * @param _account account burning the wPowerPerp\n * @param _vaultId id of the vault\n * @param _wPowerPerpAmount wPowerPerp amount to burn\n */\n function _burnWPowerPerp(\n VaultLib.Vault memory _vault,\n address _account,\n uint256 _vaultId,\n uint256 _wPowerPerpAmount\n ) internal {\n _vault.removeShort(_wPowerPerpAmount);\n IWPowerPerp(wPowerPerp).burn(_account, _wPowerPerpAmount);\n\n emit BurnShort(msg.sender, _wPowerPerpAmount, _vaultId);\n }\n\n /**\n * @notice liquidate a vault, pay the liquidator\n * @dev liquidator can only liquidate at most 1/2 of the vault in 1 transaction\n * @dev this function will update the vault memory in-place\n * @param _vault the Vault memory to update\n * @param _maxWPowerPerpAmount maximum debt amount liquidator is willing to repay\n * @param _normalizationFactor current normalization factor\n * @param _liquidator liquidator address to receive eth\n * @return debtAmount amount of wPowerPerp repaid (burn from the vault)\n * @return collateralToPay amount of collateral paid to liquidator\n */\n function _liquidate(\n VaultLib.Vault memory _vault,\n uint256 _maxWPowerPerpAmount,\n uint256 _normalizationFactor,\n address _liquidator\n ) internal returns (uint256, uint256) {\n (uint256 liquidateAmount, uint256 collateralToPay) = _getLiquidationResult(\n _maxWPowerPerpAmount,\n uint256(_vault.shortAmount),\n uint256(_vault.collateralAmount)\n );\n\n // if the liquidator didn't specify enough wPowerPerp to burn, revert.\n require(_maxWPowerPerpAmount >= liquidateAmount, \"C21\");\n\n IWPowerPerp(wPowerPerp).burn(_liquidator, liquidateAmount);\n _vault.removeShort(liquidateAmount);\n _vault.removeEthCollateral(collateralToPay);\n\n (, bool isDust) = _getVaultStatus(_vault, _normalizationFactor);\n require(!isDust, \"C22\");\n\n return (liquidateAmount, collateralToPay);\n }\n\n /**\n * @notice redeem uniswap v3 position in a vault for its constituent eth and wPowerPerp\n * @notice this will increase vault collateral by the amount of eth, and decrease debt by the amount of wPowerPerp\n * @dev will be executed before liquidation if there's an NFT in the vault\n * @dev pays a 2% bounty to the liquidator if called by liquidate()\n * @dev will update the vault memory in-place\n * @param _vault the Vault memory to update\n * @param _owner account to send any excess\n * @param _vaultId id of the vault to reduce debt on\n * @param _payBounty true if paying caller 2% bounty\n * @return bounty amount of bounty paid for liquidator\n */\n function _reduceDebt(\n VaultLib.Vault memory _vault,\n address _owner,\n uint256 _vaultId,\n bool _payBounty\n ) internal returns (uint256) {\n uint256 nftId = _vault.NftCollateralId;\n if (nftId == 0) return 0;\n\n (uint256 withdrawnEthAmount, uint256 withdrawnWPowerPerpAmount) = _redeemUniToken(nftId);\n\n // change weth back to eth\n if (withdrawnEthAmount > 0) IWETH9(weth).withdraw(withdrawnEthAmount);\n\n (uint256 burnAmount, uint256 excess, uint256 bounty) = _getReduceDebtResultInVault(\n _vault,\n withdrawnEthAmount,\n withdrawnWPowerPerpAmount,\n _payBounty\n );\n\n if (excess > 0) IWPowerPerp(wPowerPerp).transfer(_owner, excess);\n if (burnAmount > 0) IWPowerPerp(wPowerPerp).burn(address(this), burnAmount);\n\n emit ReduceDebt(\n msg.sender,\n _vaultId,\n withdrawnEthAmount,\n withdrawnWPowerPerpAmount,\n burnAmount,\n excess,\n bounty\n );\n\n return bounty;\n }\n\n /**\n * @notice pay fee recipient\n * @dev pay in eth from either the vault or the deposit amount\n * @param _vault the Vault memory to update\n * @param _wPowerPerpAmount the amount of wPowerPerpAmount minting\n * @param _depositAmount the amount of eth depositing or withdrawing\n * @return the amount of actual deposited eth into the vault, this is less than the original amount if a fee was taken\n */\n function _getFee(\n VaultLib.Vault memory _vault,\n uint256 _wPowerPerpAmount,\n uint256 _depositAmount\n ) internal view returns (uint256, uint256) {\n uint256 cachedFeeRate = feeRate;\n if (cachedFeeRate == 0) return (uint256(0), _depositAmount);\n uint256 depositAmountAfterFee;\n uint256 ethEquivalentMinted = Power2Base._getDebtValueInEth(\n _wPowerPerpAmount,\n oracle,\n wPowerPerpPool,\n wPowerPerp,\n weth\n );\n uint256 feeAmount = ethEquivalentMinted.mul(cachedFeeRate).div(10000);\n\n // if fee can be paid from deposited collateral, pay from _depositAmount\n if (_depositAmount > feeAmount) {\n depositAmountAfterFee = _depositAmount.sub(feeAmount);\n // if not, adjust the vault to pay from the vault collateral\n } else {\n _vault.removeEthCollateral(feeAmount);\n depositAmountAfterFee = _depositAmount;\n }\n //return the fee and deposit amount, which has only been reduced by a fee if it is paid out of the deposit amount\n return (feeAmount, depositAmountAfterFee);\n }\n\n /**\n * @notice write vault to storage\n * @dev writes to vaults mapping\n */\n function _writeVault(uint256 _vaultId, VaultLib.Vault memory _vault) private {\n vaults[_vaultId] = _vault;\n }\n\n /**\n * @dev redeem a uni position token and get back wPowerPerp and eth\n * @param _uniTokenId uniswap v3 position token id\n * @return wethAmount amount of weth withdrawn from uniswap\n * @return wPowerPerpAmount amount of wPowerPerp withdrawn from uniswap\n */\n function _redeemUniToken(uint256 _uniTokenId) internal returns (uint256, uint256) {\n INonfungiblePositionManager positionManager = INonfungiblePositionManager(uniswapPositionManager);\n\n (, , uint128 liquidity, , ) = VaultLib._getUniswapPositionInfo(uniswapPositionManager, _uniTokenId);\n\n // prepare parameters to withdraw liquidity from uniswap v3 position manager\n INonfungiblePositionManager.DecreaseLiquidityParams memory decreaseParams = INonfungiblePositionManager\n .DecreaseLiquidityParams({\n tokenId: _uniTokenId,\n liquidity: liquidity,\n amount0Min: 0,\n amount1Min: 0,\n deadline: block.timestamp\n });\n\n positionManager.decreaseLiquidity(decreaseParams);\n\n // withdraw max amount of weth and wPowerPerp from uniswap\n INonfungiblePositionManager.CollectParams memory collectParams = INonfungiblePositionManager.CollectParams({\n tokenId: _uniTokenId,\n recipient: address(this),\n amount0Max: uint128(-1),\n amount1Max: uint128(-1)\n });\n\n (uint256 collectedToken0, uint256 collectedToken1) = positionManager.collect(collectParams);\n\n return isWethToken0 ? (collectedToken0, collectedToken1) : (collectedToken1, collectedToken0);\n }\n\n /**\n * @notice update the normalization factor as a way to pay in-kind funding\n * @dev the normalization factor scales amount of debt that must be repaid, effecting an interest rate paid between long and short positions\n * @return new normalization factor\n **/\n function _applyFunding() internal returns (uint256) {\n // only update the norm factor once per block\n if (lastFundingUpdateTimestamp == block.timestamp) return normalizationFactor;\n\n uint256 newNormalizationFactor = _getNewNormalizationFactor();\n\n emit NormalizationFactorUpdated(\n normalizationFactor,\n newNormalizationFactor,\n lastFundingUpdateTimestamp,\n block.timestamp\n );\n\n // the following will be batch into 1 SSTORE because of type uint128\n normalizationFactor = newNormalizationFactor.toUint128();\n lastFundingUpdateTimestamp = block.timestamp.toUint128();\n\n return newNormalizationFactor;\n }\n\n /**\n * @dev calculate new normalization factor base on the current timestamp\n * @return new normalization factor if funding happens in the current block\n */\n function _getNewNormalizationFactor() internal view returns (uint256) {\n uint32 period = block.timestamp.sub(lastFundingUpdateTimestamp).toUint32();\n\n if (period == 0) {\n return normalizationFactor;\n }\n\n // make sure we use the same period for mark and index\n uint32 periodForOracle = _getConsistentPeriodForOracle(period);\n\n // avoid reading normalizationFactor from storage multiple times\n uint256 cacheNormFactor = normalizationFactor;\n\n uint256 mark = Power2Base._getDenormalizedMark(\n periodForOracle,\n oracle,\n wPowerPerpPool,\n ethQuoteCurrencyPool,\n weth,\n quoteCurrency,\n wPowerPerp,\n cacheNormFactor\n );\n uint256 index = Power2Base._getIndex(periodForOracle, oracle, ethQuoteCurrencyPool, weth, quoteCurrency);\n\n //the fraction of the funding period. used to compound the funding rate\n int128 rFunding = ABDKMath64x64.divu(period, FUNDING_PERIOD);\n\n // floor mark to be at least LOWER_MARK_RATIO of index\n uint256 lowerBound = index.mul(LOWER_MARK_RATIO).div(ONE);\n if (mark < lowerBound) {\n mark = lowerBound;\n } else {\n // cap mark to be at most UPPER_MARK_RATIO of index\n uint256 upperBound = index.mul(UPPER_MARK_RATIO).div(ONE);\n if (mark > upperBound) mark = upperBound;\n }\n\n // normFactor(new) = multiplier * normFactor(old)\n // multiplier = (index/mark)^rFunding\n // x^r = n^(log_n(x) * r)\n // multiplier = 2^( log2(index/mark) * rFunding )\n\n int128 base = ABDKMath64x64.divu(index, mark);\n int128 logTerm = ABDKMath64x64.log_2(base).mul(rFunding);\n int128 multiplier = logTerm.exp_2();\n return multiplier.mulu(cacheNormFactor);\n }\n\n /**\n * @notice check if vault has enough collateral and is not a dust vault\n * @dev revert if vault has insufficient collateral or is a dust vault\n * @param _vault the Vault memory to update\n * @param _normalizationFactor normalization factor\n */\n function _checkVault(VaultLib.Vault memory _vault, uint256 _normalizationFactor) internal view {\n (bool isSafe, bool isDust) = _getVaultStatus(_vault, _normalizationFactor);\n require(isSafe, \"C24\");\n require(!isDust, \"C22\");\n }\n\n /**\n * @notice check that the vault has enough collateral\n * @param _vault in-memory vault\n * @param _normalizationFactor normalization factor\n * @return true if the vault is properly collateralized\n */\n function _isVaultSafe(VaultLib.Vault memory _vault, uint256 _normalizationFactor) internal view returns (bool) {\n (bool isSafe, ) = _getVaultStatus(_vault, _normalizationFactor);\n return isSafe;\n }\n\n /**\n * @notice return if the vault is properly collateralized and if it is a dust vault\n * @param _vault the Vault memory to update\n * @param _normalizationFactor normalization factor\n * @return true if the vault is safe\n * @return true if the vault is a dust vault\n */\n function _getVaultStatus(VaultLib.Vault memory _vault, uint256 _normalizationFactor)\n internal\n view\n returns (bool, bool)\n {\n uint256 scaledEthPrice = Power2Base._getScaledTwap(\n oracle,\n ethQuoteCurrencyPool,\n weth,\n quoteCurrency,\n TWAP_PERIOD,\n true // do not call more than maximum period so it does not revert\n );\n return\n VaultLib.getVaultStatus(\n _vault,\n uniswapPositionManager,\n _normalizationFactor,\n scaledEthPrice,\n MIN_COLLATERAL,\n IOracle(oracle).getTimeWeightedAverageTickSafe(wPowerPerpPool, TWAP_PERIOD),\n isWethToken0\n );\n }\n\n /**\n * @notice get the expected excess, burnAmount and bounty if Uniswap position token got burned\n * @dev this function will update the vault memory in-place\n * @return burnAmount amount of wPowerPerp that should be burned\n * @return wPowerPerpExcess amount of wPowerPerp that should be send to the vault owner\n * @return bounty amount of bounty should be paid out to caller\n */\n function _getReduceDebtResultInVault(\n VaultLib.Vault memory _vault,\n uint256 nftEthAmount,\n uint256 nftWPowerperpAmount,\n bool _payBounty\n )\n internal\n view\n returns (\n uint256,\n uint256,\n uint256\n )\n {\n uint256 bounty;\n if (_payBounty) bounty = _getReduceDebtBounty(nftEthAmount, nftWPowerperpAmount);\n\n uint256 burnAmount = nftWPowerperpAmount;\n uint256 wPowerPerpExcess;\n\n if (nftWPowerperpAmount > _vault.shortAmount) {\n wPowerPerpExcess = nftWPowerperpAmount.sub(_vault.shortAmount);\n burnAmount = _vault.shortAmount;\n }\n\n _vault.removeShort(burnAmount);\n _vault.removeUniNftCollateral();\n _vault.addEthCollateral(nftEthAmount);\n _vault.removeEthCollateral(bounty);\n\n return (burnAmount, wPowerPerpExcess, bounty);\n }\n\n /**\n * @notice get how much bounty you can get by helping a vault reducing the debt.\n * @dev bounty is 2% of the total value of the position token\n * @param _ethWithdrawn amount of eth withdrawn from uniswap by redeeming the position token\n * @param _wPowerPerpReduced amount of wPowerPerp withdrawn from uniswap by redeeming the position token\n */\n function _getReduceDebtBounty(uint256 _ethWithdrawn, uint256 _wPowerPerpReduced) internal view returns (uint256) {\n return\n Power2Base\n ._getDebtValueInEth(_wPowerPerpReduced, oracle, wPowerPerpPool, wPowerPerp, weth)\n .add(_ethWithdrawn)\n .mul(REDUCE_DEBT_BOUNTY)\n .div(ONE);\n }\n\n /**\n * @notice get the expected wPowerPerp needed to liquidate a vault.\n * @dev a liquidator cannot liquidate more than half of a vault, unless only liquidating half of the debt will make the vault a \"dust vault\"\n * @dev a liquidator cannot take out more collateral than the vault holds\n * @param _maxWPowerPerpAmount the max amount of wPowerPerp willing to pay\n * @param _vaultShortAmount the amount of short in the vault\n * @param _maxWPowerPerpAmount the amount of collateral in the vault\n * @return finalLiquidateAmount the amount that should be liquidated. This amount can be higher than _maxWPowerPerpAmount, which should be checked\n * @return collateralToPay final amount of collateral paying out to the liquidator\n */\n function _getLiquidationResult(\n uint256 _maxWPowerPerpAmount,\n uint256 _vaultShortAmount,\n uint256 _vaultCollateralAmount\n ) internal view returns (uint256, uint256) {\n // try limiting liquidation amount to half of the vault debt\n (uint256 finalLiquidateAmount, uint256 collateralToPay) = _getSingleLiquidationAmount(\n _maxWPowerPerpAmount,\n _vaultShortAmount.div(2)\n );\n\n if (_vaultCollateralAmount > collateralToPay) {\n if (_vaultCollateralAmount.sub(collateralToPay) < MIN_COLLATERAL) {\n // the vault is left with dust after liquidation, allow liquidating full vault\n // calculate the new liquidation amount and collateral again based on the new limit\n (finalLiquidateAmount, collateralToPay) = _getSingleLiquidationAmount(\n _maxWPowerPerpAmount,\n _vaultShortAmount\n );\n }\n }\n\n // check if final collateral to pay is greater than vault amount.\n // if so the system only pays out the amount the vault has, which may not be profitable\n if (collateralToPay > _vaultCollateralAmount) {\n // force liquidator to pay full debt amount\n finalLiquidateAmount = _vaultShortAmount;\n collateralToPay = _vaultCollateralAmount;\n }\n\n return (finalLiquidateAmount, collateralToPay);\n }\n\n /**\n * @notice determine how much wPowerPerp to liquidate, and how much collateral to return\n * @param _maxInputWAmount maximum wPowerPerp amount liquidator is willing to repay\n * @param _maxLiquidatableWAmount maximum wPowerPerp amount a liquidator is allowed to repay\n * @return finalWAmountToLiquidate amount of wPowerPerp the liquidator will burn\n * @return collateralToPay total collateral the liquidator will get\n */\n function _getSingleLiquidationAmount(uint256 _maxInputWAmount, uint256 _maxLiquidatableWAmount)\n internal\n view\n returns (uint256, uint256)\n {\n uint256 finalWAmountToLiquidate = _maxInputWAmount > _maxLiquidatableWAmount\n ? _maxLiquidatableWAmount\n : _maxInputWAmount;\n\n uint256 collateralToPay = Power2Base._getDebtValueInEth(\n finalWAmountToLiquidate,\n oracle,\n wPowerPerpPool,\n wPowerPerp,\n weth\n );\n\n // add 10% bonus for liquidators\n collateralToPay = collateralToPay.add(collateralToPay.mul(LIQUIDATION_BOUNTY).div(ONE));\n\n return (finalWAmountToLiquidate, collateralToPay);\n }\n\n /**\n * @notice get a period can be used to request a twap for 2 uniswap v3 pools\n * @dev if the period is greater than min(max_pool_1, max_pool_2), return min(max_pool_1, max_pool_2)\n * @param _period max period that we intend to use\n * @return fair period not greator than _period to be used for both pools.\n */\n function _getConsistentPeriodForOracle(uint32 _period) internal view returns (uint32) {\n uint32 maxPeriodPool1 = IOracle(oracle).getMaxPeriod(ethQuoteCurrencyPool);\n uint32 maxPeriodPool2 = IOracle(oracle).getMaxPeriod(wPowerPerpPool);\n\n uint32 maxSafePeriod = maxPeriodPool1 > maxPeriodPool2 ? maxPeriodPool2 : maxPeriodPool1;\n return _period > maxSafePeriod ? maxSafePeriod : _period;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\nimport \"../../introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n}\n" + }, + "@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\nimport '@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol';\nimport '@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol';\n\nimport './IPoolInitializer.sol';\nimport './IERC721Permit.sol';\nimport './IPeripheryPayments.sol';\nimport './IPeripheryImmutableState.sol';\nimport '../libraries/PoolAddress.sol';\n\n/// @title Non-fungible token for positions\n/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred\n/// and authorized.\ninterface INonfungiblePositionManager is\n IPoolInitializer,\n IPeripheryPayments,\n IPeripheryImmutableState,\n IERC721Metadata,\n IERC721Enumerable,\n IERC721Permit\n{\n /// @notice Emitted when liquidity is increased for a position NFT\n /// @dev Also emitted when a token is minted\n /// @param tokenId The ID of the token for which liquidity was increased\n /// @param liquidity The amount by which liquidity for the NFT position was increased\n /// @param amount0 The amount of token0 that was paid for the increase in liquidity\n /// @param amount1 The amount of token1 that was paid for the increase in liquidity\n event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\n /// @notice Emitted when liquidity is decreased for a position NFT\n /// @param tokenId The ID of the token for which liquidity was decreased\n /// @param liquidity The amount by which liquidity for the NFT position was decreased\n /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity\n /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity\n event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);\n /// @notice Emitted when tokens are collected for a position NFT\n /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior\n /// @param tokenId The ID of the token for which underlying tokens were collected\n /// @param recipient The address of the account that received the collected tokens\n /// @param amount0 The amount of token0 owed to the position that was collected\n /// @param amount1 The amount of token1 owed to the position that was collected\n event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);\n\n /// @notice Returns the position information associated with a given token ID.\n /// @dev Throws if the token ID is not valid.\n /// @param tokenId The ID of the token that represents the position\n /// @return nonce The nonce for permits\n /// @return operator The address that is approved for spending\n /// @return token0 The address of the token0 for a specific pool\n /// @return token1 The address of the token1 for a specific pool\n /// @return fee The fee associated with the pool\n /// @return tickLower The lower end of the tick range for the position\n /// @return tickUpper The higher end of the tick range for the position\n /// @return liquidity The liquidity of the position\n /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position\n /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position\n /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation\n /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation\n function positions(uint256 tokenId)\n external\n view\n returns (\n uint96 nonce,\n address operator,\n address token0,\n address token1,\n uint24 fee,\n int24 tickLower,\n int24 tickUpper,\n uint128 liquidity,\n uint256 feeGrowthInside0LastX128,\n uint256 feeGrowthInside1LastX128,\n uint128 tokensOwed0,\n uint128 tokensOwed1\n );\n\n struct MintParams {\n address token0;\n address token1;\n uint24 fee;\n int24 tickLower;\n int24 tickUpper;\n uint256 amount0Desired;\n uint256 amount1Desired;\n uint256 amount0Min;\n uint256 amount1Min;\n address recipient;\n uint256 deadline;\n }\n\n /// @notice Creates a new position wrapped in a NFT\n /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized\n /// a method does not exist, i.e. the pool is assumed to be initialized.\n /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata\n /// @return tokenId The ID of the token that represents the minted position\n /// @return liquidity The amount of liquidity for this position\n /// @return amount0 The amount of token0\n /// @return amount1 The amount of token1\n function mint(MintParams calldata params)\n external\n payable\n returns (\n uint256 tokenId,\n uint128 liquidity,\n uint256 amount0,\n uint256 amount1\n );\n\n struct IncreaseLiquidityParams {\n uint256 tokenId;\n uint256 amount0Desired;\n uint256 amount1Desired;\n uint256 amount0Min;\n uint256 amount1Min;\n uint256 deadline;\n }\n\n /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`\n /// @param params tokenId The ID of the token for which liquidity is being increased,\n /// amount0Desired The desired amount of token0 to be spent,\n /// amount1Desired The desired amount of token1 to be spent,\n /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,\n /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,\n /// deadline The time by which the transaction must be included to effect the change\n /// @return liquidity The new liquidity amount as a result of the increase\n /// @return amount0 The amount of token0 to acheive resulting liquidity\n /// @return amount1 The amount of token1 to acheive resulting liquidity\n function increaseLiquidity(IncreaseLiquidityParams calldata params)\n external\n payable\n returns (\n uint128 liquidity,\n uint256 amount0,\n uint256 amount1\n );\n\n struct DecreaseLiquidityParams {\n uint256 tokenId;\n uint128 liquidity;\n uint256 amount0Min;\n uint256 amount1Min;\n uint256 deadline;\n }\n\n /// @notice Decreases the amount of liquidity in a position and accounts it to the position\n /// @param params tokenId The ID of the token for which liquidity is being decreased,\n /// amount The amount by which liquidity will be decreased,\n /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,\n /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,\n /// deadline The time by which the transaction must be included to effect the change\n /// @return amount0 The amount of token0 accounted to the position's tokens owed\n /// @return amount1 The amount of token1 accounted to the position's tokens owed\n function decreaseLiquidity(DecreaseLiquidityParams calldata params)\n external\n payable\n returns (uint256 amount0, uint256 amount1);\n\n struct CollectParams {\n uint256 tokenId;\n address recipient;\n uint128 amount0Max;\n uint128 amount1Max;\n }\n\n /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient\n /// @param params tokenId The ID of the NFT for which tokens are being collected,\n /// recipient The account that should receive the tokens,\n /// amount0Max The maximum amount of token0 to collect,\n /// amount1Max The maximum amount of token1 to collect\n /// @return amount0 The amount of fees collected in token0\n /// @return amount1 The amount of fees collected in token1\n function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);\n\n /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens\n /// must be collected first.\n /// @param tokenId The ID of the token that is being burned\n function burn(uint256 tokenId) external payable;\n}\n" + }, + "contracts/interfaces/IWETH9.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity =0.7.6;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IWETH9 is IERC20 {\n function deposit() external payable;\n\n function withdraw(uint256 wad) external;\n}\n" + }, + "contracts/interfaces/IWPowerPerp.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity =0.7.6;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IWPowerPerp is IERC20 {\n function mint(address _account, uint256 _amount) external;\n\n function burn(address _account, uint256 _amount) external;\n}\n" + }, + "contracts/interfaces/IShortPowerPerp.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity =0.7.6;\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\ninterface IShortPowerPerp is IERC721 {\n function nextId() external view returns (uint256);\n\n function mintNFT(address recipient) external returns (uint256 _newId);\n}\n" + }, + "contracts/interfaces/IOracle.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity =0.7.6;\n\ninterface IOracle {\n function getHistoricalTwap(\n address _pool,\n address _base,\n address _quote,\n uint32 _period,\n uint32 _periodToHistoricPrice\n ) external view returns (uint256);\n\n function getTwap(\n address _pool,\n address _base,\n address _quote,\n uint32 _period,\n bool _checkPeriod\n ) external view returns (uint256);\n\n function getMaxPeriod(address _pool) external view returns (uint32);\n\n function getTimeWeightedAverageTickSafe(address _pool, uint32 _period)\n external\n view\n returns (int24 timeWeightedAverageTick);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\nimport \"../utils/Context.sol\";\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor () {\n address msgSender = _msgSender();\n _owner = msgSender;\n emit OwnershipTransferred(address(0), msgSender);\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n _owner = address(0);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n emit OwnershipTransferred(_owner, newOwner);\n _owner = newOwner;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/ReentrancyGuard.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor () {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and make it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n" + }, + "@openzeppelin/contracts/math/SafeMath.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the substraction of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n *\n * _Available since v3.4._\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n *\n * _Available since v3.4._\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `+` operator.\n *\n * Requirements:\n *\n * - Addition cannot overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a, \"SafeMath: addition overflow\");\n return c;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting on\n * overflow (when the result is negative).\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b <= a, \"SafeMath: subtraction overflow\");\n return a - b;\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, reverting on\n * overflow.\n *\n * Counterpart to Solidity's `*` operator.\n *\n * Requirements:\n *\n * - Multiplication cannot overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) return 0;\n uint256 c = a * b;\n require(c / a == b, \"SafeMath: multiplication overflow\");\n return c;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting on\n * division by zero. The result is rounded towards zero.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b > 0, \"SafeMath: division by zero\");\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting when dividing by zero.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b > 0, \"SafeMath: modulo by zero\");\n return a % b;\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n * overflow (when the result is negative).\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {trySub}.\n *\n * Counterpart to Solidity's `-` operator.\n *\n * Requirements:\n *\n * - Subtraction cannot overflow.\n */\n function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b <= a, errorMessage);\n return a - b;\n }\n\n /**\n * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n * division by zero. The result is rounded towards zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryDiv}.\n *\n * Counterpart to Solidity's `/` operator. Note: this function uses a\n * `revert` opcode (which leaves remaining gas untouched) while Solidity\n * uses an invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n return a / b;\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n * reverting with custom message when dividing by zero.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryMod}.\n *\n * Counterpart to Solidity's `%` operator. This function uses a `revert`\n * opcode (which leaves remaining gas untouched) while Solidity uses an\n * invalid opcode to revert (consuming all remaining gas).\n *\n * Requirements:\n *\n * - The divisor cannot be zero.\n */\n function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n require(b > 0, errorMessage);\n return a % b;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n // solhint-disable-next-line no-inline-assembly\n assembly { size := extcodesize(account) }\n return size > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\n (bool success, ) = recipient.call{ value: amount }(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain`call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.call{ value: value }(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.staticcall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return _verifyCallResult(success, returndata, errorMessage);\n }\n\n function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "contracts/libs/ABDKMath64x64.sol": { + "content": "// SPDX-License-Identifier: BSD-4-Clause\n/*\n * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.\n * Author: Mikhail Vladimirov \n * Copyright (c) 2019, ABDK Consulting\n *\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n *\n * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n * All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by ABDK Consulting.\n * Neither the name of ABDK Consulting nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n * THIS SOFTWARE IS PROVIDED BY ABDK CONSULTING ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL ABDK CONSULTING BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\npragma solidity ^0.7.0;\n\n/**\n * Smart contract library of mathematical functions operating with signed\n * 64.64-bit fixed point numbers. Signed 64.64-bit fixed point number is\n * basically a simple fraction whose numerator is signed 128-bit integer and\n * denominator is 2^64. As long as denominator is always the same, there is no\n * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are\n * represented by int128 type holding only the numerator.\n *\n * Commit used - 16d7e1dd8628dfa2f88d5dadab731df7ada70bdd\n * Copied from - https://github.com/abdk-consulting/abdk-libraries-solidity/tree/v2.4\n * Changes - some function visibility switched to public, solidity version set to 0.7.x\n * Changes (cont) - revert strings added\n * solidity version set to ^0.7.0\n */\nlibrary ABDKMath64x64 {\n /*\n * Minimum value signed 64.64-bit fixed point number may have.\n * Minimum value signed 64.64-bit fixed point number may have.\n * Minimum value signed 64.64-bit fixed point number may have.\n * -2^127\n */\n int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;\n\n /*\n * Maximum value signed 64.64-bit fixed point number may have.\n * Maximum value signed 64.64-bit fixed point number may have.\n * Maximum value signed 64.64-bit fixed point number may have.\n * 2^127-1\n */\n int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n\n /**\n * Calculate x * y rounding down. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @param y signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function mul(int128 x, int128 y) internal pure returns (int128) {\n int256 result = (int256(x) * y) >> 64;\n require(result >= MIN_64x64 && result <= MAX_64x64, \"MUL-OVUF\");\n return int128(result);\n }\n\n /**\n * Calculate x * y rounding down, where x is signed 64.64 fixed point number\n * and y is unsigned 256-bit integer number. Revert on overflow.\n *\n * @param x signed 64.64 fixed point number\n * @param y unsigned 256-bit integer number\n * @return unsigned 256-bit integer number\n */\n function mulu(int128 x, uint256 y) internal pure returns (uint256) {\n if (y == 0) return 0;\n\n require(x >= 0, \"MULU-X0\");\n\n uint256 lo = (uint256(x) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;\n uint256 hi = uint256(x) * (y >> 128);\n\n require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, \"MULU-OF1\");\n hi <<= 64;\n\n require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo, \"MULU-OF2\");\n return hi + lo;\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return signed 64.64-bit fixed point number\n */\n function divu(uint256 x, uint256 y) public pure returns (int128) {\n require(y != 0, \"DIVU-INF\");\n uint128 result = divuu(x, y);\n require(result <= uint128(MAX_64x64), \"DIVU-OF\");\n return int128(result);\n }\n\n /**\n * Calculate binary logarithm of x. Revert if x <= 0.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function log_2(int128 x) public pure returns (int128) {\n require(x > 0, \"LOG_2-X0\");\n\n int256 msb = 0;\n int256 xc = x;\n if (xc >= 0x10000000000000000) {\n xc >>= 64;\n msb += 64;\n }\n if (xc >= 0x100000000) {\n xc >>= 32;\n msb += 32;\n }\n if (xc >= 0x10000) {\n xc >>= 16;\n msb += 16;\n }\n if (xc >= 0x100) {\n xc >>= 8;\n msb += 8;\n }\n if (xc >= 0x10) {\n xc >>= 4;\n msb += 4;\n }\n if (xc >= 0x4) {\n xc >>= 2;\n msb += 2;\n }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n int256 result = (msb - 64) << 64;\n uint256 ux = uint256(x) << uint256(127 - msb);\n for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {\n ux *= ux;\n uint256 b = ux >> 255;\n ux >>= 127 + b;\n result += bit * int256(b);\n }\n\n return int128(result);\n }\n\n /**\n * Calculate binary exponent of x. Revert on overflow.\n *\n * @param x signed 64.64-bit fixed point number\n * @return signed 64.64-bit fixed point number\n */\n function exp_2(int128 x) public pure returns (int128) {\n require(x < 0x400000000000000000, \"EXP_2-OF\"); // Overflow\n\n if (x < -0x400000000000000000) return 0; // Underflow\n\n uint256 result = 0x80000000000000000000000000000000;\n\n if (x & 0x8000000000000000 > 0) result = (result * 0x16A09E667F3BCC908B2FB1366EA957D3E) >> 128;\n if (x & 0x4000000000000000 > 0) result = (result * 0x1306FE0A31B7152DE8D5A46305C85EDEC) >> 128;\n if (x & 0x2000000000000000 > 0) result = (result * 0x1172B83C7D517ADCDF7C8C50EB14A791F) >> 128;\n if (x & 0x1000000000000000 > 0) result = (result * 0x10B5586CF9890F6298B92B71842A98363) >> 128;\n if (x & 0x800000000000000 > 0) result = (result * 0x1059B0D31585743AE7C548EB68CA417FD) >> 128;\n if (x & 0x400000000000000 > 0) result = (result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8) >> 128;\n if (x & 0x200000000000000 > 0) result = (result * 0x10163DA9FB33356D84A66AE336DCDFA3F) >> 128;\n if (x & 0x100000000000000 > 0) result = (result * 0x100B1AFA5ABCBED6129AB13EC11DC9543) >> 128;\n if (x & 0x80000000000000 > 0) result = (result * 0x10058C86DA1C09EA1FF19D294CF2F679B) >> 128;\n if (x & 0x40000000000000 > 0) result = (result * 0x1002C605E2E8CEC506D21BFC89A23A00F) >> 128;\n if (x & 0x20000000000000 > 0) result = (result * 0x100162F3904051FA128BCA9C55C31E5DF) >> 128;\n if (x & 0x10000000000000 > 0) result = (result * 0x1000B175EFFDC76BA38E31671CA939725) >> 128;\n if (x & 0x8000000000000 > 0) result = (result * 0x100058BA01FB9F96D6CACD4B180917C3D) >> 128;\n if (x & 0x4000000000000 > 0) result = (result * 0x10002C5CC37DA9491D0985C348C68E7B3) >> 128;\n if (x & 0x2000000000000 > 0) result = (result * 0x1000162E525EE054754457D5995292026) >> 128;\n if (x & 0x1000000000000 > 0) result = (result * 0x10000B17255775C040618BF4A4ADE83FC) >> 128;\n if (x & 0x800000000000 > 0) result = (result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB) >> 128;\n if (x & 0x400000000000 > 0) result = (result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9) >> 128;\n if (x & 0x200000000000 > 0) result = (result * 0x10000162E43F4F831060E02D839A9D16D) >> 128;\n if (x & 0x100000000000 > 0) result = (result * 0x100000B1721BCFC99D9F890EA06911763) >> 128;\n if (x & 0x80000000000 > 0) result = (result * 0x10000058B90CF1E6D97F9CA14DBCC1628) >> 128;\n if (x & 0x40000000000 > 0) result = (result * 0x1000002C5C863B73F016468F6BAC5CA2B) >> 128;\n if (x & 0x20000000000 > 0) result = (result * 0x100000162E430E5A18F6119E3C02282A5) >> 128;\n if (x & 0x10000000000 > 0) result = (result * 0x1000000B1721835514B86E6D96EFD1BFE) >> 128;\n if (x & 0x8000000000 > 0) result = (result * 0x100000058B90C0B48C6BE5DF846C5B2EF) >> 128;\n if (x & 0x4000000000 > 0) result = (result * 0x10000002C5C8601CC6B9E94213C72737A) >> 128;\n if (x & 0x2000000000 > 0) result = (result * 0x1000000162E42FFF037DF38AA2B219F06) >> 128;\n if (x & 0x1000000000 > 0) result = (result * 0x10000000B17217FBA9C739AA5819F44F9) >> 128;\n if (x & 0x800000000 > 0) result = (result * 0x1000000058B90BFCDEE5ACD3C1CEDC823) >> 128;\n if (x & 0x400000000 > 0) result = (result * 0x100000002C5C85FE31F35A6A30DA1BE50) >> 128;\n if (x & 0x200000000 > 0) result = (result * 0x10000000162E42FF0999CE3541B9FFFCF) >> 128;\n if (x & 0x100000000 > 0) result = (result * 0x100000000B17217F80F4EF5AADDA45554) >> 128;\n if (x & 0x80000000 > 0) result = (result * 0x10000000058B90BFBF8479BD5A81B51AD) >> 128;\n if (x & 0x40000000 > 0) result = (result * 0x1000000002C5C85FDF84BD62AE30A74CC) >> 128;\n if (x & 0x20000000 > 0) result = (result * 0x100000000162E42FEFB2FED257559BDAA) >> 128;\n if (x & 0x10000000 > 0) result = (result * 0x1000000000B17217F7D5A7716BBA4A9AE) >> 128;\n if (x & 0x8000000 > 0) result = (result * 0x100000000058B90BFBE9DDBAC5E109CCE) >> 128;\n if (x & 0x4000000 > 0) result = (result * 0x10000000002C5C85FDF4B15DE6F17EB0D) >> 128;\n if (x & 0x2000000 > 0) result = (result * 0x1000000000162E42FEFA494F1478FDE05) >> 128;\n if (x & 0x1000000 > 0) result = (result * 0x10000000000B17217F7D20CF927C8E94C) >> 128;\n if (x & 0x800000 > 0) result = (result * 0x1000000000058B90BFBE8F71CB4E4B33D) >> 128;\n if (x & 0x400000 > 0) result = (result * 0x100000000002C5C85FDF477B662B26945) >> 128;\n if (x & 0x200000 > 0) result = (result * 0x10000000000162E42FEFA3AE53369388C) >> 128;\n if (x & 0x100000 > 0) result = (result * 0x100000000000B17217F7D1D351A389D40) >> 128;\n if (x & 0x80000 > 0) result = (result * 0x10000000000058B90BFBE8E8B2D3D4EDE) >> 128;\n if (x & 0x40000 > 0) result = (result * 0x1000000000002C5C85FDF4741BEA6E77E) >> 128;\n if (x & 0x20000 > 0) result = (result * 0x100000000000162E42FEFA39FE95583C2) >> 128;\n if (x & 0x10000 > 0) result = (result * 0x1000000000000B17217F7D1CFB72B45E1) >> 128;\n if (x & 0x8000 > 0) result = (result * 0x100000000000058B90BFBE8E7CC35C3F0) >> 128;\n if (x & 0x4000 > 0) result = (result * 0x10000000000002C5C85FDF473E242EA38) >> 128;\n if (x & 0x2000 > 0) result = (result * 0x1000000000000162E42FEFA39F02B772C) >> 128;\n if (x & 0x1000 > 0) result = (result * 0x10000000000000B17217F7D1CF7D83C1A) >> 128;\n if (x & 0x800 > 0) result = (result * 0x1000000000000058B90BFBE8E7BDCBE2E) >> 128;\n if (x & 0x400 > 0) result = (result * 0x100000000000002C5C85FDF473DEA871F) >> 128;\n if (x & 0x200 > 0) result = (result * 0x10000000000000162E42FEFA39EF44D91) >> 128;\n if (x & 0x100 > 0) result = (result * 0x100000000000000B17217F7D1CF79E949) >> 128;\n if (x & 0x80 > 0) result = (result * 0x10000000000000058B90BFBE8E7BCE544) >> 128;\n if (x & 0x40 > 0) result = (result * 0x1000000000000002C5C85FDF473DE6ECA) >> 128;\n if (x & 0x20 > 0) result = (result * 0x100000000000000162E42FEFA39EF366F) >> 128;\n if (x & 0x10 > 0) result = (result * 0x1000000000000000B17217F7D1CF79AFA) >> 128;\n if (x & 0x8 > 0) result = (result * 0x100000000000000058B90BFBE8E7BCD6D) >> 128;\n if (x & 0x4 > 0) result = (result * 0x10000000000000002C5C85FDF473DE6B2) >> 128;\n if (x & 0x2 > 0) result = (result * 0x1000000000000000162E42FEFA39EF358) >> 128;\n if (x & 0x1 > 0) result = (result * 0x10000000000000000B17217F7D1CF79AB) >> 128;\n\n result >>= uint256(63 - (x >> 64));\n require(result <= uint256(MAX_64x64));\n\n return int128(result);\n }\n\n /**\n * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit\n * integer numbers. Revert on overflow or when y is zero.\n *\n * @param x unsigned 256-bit integer number\n * @param y unsigned 256-bit integer number\n * @return unsigned 64.64-bit fixed point number\n */\n function divuu(uint256 x, uint256 y) private pure returns (uint128) {\n require(y != 0);\n\n uint256 result;\n\n if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) result = (x << 64) / y;\n else {\n uint256 msb = 192;\n uint256 xc = x >> 192;\n if (xc >= 0x100000000) {\n xc >>= 32;\n msb += 32;\n }\n if (xc >= 0x10000) {\n xc >>= 16;\n msb += 16;\n }\n if (xc >= 0x100) {\n xc >>= 8;\n msb += 8;\n }\n if (xc >= 0x10) {\n xc >>= 4;\n msb += 4;\n }\n if (xc >= 0x4) {\n xc >>= 2;\n msb += 2;\n }\n if (xc >= 0x2) msb += 1; // No need to shift xc anymore\n\n result = (x << (255 - msb)) / (((y - 1) >> (msb - 191)) + 1);\n require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, \"DIVUU-OF1\");\n\n uint256 hi = result * (y >> 128);\n uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);\n\n uint256 xh = x >> 192;\n uint256 xl = x << 64;\n\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n lo = hi << 128;\n if (xl < lo) xh -= 1;\n xl -= lo; // We rely on overflow behavior here\n\n assert(xh == hi >> 128);\n\n result += xl / y;\n }\n\n require(result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, \"DIVUU-OF2\");\n return uint128(result);\n }\n}\n" + }, + "contracts/libs/VaultLib.sol": { + "content": "//SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity =0.7.6;\n\n//interface\nimport {INonfungiblePositionManager} from \"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\";\n\n//lib\nimport {SafeMath} from \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport {TickMathExternal} from \"./TickMathExternal.sol\";\nimport {SqrtPriceMathPartial} from \"./SqrtPriceMathPartial.sol\";\nimport {Uint256Casting} from \"./Uint256Casting.sol\";\n\n/**\n * Error code:\n * V1: Vault already had nft\n * V2: Vault has no NFT\n */\nlibrary VaultLib {\n using SafeMath for uint256;\n using Uint256Casting for uint256;\n\n uint256 constant ONE_ONE = 1e36;\n\n // the collateralization ratio (CR) is checked with the numerator and denominator separately\n // a user is safe if - collateral value >= (COLLAT_RATIO_NUMER/COLLAT_RATIO_DENOM)* debt value\n uint256 public constant CR_NUMERATOR = 3;\n uint256 public constant CR_DENOMINATOR = 2;\n\n struct Vault {\n // the address that can update the vault\n address operator;\n // uniswap position token id deposited into the vault as collateral\n // 2^32 is 4,294,967,296, which means the vault structure will work with up to 4 billion positions\n uint32 NftCollateralId;\n // amount of eth (wei) used in the vault as collateral\n // 2^96 / 1e18 = 79,228,162,514, which means a vault can store up to 79 billion eth\n // when we need to do calculations, we always cast this number to uint256 to avoid overflow\n uint96 collateralAmount;\n // amount of wPowerPerp minted from the vault\n uint128 shortAmount;\n }\n\n /**\n * @notice add eth collateral to a vault\n * @param _vault in-memory vault\n * @param _amount amount of eth to add\n */\n function addEthCollateral(Vault memory _vault, uint256 _amount) internal pure {\n _vault.collateralAmount = uint256(_vault.collateralAmount).add(_amount).toUint96();\n }\n\n /**\n * @notice add uniswap position token collateral to a vault\n * @param _vault in-memory vault\n * @param _tokenId uniswap position token id\n */\n function addUniNftCollateral(Vault memory _vault, uint256 _tokenId) internal pure {\n require(_vault.NftCollateralId == 0, \"V1\");\n require(_tokenId != 0, \"C23\");\n _vault.NftCollateralId = _tokenId.toUint32();\n }\n\n /**\n * @notice remove eth collateral from a vault\n * @param _vault in-memory vault\n * @param _amount amount of eth to remove\n */\n function removeEthCollateral(Vault memory _vault, uint256 _amount) internal pure {\n _vault.collateralAmount = uint256(_vault.collateralAmount).sub(_amount).toUint96();\n }\n\n /**\n * @notice remove uniswap position token collateral from a vault\n * @param _vault in-memory vault\n */\n function removeUniNftCollateral(Vault memory _vault) internal pure {\n require(_vault.NftCollateralId != 0, \"V2\");\n _vault.NftCollateralId = 0;\n }\n\n /**\n * @notice add debt to vault\n * @param _vault in-memory vault\n * @param _amount amount of debt to add\n */\n function addShort(Vault memory _vault, uint256 _amount) internal pure {\n _vault.shortAmount = uint256(_vault.shortAmount).add(_amount).toUint128();\n }\n\n /**\n * @notice remove debt from vault\n * @param _vault in-memory vault\n * @param _amount amount of debt to remove\n */\n function removeShort(Vault memory _vault, uint256 _amount) internal pure {\n _vault.shortAmount = uint256(_vault.shortAmount).sub(_amount).toUint128();\n }\n\n /**\n * @notice check if a vault is properly collateralized\n * @param _vault the vault we want to check\n * @param _positionManager address of the uniswap position manager\n * @param _normalizationFactor current _normalizationFactor\n * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18\n * @param _minCollateral minimum collateral that needs to be in a vault\n * @param _wsqueethPoolTick current price tick for wsqueeth pool\n * @param _isWethToken0 whether weth is token0 in the wsqueeth pool\n * @return true if the vault is sufficiently collateralized\n * @return true if the vault is considered as a dust vault\n */\n function getVaultStatus(\n Vault memory _vault,\n address _positionManager,\n uint256 _normalizationFactor,\n uint256 _ethQuoteCurrencyPrice,\n uint256 _minCollateral,\n int24 _wsqueethPoolTick,\n bool _isWethToken0\n ) internal view returns (bool, bool) {\n if (_vault.shortAmount == 0) return (true, false);\n\n uint256 debtValueInETH = uint256(_vault.shortAmount).mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div(\n ONE_ONE\n );\n uint256 totalCollateral = _getEffectiveCollateral(\n _vault,\n _positionManager,\n _normalizationFactor,\n _ethQuoteCurrencyPrice,\n _wsqueethPoolTick,\n _isWethToken0\n );\n\n bool isDust = totalCollateral < _minCollateral;\n bool isAboveWater = totalCollateral.mul(CR_DENOMINATOR) >= debtValueInETH.mul(CR_NUMERATOR);\n return (isAboveWater, isDust);\n }\n\n /**\n * @notice get the total effective collateral of a vault, which is:\n * collateral amount + uniswap position token equivelent amount in eth\n * @param _vault the vault we want to check\n * @param _positionManager address of the uniswap position manager\n * @param _normalizationFactor current _normalizationFactor\n * @param _ethQuoteCurrencyPrice current eth price scaled by 1e18\n * @param _wsqueethPoolTick current price tick for wsqueeth pool\n * @param _isWethToken0 whether weth is token0 in the wsqueeth pool\n * @return the total worth of collateral in the vault\n */\n function _getEffectiveCollateral(\n Vault memory _vault,\n address _positionManager,\n uint256 _normalizationFactor,\n uint256 _ethQuoteCurrencyPrice,\n int24 _wsqueethPoolTick,\n bool _isWethToken0\n ) internal view returns (uint256) {\n if (_vault.NftCollateralId == 0) return _vault.collateralAmount;\n\n // the user has deposited uniswap position token as collateral, see how much eth / wSqueeth the uniswap position token has\n (uint256 nftEthAmount, uint256 nftWsqueethAmount) = _getUniPositionBalances(\n _positionManager,\n _vault.NftCollateralId,\n _wsqueethPoolTick,\n _isWethToken0\n );\n // convert squeeth amount from uniswap position token as equivalent amount of collateral\n uint256 wSqueethIndexValueInEth = nftWsqueethAmount.mul(_normalizationFactor).mul(_ethQuoteCurrencyPrice).div(\n ONE_ONE\n );\n // add eth value from uniswap position token as collateral\n return nftEthAmount.add(wSqueethIndexValueInEth).add(_vault.collateralAmount);\n }\n\n /**\n * @notice determine how much eth / wPowerPerp the uniswap position contains\n * @param _positionManager address of the uniswap position manager\n * @param _tokenId uniswap position token id\n * @param _wPowerPerpPoolTick current price tick\n * @param _isWethToken0 whether weth is token0 in the pool\n * @return ethAmount the eth amount this LP token contains\n * @return wPowerPerpAmount the wPowerPerp amount this LP token contains\n */\n function _getUniPositionBalances(\n address _positionManager,\n uint256 _tokenId,\n int24 _wPowerPerpPoolTick,\n bool _isWethToken0\n ) internal view returns (uint256 ethAmount, uint256 wPowerPerpAmount) {\n (\n int24 tickLower,\n int24 tickUpper,\n uint128 liquidity,\n uint128 tokensOwed0,\n uint128 tokensOwed1\n ) = _getUniswapPositionInfo(_positionManager, _tokenId);\n (uint256 amount0, uint256 amount1) = _getToken0Token1Balances(\n tickLower,\n tickUpper,\n _wPowerPerpPoolTick,\n liquidity\n );\n\n return\n _isWethToken0\n ? (amount0 + tokensOwed0, amount1 + tokensOwed1)\n : (amount1 + tokensOwed1, amount0 + tokensOwed0);\n }\n\n /**\n * @notice get uniswap position token info\n * @param _positionManager address of the uniswap position position manager\n * @param _tokenId uniswap position token id\n * @return tickLower lower tick of the position\n * @return tickUpper upper tick of the position\n * @return liquidity raw liquidity amount of the position\n * @return tokensOwed0 amount of token 0 can be collected as fee\n * @return tokensOwed1 amount of token 1 can be collected as fee\n */\n function _getUniswapPositionInfo(address _positionManager, uint256 _tokenId)\n internal\n view\n returns (\n int24,\n int24,\n uint128,\n uint128,\n uint128\n )\n {\n INonfungiblePositionManager positionManager = INonfungiblePositionManager(_positionManager);\n (\n ,\n ,\n ,\n ,\n ,\n int24 tickLower,\n int24 tickUpper,\n uint128 liquidity,\n ,\n ,\n uint128 tokensOwed0,\n uint128 tokensOwed1\n ) = positionManager.positions(_tokenId);\n return (tickLower, tickUpper, liquidity, tokensOwed0, tokensOwed1);\n }\n\n /**\n * @notice get balances of token0 / token1 in a uniswap position\n * @dev knowing liquidity, tick range, and current tick gives balances\n * @param _tickLower address of the uniswap position manager\n * @param _tickUpper uniswap position token id\n * @param _tick current price tick used for calculation\n * @return amount0 the amount of token0 in the uniswap position token\n * @return amount1 the amount of token1 in the uniswap position token\n */\n function _getToken0Token1Balances(\n int24 _tickLower,\n int24 _tickUpper,\n int24 _tick,\n uint128 _liquidity\n ) internal pure returns (uint256 amount0, uint256 amount1) {\n // get the current price and tick from wPowerPerp pool\n uint160 sqrtPriceX96 = TickMathExternal.getSqrtRatioAtTick(_tick);\n\n if (_tick < _tickLower) {\n amount0 = SqrtPriceMathPartial.getAmount0Delta(\n TickMathExternal.getSqrtRatioAtTick(_tickLower),\n TickMathExternal.getSqrtRatioAtTick(_tickUpper),\n _liquidity,\n true\n );\n } else if (_tick < _tickUpper) {\n amount0 = SqrtPriceMathPartial.getAmount0Delta(\n sqrtPriceX96,\n TickMathExternal.getSqrtRatioAtTick(_tickUpper),\n _liquidity,\n true\n );\n amount1 = SqrtPriceMathPartial.getAmount1Delta(\n TickMathExternal.getSqrtRatioAtTick(_tickLower),\n sqrtPriceX96,\n _liquidity,\n true\n );\n } else {\n amount1 = SqrtPriceMathPartial.getAmount1Delta(\n TickMathExternal.getSqrtRatioAtTick(_tickLower),\n TickMathExternal.getSqrtRatioAtTick(_tickUpper),\n _liquidity,\n true\n );\n }\n }\n}\n" + }, + "contracts/libs/Uint256Casting.sol": { + "content": "//SPDX-License-Identifier: MIT\n\npragma solidity =0.7.6;\n\nlibrary Uint256Casting {\n /**\n * @notice cast a uint256 to a uint128, revert on overflow\n * @param y the uint256 to be downcasted\n * @return z the downcasted integer, now type uint128\n */\n function toUint128(uint256 y) internal pure returns (uint128 z) {\n require((z = uint128(y)) == y, \"OF128\");\n }\n\n /**\n * @notice cast a uint256 to a uint96, revert on overflow\n * @param y the uint256 to be downcasted\n * @return z the downcasted integer, now type uint96\n */\n function toUint96(uint256 y) internal pure returns (uint96 z) {\n require((z = uint96(y)) == y, \"OF96\");\n }\n\n /**\n * @notice cast a uint256 to a uint32, revert on overflow\n * @param y the uint256 to be downcasted\n * @return z the downcasted integer, now type uint32\n */\n function toUint32(uint256 y) internal pure returns (uint32 z) {\n require((z = uint32(y)) == y, \"OF32\");\n }\n}\n" + }, + "contracts/libs/Power2Base.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity =0.7.6;\n\n//interface\nimport {IOracle} from \"../interfaces/IOracle.sol\";\n\n//lib\nimport {SafeMath} from \"@openzeppelin/contracts/math/SafeMath.sol\";\n\nlibrary Power2Base {\n using SafeMath for uint256;\n\n uint32 private constant TWAP_PERIOD = 420 seconds;\n uint256 private constant INDEX_SCALE = 1e4;\n uint256 private constant ONE = 1e18;\n uint256 private constant ONE_ONE = 1e36;\n\n /**\n * @notice return the scaled down index of the power perp in USD, scaled by 18 decimals\n * @param _period period of time for the twap in seconds (cannot be longer than maximum period for the pool)\n * @param _oracle oracle address\n * @param _ethQuoteCurrencyPool uniswap v3 pool for weth / quoteCurrency\n * @param _weth weth address\n * @param _quoteCurrency quoteCurrency address\n * @return for squeeth, return ethPrice^2\n */\n function _getIndex(\n uint32 _period,\n address _oracle,\n address _ethQuoteCurrencyPool,\n address _weth,\n address _quoteCurrency\n ) internal view returns (uint256) {\n uint256 ethQuoteCurrencyPrice = _getScaledTwap(\n _oracle,\n _ethQuoteCurrencyPool,\n _weth,\n _quoteCurrency,\n _period,\n false\n );\n return ethQuoteCurrencyPrice.mul(ethQuoteCurrencyPrice).div(ONE);\n }\n\n /**\n * @notice return the unscaled index of the power perp in USD, scaled by 18 decimals\n * @param _period period of time for the twap in seconds (cannot be longer than maximum period for the pool)\n * @param _oracle oracle address\n * @param _ethQuoteCurrencyPool uniswap v3 pool for weth / quoteCurrency\n * @param _weth weth address\n * @param _quoteCurrency quoteCurrency address\n * @return for squeeth, return ethPrice^2\n */\n function _getUnscaledIndex(\n uint32 _period,\n address _oracle,\n address _ethQuoteCurrencyPool,\n address _weth,\n address _quoteCurrency\n ) internal view returns (uint256) {\n uint256 ethQuoteCurrencyPrice = _getTwap(_oracle, _ethQuoteCurrencyPool, _weth, _quoteCurrency, _period, false);\n return ethQuoteCurrencyPrice.mul(ethQuoteCurrencyPrice).div(ONE);\n }\n\n /**\n * @notice return the mark price of power perp in quoteCurrency, scaled by 18 decimals\n * @param _period period of time for the twap in seconds (cannot be longer than maximum period for the pool)\n * @param _oracle oracle address\n * @param _wSqueethEthPool uniswap v3 pool for wSqueeth / weth\n * @param _ethQuoteCurrencyPool uniswap v3 pool for weth / quoteCurrency\n * @param _weth weth address\n * @param _quoteCurrency quoteCurrency address\n * @param _wSqueeth wSqueeth address\n * @param _normalizationFactor current normalization factor\n * @return for squeeth, return ethPrice * squeethPriceInEth\n */\n function _getDenormalizedMark(\n uint32 _period,\n address _oracle,\n address _wSqueethEthPool,\n address _ethQuoteCurrencyPool,\n address _weth,\n address _quoteCurrency,\n address _wSqueeth,\n uint256 _normalizationFactor\n ) internal view returns (uint256) {\n uint256 ethQuoteCurrencyPrice = _getScaledTwap(\n _oracle,\n _ethQuoteCurrencyPool,\n _weth,\n _quoteCurrency,\n _period,\n false\n );\n uint256 wsqueethEthPrice = _getTwap(_oracle, _wSqueethEthPool, _wSqueeth, _weth, _period, false);\n\n return wsqueethEthPrice.mul(ethQuoteCurrencyPrice).div(_normalizationFactor);\n }\n\n /**\n * @notice get the fair collateral value for a _debtAmount of wSqueeth\n * @dev the actual amount liquidator can get should have a 10% bonus on top of this value.\n * @param _debtAmount wSqueeth amount paid by liquidator\n * @param _oracle oracle address\n * @param _wSqueethEthPool uniswap v3 pool for wSqueeth / weth\n * @param _wSqueeth wSqueeth address\n * @param _weth weth address\n * @return returns value of debt in ETH\n */\n function _getDebtValueInEth(\n uint256 _debtAmount,\n address _oracle,\n address _wSqueethEthPool,\n address _wSqueeth,\n address _weth\n ) internal view returns (uint256) {\n uint256 wSqueethPrice = _getTwap(_oracle, _wSqueethEthPool, _wSqueeth, _weth, TWAP_PERIOD, false);\n return _debtAmount.mul(wSqueethPrice).div(ONE);\n }\n\n /**\n * @notice request twap from our oracle, scaled down by INDEX_SCALE\n * @param _oracle oracle address\n * @param _pool uniswap v3 pool address\n * @param _base base currency. to get eth/usd price, eth is base token\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\n * @param _period number of seconds in the past to start calculating time-weighted average.\n * @param _checkPeriod check that period is not longer than maximum period for the pool to prevent reverts\n * @return twap price scaled down by INDEX_SCALE\n */\n function _getScaledTwap(\n address _oracle,\n address _pool,\n address _base,\n address _quote,\n uint32 _period,\n bool _checkPeriod\n ) internal view returns (uint256) {\n uint256 twap = _getTwap(_oracle, _pool, _base, _quote, _period, _checkPeriod);\n return twap.div(INDEX_SCALE);\n }\n\n /**\n * @notice request twap from our oracle\n * @dev this will revert if period is > max period for the pool\n * @param _oracle oracle address\n * @param _pool uniswap v3 pool address\n * @param _base base currency. to get eth/quoteCurrency price, eth is base token\n * @param _quote quote currency. to get eth/quoteCurrency price, quoteCurrency is the quote currency\n * @param _period number of seconds in the past to start calculating time-weighted average\n * @param _checkPeriod check that period is not longer than maximum period for the pool to prevent reverts\n * @return human readable price. scaled by 1e18\n */\n function _getTwap(\n address _oracle,\n address _pool,\n address _base,\n address _quote,\n uint32 _period,\n bool _checkPeriod\n ) internal view returns (uint256) {\n // period reaching this point should be check, otherwise might revert\n return IOracle(_oracle).getTwap(_pool, _base, _quote, _period, _checkPeriod);\n }\n\n /**\n * @notice get the index value of wsqueeth in wei, used when system settles\n * @dev the index of squeeth is ethPrice^2, so each squeeth will need to pay out {ethPrice} eth\n * @param _wsqueethAmount amount of wsqueeth used in settlement\n * @param _indexPriceForSettlement index price for settlement\n * @param _normalizationFactor current normalization factor\n * @return amount in wei that should be paid to the token holder\n */\n function _getLongSettlementValue(\n uint256 _wsqueethAmount,\n uint256 _indexPriceForSettlement,\n uint256 _normalizationFactor\n ) internal pure returns (uint256) {\n return _wsqueethAmount.mul(_normalizationFactor).mul(_indexPriceForSettlement).div(ONE_ONE);\n }\n}\n" + }, + "@openzeppelin/contracts/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\nimport \"./IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\nimport \"./IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Enumerable is IERC721 {\n\n /**\n * @dev Returns the total amount of tokens stored by the contract.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);\n\n /**\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n * Use along with {totalSupply} to enumerate all tokens.\n */\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n" + }, + "@uniswap/v3-periphery/contracts/interfaces/IPoolInitializer.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\n/// @title Creates and initializes V3 Pools\n/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that\n/// require the pool to exist.\ninterface IPoolInitializer {\n /// @notice Creates a new pool if it does not exist, then initializes if not initialized\n /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool\n /// @param token0 The contract address of token0 of the pool\n /// @param token1 The contract address of token1 of the pool\n /// @param fee The fee amount of the v3 pool for the specified token pair\n /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value\n /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary\n function createAndInitializePoolIfNecessary(\n address token0,\n address token1,\n uint24 fee,\n uint160 sqrtPriceX96\n ) external payable returns (address pool);\n}\n" + }, + "@uniswap/v3-periphery/contracts/interfaces/IERC721Permit.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\nimport '@openzeppelin/contracts/token/ERC721/IERC721.sol';\n\n/// @title ERC721 with permit\n/// @notice Extension to ERC721 that includes a permit function for signature based approvals\ninterface IERC721Permit is IERC721 {\n /// @notice The permit typehash used in the permit signature\n /// @return The typehash for the permit\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n\n /// @notice The domain separator used in the permit signature\n /// @return The domain seperator used in encoding of permit signature\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n /// @notice Approve of a specific token ID for spending by spender via signature\n /// @param spender The account that is being approved\n /// @param tokenId The ID of the token that is being approved for spending\n /// @param deadline The deadline timestamp by which the call must be mined for the approve to work\n /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`\n /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`\n /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`\n function permit(\n address spender,\n uint256 tokenId,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external payable;\n}\n" + }, + "@uniswap/v3-periphery/contracts/interfaces/IPeripheryPayments.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\n/// @title Periphery Payments\n/// @notice Functions to ease deposits and withdrawals of ETH\ninterface IPeripheryPayments {\n /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.\n /// @param amountMinimum The minimum amount of WETH9 to unwrap\n /// @param recipient The address receiving ETH\n function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;\n\n /// @notice Refunds any ETH balance held by this contract to the `msg.sender`\n /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps\n /// that use ether for the input amount\n function refundETH() external payable;\n\n /// @notice Transfers the full amount of a token held by this contract to recipient\n /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users\n /// @param token The contract address of the token which will be transferred to `recipient`\n /// @param amountMinimum The minimum amount of token required for a transfer\n /// @param recipient The destination address of the token\n function sweepToken(\n address token,\n uint256 amountMinimum,\n address recipient\n ) external payable;\n}\n" + }, + "@uniswap/v3-periphery/contracts/interfaces/IPeripheryImmutableState.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Immutable state\n/// @notice Functions that return immutable state of the router\ninterface IPeripheryImmutableState {\n /// @return Returns the address of the Uniswap V3 factory\n function factory() external view returns (address);\n\n /// @return Returns the address of WETH9\n function WETH9() external view returns (address);\n}\n" + }, + "@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee\nlibrary PoolAddress {\n bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;\n\n /// @notice The identifying key of the pool\n struct PoolKey {\n address token0;\n address token1;\n uint24 fee;\n }\n\n /// @notice Returns PoolKey: the ordered tokens with the matched fee levels\n /// @param tokenA The first token of a pool, unsorted\n /// @param tokenB The second token of a pool, unsorted\n /// @param fee The fee level of the pool\n /// @return Poolkey The pool details with ordered token0 and token1 assignments\n function getPoolKey(\n address tokenA,\n address tokenB,\n uint24 fee\n ) internal pure returns (PoolKey memory) {\n if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);\n return PoolKey({token0: tokenA, token1: tokenB, fee: fee});\n }\n\n /// @notice Deterministically computes the pool address given the factory and PoolKey\n /// @param factory The Uniswap V3 factory contract address\n /// @param key The PoolKey\n /// @return pool The contract address of the V3 pool\n function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {\n require(key.token0 < key.token1);\n pool = address(\n uint256(\n keccak256(\n abi.encodePacked(\n hex'ff',\n factory,\n keccak256(abi.encode(key.token0, key.token1, key.fee)),\n POOL_INIT_CODE_HASH\n )\n )\n )\n );\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n" + }, + "contracts/libs/TickMathExternal.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.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 TickMathExternal {\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) public pure returns (uint160 sqrtPriceX96) {\n uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\n require(absTick <= uint256(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 /// @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) external pure returns (int24 tick) {\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" + }, + "contracts/libs/SqrtPriceMathPartial.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\nimport \"@uniswap/v3-core/contracts/libraries/FullMath.sol\";\nimport \"@uniswap/v3-core/contracts/libraries/UnsafeMath.sol\";\nimport \"@uniswap/v3-core/contracts/libraries/FixedPoint96.sol\";\n\n/// @title Functions based on Q64.96 sqrt price and liquidity\n/// @notice Exposes two functions from @uniswap/v3-core SqrtPriceMath\n/// that use square root of price as a Q64.96 and liquidity to compute deltas\nlibrary SqrtPriceMathPartial {\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 ) external 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\n require(sqrtRatioAX96 > 0);\n\n return\n roundUp\n ? UnsafeMath.divRoundingUp(\n FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96),\n sqrtRatioAX96\n )\n : FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96;\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 ) external 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" + }, + "@uniswap/v3-core/contracts/libraries/FullMath.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.4.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 // 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;\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 /// @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 result = mulDiv(a, b, denominator);\n if (mulmod(a, b, denominator) > 0) {\n require(result < type(uint256).max);\n result++;\n }\n }\n}\n" + }, + "@uniswap/v3-core/contracts/libraries/UnsafeMath.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\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" + }, + "@uniswap/v3-core/contracts/libraries/FixedPoint96.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\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;\n}\n" + }, + "contracts/test/LiquidationHelper.sol": { + "content": "//SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity =0.7.6;\npragma abicoder v2;\n\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\nimport {SafeMath} from \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\n\nimport {IUniswapV3Pool} from \"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\";\nimport {IController} from \"../interfaces/IController.sol\";\n\nimport {IWETH9} from \"../interfaces/IWETH9.sol\";\nimport {IWPowerPerp} from \"../interfaces/IWPowerPerp.sol\";\nimport {IShortPowerPerp} from \"../interfaces/IShortPowerPerp.sol\";\nimport {IOracle} from \"../interfaces/IOracle.sol\";\n\nimport {VaultLib} from \"../libs/VaultLib.sol\";\nimport {Uint256Casting} from \"../libs/Uint256Casting.sol\";\nimport {Power2Base} from \"../libs/Power2Base.sol\";\n\ncontract LiquidationHelper {\n\n using SafeMath for uint256;\n using Uint256Casting for uint256;\n using VaultLib for VaultLib.Vault;\n\n // constatns\n uint256 public constant MIN_COLLATERAL = 6.9 ether;\n uint32 public constant TWAP_PERIOD = 420 seconds;\n\n address immutable public controller;\n address immutable public oracle;\n address immutable public wPowerPerp;\n address immutable public weth;\n address immutable public quoteCurrency;\n address immutable public ethQuoteCurrencyPool;\n address immutable public wPowerPerpPool;\n address immutable public uniswapPositionManager;\n\n bool immutable isWethToken0;\n \n constructor(\n address _controller,\n address _oracle,\n address _wPowerPerp,\n address _weth,\n address _quoteCurrency,\n address _ethQuoteCurrencyPool,\n address _wPowerPerpPool,\n address _uniPositionManager\n ) {\n controller = _controller;\n oracle = _oracle;\n wPowerPerp = _wPowerPerp;\n weth = _weth;\n quoteCurrency = _quoteCurrency;\n ethQuoteCurrencyPool = _ethQuoteCurrencyPool;\n wPowerPerpPool = _wPowerPerpPool;\n uniswapPositionManager = _uniPositionManager;\n isWethToken0 = _weth < _wPowerPerp;\n }\n \n /**\n * @notice check the result of a call to liquidate\n * @dev can be used before sending a transaction to determine if the vault is unsafe, if vault can be saved\n * @dev the minimum wPowerPerp to repay, the maximum wPowerPerp to repay and the proceeds at max wPowerPerp to repay\n * @param _vaultId vault to liquidate\n * @return isUnsafe\n * @return isLiquidatable after reducing debt\n * @return max wPowerPerp to repay, this is only non-zero if saving a vault is not possible\n * @return proceeds at max wPowerPerp to repay, if isLiquidatable after reducing debt is false, this is the bounty for saving a vault\n */\n function checkLiquidation(uint256 _vaultId)\n external\n view\n returns (\n bool,\n bool,\n uint256,\n uint256\n )\n {\n uint256 _newNormalizationFactor = IController(controller).getExpectedNormalizationFactor();\n return _checkLiquidation(_vaultId, _newNormalizationFactor);\n }\n\n /**\n * @notice check that the vault has enough collateral\n * @param _vault in-memory vault\n * @param _normalizationFactor normalization factor\n * @return true if the vault is properly collateralized\n */\n function _isVaultSafe(VaultLib.Vault memory _vault, uint256 _normalizationFactor) internal view returns (bool) {\n (bool isSafe, ) = _getVaultStatus(_vault, _normalizationFactor);\n return isSafe;\n }\n\n /**\n * @notice return if the vault is properly collateralized and if it is a dust vault\n * @param _vault the Vault memory to update\n * @param _normalizationFactor normalization factor\n * @return true if the vault is safe\n * @return true if the vault is a dust vault\n */\n function _getVaultStatus(VaultLib.Vault memory _vault, uint256 _normalizationFactor)\n internal\n view\n returns (bool, bool)\n {\n uint256 scaledEthPrice = Power2Base._getScaledTwap(\n oracle,\n ethQuoteCurrencyPool,\n weth,\n quoteCurrency,\n TWAP_PERIOD,\n true // do not call more than maximum period so it does not revert\n );\n return\n VaultLib.getVaultStatus(\n _vault,\n uniswapPositionManager,\n _normalizationFactor,\n scaledEthPrice,\n MIN_COLLATERAL,\n IOracle(oracle).getTimeWeightedAverageTickSafe(wPowerPerpPool, TWAP_PERIOD),\n isWethToken0\n );\n }\n\n /**\n * @notice check the result of a call to liquidate\n * @dev can be used before sending a transaction to determine if the vault is unsafe, if vault can be saved\n * @dev the minimum wPowerPerp to repay, the maximum wPowerPerp to repay and the proceeds at max wPowerPerp to repay\n * @param _vaultId vault to liquidate\n * @return isUnsafe\n * @return isLiquidatable after reducing debt\n * @return max wPowerPerp to repay, this is only non-zero if saving a vault is not possible\n * @return proceeds at max wPowerPerp to repay, if isLiquidatable after reducing debt is false, this is the bounty for saving a vault\n */\n function _checkLiquidation(uint256 _vaultId, uint256 _normalizationFactor)\n internal\n view\n returns (\n bool,\n bool,\n uint256,\n uint256\n )\n {\n VaultLib.Vault memory cachedVault = IController(controller).vaults(_vaultId);\n\n if (_isVaultSafe(cachedVault, _normalizationFactor)) {\n return (false, false, 0, 0);\n }\n\n // if there's a Uniswap Position token in the vault, stimulate reducing debt first\n if (cachedVault.NftCollateralId != 0) {\n // using current tick to check how much nft is worth\n (, int24 spotTick, , , , , ) = IUniswapV3Pool(wPowerPerpPool).slot0();\n\n // simulate vault state after removing nft\n (uint256 nftEthAmount, uint256 nftWPowerperpAmount) = VaultLib._getUniPositionBalances(\n uniswapPositionManager,\n cachedVault.NftCollateralId,\n spotTick,\n isWethToken0\n );\n\n (, , uint256 bounty) = _getReduceDebtResultInVault(\n cachedVault,\n nftEthAmount,\n nftWPowerperpAmount,\n true\n );\n\n if (_isVaultSafe(cachedVault, _normalizationFactor)) {\n return (true, false, 0, bounty);\n }\n //re-add bounty if not safe after reducing debt\n cachedVault.addEthCollateral(bounty);\n }\n\n // assuming the max the liquidator is willing to pay full debt, this should give us the max one can liquidate\n (uint256 wMaxAmountToLiquidate, uint256 collateralToPay) = _getLiquidationResult(\n cachedVault.shortAmount,\n cachedVault.shortAmount,\n cachedVault.collateralAmount\n );\n\n return (true, true, wMaxAmountToLiquidate, collateralToPay);\n }\n\n /**\n * @notice get the expected excess, burnAmount and bounty if Uniswap position token got burned\n * @dev this function will update the vault memory in-place\n * @return burnAmount amount of wSqueeth that should be burned\n * @return wPowerPerpExcess amount of wSqueeth that should be send to the vault owner\n * @return bounty amount of bounty should be paid out to caller\n */\n function _getReduceDebtResultInVault(\n VaultLib.Vault memory _vault,\n uint256 nftEthAmount,\n uint256 nftWPowerperpAmount,\n bool _payBounty\n )\n internal\n view\n returns (\n uint256,\n uint256,\n uint256\n )\n {\n uint256 bounty;\n if (_payBounty) bounty = _getReduceDebtBounty(nftEthAmount, nftWPowerperpAmount);\n\n uint256 burnAmount = nftWPowerperpAmount;\n uint256 wPowerPerpExcess;\n\n if (nftWPowerperpAmount > _vault.shortAmount) {\n wPowerPerpExcess = nftWPowerperpAmount.sub(_vault.shortAmount);\n burnAmount = _vault.shortAmount;\n }\n\n _vault.removeShort(burnAmount);\n _vault.removeUniNftCollateral();\n _vault.addEthCollateral(nftEthAmount);\n _vault.removeEthCollateral(bounty);\n\n return (burnAmount, wPowerPerpExcess, bounty);\n }\n\n /**\n * @notice get how much bounty you can get by helping a vault reducing the debt.\n * @dev bounty is 2% of the total value of the position token\n * @param _ethWithdrawn amount of eth withdrawn from uniswap by redeeming the position token\n * @param _wPowerPerpReduced amount of wPowerPerp withdrawn from uniswap by redeeming the position token\n */\n function _getReduceDebtBounty(\n uint256 _ethWithdrawn,\n uint256 _wPowerPerpReduced\n ) internal view returns (uint256) {\n return\n Power2Base\n ._getDebtValueInEth(\n _wPowerPerpReduced,\n oracle,\n wPowerPerpPool,\n wPowerPerp,\n weth\n )\n .add(_ethWithdrawn)\n .mul(2)\n .div(100);\n }\n\n /**\n * @notice get the expected wPowerPerp needed to liquidate a vault.\n * @dev a liquidator cannot liquidate more than half of a vault, unless only liquidating half of the debt will make the vault a \"dust vault\"\n * @dev a liquidator cannot take out more collateral than the vault holds\n * @param _maxWPowerPerpAmount the max amount of wPowerPerp willing to pay\n * @param _vaultShortAmount the amount of short in the vault\n * @param _maxWPowerPerpAmount the amount of collateral in the vault\n * @return finalLiquidateAmount the amount that should be liquidated. This amount can be higher than _maxWPowerPerpAmount, which should be checked\n * @return collateralToPay final amount of collateral paying out to the liquidator\n */\n function _getLiquidationResult(\n uint256 _maxWPowerPerpAmount,\n uint256 _vaultShortAmount,\n uint256 _vaultCollateralAmount\n ) internal view returns (uint256, uint256) {\n // try limiting liquidation amount to half of the vault debt\n (uint256 finalLiquidateAmount, uint256 collateralToPay) = _getSingleLiquidationAmount(\n _maxWPowerPerpAmount,\n _vaultShortAmount.div(2)\n );\n\n if (_vaultCollateralAmount > collateralToPay) {\n if (_vaultCollateralAmount.sub(collateralToPay) < MIN_COLLATERAL) {\n // the vault is left with dust after liquidation, allow liquidating full vault\n // calculate the new liquidation amount and collateral again based on the new limit\n (finalLiquidateAmount, collateralToPay) = _getSingleLiquidationAmount(\n _maxWPowerPerpAmount,\n _vaultShortAmount\n );\n }\n }\n\n // check if final collateral to pay is greater than vault amount.\n // if so the system only pays out the amount the vault has, which may not be profitable\n if (collateralToPay > _vaultCollateralAmount) {\n // force liquidator to pay full debt amount\n finalLiquidateAmount = _vaultShortAmount;\n collateralToPay = _vaultCollateralAmount;\n }\n\n return (finalLiquidateAmount, collateralToPay);\n }\n\n /**\n * @notice determine how much wPowerPerp to liquidate, and how much collateral to return\n * @param _maxInputWAmount maximum wPowerPerp amount liquidator is willing to repay\n * @param _maxLiquidatableWAmount maximum wPowerPerp amount a liquidator is allowed to repay\n * @return finalWAmountToLiquidate amount of wPowerPerp the liquidator will burn\n * @return collateralToPay total collateral the liquidator will get\n */\n function _getSingleLiquidationAmount(\n uint256 _maxInputWAmount,\n uint256 _maxLiquidatableWAmount\n ) internal view returns (uint256, uint256) {\n uint256 finalWAmountToLiquidate = _maxInputWAmount > _maxLiquidatableWAmount\n ? _maxLiquidatableWAmount\n : _maxInputWAmount;\n\n uint256 collateralToPay = Power2Base._getDebtValueInEth(\n finalWAmountToLiquidate,\n oracle,\n wPowerPerpPool,\n wPowerPerp,\n weth\n );\n\n // add 10% bonus for liquidators\n collateralToPay = collateralToPay.add(collateralToPay.div(10));\n\n return (finalWAmountToLiquidate, collateralToPay);\n }\n}\n" + }, + "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\nimport './pool/IUniswapV3PoolImmutables.sol';\nimport './pool/IUniswapV3PoolState.sol';\nimport './pool/IUniswapV3PoolDerivedState.sol';\nimport './pool/IUniswapV3PoolActions.sol';\nimport './pool/IUniswapV3PoolOwnerActions.sol';\nimport './pool/IUniswapV3PoolEvents.sol';\n\n/// @title The interface for a Uniswap V3 Pool\n/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform\n/// to the ERC20 specification\n/// @dev The pool interface is broken up into many smaller pieces\ninterface IUniswapV3Pool is\n IUniswapV3PoolImmutables,\n IUniswapV3PoolState,\n IUniswapV3PoolDerivedState,\n IUniswapV3PoolActions,\n IUniswapV3PoolOwnerActions,\n IUniswapV3PoolEvents\n{\n\n}\n" + }, + "contracts/interfaces/IController.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity =0.7.6;\n\npragma abicoder v2;\n\nimport {VaultLib} from \"../libs/VaultLib.sol\";\n\ninterface IController {\n function ethQuoteCurrencyPool() external view returns (address);\n\n function feeRate() external view returns (uint256);\n\n function getFee(\n uint256 _vaultId,\n uint256 _wPowerPerpAmount,\n uint256 _collateralAmount\n ) external view returns (uint256);\n\n function quoteCurrency() external view returns (address);\n\n function vaults(uint256 _vaultId) external view returns (VaultLib.Vault memory);\n\n function shortPowerPerp() external view returns (address);\n\n function wPowerPerp() external view returns (address);\n\n function getExpectedNormalizationFactor() external view returns (uint256);\n\n function mintPowerPerpAmount(\n uint256 _vaultId,\n uint256 _powerPerpAmount,\n uint256 _uniTokenId\n ) external payable returns (uint256 vaultId, uint256 wPowerPerpAmount);\n\n function mintWPowerPerpAmount(\n uint256 _vaultId,\n uint256 _wPowerPerpAmount,\n uint256 _uniTokenId\n ) external payable returns (uint256 vaultId);\n\n /**\n * Deposit collateral into a vault\n */\n function deposit(uint256 _vaultId) external payable;\n\n /**\n * Withdraw collateral from a vault.\n */\n function withdraw(uint256 _vaultId, uint256 _amount) external payable;\n\n function burnWPowerPerpAmount(\n uint256 _vaultId,\n uint256 _wPowerPerpAmount,\n uint256 _withdrawAmount\n ) external;\n\n function burnOnPowerPerpAmount(\n uint256 _vaultId,\n uint256 _powerPerpAmount,\n uint256 _withdrawAmount\n ) external returns (uint256 wPowerPerpAmount);\n\n function liquidate(uint256 _vaultId, uint256 _maxDebtAmount) external returns (uint256);\n\n function updateOperator(uint256 _vaultId, address _operator) external;\n\n /**\n * External function to update the normalized factor as a way to pay funding.\n */\n function applyFunding() external;\n\n function redeemShort(uint256 _vaultId) external;\n\n function reduceDebtShutdown(uint256 _vaultId) external;\n\n function isShutDown() external returns (bool);\n}\n" + }, + "@uniswap/v3-core/contracts/interfaces/pool/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" + }, + "@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolState.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that can change\n/// @notice These methods compose the pool's state, and can change with any frequency including multiple times\n/// per transaction\ninterface IUniswapV3PoolState {\n /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas\n /// when accessed externally.\n /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value\n /// tick The current tick of the pool, i.e. according to the last tick transition that was run.\n /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick\n /// boundary.\n /// observationIndex The index of the last oracle observation that was written,\n /// observationCardinality The current maximum number of observations stored in the pool,\n /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.\n /// feeProtocol The protocol fee for both tokens of the pool.\n /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0\n /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.\n /// unlocked Whether the pool is currently locked to reentrancy\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 /// @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 function feeGrowthGlobal0X128() external view returns (uint256);\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 function feeGrowthGlobal1X128() external view returns (uint256);\n\n /// @notice The amounts of token0 and token1 that are owed to the protocol\n /// @dev Protocol fees will never exceed uint128 max in either token\n function protocolFees() external view returns (uint128 token0, uint128 token1);\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 function liquidity() 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 the total amount of position liquidity that uses the pool either as tick lower or\n /// tick upper,\n /// liquidityNet how much liquidity changes when the pool price crosses the tick,\n /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,\n /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,\n /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick\n /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,\n /// secondsOutside the seconds spent on the other side of the tick from the current tick,\n /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.\n /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.\n /// In addition, these values are only relative and must be used only in comparison to previous snapshots for\n /// a specific position.\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 /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information\n function tickBitmap(int16 wordPosition) external view returns (uint256);\n\n /// @notice Returns the information about a position by the position's key\n /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper\n /// @return _liquidity The amount of liquidity in the position,\n /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,\n /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,\n /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,\n /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke\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 /// @notice Returns data about a specific observation index\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 secondsPerLiquidityCumulativeX128 the seconds per in range liquidity 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 observations(uint256 index)\n external\n view\n returns (\n uint32 blockTimestamp,\n int56 tickCumulative,\n uint160 secondsPerLiquidityCumulativeX128,\n bool initialized\n );\n}\n" + }, + "@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolDerivedState.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Pool state that is not stored\n/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the\n/// blockchain. The functions here may have variable gas costs.\ninterface IUniswapV3PoolDerivedState {\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 secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block\n /// timestamp\n function observe(uint32[] calldata secondsAgos)\n external\n view\n returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);\n\n /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range\n /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.\n /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first\n /// snapshot is taken and the second snapshot is taken.\n /// @param tickLower The lower tick of the range\n /// @param tickUpper The upper tick of the range\n /// @return tickCumulativeInside The snapshot of the tick accumulator for the range\n /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range\n /// @return secondsInside The snapshot of seconds per liquidity for the range\n function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)\n external\n view\n returns (\n int56 tickCumulativeInside,\n uint160 secondsPerLiquidityInsideX128,\n uint32 secondsInside\n );\n}\n" + }, + "@uniswap/v3-core/contracts/interfaces/pool/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" + }, + "@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolOwnerActions.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Permissioned pool actions\n/// @notice Contains pool methods that may only be called by the factory owner\ninterface IUniswapV3PoolOwnerActions {\n /// @notice Set the denominator of the protocol's % share of the fees\n /// @param feeProtocol0 new protocol fee for token0 of the pool\n /// @param feeProtocol1 new protocol fee for token1 of the pool\n function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;\n\n /// @notice Collect the protocol fee accrued to the pool\n /// @param recipient The address to which collected protocol fees should be sent\n /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1\n /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0\n /// @return amount0 The protocol fee collected in token0\n /// @return amount1 The protocol fee collected in token1\n function collectProtocol(\n address recipient,\n uint128 amount0Requested,\n uint128 amount1Requested\n ) external returns (uint128 amount0, uint128 amount1);\n}\n" + }, + "@uniswap/v3-core/contracts/interfaces/pool/IUniswapV3PoolEvents.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Events emitted by a pool\n/// @notice Contains all events emitted by the pool\ninterface IUniswapV3PoolEvents {\n /// @notice Emitted exactly once by a pool when #initialize is first called on the pool\n /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize\n /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96\n /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool\n event Initialize(uint160 sqrtPriceX96, int24 tick);\n\n /// @notice Emitted when liquidity is minted for a given position\n /// @param sender The address that minted the liquidity\n /// @param owner The owner of the position and recipient of any minted liquidity\n /// @param tickLower The lower tick of the position\n /// @param tickUpper The upper tick of the position\n /// @param amount The amount of liquidity minted to the position range\n /// @param amount0 How much token0 was required for the minted liquidity\n /// @param amount1 How much token1 was required for the minted liquidity\n event Mint(\n address sender,\n address indexed owner,\n int24 indexed tickLower,\n int24 indexed tickUpper,\n uint128 amount,\n uint256 amount0,\n uint256 amount1\n );\n\n /// @notice Emitted when fees are collected by the owner of a position\n /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees\n /// @param owner The owner of the position for which fees are collected\n /// @param tickLower The lower tick of the position\n /// @param tickUpper The upper tick of the position\n /// @param amount0 The amount of token0 fees collected\n /// @param amount1 The amount of token1 fees collected\n event Collect(\n address indexed owner,\n address recipient,\n int24 indexed tickLower,\n int24 indexed tickUpper,\n uint128 amount0,\n uint128 amount1\n );\n\n /// @notice Emitted when a position's liquidity is removed\n /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect\n /// @param owner The owner of the position for which liquidity is removed\n /// @param tickLower The lower tick of the position\n /// @param tickUpper The upper tick of the position\n /// @param amount The amount of liquidity to remove\n /// @param amount0 The amount of token0 withdrawn\n /// @param amount1 The amount of token1 withdrawn\n event Burn(\n address indexed owner,\n int24 indexed tickLower,\n int24 indexed tickUpper,\n uint128 amount,\n uint256 amount0,\n uint256 amount1\n );\n\n /// @notice Emitted by the pool for any swaps between token0 and token1\n /// @param sender The address that initiated the swap call, and that received the callback\n /// @param recipient The address that received the output of the swap\n /// @param amount0 The delta of the token0 balance of the pool\n /// @param amount1 The delta of the token1 balance of the pool\n /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96\n /// @param liquidity The liquidity of the pool after the swap\n /// @param tick The log base 1.0001 of price of the pool after the swap\n event Swap(\n address indexed sender,\n address indexed recipient,\n int256 amount0,\n int256 amount1,\n uint160 sqrtPriceX96,\n uint128 liquidity,\n int24 tick\n );\n\n /// @notice Emitted by the pool for any flashes of token0/token1\n /// @param sender The address that initiated the swap call, and that received the callback\n /// @param recipient The address that received the tokens from flash\n /// @param amount0 The amount of token0 that was flashed\n /// @param amount1 The amount of token1 that was flashed\n /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee\n /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee\n event Flash(\n address indexed sender,\n address indexed recipient,\n uint256 amount0,\n uint256 amount1,\n uint256 paid0,\n uint256 paid1\n );\n\n /// @notice Emitted by the pool 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 observationCardinalityNextOld The previous value of the next observation cardinality\n /// @param observationCardinalityNextNew The updated value of the next observation cardinality\n event IncreaseObservationCardinalityNext(\n uint16 observationCardinalityNextOld,\n uint16 observationCardinalityNextNew\n );\n\n /// @notice Emitted when the protocol fee is changed by the pool\n /// @param feeProtocol0Old The previous value of the token0 protocol fee\n /// @param feeProtocol1Old The previous value of the token1 protocol fee\n /// @param feeProtocol0New The updated value of the token0 protocol fee\n /// @param feeProtocol1New The updated value of the token1 protocol fee\n event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);\n\n /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner\n /// @param sender The address that collects the protocol fees\n /// @param recipient The address that receives the collected protocol fees\n /// @param amount0 The amount of token0 protocol fees that is withdrawn\n /// @param amount0 The amount of token1 protocol fees that is withdrawn\n event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);\n}\n" + }, + "contracts/test/OracleTester.sol": { + "content": "//SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity =0.7.6;\n\nimport {IOracle} from \"../interfaces/IOracle.sol\";\nimport {Oracle} from \"../core/Oracle.sol\";\nimport {Uint256Casting} from \"../libs/Uint256Casting.sol\";\n\n/**\n * use this contract to test how to get twap from exactly 1 timestamp\n * Since we can't access block.timestamp offchain before sending the tx\n */\ncontract OracleTester is Oracle{\n\n using Uint256Casting for uint256;\n\n IOracle oracle;\n\n constructor(address _oracle) {\n oracle = IOracle(_oracle);\n }\n\n function testGetTwapSince(\n uint256 _sinceTimestamp, \n address _pool, \n address _base, \n address _quote\n ) view external returns (uint256) {\n uint32 period = uint32(block.timestamp - _sinceTimestamp);\n return oracle.getTwap(_pool, _base, _quote, period, false);\n }\n\n function testGetTwapSafeSince(\n uint256 _sinceTimestamp, \n address _pool, \n address _base, \n address _quote\n ) view external returns (uint256) {\n uint32 period = uint32(block.timestamp - _sinceTimestamp);\n return oracle.getTwap(_pool, _base, _quote, period, true);\n }\n\n function testGetWeightedTickSafe(\n uint256 _sinceTimestamp,\n address _pool\n ) view external returns (int24) {\n uint32 period = uint32(block.timestamp - _sinceTimestamp);\n return oracle.getTimeWeightedAverageTickSafe(_pool, period);\n }\n\n function testGetHistoricalTwapToNow(\n uint256 _startTimestamp,\n address _pool,\n address _base,\n address _quote\n ) view external returns (uint256) {\n uint32 secondsAgoToStartOfTwap = uint32(block.timestamp - _startTimestamp); \n uint32 secondsAgoToEndOfTwap=0;\n \n return oracle.getHistoricalTwap(_pool, _base, _quote, secondsAgoToStartOfTwap, secondsAgoToEndOfTwap);\n }\n\n function testGetHistoricalTwap(\n uint256 _startTimestamp,\n uint256 _endTimestamp,\n address _pool,\n address _base,\n address _quote\n ) view external returns (uint256) {\n uint32 secondsAgoToStartOfTwap = uint32(block.timestamp - _startTimestamp); \n uint32 secondsAgoToEndOfTwap=uint32(block.timestamp - _endTimestamp); \n \n return oracle.getHistoricalTwap(_pool, _base, _quote, secondsAgoToStartOfTwap, secondsAgoToEndOfTwap);\n }\n\n function testToUint128(uint256 y) external pure returns (uint128 z) {\n return y.toUint128();\n }\n}" + }, + "contracts/core/Oracle.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\n// uniswap Library only works under 0.7.6\npragma solidity =0.7.6;\n\n//interface\nimport {IUniswapV3Pool} from \"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\";\nimport {IERC20Detailed} from \"../interfaces/IERC20Detailed.sol\";\n\n//library\nimport {SafeMath} from \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport {Uint256Casting} from \"../libs/Uint256Casting.sol\";\nimport {OracleLibrary} from \"../libs/OracleLibrary.sol\";\n\n/**\n * @notice read UniswapV3 pool TWAP prices, and convert to human readable term with (18 decimals)\n * @dev if ETH price is $3000, both ETH/USDC price and ETH/DAI price will be reported as 3000 * 1e18 by this oracle\n */\ncontract Oracle {\n using SafeMath for uint256;\n using Uint256Casting for uint256;\n\n uint128 private constant ONE = 1e18;\n\n /**\n * @notice get twap converted with base & quote token decimals\n * @dev if period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \"OLD\"\n * @param _pool uniswap pool address\n * @param _base base currency. to get eth/usd price, eth is base token\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\n * @param _period number of seconds in the past to start calculating time-weighted average\n * @return price of 1 base currency in quote currency. scaled by 1e18\n */\n function getTwap(\n address _pool,\n address _base,\n address _quote,\n uint32 _period,\n bool _checkPeriod\n ) external view returns (uint256) {\n // if the period is already checked, request TWAP directly. Will revert if period is too long.\n if (!_checkPeriod) return _fetchTwap(_pool, _base, _quote, _period);\n\n // make sure the requested period < maxPeriod the pool recorded.\n uint32 maxPeriod = _getMaxPeriod(_pool);\n uint32 requestPeriod = _period > maxPeriod ? maxPeriod : _period;\n return _fetchTwap(_pool, _base, _quote, requestPeriod);\n }\n\n /**\n * @notice get twap for a specific period of time, converted with base & quote token decimals\n * @dev if the _secondsAgoToStartOfTwap period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \"OLD\"\n * @param _pool uniswap pool address\n * @param _base base currency. to get eth/usd price, eth is base token\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\n * @param _secondsAgoToStartOfTwap amount of seconds in the past to start calculating time-weighted average\n * @param _secondsAgoToEndOfTwap amount of seconds in the past to end calculating time-weighted average\n * @return price of 1 base currency in quote currency. scaled by 1e18\n */\n function getHistoricalTwap(\n address _pool,\n address _base,\n address _quote,\n uint32 _secondsAgoToStartOfTwap,\n uint32 _secondsAgoToEndOfTwap\n ) external view returns (uint256) {\n return _fetchHistoricTwap(_pool, _base, _quote, _secondsAgoToStartOfTwap, _secondsAgoToEndOfTwap);\n }\n\n /**\n * @notice get the max period that can be used to request twap\n * @param _pool uniswap pool address\n * @return max period can be used to request twap\n */\n function getMaxPeriod(address _pool) external view returns (uint32) {\n return _getMaxPeriod(_pool);\n }\n\n /**\n * @notice get time weighed average tick, not converted to price\n * @dev this function will not revert\n * @param _pool address of the pool\n * @param _period period in second that we want to calculate average on\n * @return timeWeightedAverageTick the time weighted average tick\n */\n function getTimeWeightedAverageTickSafe(address _pool, uint32 _period)\n external\n view\n returns (int24 timeWeightedAverageTick)\n {\n uint32 maxPeriod = _getMaxPeriod(_pool);\n uint32 requestPeriod = _period > maxPeriod ? maxPeriod : _period;\n return OracleLibrary.consultAtHistoricTime(_pool, requestPeriod, 0);\n }\n\n /**\n * @notice get twap converted with base & quote token decimals\n * @dev if period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \"OLD\"\n * @param _pool uniswap pool address\n * @param _base base currency. to get eth/usd price, eth is base token\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\n * @param _period number of seconds in the past to start calculating time-weighted average\n * @return twap price which is scaled\n */\n function _fetchTwap(\n address _pool,\n address _base,\n address _quote,\n uint32 _period\n ) internal view returns (uint256) {\n uint256 quoteAmountOut = _fetchRawTwap(_pool, _base, _quote, _period);\n\n uint8 baseDecimals = IERC20Detailed(_base).decimals();\n uint8 quoteDecimals = IERC20Detailed(_quote).decimals();\n if (baseDecimals == quoteDecimals) return quoteAmountOut;\n\n // if quote token has less decimals, the returned quoteAmountOut will be lower, need to scale up by decimal difference\n if (baseDecimals > quoteDecimals) return quoteAmountOut.mul(10**(baseDecimals - quoteDecimals));\n\n // if quote token has more decimals, the returned quoteAmountOut will be higher, need to scale down by decimal difference\n return quoteAmountOut.div(10**(quoteDecimals - baseDecimals));\n }\n\n /**\n * @notice get raw twap from the uniswap pool\n * @dev if period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \"OLD\".\n * @param _pool uniswap pool address\n * @param _base base currency. to get eth/usd price, eth is base token\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\n * @param _period number of seconds in the past to start calculating time-weighted average\n * @return amount of quote currency received for _amountIn of base currency\n */\n function _fetchRawTwap(\n address _pool,\n address _base,\n address _quote,\n uint32 _period\n ) internal view returns (uint256) {\n int24 twapTick = OracleLibrary.consultAtHistoricTime(_pool, _period, 0);\n return OracleLibrary.getQuoteAtTick(twapTick, ONE, _base, _quote);\n }\n\n /**\n * @notice get twap for a specific period of time, converted with base & quote token decimals\n * @dev if the _secondsAgoToStartOfTwap period is longer than the current timestamp - first timestamp stored in the pool, this will revert with \"OLD\"\n * @param _pool uniswap pool address\n * @param _base base currency. to get eth/usd price, eth is base token\n * @param _quote quote currency. to get eth/usd price, usd is the quote currency\n * @param _secondsAgoToStartOfTwap amount of seconds in the past to start calculating time-weighted average\n * @param _secondsAgoToEndOfTwap amount of seconds in the past to end calculating time-weighted average\n * @return price of 1 base currency in quote currency. scaled by 1e18\n */\n function _fetchHistoricTwap(\n address _pool,\n address _base,\n address _quote,\n uint32 _secondsAgoToStartOfTwap,\n uint32 _secondsAgoToEndOfTwap\n ) internal view returns (uint256) {\n int24 twapTick = OracleLibrary.consultAtHistoricTime(_pool, _secondsAgoToStartOfTwap, _secondsAgoToEndOfTwap);\n\n return OracleLibrary.getQuoteAtTick(twapTick, ONE, _base, _quote);\n }\n\n /**\n * @notice get the max period that can be used to request twap\n * @param _pool uniswap pool address\n * @return max period can be used to request twap\n */\n function _getMaxPeriod(address _pool) internal view returns (uint32) {\n IUniswapV3Pool pool = IUniswapV3Pool(_pool);\n // observationIndex: the index of the last oracle observation that was written\n // cardinality: the current maximum number of observations stored in the pool\n (, , uint16 observationIndex, uint16 cardinality, , , ) = pool.slot0();\n\n // first observation index\n // it's safe to use % without checking cardinality = 0 because cardinality is always >= 1\n uint16 oldestObservationIndex = (observationIndex + 1) % cardinality;\n\n (uint32 oldestObservationTimestamp, , , bool initialized) = pool.observations(oldestObservationIndex);\n\n if (initialized) return uint32(block.timestamp) - oldestObservationTimestamp;\n\n // (index + 1) % cardinality is not the oldest index,\n // probably because cardinality is increased after last observation.\n // in this case, observation at index 0 should be the oldest.\n (oldestObservationTimestamp, , , ) = pool.observations(0);\n\n return uint32(block.timestamp) - oldestObservationTimestamp;\n }\n}\n" + }, + "contracts/interfaces/IERC20Detailed.sol": { + "content": "// SPDX-License-Identifier: MIT\n\n// uniswap Library only works under 0.7.6\npragma solidity =0.7.6;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ninterface IERC20Detailed is IERC20 {\n function decimals() external view returns (uint8);\n}\n" + }, + "contracts/libs/OracleLibrary.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity >=0.5.0 <0.8.0;\n\n//interface\nimport \"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\";\n\n//lib\nimport \"@uniswap/v3-core/contracts/libraries/FullMath.sol\";\nimport \"@uniswap/v3-core/contracts/libraries/TickMath.sol\";\n\n/// @title oracle library\n/// @notice provides functions to integrate with uniswap v3 oracle\n/// @author uniswap team other than consultAtHistoricTime(), built by opyn\nlibrary OracleLibrary {\n /// @notice fetches time-weighted average tick using uniswap v3 oracle\n /// @dev written by opyn team\n /// @param pool Address of uniswap v3 pool that we want to observe\n /// @param _secondsAgoToStartOfTwap number of seconds to start of TWAP period\n /// @param _secondsAgoToEndOfTwap number of seconds to end of TWAP period\n /// @return timeWeightedAverageTick The time-weighted average tick from (block.timestamp - _secondsAgoToStartOfTwap) to _secondsAgoToEndOfTwap\n function consultAtHistoricTime(\n address pool,\n uint32 _secondsAgoToStartOfTwap,\n uint32 _secondsAgoToEndOfTwap\n ) internal view returns (int24) {\n require(_secondsAgoToStartOfTwap > _secondsAgoToEndOfTwap, \"BP\");\n int24 timeWeightedAverageTick;\n uint32[] memory secondAgos = new uint32[](2);\n\n uint32 twapDuration = _secondsAgoToStartOfTwap - _secondsAgoToEndOfTwap;\n\n // get TWAP from (now - _secondsAgoToStartOfTwap) -> (now - _secondsAgoToEndOfTwap)\n secondAgos[0] = _secondsAgoToStartOfTwap;\n secondAgos[1] = _secondsAgoToEndOfTwap;\n\n (int56[] memory tickCumulatives, ) = IUniswapV3Pool(pool).observe(secondAgos);\n int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];\n\n timeWeightedAverageTick = int24(tickCumulativesDelta / (twapDuration));\n\n // Always round to negative infinity\n if (tickCumulativesDelta < 0 && (tickCumulativesDelta % (twapDuration) != 0)) timeWeightedAverageTick--;\n\n return timeWeightedAverageTick;\n }\n\n /// @notice given a tick and a token amount, calculates the amount of token received in exchange\n /// @param tick tick value used to calculate the quote\n /// @param baseAmount amount of token to be converted\n /// @param baseToken address of an ERC20 token contract used as the baseAmount denomination\n /// @param quoteToken address of an ERC20 token contract used as the quoteAmount denomination\n /// @return quoteAmount Amount of quoteToken received for baseAmount of baseToken\n function getQuoteAtTick(\n int24 tick,\n uint128 baseAmount,\n address baseToken,\n address quoteToken\n ) internal pure returns (uint256 quoteAmount) {\n uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick);\n\n // Calculate quoteAmount with better precision if it doesn't overflow when multiplied by itself\n if (sqrtRatioX96 <= type(uint128).max) {\n uint256 ratioX192 = uint256(sqrtRatioX96) * sqrtRatioX96;\n quoteAmount = baseToken < quoteToken\n ? FullMath.mulDiv(ratioX192, baseAmount, 1 << 192)\n : FullMath.mulDiv(1 << 192, baseAmount, ratioX192);\n } else {\n uint256 ratioX128 = FullMath.mulDiv(sqrtRatioX96, sqrtRatioX96, 1 << 64);\n quoteAmount = baseToken < quoteToken\n ? FullMath.mulDiv(ratioX128, baseAmount, 1 << 128)\n : FullMath.mulDiv(1 << 128, baseAmount, ratioX128);\n }\n }\n}\n" + }, + "@uniswap/v3-core/contracts/libraries/TickMath.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.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 uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));\n require(absTick <= uint256(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 /// @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 // 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" + }, + "@uniswap/v3-periphery/contracts/base/LiquidityManagement.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity =0.7.6;\npragma abicoder v2;\n\nimport '@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol';\nimport '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3MintCallback.sol';\nimport '@uniswap/v3-core/contracts/libraries/TickMath.sol';\n\nimport '../libraries/PoolAddress.sol';\nimport '../libraries/CallbackValidation.sol';\nimport '../libraries/LiquidityAmounts.sol';\n\nimport './PeripheryPayments.sol';\nimport './PeripheryImmutableState.sol';\n\n/// @title Liquidity management functions\n/// @notice Internal functions for safely managing liquidity in Uniswap V3\nabstract contract LiquidityManagement is IUniswapV3MintCallback, PeripheryImmutableState, PeripheryPayments {\n struct MintCallbackData {\n PoolAddress.PoolKey poolKey;\n address payer;\n }\n\n /// @inheritdoc IUniswapV3MintCallback\n function uniswapV3MintCallback(\n uint256 amount0Owed,\n uint256 amount1Owed,\n bytes calldata data\n ) external override {\n MintCallbackData memory decoded = abi.decode(data, (MintCallbackData));\n CallbackValidation.verifyCallback(factory, decoded.poolKey);\n\n if (amount0Owed > 0) pay(decoded.poolKey.token0, decoded.payer, msg.sender, amount0Owed);\n if (amount1Owed > 0) pay(decoded.poolKey.token1, decoded.payer, msg.sender, amount1Owed);\n }\n\n struct AddLiquidityParams {\n address token0;\n address token1;\n uint24 fee;\n address recipient;\n int24 tickLower;\n int24 tickUpper;\n uint256 amount0Desired;\n uint256 amount1Desired;\n uint256 amount0Min;\n uint256 amount1Min;\n }\n\n /// @notice Add liquidity to an initialized pool\n function addLiquidity(AddLiquidityParams memory params)\n internal\n returns (\n uint128 liquidity,\n uint256 amount0,\n uint256 amount1,\n IUniswapV3Pool pool\n )\n {\n PoolAddress.PoolKey memory poolKey =\n PoolAddress.PoolKey({token0: params.token0, token1: params.token1, fee: params.fee});\n\n pool = IUniswapV3Pool(PoolAddress.computeAddress(factory, poolKey));\n\n // compute the liquidity amount\n {\n (uint160 sqrtPriceX96, , , , , , ) = pool.slot0();\n uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(params.tickLower);\n uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(params.tickUpper);\n\n liquidity = LiquidityAmounts.getLiquidityForAmounts(\n sqrtPriceX96,\n sqrtRatioAX96,\n sqrtRatioBX96,\n params.amount0Desired,\n params.amount1Desired\n );\n }\n\n (amount0, amount1) = pool.mint(\n params.recipient,\n params.tickLower,\n params.tickUpper,\n liquidity,\n abi.encode(MintCallbackData({poolKey: poolKey, payer: msg.sender}))\n );\n\n require(amount0 >= params.amount0Min && amount1 >= params.amount1Min, 'Price slippage check');\n }\n}\n" + }, + "@uniswap/v3-core/contracts/interfaces/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" + }, + "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3MintCallback.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\n/// @title Callback for IUniswapV3PoolActions#mint\n/// @notice Any contract that calls IUniswapV3PoolActions#mint must implement this interface\ninterface IUniswapV3MintCallback {\n /// @notice Called to `msg.sender` after minting liquidity to a position from IUniswapV3Pool#mint.\n /// @dev In the implementation you must pay the pool tokens owed for the minted liquidity.\n /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.\n /// @param amount0Owed The amount of token0 due to the pool for the minted liquidity\n /// @param amount1Owed The amount of token1 due to the pool for the minted liquidity\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#mint call\n function uniswapV3MintCallback(\n uint256 amount0Owed,\n uint256 amount1Owed,\n bytes calldata data\n ) external;\n}\n" + }, + "@uniswap/v3-periphery/contracts/libraries/CallbackValidation.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity =0.7.6;\n\nimport '@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol';\nimport './PoolAddress.sol';\n\n/// @notice Provides validation for callbacks from Uniswap V3 Pools\nlibrary CallbackValidation {\n /// @notice Returns the address of a valid Uniswap V3 Pool\n /// @param factory The contract address of the Uniswap V3 factory\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 V3 pool contract address\n function verifyCallback(\n address factory,\n address tokenA,\n address tokenB,\n uint24 fee\n ) internal view returns (IUniswapV3Pool pool) {\n return verifyCallback(factory, PoolAddress.getPoolKey(tokenA, tokenB, fee));\n }\n\n /// @notice Returns the address of a valid Uniswap V3 Pool\n /// @param factory The contract address of the Uniswap V3 factory\n /// @param poolKey The identifying key of the V3 pool\n /// @return pool The V3 pool contract address\n function verifyCallback(address factory, PoolAddress.PoolKey memory poolKey)\n internal\n view\n returns (IUniswapV3Pool pool)\n {\n pool = IUniswapV3Pool(PoolAddress.computeAddress(factory, poolKey));\n require(msg.sender == address(pool));\n }\n}\n" + }, + "@uniswap/v3-periphery/contracts/libraries/LiquidityAmounts.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\nimport '@uniswap/v3-core/contracts/libraries/FullMath.sol';\nimport '@uniswap/v3-core/contracts/libraries/FixedPoint96.sol';\n\n/// @title Liquidity amount functions\n/// @notice Provides functions for computing liquidity amounts from token amounts and prices\nlibrary LiquidityAmounts {\n /// @notice Downcasts uint256 to uint128\n /// @param x The uint258 to be downcasted\n /// @return y The passed value, downcasted to uint128\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 representing the first tick boundary\n /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\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 representing the first tick boundary\n /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\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 /// @param sqrtRatioX96 A sqrt price representing the current pool prices\n /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary\n /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n /// @param amount0 The amount of token0 being sent in\n /// @param amount1 The amount of token1 being sent in\n /// @return liquidity The maximum amount of liquidity received\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 representing the first tick boundary\n /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n /// @param liquidity The liquidity being valued\n /// @return amount0 The amount of token0\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(\n uint256(liquidity) << FixedPoint96.RESOLUTION,\n sqrtRatioBX96 - sqrtRatioAX96,\n 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 representing the first tick boundary\n /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n /// @param liquidity The liquidity being valued\n /// @return amount1 The amount of token1\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 /// @param sqrtRatioX96 A sqrt price representing the current pool prices\n /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary\n /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n /// @param liquidity The liquidity being valued\n /// @return amount0 The amount of token0\n /// @return amount1 The amount of token1\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" + }, + "@uniswap/v3-periphery/contracts/base/PeripheryPayments.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\n\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\n\nimport '../interfaces/IPeripheryPayments.sol';\nimport '../interfaces/external/IWETH9.sol';\n\nimport '../libraries/TransferHelper.sol';\n\nimport './PeripheryImmutableState.sol';\n\nabstract contract PeripheryPayments is IPeripheryPayments, PeripheryImmutableState {\n receive() external payable {\n require(msg.sender == WETH9, 'Not WETH9');\n }\n\n /// @inheritdoc IPeripheryPayments\n function unwrapWETH9(uint256 amountMinimum, address recipient) external payable override {\n uint256 balanceWETH9 = IWETH9(WETH9).balanceOf(address(this));\n require(balanceWETH9 >= amountMinimum, 'Insufficient WETH9');\n\n if (balanceWETH9 > 0) {\n IWETH9(WETH9).withdraw(balanceWETH9);\n TransferHelper.safeTransferETH(recipient, balanceWETH9);\n }\n }\n\n /// @inheritdoc IPeripheryPayments\n function sweepToken(\n address token,\n uint256 amountMinimum,\n address recipient\n ) external payable override {\n uint256 balanceToken = IERC20(token).balanceOf(address(this));\n require(balanceToken >= amountMinimum, 'Insufficient token');\n\n if (balanceToken > 0) {\n TransferHelper.safeTransfer(token, recipient, balanceToken);\n }\n }\n\n /// @inheritdoc IPeripheryPayments\n function refundETH() external payable override {\n if (address(this).balance > 0) TransferHelper.safeTransferETH(msg.sender, address(this).balance);\n }\n\n /// @param token The token to pay\n /// @param payer The entity that must pay\n /// @param recipient The entity that will receive payment\n /// @param value The amount to pay\n function pay(\n address token,\n address payer,\n address recipient,\n uint256 value\n ) internal {\n if (token == WETH9 && address(this).balance >= value) {\n // pay with WETH9\n IWETH9(WETH9).deposit{value: value}(); // wrap only what is needed to pay\n IWETH9(WETH9).transfer(recipient, value);\n } else if (payer == address(this)) {\n // pay with tokens already in the contract (for the exact input multihop case)\n TransferHelper.safeTransfer(token, recipient, value);\n } else {\n // pull payment\n TransferHelper.safeTransferFrom(token, payer, recipient, value);\n }\n }\n}\n" + }, + "@uniswap/v3-periphery/contracts/base/PeripheryImmutableState.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity =0.7.6;\n\nimport '../interfaces/IPeripheryImmutableState.sol';\n\n/// @title Immutable state\n/// @notice Immutable state used by periphery contracts\nabstract contract PeripheryImmutableState is IPeripheryImmutableState {\n /// @inheritdoc IPeripheryImmutableState\n address public immutable override factory;\n /// @inheritdoc IPeripheryImmutableState\n address public immutable override WETH9;\n\n constructor(address _factory, address _WETH9) {\n factory = _factory;\n WETH9 = _WETH9;\n }\n}\n" + }, + "@uniswap/v3-periphery/contracts/interfaces/external/IWETH9.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity =0.7.6;\n\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\n\n/// @title Interface for WETH9\ninterface IWETH9 is IERC20 {\n /// @notice Deposit ether to get wrapped ether\n function deposit() external payable;\n\n /// @notice Withdraw wrapped ether to get ether\n function withdraw(uint256) external;\n}\n" + }, + "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.6.0;\n\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\n\nlibrary TransferHelper {\n /// @notice Transfers tokens from the targeted address to the given destination\n /// @notice Errors with 'STF' if transfer fails\n /// @param token The contract address of the token to be transferred\n /// @param from The originating address from which the tokens will be transferred\n /// @param to The destination address of the transfer\n /// @param value The amount to be transferred\n function safeTransferFrom(\n address token,\n address from,\n address to,\n uint256 value\n ) internal {\n (bool success, bytes memory data) =\n token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value));\n require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');\n }\n\n /// @notice Transfers tokens from msg.sender to a recipient\n /// @dev Errors with ST if transfer fails\n /// @param token The contract address of the token which will be transferred\n /// @param to The recipient of the transfer\n /// @param value The value of the transfer\n function safeTransfer(\n address token,\n address to,\n uint256 value\n ) internal {\n (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));\n require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');\n }\n\n /// @notice Approves the stipulated contract to spend the given allowance in the given token\n /// @dev Errors with 'SA' if transfer fails\n /// @param token The contract address of the token to be approved\n /// @param to The target of the approval\n /// @param value The amount of the given token the target will be allowed to spend\n function safeApprove(\n address token,\n address to,\n uint256 value\n ) internal {\n (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));\n require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');\n }\n\n /// @notice Transfers ETH to the recipient address\n /// @dev Fails with `STE`\n /// @param to The destination of the transfer\n /// @param value The value to be transferred\n function safeTransferETH(address to, uint256 value) internal {\n (bool success, ) = to.call{value: value}(new bytes(0));\n require(success, 'STE');\n }\n}\n" + }, + "contracts/mocks/MockUniPositionManager.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity =0.7.6;\npragma abicoder v2;\n\nimport {ERC721} from \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {INonfungiblePositionManager} from \"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\";\n\ncontract MockUniPositionManager is ERC721 {\n int24 public tickLower;\n int24 public tickUpper;\n uint128 public liquidity;\n address public token0;\n address public token1;\n\n uint256 token0ToCollect;\n uint256 token1ToCollect;\n\n constructor() ERC721(\"Uniswap Position\", \"UNIP\") {}\n\n function mint(address account, uint256 tokenId) external {\n _mint(account, tokenId);\n }\n\n function setMockedProperties(\n address _token0,\n address _token1,\n int24 _tickLower,\n int24 _tickUpper,\n uint128 _liquidity\n ) external {\n token0 = _token0;\n token1 = _token1;\n tickLower = _tickLower;\n tickUpper = _tickUpper;\n liquidity = _liquidity;\n }\n\n function positions(uint256)\n public\n view\n returns (\n uint96, //nonce,\n address, //operator,\n address, //token0,\n address, //token1,\n uint24, // fee,\n int24, // tickLower,\n int24, // tickUpper,\n uint128, // liquidity,\n uint256, //feeGrowthInside0LastX128,\n uint256, //feeGrowthInside1LastX128,\n uint128, //tokensOwed0,\n uint128 //tokensOwed1\n )\n {\n // return 0 for everything\n return (\n 0, //nonce,\n address(0), //operator,\n token0, //token0,\n token1, //token1,\n 3000, // fee,\n tickLower, // tickLower,\n tickUpper, // tickUpper,\n liquidity, // liquidity,\n 0, //feeGrowthInside0LastX128,\n 0, //feeGrowthInside1LastX128,\n 0, //tokensOwed0,\n 0 //tokensOwed1\n );\n }\n\n function setAmount0Amount1ToDecrease(uint256 amount0, uint256 amount1) external {\n token0ToCollect = amount0;\n token1ToCollect = amount1;\n }\n\n // SPDX-License-Identifier: GPL-2.0-or-later\n function decreaseLiquidity(\n INonfungiblePositionManager.DecreaseLiquidityParams memory /*params*/\n ) external view returns (uint256, uint256) {\n return (token0ToCollect, token1ToCollect);\n }\n\n function collect(INonfungiblePositionManager.CollectParams memory params) external returns (uint256, uint256) {\n uint256 cachedAmount0 = token0ToCollect;\n uint256 cachedAmount1 = token1ToCollect;\n uint256 token0Amount = cachedAmount0 > params.amount0Max ? params.amount0Max : cachedAmount0;\n uint256 token1Amount = cachedAmount1 > params.amount1Max ? params.amount1Max : cachedAmount1;\n IERC20(token0).transfer(params.recipient, token0Amount);\n IERC20(token1).transfer(params.recipient, token1Amount);\n token0ToCollect = 0;\n token1ToCollect = 0;\n return (token0Amount, token1Amount);\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/ERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\nimport \"../../utils/Context.sol\";\nimport \"./IERC721.sol\";\nimport \"./IERC721Metadata.sol\";\nimport \"./IERC721Enumerable.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"../../introspection/ERC165.sol\";\nimport \"../../math/SafeMath.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/EnumerableSet.sol\";\nimport \"../../utils/EnumerableMap.sol\";\nimport \"../../utils/Strings.sol\";\n\n/**\n * @title ERC721 Non-Fungible Token Standard basic implementation\n * @dev see https://eips.ethereum.org/EIPS/eip-721\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {\n using SafeMath for uint256;\n using Address for address;\n using EnumerableSet for EnumerableSet.UintSet;\n using EnumerableMap for EnumerableMap.UintToAddressMap;\n using Strings for uint256;\n\n // Equals to `bytes4(keccak256(\"onERC721Received(address,address,uint256,bytes)\"))`\n // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`\n bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;\n\n // Mapping from holder address to their (enumerable) set of owned tokens\n mapping (address => EnumerableSet.UintSet) private _holderTokens;\n\n // Enumerable mapping from token ids to their owners\n EnumerableMap.UintToAddressMap private _tokenOwners;\n\n // Mapping from token ID to approved address\n mapping (uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping (address => mapping (address => bool)) private _operatorApprovals;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Optional mapping for token URIs\n mapping (uint256 => string) private _tokenURIs;\n\n // Base URI\n string private _baseURI;\n\n /*\n * bytes4(keccak256('balanceOf(address)')) == 0x70a08231\n * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e\n * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3\n * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc\n * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465\n * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5\n * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd\n * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e\n * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde\n *\n * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^\n * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd\n */\n bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;\n\n /*\n * bytes4(keccak256('name()')) == 0x06fdde03\n * bytes4(keccak256('symbol()')) == 0x95d89b41\n * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd\n *\n * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f\n */\n bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;\n\n /*\n * bytes4(keccak256('totalSupply()')) == 0x18160ddd\n * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59\n * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7\n *\n * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63\n */\n bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor (string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n\n // register the supported interfaces to conform to ERC721 via ERC165\n _registerInterface(_INTERFACE_ID_ERC721);\n _registerInterface(_INTERFACE_ID_ERC721_METADATA);\n _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: balance query for the zero address\");\n return _holderTokens[owner].length();\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n return _tokenOwners.get(tokenId, \"ERC721: owner query for nonexistent token\");\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n require(_exists(tokenId), \"ERC721Metadata: URI query for nonexistent token\");\n\n string memory _tokenURI = _tokenURIs[tokenId];\n string memory base = baseURI();\n\n // If there is no base URI, return the token URI.\n if (bytes(base).length == 0) {\n return _tokenURI;\n }\n // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).\n if (bytes(_tokenURI).length > 0) {\n return string(abi.encodePacked(base, _tokenURI));\n }\n // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.\n return string(abi.encodePacked(base, tokenId.toString()));\n }\n\n /**\n * @dev Returns the base URI set via {_setBaseURI}. This will be\n * automatically added as a prefix in {tokenURI} to each token's URI, or\n * to the token ID if no specific URI is set for that token ID.\n */\n function baseURI() public view virtual returns (string memory) {\n return _baseURI;\n }\n\n /**\n * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {\n return _holderTokens[owner].at(index);\n }\n\n /**\n * @dev See {IERC721Enumerable-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds\n return _tokenOwners.length();\n }\n\n /**\n * @dev See {IERC721Enumerable-tokenByIndex}.\n */\n function tokenByIndex(uint256 index) public view virtual override returns (uint256) {\n (uint256 tokenId, ) = _tokenOwners.at(index);\n return tokenId;\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n require(_exists(tokenId), \"ERC721: approved query for nonexistent token\");\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n require(operator != _msgSender(), \"ERC721: approve to caller\");\n\n _operatorApprovals[_msgSender()][operator] = approved;\n emit ApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(address from, address to, uint256 tokenId) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor approved\");\n _safeTransfer(from, to, tokenId, _data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `_data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, _data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _tokenOwners.contains(tokenId);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n require(_exists(tokenId), \"ERC721: operator query for nonexistent token\");\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender));\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n d*\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual {\n _mint(to, tokenId);\n require(_checkOnERC721Received(address(0), to, tokenId, _data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _holderTokens[to].add(tokenId);\n\n _tokenOwners.set(tokenId, to);\n\n emit Transfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId); // internal owner\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n // Clear metadata (if any)\n if (bytes(_tokenURIs[tokenId]).length != 0) {\n delete _tokenURIs[tokenId];\n }\n\n _holderTokens[owner].remove(tokenId);\n\n _tokenOwners.remove(tokenId);\n\n emit Transfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(address from, address to, uint256 tokenId) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer of token that is not own\"); // internal owner\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _holderTokens[from].remove(tokenId);\n _holderTokens[to].add(tokenId);\n\n _tokenOwners.set(tokenId, to);\n\n emit Transfer(from, to, tokenId);\n }\n\n /**\n * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {\n require(_exists(tokenId), \"ERC721Metadata: URI set of nonexistent token\");\n _tokenURIs[tokenId] = _tokenURI;\n }\n\n /**\n * @dev Internal function to set the base URI for all token IDs. It is\n * automatically added as a prefix to the value returned in {tokenURI},\n * or to the token ID if {tokenURI} is empty.\n */\n function _setBaseURI(string memory baseURI_) internal virtual {\n _baseURI = baseURI_;\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param _data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)\n private returns (bool)\n {\n if (!to.isContract()) {\n return true;\n }\n bytes memory returndata = to.functionCall(abi.encodeWithSelector(\n IERC721Receiver(to).onERC721Received.selector,\n _msgSender(),\n from,\n tokenId,\n _data\n ), \"ERC721: transfer to non ERC721Receiver implementer\");\n bytes4 retval = abi.decode(returndata, (bytes4));\n return (retval == _ERC721_RECEIVED);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits an {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }\n}\n" + }, + "@openzeppelin/contracts/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts may inherit from this and call {_registerInterface} to declare\n * their support of an interface.\n */\nabstract contract ERC165 is IERC165 {\n /*\n * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7\n */\n bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;\n\n /**\n * @dev Mapping of interface ids to whether or not it's supported.\n */\n mapping(bytes4 => bool) private _supportedInterfaces;\n\n constructor () {\n // Derived contracts need only register support for their own interfaces,\n // we register support for ERC165 itself here\n _registerInterface(_INTERFACE_ID_ERC165);\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n *\n * Time complexity O(1), guaranteed to always use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return _supportedInterfaces[interfaceId];\n }\n\n /**\n * @dev Registers the contract as an implementer of the interface defined by\n * `interfaceId`. Support of the actual ERC165 interface is automatic and\n * registering its interface id is not required.\n *\n * See {IERC165-supportsInterface}.\n *\n * Requirements:\n *\n * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).\n */\n function _registerInterface(bytes4 interfaceId) internal virtual {\n require(interfaceId != 0xffffffff, \"ERC165: invalid interface id\");\n _supportedInterfaces[interfaceId] = true;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping (bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) { // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\n\n bytes32 lastvalue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n require(set._values.length > index, \"EnumerableSet: index out of bounds\");\n return set._values[index];\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/EnumerableMap.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\n/**\n * @dev Library for managing an enumerable variant of Solidity's\n * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]\n * type.\n *\n * Maps have the following properties:\n *\n * - Entries are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Entries are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableMap for EnumerableMap.UintToAddressMap;\n *\n * // Declare a set state variable\n * EnumerableMap.UintToAddressMap private myMap;\n * }\n * ```\n *\n * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are\n * supported.\n */\nlibrary EnumerableMap {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Map type with\n // bytes32 keys and values.\n // The Map implementation uses private functions, and user-facing\n // implementations (such as Uint256ToAddressMap) are just wrappers around\n // the underlying Map.\n // This means that we can only create new EnumerableMaps for types that fit\n // in bytes32.\n\n struct MapEntry {\n bytes32 _key;\n bytes32 _value;\n }\n\n struct Map {\n // Storage of map keys and values\n MapEntry[] _entries;\n\n // Position of the entry defined by a key in the `entries` array, plus 1\n // because index 0 means a key is not in the map.\n mapping (bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Adds a key-value pair to a map, or updates the value for an existing\n * key. O(1).\n *\n * Returns true if the key was added to the map, that is if it was not\n * already present.\n */\n function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {\n // We read and store the key's index to prevent multiple reads from the same storage slot\n uint256 keyIndex = map._indexes[key];\n\n if (keyIndex == 0) { // Equivalent to !contains(map, key)\n map._entries.push(MapEntry({ _key: key, _value: value }));\n // The entry is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n map._indexes[key] = map._entries.length;\n return true;\n } else {\n map._entries[keyIndex - 1]._value = value;\n return false;\n }\n }\n\n /**\n * @dev Removes a key-value pair from a map. O(1).\n *\n * Returns true if the key was removed from the map, that is if it was present.\n */\n function _remove(Map storage map, bytes32 key) private returns (bool) {\n // We read and store the key's index to prevent multiple reads from the same storage slot\n uint256 keyIndex = map._indexes[key];\n\n if (keyIndex != 0) { // Equivalent to contains(map, key)\n // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one\n // in the array, and then remove the last entry (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = keyIndex - 1;\n uint256 lastIndex = map._entries.length - 1;\n\n // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs\n // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.\n\n MapEntry storage lastEntry = map._entries[lastIndex];\n\n // Move the last entry to the index where the entry to delete is\n map._entries[toDeleteIndex] = lastEntry;\n // Update the index for the moved entry\n map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based\n\n // Delete the slot where the moved entry was stored\n map._entries.pop();\n\n // Delete the index for the deleted slot\n delete map._indexes[key];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the key is in the map. O(1).\n */\n function _contains(Map storage map, bytes32 key) private view returns (bool) {\n return map._indexes[key] != 0;\n }\n\n /**\n * @dev Returns the number of key-value pairs in the map. O(1).\n */\n function _length(Map storage map) private view returns (uint256) {\n return map._entries.length;\n }\n\n /**\n * @dev Returns the key-value pair stored at position `index` in the map. O(1).\n *\n * Note that there are no guarantees on the ordering of entries inside the\n * array, and it may change when more entries are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {\n require(map._entries.length > index, \"EnumerableMap: index out of bounds\");\n\n MapEntry storage entry = map._entries[index];\n return (entry._key, entry._value);\n }\n\n /**\n * @dev Tries to returns the value associated with `key`. O(1).\n * Does not revert if `key` is not in the map.\n */\n function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {\n uint256 keyIndex = map._indexes[key];\n if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key)\n return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based\n }\n\n /**\n * @dev Returns the value associated with `key`. O(1).\n *\n * Requirements:\n *\n * - `key` must be in the map.\n */\n function _get(Map storage map, bytes32 key) private view returns (bytes32) {\n uint256 keyIndex = map._indexes[key];\n require(keyIndex != 0, \"EnumerableMap: nonexistent key\"); // Equivalent to contains(map, key)\n return map._entries[keyIndex - 1]._value; // All indexes are 1-based\n }\n\n /**\n * @dev Same as {_get}, with a custom error message when `key` is not in the map.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {_tryGet}.\n */\n function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {\n uint256 keyIndex = map._indexes[key];\n require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)\n return map._entries[keyIndex - 1]._value; // All indexes are 1-based\n }\n\n // UintToAddressMap\n\n struct UintToAddressMap {\n Map _inner;\n }\n\n /**\n * @dev Adds a key-value pair to a map, or updates the value for an existing\n * key. O(1).\n *\n * Returns true if the key was added to the map, that is if it was not\n * already present.\n */\n function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {\n return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the key was removed from the map, that is if it was present.\n */\n function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {\n return _remove(map._inner, bytes32(key));\n }\n\n /**\n * @dev Returns true if the key is in the map. O(1).\n */\n function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {\n return _contains(map._inner, bytes32(key));\n }\n\n /**\n * @dev Returns the number of elements in the map. O(1).\n */\n function length(UintToAddressMap storage map) internal view returns (uint256) {\n return _length(map._inner);\n }\n\n /**\n * @dev Returns the element stored at position `index` in the set. O(1).\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {\n (bytes32 key, bytes32 value) = _at(map._inner, index);\n return (uint256(key), address(uint160(uint256(value))));\n }\n\n /**\n * @dev Tries to returns the value associated with `key`. O(1).\n * Does not revert if `key` is not in the map.\n *\n * _Available since v3.4._\n */\n function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {\n (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));\n return (success, address(uint160(uint256(value))));\n }\n\n /**\n * @dev Returns the value associated with `key`. O(1).\n *\n * Requirements:\n *\n * - `key` must be in the map.\n */\n function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {\n return address(uint160(uint256(_get(map._inner, bytes32(key)))));\n }\n\n /**\n * @dev Same as {get}, with a custom error message when `key` is not in the map.\n *\n * CAUTION: This function is deprecated because it requires allocating memory for the error\n * message unnecessarily. For custom revert reasons use {tryGet}.\n */\n function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {\n return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n /**\n * @dev Converts a `uint256` to its ASCII `string` representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n uint256 index = digits - 1;\n temp = value;\n while (temp != 0) {\n buffer[index--] = bytes1(uint8(48 + temp % 10));\n temp /= 10;\n }\n return string(buffer);\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\nimport \"../../utils/Context.sol\";\nimport \"./IERC20.sol\";\nimport \"../../math/SafeMath.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin guidelines: functions revert instead\n * of returning `false` on failure. This behavior is nonetheless conventional\n * and does not conflict with the expectations of ERC20 applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20 {\n using SafeMath for uint256;\n\n mapping (address => uint256) private _balances;\n\n mapping (address => mapping (address => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n uint8 private _decimals;\n\n /**\n * @dev Sets the values for {name} and {symbol}, initializes {decimals} with\n * a default value of 18.\n *\n * To select a different value for {decimals}, use {_setupDecimals}.\n *\n * All three of these values are immutable: they can only be set once during\n * construction.\n */\n constructor (string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n _decimals = 18;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5,05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is\n * called.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return _decimals;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `recipient` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\n _transfer(_msgSender(), recipient, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) public virtual override returns (bool) {\n _approve(_msgSender(), spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * Requirements:\n *\n * - `sender` and `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n * - the caller must have allowance for ``sender``'s tokens of at least\n * `amount`.\n */\n function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\n _transfer(sender, recipient, amount);\n _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, \"ERC20: transfer amount exceeds allowance\"));\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, \"ERC20: decreased allowance below zero\"));\n return true;\n }\n\n /**\n * @dev Moves tokens `amount` from `sender` to `recipient`.\n *\n * This is internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `sender` cannot be the zero address.\n * - `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n */\n function _transfer(address sender, address recipient, uint256 amount) internal virtual {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(sender, recipient, amount);\n\n _balances[sender] = _balances[sender].sub(amount, \"ERC20: transfer amount exceeds balance\");\n _balances[recipient] = _balances[recipient].add(amount);\n emit Transfer(sender, recipient, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply = _totalSupply.add(amount);\n _balances[account] = _balances[account].add(amount);\n emit Transfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n _balances[account] = _balances[account].sub(amount, \"ERC20: burn amount exceeds balance\");\n _totalSupply = _totalSupply.sub(amount);\n emit Transfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(address owner, address spender, uint256 amount) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Sets {decimals} to a value other than the default one of 18.\n *\n * WARNING: This function should only be called from the constructor. Most\n * applications that interact with token contracts will not expect\n * {decimals} to ever change, and may work incorrectly if it does.\n */\n function _setupDecimals(uint8 decimals_) internal virtual {\n _decimals = decimals_;\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be to transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }\n}\n" + }, + "contracts/strategy/base/StrategyBase.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity =0.7.6;\n\npragma abicoder v2;\n\n// interface\nimport {IController} from \"../../interfaces/IController.sol\";\nimport {IWPowerPerp} from \"../../interfaces/IWPowerPerp.sol\";\n\n// contract\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\n// lib\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {StrategyMath} from \"./StrategyMath.sol\";\nimport {VaultLib} from \"../../libs/VaultLib.sol\";\n\n/**\n * @dev StrategyBase contract\n * @notice base contract for PowerToken strategy\n * @author opyn team\n */\ncontract StrategyBase is ERC20 {\n using StrategyMath for uint256;\n using Address for address payable;\n\n /// @dev power token controller\n IController public powerTokenController;\n\n /// @dev WETH token\n address public immutable weth;\n address public immutable wPowerPerp;\n\n /// @dev power token strategy vault ID\n uint256 public immutable vaultId;\n\n /**\n * @notice constructor for StrategyBase\n * @dev this will open a vault in the power token contract and store the vault ID\n * @param _powerTokenController power token controller address\n * @param _weth weth token address\n * @param _name token name for strategy ERC20 token\n * @param _symbol token symbol for strategy ERC20 token\n */\n constructor(address _powerTokenController, address _weth, string memory _name, string memory _symbol) ERC20(_name, _symbol) {\n require(_powerTokenController != address(0), \"invalid power token controller address\");\n require(_weth != address(0), \"invalid weth address\");\n\n weth = _weth;\n powerTokenController = IController(_powerTokenController);\n wPowerPerp = address(powerTokenController.wPowerPerp());\n vaultId = powerTokenController.mintWPowerPerpAmount(0, 0, 0);\n }\n /**\n * @notice get power token strategy vault ID \n * @return vault ID\n */\n function getStrategyVaultId() external view returns (uint256) {\n return vaultId;\n }\n\n /**\n * @notice get the vault composition of the strategy \n * @return operator\n * @return nft collateral id\n * @return collateral amount\n * @return short amount\n */\n function getVaultDetails() external view returns (address, uint256, uint256, uint256) {\n return _getVaultDetails();\n }\n\n /**\n * @notice mint WPowerPerp and deposit collateral\n * @dev this function will not send WPowerPerp to msg.sender if _keepWSqueeth == true\n * @param _to receiver address\n * @param _wAmount amount of WPowerPerp to mint\n * @param _collateral amount of collateral to deposit\n * @param _keepWsqueeth keep minted wSqueeth in this contract if it is set to true\n */\n function _mintWPowerPerp(\n address _to,\n uint256 _wAmount,\n uint256 _collateral,\n bool _keepWsqueeth\n ) internal {\n powerTokenController.mintWPowerPerpAmount{value: _collateral}(vaultId, _wAmount, 0);\n\n if (!_keepWsqueeth) {\n IWPowerPerp(wPowerPerp).transfer(_to, _wAmount);\n }\n }\n\n /**\n * @notice burn WPowerPerp and withdraw collateral\n * @dev this function will not take WPowerPerp from msg.sender if _isOwnedWSqueeth == true\n * @param _from WPowerPerp holder address\n * @param _amount amount of wPowerPerp to burn\n * @param _collateralToWithdraw amount of collateral to withdraw\n * @param _isOwnedWSqueeth transfer WPowerPerp from holder if it is set to false\n */\n function _burnWPowerPerp(\n address _from,\n uint256 _amount,\n uint256 _collateralToWithdraw,\n bool _isOwnedWSqueeth\n ) internal {\n if (!_isOwnedWSqueeth) {\n IWPowerPerp(wPowerPerp).transferFrom(_from, address(this), _amount);\n }\n\n powerTokenController.burnWPowerPerpAmount(vaultId, _amount, _collateralToWithdraw);\n }\n\n /**\n * @notice mint strategy token\n * @param _to recepient address\n * @param _amount token amount\n */\n function _mintStrategyToken(address _to, uint256 _amount) internal {\n _mint(_to, _amount);\n }\n\n /**\n * @notice get strategy debt amount for a specific strategy token amount\n * @param _strategyAmount strategy amount\n * @return debt amount\n */\n function _getDebtFromStrategyAmount(uint256 _strategyAmount) internal view returns (uint256) {\n (, , ,uint256 strategyDebt) = _getVaultDetails();\n return strategyDebt.wmul(_strategyAmount).wdiv(totalSupply());\n }\n\n /**\n * @notice get the vault composition of the strategy \n * @return operator\n * @return nft collateral id\n * @return collateral amount\n * @return short amount\n */\n function _getVaultDetails() internal view returns (address, uint256, uint256, uint256) {\n VaultLib.Vault memory strategyVault = powerTokenController.vaults(vaultId);\n\n return (strategyVault.operator, strategyVault.NftCollateralId, strategyVault.collateralAmount, strategyVault.shortAmount);\n }\n}\n\n" + }, + "contracts/strategy/base/StrategyMath.sol": { + "content": "//SPDX-License-Identifier: AGPL-3.0-only\n\n/// math.sol -- mixin for inline numerical wizardry\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.4.13;\n\n\n/**\n * @notice Copied from https://github.com/dapphub/ds-math/blob/e70a364787804c1ded9801ed6c27b440a86ebd32/src/math.sol\n * @dev change contract to library, all uint to uint256, added div() function\n */\nlibrary StrategyMath {\n function add(uint x, uint y) internal pure returns (uint z) {\n require((z = x + y) >= x, \"ds-math-add-overflow\");\n }\n function sub(uint x, uint y) internal pure returns (uint z) {\n require((z = x - y) <= x, \"ds-math-sub-underflow\");\n }\n function mul(uint x, uint y) internal pure returns (uint z) {\n require(y == 0 || (z = x * y) / y == x, \"ds-math-mul-overflow\");\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b > 0, \"SafeMath: division by zero\");\n return a / b;\n }\n\n function min(uint x, uint y) internal pure returns (uint z) {\n return x <= y ? x : y;\n }\n function max(uint x, uint y) internal pure returns (uint z) {\n return x >= y ? x : y;\n }\n function imin(int x, int y) internal pure returns (int z) {\n return x <= y ? x : y;\n }\n function imax(int x, int y) internal pure returns (int z) {\n return x >= y ? x : y;\n }\n\n uint constant WAD = 10 ** 18;\n uint constant RAY = 10 ** 27;\n\n //rounds to zero if x*y < WAD / 2\n function wmul(uint x, uint y) internal pure returns (uint z) {\n z = add(mul(x, y), WAD / 2) / WAD;\n }\n //rounds to zero if x*y < WAD / 2\n function rmul(uint x, uint y) internal pure returns (uint z) {\n z = add(mul(x, y), RAY / 2) / RAY;\n }\n //rounds to zero if x*y < WAD / 2\n function wdiv(uint x, uint y) internal pure returns (uint z) {\n z = add(mul(x, WAD), y / 2) / y;\n }\n //rounds to zero if x*y < RAY / 2\n function rdiv(uint x, uint y) internal pure returns (uint z) {\n z = add(mul(x, RAY), y / 2) / y;\n }\n\n // This famous algorithm is called \"exponentiation by squaring\"\n // and calculates x^n with x as fixed-point and n as regular unsigned.\n //\n // It's O(log n), instead of O(n) for naive repeated multiplication.\n //\n // These facts are why it works:\n //\n // If n is even, then x^n = (x^2)^(n/2).\n // If n is odd, then x^n = x * x^(n-1),\n // and applying the equation for even x gives\n // x^n = x * (x^2)^((n-1) / 2).\n //\n // Also, EVM division is flooring and\n // floor[(n-1) / 2] = floor[n / 2].\n //\n function rpow(uint x, uint n) internal pure returns (uint z) {\n z = n % 2 != 0 ? x : RAY;\n\n for (n /= 2; n != 0; n /= 2) {\n x = rmul(x, x);\n\n if (n % 2 != 0) {\n z = rmul(z, x);\n }\n }\n }\n}" + }, + "contracts/strategy/CrabStrategy.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity =0.7.6;\npragma abicoder v2;\n\n// interface\nimport {IController} from \"../interfaces/IController.sol\";\nimport {IWPowerPerp} from \"../interfaces/IWPowerPerp.sol\";\nimport {IOracle} from \"../interfaces/IOracle.sol\";\nimport {IWETH9} from \"../interfaces/IWETH9.sol\";\nimport {IUniswapV3Pool} from \"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\";\nimport {IController} from \"../interfaces/IController.sol\";\n\n// contract\nimport \"@openzeppelin/contracts/utils/ReentrancyGuard.sol\";\nimport {StrategyBase} from \"./base/StrategyBase.sol\";\nimport {StrategyFlashSwap} from \"./base/StrategyFlashSwap.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\n\n// lib\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {StrategyMath} from \"./base/StrategyMath.sol\";\nimport {Power2Base} from \"../libs/Power2Base.sol\";\n\n/**\n * @dev CrabStrategy contract\n * @notice Contract for Crab strategy\n * @author Opyn team\n */\ncontract CrabStrategy is StrategyBase, StrategyFlashSwap, ReentrancyGuard, Ownable {\n using StrategyMath for uint256;\n using Address for address payable;\n\n uint32 public constant TWAP_PERIOD = 420 seconds;\n uint32 public constant POWER_PERP_PERIOD = 420 seconds;\n // strategy will only allow hedging if collateral to trade is at least 0.1% of the total strategy collateral\n uint256 public constant DELTA_HEDGE_THRESHOLD = 1e15;\n\n uint256 public strategyCap;\n\n /// @dev enum to differentiate between uniswap swap callback function source\n enum FLASH_SOURCE {\n FLASH_DEPOSIT,\n FLASH_WITHDRAW,\n FLASH_HEDGE_SELL,\n FLASH_HEDGE_BUY\n }\n\n /// @dev ETH:WSqueeth uniswap pool\n address public immutable ethWSqueethPool;\n /// @dev strategy uniswap oracle\n address public immutable oracle;\n address public immutable ethQuoteCurrencyPool;\n address public immutable quoteCurrency;\n\n /// @dev time difference to trigger a hedge (seconds)\n uint256 public immutable hedgeTimeThreshold;\n /// @dev price movement to trigger a hedge (0.1*1e18 = 10%)\n uint256 public immutable hedgePriceThreshold;\n /// @dev hedge auction duration (seconds)\n uint256 public immutable auctionTime;\n /// @dev start auction price multiplier for hedge buy auction and reserve price for end sell auction (scaled 1e18)\n uint256 public immutable minPriceMultiplier;\n /// @dev start auction price multiplier for hedge sell auction and reserve price for hedge buy auction (scaled 1e18)\n uint256 public immutable maxPriceMultiplier;\n\n /// @dev timestamp when last hedge executed\n uint256 public timeAtLastHedge;\n /// @dev WSqueeth/Eth price when last hedge executed\n uint256 public priceAtLastHedge;\n uint256 public auctionStartTime;\n\n /// @dev set to true when redeemShortShutdown has been called\n bool public hasRedeemedInShutdown;\n\n struct FlashDepositData {\n uint256 totalDeposit;\n }\n\n struct FlashWithdrawData {\n uint256 crabAmount;\n }\n\n struct FlashHedgeData {\n uint256 wSqueethAmount;\n uint256 ethProceeds;\n uint256 minWSqueeth;\n uint256 minEth;\n }\n\n event Deposit(address indexed depositor, uint256 wSqueethAmount, uint256 lpAmount);\n event Withdraw(address indexed withdrawer, uint256 crabAmount, uint256 wSqueethAmount, uint256 ethWithdrawn);\n event WithdrawShutdown(address indexed withdrawer, uint256 crabAmount, uint256 ethWithdrawn);\n event FlashDeposit(address indexed depositor, uint256 depositedAmount, uint256 tradedAmountOut);\n event FlashWithdraw(address indexed withdrawer, uint256 crabAmount, uint256 wSqueethAmount);\n event TimeHedgeOnUniswap(\n address indexed hedger,\n uint256 hedgeTimestamp,\n uint256 auctionTriggerTimestamp,\n uint256 minWSqueeth,\n uint256 minEth\n );\n event PriceHedgeOnUniswap(\n address indexed hedger,\n uint256 hedgeTimestamp,\n uint256 auctionTriggerTimestamp,\n uint256 minWSqueeth,\n uint256 minEth\n );\n event TimeHedge(address indexed hedger, bool auctionType, uint256 hedgerPrice, uint256 auctionTriggerTimestamp);\n event PriceHedge(address indexed hedger, bool auctionType, uint256 hedgerPrice, uint256 auctionTriggerTimestamp);\n event Hedge(\n address indexed hedger,\n bool auctionType,\n uint256 hedgerPrice,\n uint256 auctionPrice,\n uint256 wSqueethHedgeTargetAmount,\n uint256 ethHedgetargetAmount\n );\n event HedgeOnUniswap(\n address indexed hedger,\n bool auctionType,\n uint256 auctionPrice,\n uint256 wSqueethHedgeTargetAmount,\n uint256 ethHedgetargetAmount\n );\n event ExecuteSellAuction(address indexed buyer, uint256 wSqueethSold, uint256 ethBought, bool isHedgingOnUniswap);\n event ExecuteBuyAuction(address indexed seller, uint256 wSqueethBought, uint256 ethSold, bool isHedgingOnUniswap);\n event SetStrategyCap(uint256 newCapAmount, uint256 oldCapAmount);\n\n /**\n * @notice strategy constructor\n * @dev this will open a vault in the power token contract and store the vault ID\n * @param _wSqueethController power token controller address\n * @param _oracle oracle address\n * @param _weth weth address\n * @param _uniswapFactory uniswap factory address\n * @param _ethWSqueethPool eth:wSqueeth uniswap pool address\n * @param _hedgeTimeThreshold hedge time threshold (seconds)\n * @param _hedgePriceThreshold hedge price threshold (0.1*1e18 = 10%)\n * @param _auctionTime auction duration (seconds)\n * @param _minPriceMultiplier minimum auction price multiplier (0.9*1e18 = min auction price is 90% of twap)\n * @param _maxPriceMultiplier maximum auction price multiplier (1.1*1e18 = max auction price is 110% of twap)\n */\n constructor(\n address _wSqueethController,\n address _oracle,\n address _weth,\n address _uniswapFactory,\n address _ethWSqueethPool,\n uint256 _hedgeTimeThreshold,\n uint256 _hedgePriceThreshold,\n uint256 _auctionTime,\n uint256 _minPriceMultiplier,\n uint256 _maxPriceMultiplier\n ) StrategyBase(_wSqueethController, _weth, \"Crab Strategy\", \"Crab\") StrategyFlashSwap(_uniswapFactory) {\n require(_oracle != address(0), \"invalid oracle address\");\n require(_ethWSqueethPool != address(0), \"invalid ETH:WSqueeth address\");\n require(_hedgeTimeThreshold > 0, \"invalid hedge time threshold\");\n require(_hedgePriceThreshold > 0, \"invalid hedge price threshold\");\n require(_auctionTime > 0, \"invalid auction time\");\n require(_minPriceMultiplier < 1e18, \"auction min price multiplier too high\");\n require(_minPriceMultiplier > 0, \"invalid auction min price multiplier\");\n require(_maxPriceMultiplier > 1e18, \"auction max price multiplier too low\");\n\n oracle = _oracle;\n ethWSqueethPool = _ethWSqueethPool;\n hedgeTimeThreshold = _hedgeTimeThreshold;\n hedgePriceThreshold = _hedgePriceThreshold;\n auctionTime = _auctionTime;\n minPriceMultiplier = _minPriceMultiplier;\n maxPriceMultiplier = _maxPriceMultiplier;\n ethQuoteCurrencyPool = IController(_wSqueethController).ethQuoteCurrencyPool();\n quoteCurrency = IController(_wSqueethController).quoteCurrency();\n }\n\n /**\n * @notice receive function to allow ETH transfer to this contract\n */\n receive() external payable {\n require(msg.sender == weth || msg.sender == address(powerTokenController), \"Cannot receive eth\");\n }\n\n /**\n * @notice flash deposit into strategy, providing ETH, selling wSqueeth and receiving strategy tokens\n * @dev this function will execute a flash swap where it receives ETH, deposits and mints using flash swap proceeds and msg.value, and then repays the flash swap with wSqueeth\n * @dev _ethToDeposit must be less than msg.value plus the proceeds from the flash swap\n * @dev the difference between _ethToDeposit and msg.value provides the minimum that a user can receive for their sold wSqueeth\n * @param _ethToDeposit total ETH that will be deposited in to the strategy which is a combination of msg.value and flash swap proceeds\n */\n function flashDeposit(uint256 _ethToDeposit) external payable nonReentrant {\n (uint256 cachedStrategyDebt, uint256 cachedStrategyCollateral) = _syncStrategyState();\n _checkStrategyCap(_ethToDeposit, cachedStrategyCollateral);\n\n (uint256 wSqueethToMint, ) = _calcWsqueethToMintAndFee(\n _ethToDeposit,\n cachedStrategyDebt,\n cachedStrategyCollateral\n );\n\n if (cachedStrategyDebt == 0 && cachedStrategyCollateral == 0) {\n // store hedge data as strategy is delta neutral at this point\n // only execute this upon first deposit\n uint256 wSqueethEthPrice = IOracle(oracle).getTwap(ethWSqueethPool, wPowerPerp, weth, TWAP_PERIOD, true);\n timeAtLastHedge = block.timestamp;\n priceAtLastHedge = wSqueethEthPrice;\n }\n\n _exactInFlashSwap(\n wPowerPerp,\n weth,\n IUniswapV3Pool(ethWSqueethPool).fee(),\n wSqueethToMint,\n _ethToDeposit.sub(msg.value),\n uint8(FLASH_SOURCE.FLASH_DEPOSIT),\n abi.encodePacked(_ethToDeposit)\n );\n\n emit FlashDeposit(msg.sender, _ethToDeposit, wSqueethToMint);\n }\n\n /**\n * @notice flash deposit into strategy, providing strategy tokens, buying wSqueeth, burning and receiving ETH\n * @dev this function will execute a flash swap where it receives wSqueeth, burns, withdraws ETH and then repays the flash swap with ETH\n * @param _crabAmount strategy token amount to burn\n * @param _maxEthToPay maximum ETH to pay to buy back the owed wSqueeth debt\n */\n function flashWithdraw(uint256 _crabAmount, uint256 _maxEthToPay) external nonReentrant {\n uint256 exactWSqueethNeeded = _getDebtFromStrategyAmount(_crabAmount);\n\n _exactOutFlashSwap(\n weth,\n wPowerPerp,\n IUniswapV3Pool(ethWSqueethPool).fee(),\n exactWSqueethNeeded,\n _maxEthToPay,\n uint8(FLASH_SOURCE.FLASH_WITHDRAW),\n abi.encodePacked(_crabAmount)\n );\n\n emit FlashWithdraw(msg.sender, _crabAmount, exactWSqueethNeeded);\n }\n\n /**\n * @notice deposit ETH into strategy\n * @dev provide ETH, return wSqueeth and strategy token\n * @return wSqueethToMint minted amount of wSqueeth\n * @return depositorCrabAmount minted amount of strategy token\n */\n function deposit() external payable nonReentrant returns (uint256, uint256) {\n uint256 amount = msg.value;\n\n (uint256 wSqueethToMint, uint256 depositorCrabAmount) = _deposit(msg.sender, amount, false);\n\n emit Deposit(msg.sender, wSqueethToMint, depositorCrabAmount);\n\n return (wSqueethToMint, depositorCrabAmount);\n }\n\n /**\n * @notice withdraw WETH from strategy\n * @dev provide strategy tokens and wSqueeth, returns eth\n * @param _crabAmount amount of strategy token to burn\n */\n function withdraw(uint256 _crabAmount) external payable nonReentrant {\n uint256 wSqueethAmount = _getDebtFromStrategyAmount(_crabAmount);\n uint256 ethToWithdraw = _withdraw(msg.sender, _crabAmount, wSqueethAmount, false);\n\n // send back ETH collateral\n payable(msg.sender).sendValue(ethToWithdraw);\n\n emit Withdraw(msg.sender, _crabAmount, wSqueethAmount, ethToWithdraw);\n }\n\n /**\n * @notice called to exit a vault if the Squeeth Power Perp contracts are shutdown\n * @param _crabAmount amount of strategy token to burn\n */\n function withdrawShutdown(uint256 _crabAmount) external nonReentrant {\n require(powerTokenController.isShutDown(), \"Squeeth contracts are not shut down\");\n require(hasRedeemedInShutdown, \"Strategy has not redeemed vault proceeds\");\n\n uint256 strategyShare = _calcCrabRatio(_crabAmount, totalSupply());\n uint256 ethToWithdraw = _calcEthToWithdraw(strategyShare, address(this).balance);\n _burn(msg.sender, _crabAmount);\n\n payable(msg.sender).sendValue(ethToWithdraw);\n emit WithdrawShutdown(msg.sender, _crabAmount, ethToWithdraw);\n }\n\n /**\n * @notice hedge startegy based on time threshold with uniswap arbing\n * @param _minWSqueeth minimum WSqueeth amount of profit if hedge auction is selling WSqueeth\n * @param _minEth minimum ETH amount of profit if hedge auction is buying WSqueeth\n */\n function timeHedgeOnUniswap(uint256 _minWSqueeth, uint256 _minEth) external {\n uint256 auctionTriggerTime = timeAtLastHedge.add(hedgeTimeThreshold);\n\n require(block.timestamp >= auctionTriggerTime, \"Time hedging is not allowed\");\n\n _hedgeOnUniswap(auctionTriggerTime, _minWSqueeth, _minEth);\n\n emit TimeHedgeOnUniswap(msg.sender, block.timestamp, auctionTriggerTime, _minWSqueeth, _minEth);\n }\n\n /**\n * @notice hedge startegy based on price threshold with uniswap arbing\n */\n function priceHedgeOnUniswap(\n uint256 _auctionTriggerTime,\n uint256 _minWSqueeth,\n uint256 _minEth\n ) external payable {\n require(_isPriceHedge(_auctionTriggerTime), \"Price hedging not allowed\");\n\n _hedgeOnUniswap(_auctionTriggerTime, _minWSqueeth, _minEth);\n\n emit PriceHedgeOnUniswap(msg.sender, block.timestamp, _auctionTriggerTime, _minWSqueeth, _minEth);\n }\n\n /**\n * @notice strategy hedging based on time threshold\n * @dev need to attach msg.value if buying WSqueeth\n * @param _isStrategySellingWSqueeth sell or buy auction, true for sell auction\n * @param _limitPrice hedger limit auction price, should be the max price when auction is sell auction, min price when it is a buy auction\n */\n function timeHedge(bool _isStrategySellingWSqueeth, uint256 _limitPrice) external payable nonReentrant {\n (bool isTimeHedgeAllowed, uint256 auctionTriggerTime) = _isTimeHedge();\n\n require(isTimeHedgeAllowed, \"Time hedging is not allowed\");\n\n _hedge(auctionTriggerTime, _isStrategySellingWSqueeth, _limitPrice);\n\n emit TimeHedge(msg.sender, _isStrategySellingWSqueeth, _limitPrice, auctionTriggerTime);\n }\n\n /**\n * @notice strategy hedging based on price threshold\n * @dev need to attach msg.value if buying WSqueeth\n * @param _auctionTriggerTime timestamp where auction started\n */\n function priceHedge(\n uint256 _auctionTriggerTime,\n bool _isStrategySellingWSqueeth,\n uint256 _limitPrice\n ) external payable nonReentrant {\n require(_isPriceHedge(_auctionTriggerTime), \"Price hedging not allowed\");\n\n _hedge(_auctionTriggerTime, _isStrategySellingWSqueeth, _limitPrice);\n\n emit PriceHedge(msg.sender, _isStrategySellingWSqueeth, _limitPrice, _auctionTriggerTime);\n }\n\n /**\n * @notice check if hedging based on price threshold is allowed\n * @param _auctionTriggerTime alleged timestamp where auction was triggered\n * @return true if hedging is allowed\n */\n function checkPriceHedge(uint256 _auctionTriggerTime) external view returns (bool) {\n return _isPriceHedge(_auctionTriggerTime);\n }\n\n /**\n * @notice check if hedging based on time threshold is allowed\n * @return isTimeHedgeAllowed true if hedging is allowed\n * @return auctionTriggertime auction trigger timestamp\n */\n function checkTimeHedge() external view returns (bool, uint256) {\n (bool isTimeHedgeAllowed, uint256 auctionTriggerTime) = _isTimeHedge();\n\n return (isTimeHedgeAllowed, auctionTriggerTime);\n }\n\n /**\n * @notice get wSqueeth debt amount associated with strategy token amount\n * @dev _crabAmount strategy token amount\n * @return wSqueeth amount\n */\n function getWsqueethFromCrabAmount(uint256 _crabAmount) external view returns (uint256) {\n return _getDebtFromStrategyAmount(_crabAmount);\n }\n\n /**\n * @notice owner can set the strategy cap in ETH collateral terms\n * @dev deposits are rejected if it would put the strategy above the cap amount\n * @dev strategy collateral can be above the cap amount due to hedging activities\n * @param _capAmount the maximum strategy collateral in ETH, checked on deposits\n */\n function setStrategyCap(uint256 _capAmount) external onlyOwner {\n uint256 oldCap = strategyCap;\n strategyCap = _capAmount;\n\n emit SetStrategyCap(_capAmount, oldCap);\n }\n\n /**\n * @notice called to redeem the net value of a vault post shutdown\n * @dev needs to be called 1 time before users can exit the strategy using withdrawShutdown\n */\n function redeemShortShutdown() external {\n hasRedeemedInShutdown = true;\n powerTokenController.redeemShort(vaultId);\n }\n\n /**\n * @notice check if a user deposit puts the strategy above the cap\n * @dev reverts if a deposit amount puts strategy over the cap\n * @dev it is possible for the strategy to be over the cap from trading/hedging activities, but withdrawals are still allowed\n * @param _depositAmount the user deposit amount in ETH\n * @param _strategyCollateral the updated strategy collateral\n */\n function _checkStrategyCap(uint256 _depositAmount, uint256 _strategyCollateral) internal view {\n require(_strategyCollateral.add(_depositAmount) <= strategyCap, \"Deposit exceeds strategy cap\");\n }\n\n /**\n * @notice uniswap flash swap callback function\n * @dev this function will be called by flashswap callback function uniswapV3SwapCallback()\n * @param _caller address of original function caller\n * @param _amountToPay amount to pay back for flashswap\n * @param _callData arbitrary data attached to callback\n * @param _callSource identifier for which function triggered callback\n */\n function _strategyFlash(\n address _caller,\n address, /*_tokenIn*/\n address, /*_tokenOut*/\n uint24, /*_fee*/\n uint256 _amountToPay,\n bytes memory _callData,\n uint8 _callSource\n ) internal override {\n if (FLASH_SOURCE(_callSource) == FLASH_SOURCE.FLASH_DEPOSIT) {\n FlashDepositData memory data = abi.decode(_callData, (FlashDepositData));\n\n // convert WETH to ETH as Uniswap uses WETH\n IWETH9(weth).withdraw(IWETH9(weth).balanceOf(address(this)));\n\n //use user msg.value and unwrapped WETH from uniswap flash swap proceeds to deposit into strategy\n //will revert if data.totalDeposit is > eth balance in contract\n _deposit(_caller, data.totalDeposit, true);\n\n //repay the flash swap\n IWPowerPerp(wPowerPerp).transfer(ethWSqueethPool, _amountToPay);\n\n //return excess eth to the user that was not needed for slippage\n if (address(this).balance > 0) {\n payable(_caller).sendValue(address(this).balance);\n }\n } else if (FLASH_SOURCE(_callSource) == FLASH_SOURCE.FLASH_WITHDRAW) {\n FlashWithdrawData memory data = abi.decode(_callData, (FlashWithdrawData));\n\n //use flash swap wSqueeth proceeds to withdraw ETH along with user crabAmount\n uint256 ethToWithdraw = _withdraw(\n _caller,\n data.crabAmount,\n IWPowerPerp(wPowerPerp).balanceOf(address(this)),\n true\n );\n\n //use some amount of withdrawn ETH to repay flash swap\n IWETH9(weth).deposit{value: _amountToPay}();\n IWETH9(weth).transfer(ethWSqueethPool, _amountToPay);\n\n //excess ETH not used to repay flash swap is transferred to the user\n uint256 proceeds = ethToWithdraw.sub(_amountToPay);\n if (proceeds > 0) {\n payable(_caller).sendValue(proceeds);\n }\n } else if (FLASH_SOURCE(_callSource) == FLASH_SOURCE.FLASH_HEDGE_SELL) {\n //strategy is selling wSqueeth for ETH\n FlashHedgeData memory data = abi.decode(_callData, (FlashHedgeData));\n\n // convert WETH to ETH as Uniswap uses WETH\n IWETH9(weth).withdraw(IWETH9(weth).balanceOf(address(this)));\n //mint wSqueeth to pay hedger and repay flash swap, deposit ETH\n _executeSellAuction(_caller, data.ethProceeds, data.wSqueethAmount, data.ethProceeds, true);\n\n //determine excess wSqueeth that the auction would have sold but is not needed to repay flash swap\n uint256 wSqueethProfit = data.wSqueethAmount.sub(_amountToPay);\n\n //minimum profit check for hedger\n require(wSqueethProfit >= data.minWSqueeth, \"profit is less than min wSqueeth\");\n\n //repay flash swap and transfer profit to hedger\n IWPowerPerp(wPowerPerp).transfer(ethWSqueethPool, _amountToPay);\n IWPowerPerp(wPowerPerp).transfer(_caller, wSqueethProfit);\n } else if (FLASH_SOURCE(_callSource) == FLASH_SOURCE.FLASH_HEDGE_BUY) {\n //strategy is buying wSqueeth for ETH\n FlashHedgeData memory data = abi.decode(_callData, (FlashHedgeData));\n\n //withdraw ETH to pay hedger and repay flash swap, burn wSqueeth\n _executeBuyAuction(_caller, data.wSqueethAmount, data.ethProceeds, true);\n\n //determine excess ETH that the auction would have paid but is not needed to repay flash swap\n uint256 ethProfit = data.ethProceeds.sub(_amountToPay);\n\n //minimum profit check for hedger\n require(ethProfit >= data.minEth, \"profit is less than min ETH\");\n\n //repay flash swap and transfer profit to hedger\n IWETH9(weth).deposit{value: _amountToPay}();\n IWETH9(weth).transfer(ethWSqueethPool, _amountToPay);\n payable(_caller).sendValue(ethProfit);\n }\n }\n\n /**\n * @notice deposit into strategy\n * @dev if _isFlashDeposit is true, keeps wSqueeth in contract, otherwise sends to user\n * @param _depositor depositor address\n * @param _amount amount of ETH collateral to deposit\n * @param _isFlashDeposit true if called by flashDeposit\n * @return wSqueethToMint minted amount of WSqueeth\n * @return depositorCrabAmount minted CRAB strategy token amount\n */\n function _deposit(\n address _depositor,\n uint256 _amount,\n bool _isFlashDeposit\n ) internal returns (uint256, uint256) {\n (uint256 strategyDebt, uint256 strategyCollateral) = _syncStrategyState();\n _checkStrategyCap(_amount, strategyCollateral);\n\n (uint256 wSqueethToMint, uint256 ethFee) = _calcWsqueethToMintAndFee(_amount, strategyDebt, strategyCollateral);\n\n uint256 depositorCrabAmount = _calcSharesToMint(_amount.sub(ethFee), strategyCollateral, totalSupply());\n\n if (strategyDebt == 0 && strategyCollateral == 0) {\n // store hedge data as strategy is delta neutral at this point\n // only execute this upon first deposit\n uint256 wSqueethEthPrice = IOracle(oracle).getTwap(ethWSqueethPool, wPowerPerp, weth, TWAP_PERIOD, true);\n timeAtLastHedge = block.timestamp;\n priceAtLastHedge = wSqueethEthPrice;\n }\n\n // mint wSqueeth and send it to msg.sender\n _mintWPowerPerp(_depositor, wSqueethToMint, _amount, _isFlashDeposit);\n // mint LP to depositor\n _mintStrategyToken(_depositor, depositorCrabAmount);\n\n return (wSqueethToMint, depositorCrabAmount);\n }\n\n /**\n * @notice withdraw WETH from strategy\n * @dev if _isFlashDeposit is true, keeps wSqueeth in contract, otherwise sends to user\n * @param _crabAmount amount of strategy token to burn\n * @param _wSqueethAmount amount of wSqueeth to burn\n * @param _isFlashWithdraw flag if called by flashWithdraw\n * @return ETH amount to withdraw\n */\n function _withdraw(\n address _from,\n uint256 _crabAmount,\n uint256 _wSqueethAmount,\n bool _isFlashWithdraw\n ) internal returns (uint256) {\n (, uint256 strategyCollateral) = _syncStrategyState();\n\n uint256 strategyShare = _calcCrabRatio(_crabAmount, totalSupply());\n uint256 ethToWithdraw = _calcEthToWithdraw(strategyShare, strategyCollateral);\n\n _burnWPowerPerp(_from, _wSqueethAmount, ethToWithdraw, _isFlashWithdraw);\n _burn(_from, _crabAmount);\n\n return ethToWithdraw;\n }\n\n /**\n * @notice hedging function to adjust collateral and debt to be eth delta neutral\n * @param _auctionTriggerTime timestamp where auction started\n * @param _isStrategySellingWSqueeth auction type, true for sell auction\n * @param _limitPrice hedger accepted auction price, should be the max price when auction is sell auction, min price when it is a buy auction\n */\n function _hedge(\n uint256 _auctionTriggerTime,\n bool _isStrategySellingWSqueeth,\n uint256 _limitPrice\n ) internal {\n (\n bool isSellingAuction,\n uint256 wSqueethToAuction,\n uint256 ethProceeds,\n uint256 auctionWSqueethEthPrice\n ) = _startAuction(_auctionTriggerTime);\n\n require(_isStrategySellingWSqueeth == isSellingAuction, \"wrong auction type\");\n\n if (isSellingAuction) {\n // Receiving ETH and paying wSqueeth\n require(auctionWSqueethEthPrice <= _limitPrice, \"Auction price greater than max accepted price\");\n require(msg.value >= ethProceeds, \"Low ETH amount received\");\n\n _executeSellAuction(msg.sender, msg.value, wSqueethToAuction, ethProceeds, false);\n } else {\n require(msg.value == 0, \"ETH attached for buy auction\");\n // Receiving wSqueeth and paying ETH\n require(auctionWSqueethEthPrice >= _limitPrice, \"Auction price greater than min accepted price\");\n _executeBuyAuction(msg.sender, wSqueethToAuction, ethProceeds, false);\n }\n\n emit Hedge(\n msg.sender,\n _isStrategySellingWSqueeth,\n _limitPrice,\n auctionWSqueethEthPrice,\n wSqueethToAuction,\n ethProceeds\n );\n }\n\n /**\n * @notice execute arb between auction price and uniswap price\n * @param _auctionTriggerTime auction starting time\n */\n function _hedgeOnUniswap(\n uint256 _auctionTriggerTime,\n uint256 _minWSqueeth,\n uint256 _minEth\n ) internal {\n (\n bool isSellingAuction,\n uint256 wSqueethToAuction,\n uint256 ethProceeds,\n uint256 auctionWSqueethEthPrice\n ) = _startAuction(_auctionTriggerTime);\n\n if (isSellingAuction) {\n _exactOutFlashSwap(\n wPowerPerp,\n weth,\n IUniswapV3Pool(ethWSqueethPool).fee(),\n ethProceeds,\n wSqueethToAuction,\n uint8(FLASH_SOURCE.FLASH_HEDGE_SELL),\n abi.encodePacked(wSqueethToAuction, ethProceeds, _minWSqueeth, _minEth)\n );\n } else {\n _exactOutFlashSwap(\n weth,\n wPowerPerp,\n IUniswapV3Pool(ethWSqueethPool).fee(),\n wSqueethToAuction,\n ethProceeds,\n uint8(FLASH_SOURCE.FLASH_HEDGE_BUY),\n abi.encodePacked(wSqueethToAuction, ethProceeds, _minWSqueeth, _minEth)\n );\n }\n\n emit HedgeOnUniswap(msg.sender, isSellingAuction, auctionWSqueethEthPrice, wSqueethToAuction, ethProceeds);\n }\n\n /**\n * @notice execute sell auction based on the parameters calculated\n * @dev if _isHedgingOnUniswap, wSqueeth minted is kept to repay flashswap, otherwise sent to seller\n * @param _buyer buyer address\n * @param _buyerAmount buyer ETH amount sent\n * @param _wSqueethToSell wSqueeth amount to sell\n * @param _ethToBuy ETH amount to buy\n * @param _isHedgingOnUniswap true if arbing with uniswap price\n */\n function _executeSellAuction(\n address _buyer,\n uint256 _buyerAmount,\n uint256 _wSqueethToSell,\n uint256 _ethToBuy,\n bool _isHedgingOnUniswap\n ) internal {\n if (_isHedgingOnUniswap) {\n _mintWPowerPerp(_buyer, _wSqueethToSell, _ethToBuy, true);\n } else {\n _mintWPowerPerp(_buyer, _wSqueethToSell, _ethToBuy, false);\n\n uint256 remainingEth = _buyerAmount.sub(_ethToBuy);\n\n if (remainingEth > 0) {\n payable(_buyer).sendValue(remainingEth);\n }\n }\n\n emit ExecuteSellAuction(_buyer, _wSqueethToSell, _ethToBuy, _isHedgingOnUniswap);\n }\n\n /**\n * @notice execute buy auction based on the parameters calculated\n * @dev if _isHedgingOnUniswap, ETH proceeds are not sent to seller\n * @param _seller seller address\n * @param _wSqueethToBuy wSqueeth amount to buy\n * @param _ethToSell ETH amount to sell\n * @param _isHedgingOnUniswap true if arbing with uniswap price\n */\n function _executeBuyAuction(\n address _seller,\n uint256 _wSqueethToBuy,\n uint256 _ethToSell,\n bool _isHedgingOnUniswap\n ) internal {\n _burnWPowerPerp(_seller, _wSqueethToBuy, _ethToSell, _isHedgingOnUniswap);\n\n if (!_isHedgingOnUniswap) {\n payable(_seller).sendValue(_ethToSell);\n }\n\n emit ExecuteBuyAuction(_seller, _wSqueethToBuy, _ethToSell, _isHedgingOnUniswap);\n }\n\n /**\n * @notice determine auction direction, price, and ensure auction hasn't switched directions\n * @param _auctionTriggerTime auction starting time\n * @return auction type\n * @return WSqueeth amount to sell or buy\n * @return ETH to sell/buy\n * @return auction WSqueeth/ETH price\n */\n function _startAuction(uint256 _auctionTriggerTime)\n internal\n returns (\n bool,\n uint256,\n uint256,\n uint256\n )\n {\n (uint256 strategyDebt, uint256 ethDelta) = _syncStrategyState();\n uint256 currentWSqueethPrice = IOracle(oracle).getTwap(ethWSqueethPool, wPowerPerp, weth, TWAP_PERIOD, true);\n uint256 feeAdjustment = _calcFeeAdjustment();\n (bool isSellingAuction, ) = _checkAuctionType(strategyDebt, ethDelta, currentWSqueethPrice, feeAdjustment);\n uint256 auctionWSqueethEthPrice = _getAuctionPrice(_auctionTriggerTime, currentWSqueethPrice, isSellingAuction);\n (bool isStillSellingAuction, uint256 wSqueethToAuction) = _checkAuctionType(\n strategyDebt,\n ethDelta,\n auctionWSqueethEthPrice,\n feeAdjustment\n );\n\n require(isSellingAuction == isStillSellingAuction, \"can not execute hedging trade as auction type changed\");\n\n uint256 ethProceeds = wSqueethToAuction.wmul(auctionWSqueethEthPrice);\n\n timeAtLastHedge = block.timestamp;\n priceAtLastHedge = currentWSqueethPrice;\n\n return (isSellingAuction, wSqueethToAuction, ethProceeds, auctionWSqueethEthPrice);\n }\n\n /**\n * @notice sync strategy debt and collateral amount from vault\n * @return synced debt amount\n * @return synced collateral amount\n */\n function _syncStrategyState() internal view returns (uint256, uint256) {\n (, , uint256 syncedStrategyCollateral, uint256 syncedStrategyDebt) = _getVaultDetails();\n\n return (syncedStrategyDebt, syncedStrategyCollateral);\n }\n\n /**\n * @notice calculate the fee adjustment factor, which is the amount of ETH owed per 1 wSqueeth minted\n * @dev the fee is a based off the index value of squeeth and uses a twap scaled down by the PowerPerp's INDEX_SCALE\n * @return the fee adjustment factor\n */\n function _calcFeeAdjustment() internal view returns (uint256) {\n uint256 wSqueethEthPrice = Power2Base._getTwap(\n oracle,\n ethWSqueethPool,\n wPowerPerp,\n weth,\n POWER_PERP_PERIOD,\n false\n );\n uint256 feeRate = IController(powerTokenController).feeRate();\n return wSqueethEthPrice.mul(feeRate).div(10000);\n }\n\n /**\n * @notice calculate amount of wSqueeth to mint and fee paid from deposited amount\n * @param _depositedAmount amount of deposited WETH\n * @param _strategyDebtAmount amount of strategy debt\n * @param _strategyCollateralAmount collateral amount in strategy\n * @return amount of minted wSqueeth and ETH fee paid on minted squeeth\n */\n function _calcWsqueethToMintAndFee(\n uint256 _depositedAmount,\n uint256 _strategyDebtAmount,\n uint256 _strategyCollateralAmount\n ) internal view returns (uint256, uint256) {\n uint256 wSqueethToMint;\n uint256 feeAdjustment = _calcFeeAdjustment();\n\n if (_strategyDebtAmount == 0 && _strategyCollateralAmount == 0) {\n require(\n totalSupply() == 0,\n \"Crab strategy shut down due to full liquidation or shutdown of squeeth contracts\"\n );\n\n uint256 wSqueethEthPrice = IOracle(oracle).getTwap(ethWSqueethPool, wPowerPerp, weth, TWAP_PERIOD, true);\n uint256 squeethDelta = wSqueethEthPrice.wmul(2e18);\n wSqueethToMint = _depositedAmount.wdiv(squeethDelta.add(feeAdjustment));\n } else {\n wSqueethToMint = _depositedAmount.wmul(_strategyDebtAmount).wdiv(\n _strategyCollateralAmount.add(_strategyDebtAmount.wmul(feeAdjustment))\n );\n }\n\n uint256 fee = wSqueethToMint.wmul(feeAdjustment);\n\n return (wSqueethToMint, fee);\n }\n\n /**\n * @notice check if hedging based on time threshold is allowed\n * @return true if time hedging is allowed\n * @return auction trigger timestamp\n */\n function _isTimeHedge() internal view returns (bool, uint256) {\n uint256 auctionTriggerTime = timeAtLastHedge.add(hedgeTimeThreshold);\n\n return (block.timestamp >= auctionTriggerTime, auctionTriggerTime);\n }\n\n /**\n * @notice check if hedging based on price threshold is allowed\n * @return true if hedging is allowed\n */\n function _isPriceHedge(uint256 _auctionTriggerTime) internal view returns (bool) {\n uint32 secondsToPriceHedgeTrigger = uint32(block.timestamp.sub(_auctionTriggerTime));\n uint256 wSqueethEthPriceAtTriggerTime = IOracle(oracle).getHistoricalTwap(\n ethWSqueethPool,\n wPowerPerp,\n weth,\n secondsToPriceHedgeTrigger + TWAP_PERIOD,\n secondsToPriceHedgeTrigger\n );\n uint256 cachedRatio = wSqueethEthPriceAtTriggerTime.wdiv(priceAtLastHedge);\n uint256 priceThreshold = cachedRatio > 1e18 ? (cachedRatio).sub(1e18) : uint256(1e18).sub(cachedRatio);\n\n return priceThreshold >= hedgePriceThreshold;\n }\n\n /**\n * @notice calculate auction price based on auction direction, start time and wSqueeth price\n * @param _auctionTriggerTime timestamp where auction started\n * @param _wSqueethEthPrice WSqueeth/ETH price\n * @param _isSellingAuction auction type (true for selling, false for buying auction)\n * @return auction price\n */\n function _getAuctionPrice(\n uint256 _auctionTriggerTime,\n uint256 _wSqueethEthPrice,\n bool _isSellingAuction\n ) internal view returns (uint256) {\n uint256 auctionCompletionRatio = block.timestamp.sub(_auctionTriggerTime) >= auctionTime\n ? 1e18\n : (block.timestamp.sub(_auctionTriggerTime)).wdiv(auctionTime);\n\n uint256 priceMultiplier;\n if (_isSellingAuction) {\n priceMultiplier = maxPriceMultiplier.sub(\n auctionCompletionRatio.wmul(maxPriceMultiplier.sub(minPriceMultiplier))\n );\n } else {\n priceMultiplier = minPriceMultiplier.add(\n auctionCompletionRatio.wmul(maxPriceMultiplier.sub(minPriceMultiplier))\n );\n }\n\n return _wSqueethEthPrice.wmul(priceMultiplier);\n }\n\n /**\n * @notice check the direction of auction and the target amount of wSqueeth to hedge\n * @param _debt strategy debt\n * @param _ethDelta ETH delta (amount of ETH in strategy)\n * @param _wSqueethEthPrice WSqueeth/ETH price\n * @param _feeAdjustment the fee adjustment, the amount of ETH owed per wSqueeth minted\n * @return auction type(sell or buy) and auction initial target hedge in wSqueth\n */\n function _checkAuctionType(\n uint256 _debt,\n uint256 _ethDelta,\n uint256 _wSqueethEthPrice,\n uint256 _feeAdjustment\n ) internal pure returns (bool, uint256) {\n uint256 wSqueethDelta = _debt.wmul(2e18).wmul(_wSqueethEthPrice);\n\n (uint256 targetHedge, bool isSellingAuction) = _getTargetHedgeAndAuctionType(\n wSqueethDelta,\n _ethDelta,\n _wSqueethEthPrice,\n _feeAdjustment\n );\n\n uint256 collateralRatioToHedge = targetHedge.wmul(_wSqueethEthPrice).wdiv(_ethDelta);\n\n require(collateralRatioToHedge > DELTA_HEDGE_THRESHOLD, \"strategy is delta neutral\");\n\n return (isSellingAuction, targetHedge);\n }\n\n /**\n * @dev calculate amount of strategy token to mint for depositor\n * @param _amount amount of ETH deposited\n * @param _strategyCollateralAmount amount of strategy collateral\n * @param _crabTotalSupply total supply of strategy token\n * @return amount of strategy token to mint\n */\n function _calcSharesToMint(\n uint256 _amount,\n uint256 _strategyCollateralAmount,\n uint256 _crabTotalSupply\n ) internal pure returns (uint256) {\n uint256 depositorShare = _amount.wdiv(_strategyCollateralAmount.add(_amount));\n\n if (_crabTotalSupply != 0) return _crabTotalSupply.wmul(depositorShare).wdiv(uint256(1e18).sub(depositorShare));\n\n return _amount;\n }\n\n /**\n * @notice calculates the ownership proportion for strategy debt and collateral relative to a total amount of strategy tokens\n * @param _crabAmount strategy token amount\n * @param _totalSupply strategy total supply\n * @return ownership proportion of a strategy token amount relative to the total strategy tokens\n */\n function _calcCrabRatio(uint256 _crabAmount, uint256 _totalSupply) internal pure returns (uint256) {\n return _crabAmount.wdiv(_totalSupply);\n }\n\n /**\n * @notice calculate ETH to withdraw from strategy given a ownership proportion\n * @param _crabRatio crab ratio\n * @param _strategyCollateralAmount amount of collateral in strategy\n * @return amount of ETH allowed to withdraw\n */\n function _calcEthToWithdraw(uint256 _crabRatio, uint256 _strategyCollateralAmount) internal pure returns (uint256) {\n return _strategyCollateralAmount.wmul(_crabRatio);\n }\n\n /**\n * @notice determine target hedge and auction type (selling/buying auction)\n * @dev target hedge is the amount of WSqueeth the auction needs to sell or buy to be eth delta neutral\n * @param _wSqueethDelta WSqueeth delta\n * @param _ethDelta ETH delta\n * @param _wSqueethEthPrice WSqueeth/ETH price\n * @param _feeAdjustment the fee adjustment, the amount of ETH owed per wSqueeth minted\n * @return target hedge in wSqueeth\n * @return auction type: true if auction is selling WSqueeth, false if buying WSqueeth\n */\n function _getTargetHedgeAndAuctionType(\n uint256 _wSqueethDelta,\n uint256 _ethDelta,\n uint256 _wSqueethEthPrice,\n uint256 _feeAdjustment\n ) internal pure returns (uint256, bool) {\n return\n (_wSqueethDelta > _ethDelta)\n ? ((_wSqueethDelta.sub(_ethDelta)).wdiv(_wSqueethEthPrice), false)\n : ((_ethDelta.sub(_wSqueethDelta)).wdiv(_wSqueethEthPrice.add(_feeAdjustment)), true);\n }\n}\n" + }, + "contracts/strategy/base/StrategyFlashSwap.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity =0.7.6;\npragma abicoder v2;\n\n// interface\nimport \"@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol\";\nimport \"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\";\n\n// lib\nimport '@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol';\nimport '@uniswap/v3-periphery/contracts/libraries/Path.sol';\nimport '@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol';\nimport '@uniswap/v3-periphery/contracts/libraries/CallbackValidation.sol';\nimport '@uniswap/v3-core/contracts/libraries/TickMath.sol';\nimport '@uniswap/v3-core/contracts/libraries/SafeCast.sol';\n\ncontract StrategyFlashSwap is IUniswapV3SwapCallback {\n using Path for bytes;\n using SafeCast for uint256;\n using LowGasSafeMath for uint256;\n using LowGasSafeMath for int256;\n\n /// @dev Uniswap factory address\n address public immutable factory;\n\n struct SwapCallbackData {\n bytes path;\n address caller;\n uint8 callSource;\n bytes callData;\n }\n\n /**\n * @dev constructor\n * @param _factory uniswap factory address\n */\n constructor(\n address _factory\n ) {\n require(_factory != address(0), \"invalid factory address\");\n factory = _factory;\n }\n\n /**\n * @notice uniswap swap callback function for flashes\n * @param amount0Delta amount of token0\n * @param amount1Delta amount of token1\n * @param _data callback data encoded as SwapCallbackData struct\n */\n function uniswapV3SwapCallback(\n int256 amount0Delta,\n int256 amount1Delta,\n bytes calldata _data\n ) external override {\n require(amount0Delta > 0 || amount1Delta > 0); // swaps entirely within 0-liquidity regions are not supported\n\n SwapCallbackData memory data = abi.decode(_data, (SwapCallbackData));\n (address tokenIn, address tokenOut, uint24 fee) = data.path.decodeFirstPool();\n\n //ensure that callback comes from uniswap pool\n CallbackValidation.verifyCallback(factory, tokenIn, tokenOut, fee);\n\n //determine the amount that needs to be repaid as part of the flashswap\n uint256 amountToPay =\n amount0Delta > 0\n ? uint256(amount0Delta)\n : uint256(amount1Delta);\n \n //calls the strategy function that uses the proceeds from flash swap and executes logic to have an amount of token to repay the flash swap\n _strategyFlash(data.caller, tokenIn, tokenOut, fee, amountToPay, data.callData, data.callSource);\n }\n\n /**\n * @notice execute an exact-in flash swap (specify an exact amount to pay)\n * @param _tokenIn token address to sell\n * @param _tokenOut token address to receive\n * @param _fee pool fee\n * @param _amountIn amount to sell\n * @param _amountOutMinimum minimum amount to receive\n * @param _callSource function call source\n * @param _data arbitrary data assigned with the call \n */\n function _exactInFlashSwap(address _tokenIn, address _tokenOut, uint24 _fee, uint256 _amountIn, uint256 _amountOutMinimum, uint8 _callSource, bytes memory _data) internal {\n //calls internal uniswap swap function that will trigger a callback for the flash swap\n uint256 amountOut = _exactInputInternal(\n _amountIn,\n address(this),\n uint160(0),\n SwapCallbackData({path: abi.encodePacked(_tokenIn, _fee, _tokenOut), caller: msg.sender, callSource: _callSource, callData: _data})\n );\n \n //slippage limit check\n require(amountOut >= _amountOutMinimum, \"amount out less than min\");\n }\n\n\n /**\n * @notice execute an exact-out flash swap (specify an exact amount to receive)\n * @param _tokenIn token address to sell\n * @param _tokenOut token address to receive\n * @param _fee pool fee\n * @param _amountOut exact amount to receive\n * @param _amountInMaximum maximum amount to sell\n * @param _callSource function call source\n * @param _data arbitrary data assigned with the call \n */\n function _exactOutFlashSwap(address _tokenIn, address _tokenOut, uint24 _fee, uint256 _amountOut, uint256 _amountInMaximum, uint8 _callSource, bytes memory _data) internal {\n //calls internal uniswap swap function that will trigger a callback for the flash swap\n uint256 amountIn = _exactOutputInternal(\n _amountOut,\n address(this),\n uint160(0),\n SwapCallbackData({path: abi.encodePacked(_tokenOut, _fee, _tokenIn), caller: msg.sender, callSource: _callSource, callData: _data})\n );\n \n //slippage limit check\n require(amountIn <= _amountInMaximum, \"amount in greater than max\");\n }\n\n\n /**\n * @notice function to be called by uniswap callback. \n * @dev this function should be overridden by the child contract\n * param _caller initial strategy function caller\n * param _tokenIn token address sold\n * param _tokenOut token address bought\n * param _fee pool fee\n * param _amountToPay amount to pay for the pool second token\n * param _callData arbitrary data assigned with the flashswap call \n * param _callSource function call source\n */\n function _strategyFlash(address /*_caller*/, address /*_tokenIn*/, address /*_tokenOut*/, uint24 /*_fee*/, uint256 /*_amountToPay*/, bytes memory _callData, uint8 _callSource) internal virtual {}\n \n /** \n * @notice internal function for exact-in swap on uniswap (specify exact amount to pay)\n * @param _amountIn amount of token to pay\n * @param _recipient recipient for receive\n * @param _sqrtPriceLimitX96 price limit\n * @return amount of token bought (amountOut)\n */\n function _exactInputInternal(\n uint256 _amountIn,\n address _recipient,\n uint160 _sqrtPriceLimitX96,\n SwapCallbackData memory data\n ) private returns (uint256) {\n (address tokenIn, address tokenOut, uint24 fee) = data.path.decodeFirstPool();\n \n //uniswap token0 has a lower address than token1\n //if tokenIn=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" + }, + "@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\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" + }, + "@uniswap/v3-periphery/contracts/libraries/Path.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.6.0;\n\nimport './BytesLib.sol';\n\n/// @title Functions for manipulating path data for multihop swaps\nlibrary Path {\n using BytesLib for bytes;\n\n /// @dev The length of the bytes encoded address\n uint256 private constant ADDR_SIZE = 20;\n /// @dev The length of the bytes encoded fee\n uint256 private constant FEE_SIZE = 3;\n\n /// @dev The offset of a single token address and pool fee\n uint256 private constant NEXT_OFFSET = ADDR_SIZE + FEE_SIZE;\n /// @dev The offset of an encoded pool key\n uint256 private constant POP_OFFSET = NEXT_OFFSET + ADDR_SIZE;\n /// @dev The minimum length of an encoding that contains 2 or more pools\n uint256 private constant MULTIPLE_POOLS_MIN_LENGTH = POP_OFFSET + NEXT_OFFSET;\n\n /// @notice Returns true iff the path contains two or more pools\n /// @param path The encoded swap path\n /// @return True if path contains two or more pools, otherwise false\n function hasMultiplePools(bytes memory path) internal pure returns (bool) {\n return path.length >= MULTIPLE_POOLS_MIN_LENGTH;\n }\n\n /// @notice Returns the number of pools in the path\n /// @param path The encoded swap path\n /// @return The number of pools in the path\n function numPools(bytes memory path) internal pure returns (uint256) {\n // Ignore the first token address. From then on every fee and token offset indicates a pool.\n return ((path.length - ADDR_SIZE) / NEXT_OFFSET);\n }\n\n /// @notice Decodes the first pool in path\n /// @param path The bytes encoded swap path\n /// @return tokenA The first token of the given pool\n /// @return tokenB The second token of the given pool\n /// @return fee The fee level of the pool\n function decodeFirstPool(bytes memory path)\n internal\n pure\n returns (\n address tokenA,\n address tokenB,\n uint24 fee\n )\n {\n tokenA = path.toAddress(0);\n fee = path.toUint24(ADDR_SIZE);\n tokenB = path.toAddress(NEXT_OFFSET);\n }\n\n /// @notice Gets the segment corresponding to the first pool in the path\n /// @param path The bytes encoded swap path\n /// @return The segment containing all data necessary to target the first pool in the path\n function getFirstPool(bytes memory path) internal pure returns (bytes memory) {\n return path.slice(0, POP_OFFSET);\n }\n\n /// @notice Skips a token + fee element from the buffer and returns the remainder\n /// @param path The swap path\n /// @return The remaining token + fee elements in the path\n function skipToken(bytes memory path) internal pure returns (bytes memory) {\n return path.slice(NEXT_OFFSET, path.length - NEXT_OFFSET);\n }\n}\n" + }, + "@uniswap/v3-core/contracts/libraries/SafeCast.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\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" + }, + "@uniswap/v3-periphery/contracts/libraries/BytesLib.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\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.5.0 <0.8.0;\n\nlibrary BytesLib {\n function slice(\n bytes memory _bytes,\n uint256 _start,\n uint256 _length\n ) internal pure returns (bytes memory) {\n require(_length + 31 >= _length, 'slice_overflow');\n require(_start + _length >= _start, '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(_start + 20 >= _start, 'toAddress_overflow');\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 toUint24(bytes memory _bytes, uint256 _start) internal pure returns (uint24) {\n require(_start + 3 >= _start, 'toUint24_overflow');\n require(_bytes.length >= _start + 3, 'toUint24_outOfBounds');\n uint24 tempUint;\n\n assembly {\n tempUint := mload(add(add(_bytes, 0x3), _start))\n }\n\n return tempUint;\n }\n}\n" + }, + "contracts/periphery/ShortHelper.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity =0.7.6;\npragma abicoder v2;\n// Interfaces\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport {IERC721Receiver} from \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport {ISwapRouter} from \"@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol\";\n\nimport {IWPowerPerp} from \"../interfaces/IWPowerPerp.sol\";\nimport {IWETH9} from \"../interfaces/IWETH9.sol\";\nimport {IShortPowerPerp} from \"../interfaces/IShortPowerPerp.sol\";\nimport {IController} from \"../interfaces/IController.sol\";\n\n// Libraries\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {ReentrancyGuard} from \"@openzeppelin/contracts/utils/ReentrancyGuard.sol\";\nimport {SafeMath} from \"@openzeppelin/contracts/math/SafeMath.sol\";\n\n/**\n * @notice contract simplifies opening a short wPowerPerp position by selling wPowerPerp on uniswap v3 and returning eth to user\n */\ncontract ShortHelper is IERC721Receiver, ReentrancyGuard {\n using SafeMath for uint256;\n using Address for address payable;\n\n IController public immutable controller;\n ISwapRouter public immutable router;\n IWETH9 public immutable weth;\n IShortPowerPerp public immutable shortPowerPerp;\n address public immutable wPowerPerp;\n\n /**\n * @notice constructor for short helper\n * @param _controllerAddr controller address for wPowerPerp\n * @param _swapRouter uniswap v3 swap router address\n * @param _wethAddr weth address\n */\n constructor(\n address _controllerAddr,\n address _swapRouter,\n address _wethAddr\n ) {\n require(_controllerAddr != address(0), \"Invalid controller address\");\n require(_swapRouter != address(0), \"Invalid swap router address\");\n require(_wethAddr != address(0), \"Invalid weth address\");\n IController _controller = IController(_controllerAddr);\n router = ISwapRouter(_swapRouter);\n wPowerPerp = _controller.wPowerPerp();\n IWPowerPerp _wPowerPerp = IWPowerPerp(_controller.wPowerPerp());\n IWETH9 _weth = IWETH9(_wethAddr);\n _wPowerPerp.approve(_swapRouter, type(uint256).max);\n _weth.approve(_swapRouter, type(uint256).max);\n\n // assign immutable variables\n shortPowerPerp = IShortPowerPerp(_controller.shortPowerPerp());\n weth = _weth;\n controller = _controller;\n }\n\n /**\n * @notice mint power perp, trade with uniswap v3 and send back premium in eth\n * @param _vaultId short wPowerPerp vault id\n * @param _powerPerpAmount amount of powerPerp to mint/sell\n * @param _uniNftId uniswap v3 position token id\n */\n function openShort(\n uint256 _vaultId,\n uint256 _powerPerpAmount,\n uint256 _uniNftId,\n ISwapRouter.ExactInputSingleParams memory _exactInputParams\n ) external payable nonReentrant {\n if (_vaultId != 0) require(shortPowerPerp.ownerOf(_vaultId) == msg.sender, \"Not allowed\");\n require(\n _exactInputParams.tokenOut == address(weth) && _exactInputParams.tokenIn == wPowerPerp,\n \"Wrong swap tokens\"\n );\n\n (uint256 vaultId, uint256 wPowerPerpAmount) = controller.mintPowerPerpAmount{value: msg.value}(\n _vaultId,\n _powerPerpAmount,\n _uniNftId\n );\n _exactInputParams.amountIn = wPowerPerpAmount;\n\n uint256 amountOut = router.exactInputSingle(_exactInputParams);\n\n // if the recipient is this address: unwrap eth and send back to msg.sender\n if (_exactInputParams.recipient == address(this)) {\n weth.withdraw(amountOut);\n payable(msg.sender).sendValue(amountOut);\n }\n\n // this is a newly open vault, transfer to the user.\n if (_vaultId == 0) shortPowerPerp.safeTransferFrom(address(this), msg.sender, vaultId);\n }\n\n /**\n * @notice buy back wPowerPerp with eth on uniswap v3 and close position\n * @param _vaultId short wPowerPerp vault id\n * @param _wPowerPerpAmount amount of wPowerPerp to burn\n * @param _withdrawAmount amount to withdraw\n */\n function closeShort(\n uint256 _vaultId,\n uint256 _wPowerPerpAmount,\n uint256 _withdrawAmount,\n ISwapRouter.ExactOutputSingleParams memory _exactOutputParams\n ) external payable nonReentrant {\n require(shortPowerPerp.ownerOf(_vaultId) == msg.sender, \"Not allowed\");\n require(\n _exactOutputParams.tokenOut == wPowerPerp && _exactOutputParams.tokenIn == address(weth),\n \"Wrong swap tokens\"\n );\n\n // wrap eth to weth\n weth.deposit{value: msg.value}();\n\n // pay weth and get wPowerPerp in return.\n uint256 amountIn = router.exactOutputSingle(_exactOutputParams);\n\n controller.burnWPowerPerpAmount(_vaultId, _wPowerPerpAmount, _withdrawAmount);\n\n // send back unused eth and withdrawn collateral\n weth.withdraw(msg.value.sub(amountIn));\n // no eth should be left in the contract, so we send it all back\n payable(msg.sender).sendValue(address(this).balance);\n }\n\n /**\n * @dev only receive eth from weth contract and controller.\n */\n receive() external payable {\n require(msg.sender == address(weth) || msg.sender == address(controller), \"can't receive eth\");\n }\n\n /**\n * @dev accept erc721 from safeTransferFrom and safeMint after callback\n * @return returns received selector\n */\n function onERC721Received(\n address,\n address,\n uint256,\n bytes memory\n ) public virtual override returns (bytes4) {\n return this.onERC721Received.selector;\n }\n}\n" + }, + "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.7.5;\npragma abicoder v2;\n\nimport '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol';\n\n/// @title Router token swapping functionality\n/// @notice Functions for swapping tokens via Uniswap V3\ninterface ISwapRouter is IUniswapV3SwapCallback {\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 /// @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 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/mocks/MockUniswapV3Pool.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity =0.7.6;\n\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\nimport {SafeMath} from \"@openzeppelin/contracts/math/SafeMath.sol\";\n\ninterface IUniswapV3FlashCallback {\n function uniswapV3FlashCallback(\n uint256 fee0,\n uint256 fee1,\n bytes calldata data\n ) external;\n}\n\ncontract MockUniswapV3Pool {\n using SafeMath for uint256;\n\n address public token0;\n address public token1;\n uint256 public fee;\n\n struct PoolKey {\n address token0;\n address token1;\n uint24 fee;\n }\n\n struct Slot0 {\n // the current price\n uint160 sqrtPriceX96;\n // the current tick\n int24 tick;\n // the most-recently updated index of the observations array\n uint16 observationIndex;\n // the current maximum number of observations that are being stored\n uint16 observationCardinality;\n // the next maximum number of observations to store, triggered in observations.write\n uint16 observationCardinalityNext;\n // the current protocol fee as a percentage of the swap fee taken on withdrawal\n // represented as an integer denominator (1/x)%\n uint8 feeProtocol;\n // whether the pool is locked\n bool unlocked;\n }\n\n Slot0 public slot0;\n\n function setPoolTokens(address _token0, address _token1) external {\n token0 = _token0;\n token1 = _token1;\n }\n\n function setSlot0Data(uint160 _sqrtPriceX96, int24 _tick) external {\n slot0.sqrtPriceX96 = _sqrtPriceX96;\n slot0.tick = _tick;\n }\n\n function flash(\n address recipient,\n uint256 amount0,\n uint256 amount1,\n bytes calldata data\n ) external {\n // uint128 _liquidity = liquidity;\n // require(_liquidity > 0, 'L');\n\n // uint256 fee0 = FullMath.mulDivRoundingUp(amount0, fee, 1e6);\n // uint256 fee1 = FullMath.mulDivRoundingUp(amount1, fee, 1e6);\n uint256 fee0 = 0;\n uint256 fee1 = 0;\n\n uint256 balance0Before = ERC20(token0).balanceOf(address(this));\n uint256 balance1Before = ERC20(token1).balanceOf(address(this));\n\n if (amount0 > 0) ERC20(token0).transfer(recipient, amount0);\n if (amount1 > 0) ERC20(token1).transfer(recipient, amount1);\n\n IUniswapV3FlashCallback(msg.sender).uniswapV3FlashCallback(fee0, fee1, data);\n\n uint256 balance0After = ERC20(token0).balanceOf(address(this));\n uint256 balance1After = ERC20(token1).balanceOf(address(this));\n\n require(balance0Before.add(fee0) <= balance0After, \"F0\");\n require(balance1Before.add(fee1) <= balance1After, \"F1\");\n }\n\n function computeAddress(\n address, /*factory*/\n PoolKey memory /*key*/\n ) internal view returns (address pool) {\n return address(this);\n }\n}\n" + }, + "contracts/mocks/MockController.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity =0.7.6;\n\nimport {IShortPowerPerp} from \"../interfaces/IShortPowerPerp.sol\";\nimport {IWPowerPerp} from \"../interfaces/IWPowerPerp.sol\";\n\nimport {SafeMath} from \"@openzeppelin/contracts/math/SafeMath.sol\";\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {VaultLib} from \"../libs/VaultLib.sol\";\n\ncontract MockController {\n using SafeMath for uint256;\n using VaultLib for VaultLib.Vault;\n using Address for address payable;\n\n uint256 internal constant secInDay = 86400;\n\n address public quoteCurrency;\n address public ethQuoteCurrencyPool;\n uint256 public normalizationFactor;\n uint256 public feeRate = 0;\n\n /// @dev The token ID vault data\n mapping(uint256 => VaultLib.Vault) public vaults;\n\n IWPowerPerp public wPowerPerp;\n IShortPowerPerp public shortPowerPerp;\n\n function init(\n address _shortPowerPerp,\n address _wPowerPerp,\n address _ethQuoteCurrencyPool,\n address _quoteCurrency\n ) public {\n require(_shortPowerPerp != address(0), \"C5\");\n require(_wPowerPerp != address(0), \"Invalid wPowerPerp address\");\n\n shortPowerPerp = IShortPowerPerp(_shortPowerPerp);\n wPowerPerp = IWPowerPerp(_wPowerPerp);\n ethQuoteCurrencyPool = _ethQuoteCurrencyPool;\n quoteCurrency = _quoteCurrency;\n\n normalizationFactor = 1e18;\n }\n\n function mintWPowerPerpAmount(\n uint256 _vaultId,\n uint256 _mintAmount,\n uint256 /*_nftTokenId*/\n ) external payable returns (uint256, uint256) {\n uint256 wPowerPerpMinted;\n\n if (_vaultId == 0) _vaultId = _openVault(msg.sender);\n if (msg.value > 0) _addEthCollateral(_vaultId, msg.value);\n if (_mintAmount > 0) {\n wPowerPerpMinted = _addShort(msg.sender, _vaultId, _mintAmount);\n }\n\n return (_vaultId, wPowerPerpMinted);\n }\n\n function burnWPowerPerpAmount(\n uint256 _vaultId,\n uint256 _amount,\n uint256 _withdrawAmount\n ) external {\n if (_amount > 0) _removeShort(msg.sender, _vaultId, _amount);\n if (_withdrawAmount > 0) _withdrawCollateral(msg.sender, _vaultId, _withdrawAmount);\n if (_withdrawAmount > 0) payable(msg.sender).sendValue(_withdrawAmount);\n }\n\n function _openVault(address _recipient) internal returns (uint256) {\n uint256 vaultId = shortPowerPerp.mintNFT(_recipient);\n vaults[vaultId] = VaultLib.Vault({\n NftCollateralId: 0,\n collateralAmount: 0,\n shortAmount: 0,\n operator: address(0)\n });\n\n return vaultId;\n }\n\n function _addEthCollateral(uint256 _vaultId, uint256 _amount) internal {\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\n cachedVault.addEthCollateral(uint128(_amount));\n vaults[_vaultId] = cachedVault;\n }\n\n function _withdrawCollateral(\n address, /*_account*/\n uint256 _vaultId,\n uint256 _amount\n ) internal {\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\n cachedVault.removeEthCollateral(_amount);\n vaults[_vaultId] = cachedVault;\n }\n\n function _addShort(\n address _account,\n uint256 _vaultId,\n uint256 _wPowerPerpAmount\n ) internal returns (uint256 amountToMint) {\n require(_canModifyVault(_vaultId, _account), \"C3\");\n\n amountToMint = _wPowerPerpAmount.mul(1e18).div(normalizationFactor);\n\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\n cachedVault.addShort(amountToMint);\n vaults[_vaultId] = cachedVault;\n\n wPowerPerp.mint(_account, amountToMint);\n }\n\n function _removeShort(\n address _account,\n uint256 _vaultId,\n uint256 _amount\n ) internal {\n VaultLib.Vault memory cachedVault = vaults[_vaultId];\n cachedVault.removeShort(_amount);\n vaults[_vaultId] = cachedVault;\n\n wPowerPerp.burn(_account, _amount);\n }\n\n function _canModifyVault(uint256 _vaultId, address _account) internal view returns (bool) {\n return shortPowerPerp.ownerOf(_vaultId) == _account || vaults[_vaultId].operator == _account;\n }\n\n function getExpectedNormalizationFactor() external view returns (uint256) {\n return normalizationFactor;\n }\n}\n" + }, + "contracts/test/VaultTester.sol": { + "content": "//SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity =0.7.6;\n\nimport {VaultLib} from \"../libs/VaultLib.sol\";\nimport \"@uniswap/v3-periphery/contracts/base/LiquidityManagement.sol\";\n\ncontract VaultLibTester {\n\n function getUniPositionBalances(\n address _positionManager,\n uint256 _tokenId,\n int24 _wPowerPerpPoolTick,\n bool _isWethToken0\n ) external view returns (uint256 ethAmount, uint256 wPowerPerpAmount) {\n return VaultLib._getUniPositionBalances(_positionManager, _tokenId, _wPowerPerpPoolTick, _isWethToken0);\n }\n\n /**\n * expose this function so it's easier to test vault lib.\n */\n function getLiquidity(\n uint160 sqrtRatioX96,\n int24 tickA,\n int24 tickB,\n uint256 amount0Desired,\n uint256 amount1Desired\n ) external pure returns (uint128 liquidity) {\n\n uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickA);\n uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickB);\n\n liquidity = LiquidityAmounts.getLiquidityForAmounts(\n sqrtRatioX96,\n sqrtRatioAX96,\n sqrtRatioBX96,\n amount0Desired,\n amount1Desired\n );\n }\n\n function getLiquidityForAmount0(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint256 amount0\n ) external pure returns (uint128 liquidity) {\n\n // uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickA);\n // uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickB);\n\n return LiquidityAmounts.getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0);\n }\n\n function getLiquidityForAmount1(\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint256 amount1\n ) external pure returns (uint128 liquidity) {\n // uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickA);\n // uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickB);\n\n return LiquidityAmounts.getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1);\n }\n\n function getAmountsForLiquidity(\n uint160 sqrtRatioX96,\n uint160 sqrtRatioAX96,\n uint160 sqrtRatioBX96,\n uint128 liquidity\n ) external pure returns (uint256 amount0, uint256 amount1) {\n return LiquidityAmounts.getAmountsForLiquidity(\n sqrtRatioX96,\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidity\n );\n }\n}" + }, + "contracts/test/ControllerTester.sol": { + "content": "//SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity =0.7.6;\n\nimport {IController} from \"../interfaces/IController.sol\";\n\n/**\n* use this contract to confirm that funding is not charged twice if called in same block\n */\ncontract ControllerTester{\n\n IController controller;\n\n constructor(address _controller) {\n controller = IController(_controller);\n }\n\n function testDoubleFunding() external {\n controller.applyFunding();\n uint256 normalizationFactor1 = controller.getExpectedNormalizationFactor();\n controller.applyFunding();\n uint256 normalizationFactor2 = controller.getExpectedNormalizationFactor();\n require(normalizationFactor1==normalizationFactor2, \"funding charged twice\");\n }\n}" + }, + "contracts/core/ShortPowerPerp.sol": { + "content": "//SPDX-License-Identifier: BUSL-1.1\n\npragma solidity =0.7.6;\n\n//contract\nimport {ERC721} from \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport {Initializable} from \"@openzeppelin/contracts/proxy/Initializable.sol\";\nimport {IController} from \"../interfaces/IController.sol\";\n\n/**\n * @notice ERC721 NFT representing ownership of a vault (short position)\n */\ncontract ShortPowerPerp is ERC721, Initializable {\n /// @dev tokenId for the next vault opened\n uint256 public nextId = 1;\n\n address public controller;\n address private immutable deployer;\n\n modifier onlyController() {\n require(msg.sender == controller, \"Not controller\");\n _;\n }\n\n /**\n * @notice short power perpetual constructor\n * @param _name token name for ERC721\n * @param _symbol token symbol for ERC721\n */\n constructor(string memory _name, string memory _symbol) ERC721(_name, _symbol) {\n deployer = msg.sender;\n }\n\n /**\n * @notice initialize short contract\n * @param _controller controller address\n */\n function init(address _controller) public initializer {\n require(msg.sender == deployer, \"Invalid caller of init\");\n require(_controller != address(0), \"Invalid controller address\");\n controller = _controller;\n }\n\n /**\n * @notice mint new NFT\n * @dev autoincrement tokenId starts at 1\n * @param _recipient recipient address for NFT\n */\n function mintNFT(address _recipient) external onlyController returns (uint256 tokenId) {\n // mint NFT\n _safeMint(_recipient, (tokenId = nextId++));\n }\n\n function _beforeTokenTransfer(\n address, /* from */\n address, /* to */\n uint256 tokenId\n ) internal override {\n IController(controller).updateOperator(tokenId, address(0));\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n\n// solhint-disable-next-line compiler-version\npragma solidity >=0.4.24 <0.8.0;\n\nimport \"../utils/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 a proxied contract can't have a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n */\nabstract contract Initializable {\n\n /**\n * @dev Indicates that the contract has been initialized.\n */\n bool private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Modifier to protect an initializer function from being invoked twice.\n */\n modifier initializer() {\n require(_initializing || _isConstructor() || !_initialized, \"Initializable: contract is already initialized\");\n\n bool isTopLevelCall = !_initializing;\n if (isTopLevelCall) {\n _initializing = true;\n _initialized = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n }\n }\n\n /// @dev Returns true if and only if the function is running in the constructor\n function _isConstructor() private view returns (bool) {\n return !Address.isContract(address(this));\n }\n}\n" + }, + "contracts/core/WPowerPerp.sol": { + "content": "// SPDX-License-Identifier: BUSL-1.1\n\npragma solidity =0.7.6;\n\n//interface\nimport {IWPowerPerp} from \"../interfaces/IWPowerPerp.sol\";\n\n//contract\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport {Initializable} from \"@openzeppelin/contracts/proxy/Initializable.sol\";\n\n/**\n * @notice ERC20 Token representing wrapped long power perpetual position\n * @dev value of power perpetual is expected to go down over time through the impact of funding\n */\ncontract WPowerPerp is ERC20, Initializable, IWPowerPerp {\n address public controller;\n address private immutable deployer;\n\n /**\n * @notice long power perpetual constructor\n * @param _name token name for ERC20\n * @param _symbol token symbol for ERC20\n */\n constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) {\n deployer = msg.sender;\n }\n\n modifier onlyController() {\n require(msg.sender == controller, \"Not controller\");\n _;\n }\n\n /**\n * @notice init wPowerPerp contract\n * @param _controller controller address\n */\n function init(address _controller) external initializer {\n require(msg.sender == deployer, \"Invalid caller of init\");\n require(_controller != address(0), \"Invalid controller address\");\n controller = _controller;\n }\n\n /**\n * @notice mint wPowerPerp\n * @param _account account to mint to\n * @param _amount amount to mint\n */\n function mint(address _account, uint256 _amount) external override onlyController {\n _mint(_account, _amount);\n }\n\n /**\n * @notice burn wPowerPerp\n * @param _account account to burn from\n * @param _amount amount to burn\n */\n function burn(address _account, uint256 _amount) external override onlyController {\n _burn(_account, _amount);\n }\n}\n" + }, + "contracts/test/ControllerAccessTester.sol": { + "content": "//SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity =0.7.6;\n\nimport {IShortPowerPerp} from \"../interfaces/IShortPowerPerp.sol\";\n\n/**\n * use this contract to check that controller has correct access control to mint NFTs\n * a testing contract is necessary as the before transfer hook calls updateOperator\n */\ncontract ControllerAccessTester{\n \n IShortPowerPerp shortPowerPerp;\n\n constructor(address _shortPowerPerp) {\n shortPowerPerp = IShortPowerPerp(_shortPowerPerp);\n }\n \n function mintTest(address _address) external returns (uint256) {\n return shortPowerPerp.mintNFT(_address);\n }\n\n function updateOperator(uint256 _tokenId, address _operator) external {\n\n }\n}" + }, + "contracts/import/Uni.sol": { + "content": "// SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity =0.7.6;\n\nimport \"@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol\";\nimport \"@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol\";\nimport \"@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol\";\nimport \"@uniswap/v3-periphery/contracts/interfaces/IQuoter.sol\";\nimport \"@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol\";\n\ncontract Uni {\n // hack: force hardhat to import all the interfaces at compile time\n}\n" + }, + "@uniswap/v3-periphery/contracts/interfaces/IQuoter.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 IQuoter {\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/mocks/MockWSqueeth.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity =0.7.6;\n\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract MockWPowerPerp is ERC20 {\n address public controller;\n\n constructor() ERC20(\"Wrapped Power Perp\", \"WPowerPerp\") {}\n\n function mint(address _account, uint256 _amount) external {\n _mint(_account, _amount);\n }\n\n function burn(address _account, uint256 _amount) external {\n _burn(_account, _amount);\n }\n}\n" + }, + "contracts/mocks/MockErc20.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity =0.7.6;\n\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract MockErc20 is ERC20 {\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals\n ) ERC20(_name, _symbol) {\n _setupDecimals(_decimals);\n }\n\n function mint(address _account, uint256 _amount) external {\n _mint(_account, _amount);\n }\n\n function burn(address _account, uint256 _amount) external {\n _burn(_account, _amount);\n }\n}\n" + }, + "contracts/test/CastingTester.sol": { + "content": "//SPDX-License-Identifier: GPL-2.0-or-later\n\npragma solidity =0.7.6;\n\nimport {Uint256Casting} from \"../libs/Uint256Casting.sol\";\n\ncontract CastingTester{ \n using Uint256Casting for uint256;\n\n function testToUint128(uint256 y) external pure returns (uint128 z) {\n return y.toUint128();\n }\n\n function testToUint96(uint256 y) external pure returns (uint96 z) {\n return y.toUint96();\n }\n\n function testToUint32(uint256 y) external pure returns (uint32 z) {\n return y.toUint32();\n }\n}" + }, + "contracts/test/ABDKTester.sol": { + "content": "// SPDX-License-Identifier: BSD-4-Clause\n/*\n * ABDK Math 64.64 Smart Contract Library. Copyright © 2019 by ABDK Consulting.\n * Author: Mikhail Vladimirov \n * Copyright (c) 2019, ABDK Consulting\n *\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n *\n * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n * All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by ABDK Consulting.\n * Neither the name of ABDK Consulting nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n * THIS SOFTWARE IS PROVIDED BY ABDK CONSULTING ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL ABDK CONSULTING BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n \npragma solidity =0.7.6;\n\nimport {ABDKMath64x64} from \"../libs/ABDKMath64x64.sol\";\n\ncontract ABDKTester{ \n using ABDKMath64x64 for int128;\n using ABDKMath64x64 for uint256;\n\n function testMul(int128 x, int128 y) external pure returns (int128 z) {\n return x.mul(y);\n }\n \n function testNegMul(int128 x, int128 y) external pure returns (int128 z) {\n return -x.mul(y);\n }\n\n function testMulu(int128 x, uint256 y) external pure returns (uint256 z) {\n return x.mulu(y);\n }\n function testDivu(uint256 x, uint256 y) external pure returns (int128 z) {\n return x.divu(y);\n }\n function testLog_2(int128 x) external pure returns (int128 z) {\n return x.log_2();\n }\n function testExp_2(int128 x) external pure returns (int128 z) {\n return x.exp_2();\n }\n}" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 825 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file