From d995bb8636baf0a590c114c5600f480a290bc642 Mon Sep 17 00:00:00 2001 From: Maurizio Murru Date: Tue, 7 Nov 2023 19:08:35 +0100 Subject: [PATCH 1/2] Adding PancakeswapV3 support. --- .env.sample | 2 + README.md | 1 + deploy/pancakeV3.ts | 38 +++ deployments/bsc/.chainId | 1 + deployments/bsc/UniswapV3StaticQuoter.json | 188 +++++++++++++ hardhat.config.ts | 293 +++++++++++---------- test/addresses.json | 8 + 7 files changed, 398 insertions(+), 133 deletions(-) create mode 100644 deploy/pancakeV3.ts create mode 100644 deployments/bsc/.chainId create mode 100644 deployments/bsc/UniswapV3StaticQuoter.json diff --git a/.env.sample b/.env.sample index 7e5647c..b8934bd 100644 --- a/.env.sample +++ b/.env.sample @@ -3,9 +3,11 @@ OPTIMISM_RPC= ARBITRUM_RPC= DOGECHAIN_RPC= AVALANCHE_RPC= +BSC_RPC= DEPLOYER_ADDRESS= DEPLOYER_PRIVATE_KEY= ETHERSCAN_API_KEY= SNOWTRACE_API_KEY= OPSCAN_API_KEY= ARBISCAN_API_KEY= +BSCSCAN_API_KEY= diff --git a/README.md b/README.md index 1847684..0e93627 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,4 @@ Has similar interface to the official [QuoterV2](https://docs.uniswap.org/protoc | Dogechain | Quickswap | `0x4a6c794192831fB9F4782E61Bec05d6C5cC9F3eA` | | Polygon | Quickswap | `0x2E0A046481c676235B806Bd004C4b492C850fb34` | | Arbitrum | Camelot | `0x11E68A3CE9A5A0F95ca9c4B0B8F17849752e24DD` | +| BSC | PancakeswapV3| `0xeB281D33A975CbF17c2Ac13063F6C38B50e05540` | \ No newline at end of file diff --git a/deploy/pancakeV3.ts b/deploy/pancakeV3.ts new file mode 100644 index 0000000..2d4faf3 --- /dev/null +++ b/deploy/pancakeV3.ts @@ -0,0 +1,38 @@ +import { HardhatRuntimeEnvironment } from "hardhat/types"; +import { DeployFunction } from "hardhat-deploy/types"; + +import addresses from "../test/addresses.json"; + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts, network } = hre; + const { deploy, log } = deployments; + + + const allowedNetworks = ["bsc"]; + if (!allowedNetworks.includes(network.name)) + throw new Error(`Wrong network! Only "${allowedNetworks}" supported`); + + const contractName = "UniswapV3StaticQuoter"; + let factory; + factory = addresses.bsc.protocols.pancakeswapV3.factory; + + const args = [ factory ] + const { deployer } = await getNamedAccounts(); + + log("1) Deploy contract"); + const deployResult: any = await deploy(contractName, { + from: deployer, + contract: contractName, + skipIfAlreadyDeployed: true, + log: true, + args + }); + + if (deployResult.newlyDeployed) + log(`- 🎉 Deployed at: ${deployResult.address}`); + else + log(`- ⏩ Deployment skipped, using previous deployment at: ${deployResult.address}`); +}; + +export default func; +func.tags = [ "pancakeswapV3" ] \ No newline at end of file diff --git a/deployments/bsc/.chainId b/deployments/bsc/.chainId new file mode 100644 index 0000000..2ebc651 --- /dev/null +++ b/deployments/bsc/.chainId @@ -0,0 +1 @@ +56 \ No newline at end of file diff --git a/deployments/bsc/UniswapV3StaticQuoter.json b/deployments/bsc/UniswapV3StaticQuoter.json new file mode 100644 index 0000000..ff41c72 --- /dev/null +++ b/deployments/bsc/UniswapV3StaticQuoter.json @@ -0,0 +1,188 @@ +{ + "address": "0xeB281D33A975CbF17c2Ac13063F6C38B50e05540", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_factory", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "zeroForOne", + "type": "bool" + }, + { + "internalType": "int256", + "name": "amountSpecified", + "type": "int256" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + } + ], + "name": "quote", + "outputs": [ + { + "internalType": "int256", + "name": "amount0", + "type": "int256" + }, + { + "internalType": "int256", + "name": "amount1", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "path", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "name": "quoteExactInput", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + } + ], + "internalType": "struct IUniswapV3StaticQuoter.QuoteExactInputSingleParams", + "name": "params", + "type": "tuple" + } + ], + "name": "quoteExactInputSingle", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x2f9498c747f515dcd91c908526e53310b5626248e67e6c7f4ec1a72fe43caff6", + "receipt": { + "to": null, + "from": "0x64966bc22648dd5f3682FeA4fB093f88eb8C2920", + "contractAddress": "0xeB281D33A975CbF17c2Ac13063F6C38B50e05540", + "transactionIndex": 43, + "gasUsed": "2427861", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xe6c892bbeed97ab2d174a1b1d963459ee3c794774f143d228697efa1e7b61974", + "transactionHash": "0x2f9498c747f515dcd91c908526e53310b5626248e67e6c7f4ec1a72fe43caff6", + "logs": [], + "blockNumber": 33289575, + "cumulativeGasUsed": "7339481", + "status": 1, + "byzantium": true + }, + "args": [ + "0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865" + ], + "numDeployments": 1, + "solcInputHash": "b114f1a83d51911d7a217e1f65fcbe3e", + "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_factory\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"zeroForOne\",\"type\":\"bool\"},{\"internalType\":\"int256\",\"name\":\"amountSpecified\",\"type\":\"int256\"},{\"internalType\":\"uint160\",\"name\":\"sqrtPriceLimitX96\",\"type\":\"uint160\"}],\"name\":\"quote\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"amount0\",\"type\":\"int256\"},{\"internalType\":\"int256\",\"name\":\"amount1\",\"type\":\"int256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"path\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"}],\"name\":\"quoteExactInput\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"tokenIn\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenOut\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"uint24\",\"name\":\"fee\",\"type\":\"uint24\"},{\"internalType\":\"uint160\",\"name\":\"sqrtPriceLimitX96\",\"type\":\"uint160\"}],\"internalType\":\"struct IUniswapV3StaticQuoter.QuoteExactInputSingleParams\",\"name\":\"params\",\"type\":\"tuple\"}],\"name\":\"quoteExactInputSingle\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"quoteExactInput(bytes,uint256)\":{\"params\":{\"amountIn\":\"The amount of the first token to swap\",\"path\":\"The path of the swap, i.e. each token pair and the pool fee\"},\"returns\":{\"amountOut\":\"The amount of the last token that would be received\"}},\"quoteExactInputSingle((address,address,uint256,uint24,uint160))\":{\"params\":{\"params\":\"The params for the quote, encoded as `QuoteExactInputSingleParams` tokenIn The token being swapped in tokenOut The token being swapped out fee The fee of the token pool to consider for the pair amountIn The desired input amount sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\"},\"returns\":{\"amountOut\":\"The amount of `tokenOut` that would be received\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"quoteExactInput(bytes,uint256)\":{\"notice\":\"Returns the amount out received for a given exact input swap without executing the swap\"},\"quoteExactInputSingle((address,address,uint256,uint24,uint160))\":{\"notice\":\"Returns the amount out received for a given exact input but for a swap of a single pool\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/UniV3Quoter/UniswapV3StaticQuoter.sol\":\"UniswapV3StaticQuoter\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"none\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@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/BitMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title BitMath\\n/// @dev This library provides functionality for computing bit properties of an unsigned integer\\nlibrary BitMath {\\n /// @notice Returns the index of the most significant bit of the number,\\n /// where the least significant bit is at index 0 and the most significant bit is at index 255\\n /// @dev The function satisfies the property:\\n /// x >= 2**mostSignificantBit(x) and x < 2**(mostSignificantBit(x)+1)\\n /// @param x the value for which to compute the most significant bit, must be greater than 0\\n /// @return r the index of the most significant bit\\n function mostSignificantBit(uint256 x) internal pure returns (uint8 r) {\\n require(x > 0);\\n\\n if (x >= 0x100000000000000000000000000000000) {\\n x >>= 128;\\n r += 128;\\n }\\n if (x >= 0x10000000000000000) {\\n x >>= 64;\\n r += 64;\\n }\\n if (x >= 0x100000000) {\\n x >>= 32;\\n r += 32;\\n }\\n if (x >= 0x10000) {\\n x >>= 16;\\n r += 16;\\n }\\n if (x >= 0x100) {\\n x >>= 8;\\n r += 8;\\n }\\n if (x >= 0x10) {\\n x >>= 4;\\n r += 4;\\n }\\n if (x >= 0x4) {\\n x >>= 2;\\n r += 2;\\n }\\n if (x >= 0x2) r += 1;\\n }\\n\\n /// @notice Returns the index of the least significant bit of the number,\\n /// where the least significant bit is at index 0 and the most significant bit is at index 255\\n /// @dev The function satisfies the property:\\n /// (x & 2**leastSignificantBit(x)) != 0 and (x & (2**(leastSignificantBit(x)) - 1)) == 0)\\n /// @param x the value for which to compute the least significant bit, must be greater than 0\\n /// @return r the index of the least significant bit\\n function leastSignificantBit(uint256 x) internal pure returns (uint8 r) {\\n require(x > 0);\\n\\n r = 255;\\n if (x & type(uint128).max > 0) {\\n r -= 128;\\n } else {\\n x >>= 128;\\n }\\n if (x & type(uint64).max > 0) {\\n r -= 64;\\n } else {\\n x >>= 64;\\n }\\n if (x & type(uint32).max > 0) {\\n r -= 32;\\n } else {\\n x >>= 32;\\n }\\n if (x & type(uint16).max > 0) {\\n r -= 16;\\n } else {\\n x >>= 16;\\n }\\n if (x & type(uint8).max > 0) {\\n r -= 8;\\n } else {\\n x >>= 8;\\n }\\n if (x & 0xf > 0) {\\n r -= 4;\\n } else {\\n x >>= 4;\\n }\\n if (x & 0x3 > 0) {\\n r -= 2;\\n } else {\\n x >>= 2;\\n }\\n if (x & 0x1 > 0) r -= 1;\\n }\\n}\\n\",\"keccak256\":\"0x82e425066110aac05ed8a9fc90f9ee85142b6f434769447e49d4438a8d9fcd82\",\"license\":\"GPL-2.0-or-later\"},\"@uniswap/v3-core/contracts/libraries/FixedPoint128.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.4.0;\\n\\n/// @title FixedPoint128\\n/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)\\nlibrary FixedPoint128 {\\n uint256 internal constant Q128 = 0x100000000000000000000000000000000;\\n}\\n\",\"keccak256\":\"0x2d1f4f73ae0d8f0a210b8d30084659b57c56ac8f2f96011fca36f00a6d417178\",\"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 <0.8.0;\\n\\n/// @title Contains 512-bit math functions\\n/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision\\n/// @dev Handles \\\"phantom overflow\\\" i.e., allows multiplication and division where an intermediate value overflows 256 bits\\nlibrary FullMath {\\n /// @notice Calculates floor(a\\u00d7b\\u00f7denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n /// @param a The multiplicand\\n /// @param b The multiplier\\n /// @param denominator The divisor\\n /// @return result The 256-bit result\\n /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv\\n function mulDiv(\\n uint256 a,\\n uint256 b,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n // 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\":\"0x50e87f7a3197525d1c6f7e04290060e848677c8a4e86c554bc6ace4a4d0d476d\",\"license\":\"MIT\"},\"@uniswap/v3-core/contracts/libraries/LiquidityMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Math library for liquidity\\nlibrary LiquidityMath {\\n /// @notice Add a signed liquidity delta to liquidity and revert if it overflows or underflows\\n /// @param x The liquidity before change\\n /// @param y The delta by which liquidity should be changed\\n /// @return z The liquidity delta\\n function addDelta(uint128 x, int128 y) internal pure returns (uint128 z) {\\n if (y < 0) {\\n require((z = x - uint128(-y)) < x, 'LS');\\n } else {\\n require((z = x + uint128(y)) >= x, 'LA');\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd53041349718d5bce4a89e87cd911879d41ba42ba3fab0614e5e8b742f352b88\",\"license\":\"GPL-2.0-or-later\"},\"@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/SwapMath.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity >=0.5.0;\\n\\nimport './FullMath.sol';\\nimport './SqrtPriceMath.sol';\\n\\n/// @title Computes the result of a swap within ticks\\n/// @notice Contains methods for computing the result of a swap within a single tick price range, i.e., a single tick.\\nlibrary SwapMath {\\n /// @notice Computes the result of swapping some amount in, or amount out, given the parameters of the swap\\n /// @dev The fee, plus the amount in, will never exceed the amount remaining if the swap's `amountSpecified` is positive\\n /// @param sqrtRatioCurrentX96 The current sqrt price of the pool\\n /// @param sqrtRatioTargetX96 The price that cannot be exceeded, from which the direction of the swap is inferred\\n /// @param liquidity The usable liquidity\\n /// @param amountRemaining How much input or output amount is remaining to be swapped in/out\\n /// @param feePips The fee taken from the input amount, expressed in hundredths of a bip\\n /// @return sqrtRatioNextX96 The price after swapping the amount in/out, not to exceed the price target\\n /// @return amountIn The amount to be swapped in, of either token0 or token1, based on the direction of the swap\\n /// @return amountOut The amount to be received, of either token0 or token1, based on the direction of the swap\\n /// @return feeAmount The amount of input that will be taken as a fee\\n function computeSwapStep(\\n uint160 sqrtRatioCurrentX96,\\n uint160 sqrtRatioTargetX96,\\n uint128 liquidity,\\n int256 amountRemaining,\\n uint24 feePips\\n )\\n internal\\n pure\\n returns (\\n uint160 sqrtRatioNextX96,\\n uint256 amountIn,\\n uint256 amountOut,\\n uint256 feeAmount\\n )\\n {\\n bool zeroForOne = sqrtRatioCurrentX96 >= sqrtRatioTargetX96;\\n bool exactIn = amountRemaining >= 0;\\n\\n if (exactIn) {\\n uint256 amountRemainingLessFee = FullMath.mulDiv(uint256(amountRemaining), 1e6 - feePips, 1e6);\\n amountIn = zeroForOne\\n ? SqrtPriceMath.getAmount0Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, true)\\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, true);\\n if (amountRemainingLessFee >= amountIn) sqrtRatioNextX96 = sqrtRatioTargetX96;\\n else\\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromInput(\\n sqrtRatioCurrentX96,\\n liquidity,\\n amountRemainingLessFee,\\n zeroForOne\\n );\\n } else {\\n amountOut = zeroForOne\\n ? SqrtPriceMath.getAmount1Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, false)\\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, false);\\n if (uint256(-amountRemaining) >= amountOut) sqrtRatioNextX96 = sqrtRatioTargetX96;\\n else\\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromOutput(\\n sqrtRatioCurrentX96,\\n liquidity,\\n uint256(-amountRemaining),\\n zeroForOne\\n );\\n }\\n\\n bool max = sqrtRatioTargetX96 == sqrtRatioNextX96;\\n\\n // get the input/output amounts\\n if (zeroForOne) {\\n amountIn = max && exactIn\\n ? amountIn\\n : SqrtPriceMath.getAmount0Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, true);\\n amountOut = max && !exactIn\\n ? amountOut\\n : SqrtPriceMath.getAmount1Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, false);\\n } else {\\n amountIn = max && exactIn\\n ? amountIn\\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, true);\\n amountOut = max && !exactIn\\n ? amountOut\\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, false);\\n }\\n\\n // cap the output amount to not exceed the remaining output amount\\n if (!exactIn && amountOut > uint256(-amountRemaining)) {\\n amountOut = uint256(-amountRemaining);\\n }\\n\\n if (exactIn && sqrtRatioNextX96 != sqrtRatioTargetX96) {\\n // we didn't reach the target, so take the remainder of the maximum input as fee\\n feeAmount = uint256(amountRemaining) - amountIn;\\n } else {\\n feeAmount = FullMath.mulDivRoundingUp(amountIn, feePips, 1e6 - feePips);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xcd310be830646d0d55bef86683847577f742704d227471ad7b4cab3df9c47cf7\",\"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 <0.8.0;\\n\\n/// @title Math library for computing sqrt prices from ticks and vice versa\\n/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports\\n/// prices between 2**-128 and 2**128\\nlibrary TickMath {\\n /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128\\n int24 internal constant MIN_TICK = -887272;\\n /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128\\n int24 internal constant MAX_TICK = -MIN_TICK;\\n\\n /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\\n uint160 internal constant MIN_SQRT_RATIO = 4295128739;\\n /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\\n uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\\n\\n /// @notice Calculates sqrt(1.0001^tick) * 2^96\\n /// @dev Throws if |tick| > max tick\\n /// @param tick The input tick for the above formula\\n /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)\\n /// at the given tick\\n function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {\\n 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\":\"0xda8c2c0b12d2976acfd364453ba5f5bf0117ba3c91175ee9e1067d3fb26944d9\",\"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/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\",\"keccak256\":\"0xd43c2355a7d5659b1fa1fb322647f760722d73a6a5e62ede53d426f3b406b795\",\"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/libraries/BytesLib.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\n/*\\n * @title Solidity Bytes Arrays Utils\\n * @author Gon\\u00e7alo S\\u00e1 \\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\",\"keccak256\":\"0x68629e5b1a30b6490c6ae721c28117f6f963745462b007da0769758eb67f10d4\",\"license\":\"GPL-2.0-or-later\"},\"@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\",\"keccak256\":\"0xb22c562b5175d50dbcc2224325666090d985f052abdcfe275c8dfc884e34de61\",\"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/IUniV3likeQuoterCore.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity =0.7.6;\\n\\nstruct GlobalState {\\n uint160 startPrice;\\n int24 startTick;\\n uint16 fee;\\n}\\n\\n// the top level state of the swap, the results of which are recorded in storage at the end\\nstruct SwapState {\\n // the amount remaining to be swapped in/out of the input/output asset\\n int256 amountSpecifiedRemaining;\\n // the amount already swapped out/in of the output/input asset\\n int256 amountCalculated;\\n // current sqrt(price)\\n uint160 sqrtPriceX96;\\n // the tick associated with the current price\\n int24 tick;\\n // the current liquidity in range\\n uint128 liquidity;\\n}\\n\\nstruct StepComputations {\\n // the price at the beginning of the step\\n uint160 sqrtPriceStartX96;\\n // the next tick to swap to from the current tick in the swap direction\\n int24 tickNext;\\n // whether tickNext is initialized or not\\n bool initialized;\\n // sqrt(price) for the next tick (1/0)\\n uint160 sqrtPriceNextX96;\\n // how much is being swapped in in this step\\n uint256 amountIn;\\n // how much is being swapped out\\n uint256 amountOut;\\n // how much fee is being paid in\\n uint256 feeAmount;\\n}\\n\\ninterface IUniV3likeQuoterCore {\\n\\n function quote(\\n address poolAddress,\\n bool zeroForOne,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96\\n ) external view returns (int256 amount0, int256 amount1);\\n\\n}\",\"keccak256\":\"0xd269f4631d3efa8658798ad07678df11843fe3f0e2045d85a7666c514fa0b943\",\"license\":\"GPL-2.0-or-later\"},\"contracts/UniV3Quoter/UniV3QuoterCore.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity =0.7.6;\\n\\nimport '../UniV3likeQuoterCore.sol';\\nimport './lib/TickBitmap.sol';\\n\\ncontract UniV3QuoterCore is UniV3likeQuoterCore {\\n\\n function getPoolGlobalState(\\n address pool\\n ) internal override view returns (GlobalState memory gs) {\\n gs.fee = uint16(IUniswapV3Pool(pool).fee());\\n (gs.startPrice, gs.startTick,,,,,) = IUniswapV3Pool(pool).slot0();\\n }\\n \\n function getTickSpacing(\\n address pool\\n ) internal override view returns (int24) {\\n return IUniswapV3Pool(pool).tickSpacing();\\n }\\n \\n function getLiquidity(address pool) internal override view returns (uint128) {\\n return IUniswapV3Pool(pool).liquidity();\\n }\\n \\n function nextInitializedTickWithinOneWord(\\n address poolAddress,\\n int24 tick,\\n int24 tickSpacing,\\n bool zeroForOne\\n ) internal override view returns (int24 next, bool initialized) {\\n return TickBitmap.nextInitializedTickWithinOneWord(\\n poolAddress,\\n tick,\\n tickSpacing,\\n zeroForOne\\n );\\n }\\n \\n function getTicks(address pool, int24 tick) internal override view returns (\\n uint128 liquidityTotal,\\n int128 liquidityDelta,\\n uint256 outerFeeGrowth0Token,\\n uint256 outerFeeGrowth1Token,\\n int56 outerTickCumulative,\\n uint160 outerSecondsPerLiquidity,\\n uint32 outerSecondsSpent,\\n bool initialized\\n ) {\\n return IUniswapV3Pool(pool).ticks(tick);\\n }\\n\\n}\\n\",\"keccak256\":\"0x36dde1784257c115d7fc7593e06fbf31fe60da219576c008957cba5444f71c41\",\"license\":\"GPL-2.0-or-later\"},\"contracts/UniV3Quoter/UniswapV3StaticQuoter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity =0.7.6;\\npragma abicoder v2;\\n\\nimport '@uniswap/v3-periphery/contracts/base/PeripheryImmutableState.sol';\\nimport '@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol';\\nimport '@uniswap/v3-periphery/contracts/libraries/Path.sol';\\n\\nimport './interfaces/IUniswapV3StaticQuoter.sol';\\nimport './UniV3QuoterCore.sol';\\n\\ncontract UniswapV3StaticQuoter is IUniswapV3StaticQuoter, UniV3QuoterCore {\\n using LowGasSafeMath for uint256;\\n using LowGasSafeMath for int256;\\n using SafeCast for uint256;\\n using SafeCast for int256;\\n using Path for bytes;\\n\\n address immutable factory;\\n\\n constructor(address _factory) {\\n factory = _factory;\\n }\\n\\n function getPool(\\n address tokenA,\\n address tokenB,\\n uint24 fee\\n ) private view returns (IUniswapV3Pool) {\\n return IUniswapV3Pool(PoolAddress.computeAddress(factory, PoolAddress.getPoolKey(tokenA, tokenB, fee)));\\n }\\n\\n function quoteExactInputSingle(QuoteExactInputSingleParams memory params)\\n public\\n view\\n override\\n returns (uint256 amountOut)\\n {\\n bool zeroForOne = params.tokenIn < params.tokenOut;\\n IUniswapV3Pool pool = getPool(params.tokenIn, params.tokenOut, params.fee);\\n\\n (int256 amount0, int256 amount1) = quote(\\n address(pool),\\n zeroForOne,\\n params.amountIn.toInt256(),\\n params.sqrtPriceLimitX96 == 0\\n ? (zeroForOne ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1)\\n : params.sqrtPriceLimitX96\\n );\\n\\n return zeroForOne ? uint256(-amount1) : uint256(-amount0);\\n }\\n\\n function quoteExactInput(bytes memory path, uint256 amountIn)\\n public\\n view\\n override\\n returns (uint256 amountOut)\\n {\\n uint256 i = 0;\\n while (true) {\\n (address tokenIn, address tokenOut, uint24 fee) = path.decodeFirstPool();\\n\\n // the outputs of prior swaps become the inputs to subsequent ones\\n uint256 _amountOut =\\n quoteExactInputSingle(\\n QuoteExactInputSingleParams({\\n tokenIn: tokenIn,\\n tokenOut: tokenOut,\\n fee: fee,\\n amountIn: amountIn,\\n sqrtPriceLimitX96: 0\\n })\\n );\\n\\n amountIn = _amountOut;\\n i++;\\n\\n // decide whether to continue or terminate\\n if (path.hasMultiplePools()) {\\n path = path.skipToken();\\n } else {\\n return amountIn;\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xfe6e1a406d16251051a7df5f6b35ea8102a8990525dc5ca3cbd9de98ee5edc01\",\"license\":\"GPL-2.0-or-later\"},\"contracts/UniV3Quoter/interfaces/IUniswapV3StaticQuoter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\ninterface IUniswapV3StaticQuoter {\\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)\\n external\\n view\\n returns (uint256 amountOut);\\n\\n struct QuoteExactInputSingleParams {\\n address tokenIn;\\n address tokenOut;\\n uint256 amountIn;\\n uint24 fee;\\n uint160 sqrtPriceLimitX96;\\n }\\n\\n /// @notice Returns the amount out received for a given exact input but for a swap of a single pool\\n /// @param params The params for the quote, encoded as `QuoteExactInputSingleParams`\\n /// tokenIn The token being swapped in\\n /// tokenOut The token being swapped out\\n /// fee The fee of the token pool to consider for the pair\\n /// amountIn The desired input amount\\n /// 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(QuoteExactInputSingleParams memory params)\\n external\\n view\\n returns (uint256 amountOut);\\n}\",\"keccak256\":\"0x6b8609ab43d75ba9ab8796c2dd55b120f4f6c8bbc630da5b3dd90553f12eb25e\",\"license\":\"GPL-2.0-or-later\"},\"contracts/UniV3Quoter/lib/TickBitmap.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 '@uniswap/v3-core/contracts/libraries/BitMath.sol';\\n\\n/// @title Packed tick initialized state library\\n/// @notice Stores a packed mapping of tick index to its initialized state\\n/// @dev The mapping uses int16 for keys since ticks are represented as int24 and there are 256 (2^8) values per word.\\nlibrary TickBitmap {\\n /// @notice Computes the position in the mapping where the initialized bit for a tick lives\\n /// @param tick The tick for which to compute the position\\n /// @return wordPos The key in the mapping containing the word in which the bit is stored\\n /// @return bitPos The bit position in the word where the flag is stored\\n function position(int24 tick) private pure returns (int16 wordPos, uint8 bitPos) {\\n wordPos = int16(tick >> 8);\\n bitPos = uint8(tick % 256);\\n }\\n\\n /// @notice Returns the next initialized tick contained in the same word (or adjacent word) as the tick that is either\\n /// to the left (less than or equal to) or right (greater than) of the given tick\\n /// @param poolAddress Pool containing the mapping in which to compute the next initialized tick\\n /// @param tick The starting tick\\n /// @param tickSpacing The spacing between usable ticks\\n /// @param lte Whether to search for the next initialized tick to the left (less than or equal to the starting tick)\\n /// @return next The next initialized or uninitialized tick up to 256 ticks away from the current tick\\n /// @return initialized Whether the next tick is initialized, as the function only searches within up to 256 ticks\\n function nextInitializedTickWithinOneWord(\\n address poolAddress,\\n int24 tick,\\n int24 tickSpacing,\\n bool lte\\n ) internal view returns (int24 next, bool initialized) {\\n IUniswapV3Pool pool = IUniswapV3Pool(poolAddress);\\n int24 compressed = tick / tickSpacing;\\n if (tick < 0 && tick % tickSpacing != 0) compressed--; // round towards negative infinity\\n\\n if (lte) {\\n (int16 wordPos, uint8 bitPos) = position(compressed);\\n // all the 1s at or to the right of the current bitPos\\n uint256 mask = (1 << bitPos) - 1 + (1 << bitPos);\\n uint256 masked = pool.tickBitmap(wordPos) & mask;\\n\\n // if there are no initialized ticks to the right of or at the current tick, return rightmost in the word\\n initialized = masked != 0;\\n // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick\\n next = initialized\\n ? (compressed - int24(bitPos - BitMath.mostSignificantBit(masked))) * tickSpacing\\n : (compressed - int24(bitPos)) * tickSpacing;\\n } else {\\n // start from the word of the next tick, since the current tick state doesn't matter\\n (int16 wordPos, uint8 bitPos) = position(compressed + 1);\\n // all the 1s at or to the left of the bitPos\\n uint256 mask = ~((1 << bitPos) - 1);\\n uint256 masked = pool.tickBitmap(wordPos) & mask;\\n\\n // if there are no initialized ticks to the left of the current tick, return leftmost in the word\\n initialized = masked != 0;\\n // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick\\n next = initialized\\n ? (compressed + 1 + int24(BitMath.leastSignificantBit(masked) - bitPos)) * tickSpacing\\n : (compressed + 1 + int24(type(uint8).max - bitPos)) * tickSpacing;\\n }\\n }\\n}\",\"keccak256\":\"0x4f72b68d321274361c94ce518806f8fbcbde61e88481a8b1cbeb439e5d9364de\",\"license\":\"GPL-2.0-or-later\"},\"contracts/UniV3likeQuoterCore.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity =0.7.6;\\n\\nimport '@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol';\\nimport '@uniswap/v3-core/contracts/libraries/LiquidityMath.sol';\\nimport '@uniswap/v3-core/contracts/libraries/FixedPoint128.sol';\\nimport '@uniswap/v3-core/contracts/libraries/SafeCast.sol';\\nimport '@uniswap/v3-core/contracts/libraries/TickMath.sol';\\nimport '@uniswap/v3-core/contracts/libraries/FullMath.sol';\\nimport '@uniswap/v3-core/contracts/libraries/SwapMath.sol';\\nimport './IUniV3likeQuoterCore.sol';\\n\\n\\nabstract contract UniV3likeQuoterCore {\\n using LowGasSafeMath for int256;\\n using SafeCast for uint256;\\n using SafeCast for int256;\\n\\n function quote(\\n address poolAddress,\\n bool zeroForOne,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96\\n ) public virtual view returns (int256 amount0, int256 amount1) {\\n require(amountSpecified != 0, 'amountSpecified cannot be zero');\\n bool exactInput = amountSpecified > 0;\\n (int24 tickSpacing, uint16 fee, SwapState memory state) = getInitState(\\n poolAddress,\\n zeroForOne,\\n amountSpecified,\\n sqrtPriceLimitX96\\n );\\n // continue swapping as long as we haven't used the entire input/output and haven't reached the price limit\\n while (state.amountSpecifiedRemaining != 0 && state.sqrtPriceX96 != sqrtPriceLimitX96) {\\n StepComputations memory step;\\n step.sqrtPriceStartX96 = state.sqrtPriceX96;\\n\\n (step.tickNext, step.initialized, step.sqrtPriceNextX96) = nextInitializedTickAndPrice(\\n poolAddress,\\n state.tick,\\n tickSpacing,\\n zeroForOne\\n );\\n // compute values to swap to the target tick, price limit, or point where input/output amount is exhausted\\n (state.sqrtPriceX96, step.amountIn, step.amountOut, step.feeAmount) = SwapMath.computeSwapStep(\\n state.sqrtPriceX96,\\n getSqrtRatioTargetX96(zeroForOne, step.sqrtPriceNextX96, sqrtPriceLimitX96),\\n state.liquidity,\\n state.amountSpecifiedRemaining,\\n fee\\n );\\n if (exactInput) {\\n state.amountSpecifiedRemaining -= (step.amountIn + step.feeAmount).toInt256();\\n state.amountCalculated = state.amountCalculated.sub(step.amountOut.toInt256());\\n } else {\\n state.amountSpecifiedRemaining += step.amountOut.toInt256();\\n state.amountCalculated = state.amountCalculated.add((step.amountIn + step.feeAmount).toInt256());\\n }\\n // shift tick if we reached the next price\\n if (state.sqrtPriceX96 == step.sqrtPriceNextX96) {\\n // if the tick is initialized, run the tick transition\\n if (step.initialized) {\\n (,int128 liquidityNet,,,,,,) = getTicks(poolAddress, step.tickNext);\\n // if we're moving leftward, we interpret liquidityNet as the opposite sign\\n // safe because liquidityNet cannot be type(int128).min\\n if (zeroForOne)\\n liquidityNet = -liquidityNet;\\n state.liquidity = LiquidityMath.addDelta(state.liquidity, liquidityNet);\\n }\\n state.tick = zeroForOne ? step.tickNext - 1 : step.tickNext;\\n } else if (state.sqrtPriceX96 != step.sqrtPriceStartX96) {\\n // recompute unless we're on a lower tick boundary (i.e. already transitioned ticks), and haven't moved\\n state.tick = TickMath.getTickAtSqrtRatio(state.sqrtPriceX96);\\n }\\n }\\n\\n (amount0, amount1) = zeroForOne == exactInput\\n ? (amountSpecified - state.amountSpecifiedRemaining, state.amountCalculated)\\n : (state.amountCalculated, amountSpecified - state.amountSpecifiedRemaining);\\n }\\n\\n function getInitState(\\n address poolAddress,\\n bool zeroForOne,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96\\n ) internal view returns (int24 ts, uint16 fee, SwapState memory state) {\\n GlobalState memory gs = getPoolGlobalState(poolAddress);\\n checkSqrtPriceLimitWithinAllowed(zeroForOne, sqrtPriceLimitX96, gs.startPrice);\\n ts = getTickSpacing(poolAddress);\\n fee = gs.fee;\\n state = SwapState({\\n amountSpecifiedRemaining: amountSpecified,\\n liquidity: getLiquidity(poolAddress),\\n sqrtPriceX96: gs.startPrice,\\n amountCalculated: 0,\\n tick: gs.startTick\\n });\\n }\\n\\n function checkSqrtPriceLimitWithinAllowed(\\n bool zeroForOne,\\n uint160 sqrtPriceLimit, \\n uint160 startPrice\\n ) internal pure {\\n bool withinAllowed = zeroForOne\\n ? sqrtPriceLimit < startPrice && sqrtPriceLimit > TickMath.MIN_SQRT_RATIO\\n : sqrtPriceLimit > startPrice && sqrtPriceLimit < TickMath.MAX_SQRT_RATIO;\\n require(withinAllowed, 'sqrtPriceLimit out of bounds');\\n }\\n\\n function nextInitializedTickAndPrice(\\n address pool, \\n int24 tick, \\n int24 tickSpacing,\\n bool zeroForOne\\n ) internal view returns (int24 tickNext, bool initialized, uint160 sqrtPriceNextX96) {\\n (tickNext, initialized) = nextInitializedTickWithinOneWord(pool, tick, tickSpacing, zeroForOne);\\n // ensure that we do not overshoot the min/max tick, as the tick bitmap is not aware of these bounds\\n if (tickNext < TickMath.MIN_TICK)\\n tickNext = TickMath.MIN_TICK;\\n else if (tickNext > TickMath.MAX_TICK)\\n tickNext = TickMath.MAX_TICK;\\n // get the price for the next tick\\n sqrtPriceNextX96 = TickMath.getSqrtRatioAtTick(tickNext);\\n }\\n\\n function getSqrtRatioTargetX96(\\n bool zeroForOne,\\n uint160 sqrtPriceNextX96,\\n uint160 sqrtPriceLimitX96\\n ) internal pure returns (uint160) {\\n return (zeroForOne ? sqrtPriceNextX96sqrtPriceLimitX96)\\n ? sqrtPriceLimitX96\\n : sqrtPriceNextX96;\\n }\\n\\n function getPoolGlobalState(address pool) internal virtual view returns (GlobalState memory);\\n \\n function getLiquidity(address pool) internal virtual view returns (uint128);\\n\\n function getTickSpacing(address pool) internal virtual view returns (int24);\\n \\n function nextInitializedTickWithinOneWord(\\n address poolAddress,\\n int24 tick,\\n int24 tickSpacing,\\n bool zeroForOne\\n ) internal virtual view returns (int24 next, bool initialized);\\n \\n function getTicks(address pool, int24 tick) internal virtual view returns (\\n uint128 liquidityTotal,\\n int128 liquidityDelta,\\n uint256 outerFeeGrowth0Token,\\n uint256 outerFeeGrowth1Token,\\n int56 outerTickCumulative,\\n uint160 outerSecondsPerLiquidity,\\n uint32 outerSecondsSpent,\\n bool initialized\\n );\\n\\n}\",\"keccak256\":\"0x88ee57ab5681b55a01fc270be7ac20c333d059a6d7d125d181964b47fe127e06\",\"license\":\"GPL-2.0-or-later\"}},\"version\":1}", + "bytecode": "0x60a06040523480156200001157600080fd5b5060405162002bb438038062002bb483398101604081905262000034916200004a565b60601b6001600160601b0319166080526200007a565b6000602082840312156200005c578081fd5b81516001600160a01b038116811462000073578182fd5b9392505050565b60805160601c612b1c6200009860003980610fc25250612b1c6000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806390405d3614610046578063c6a5026a14610070578063cdca175314610090575b600080fd5b610059610054366004612920565b6100a3565b604051610067929190612aaf565b60405180910390f35b61008361007e366004612a22565b6103f9565b6040516100679190612abd565b61008361009e366004612976565b6104bf565b6000808361011257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f616d6f756e745370656369666965642063616e6e6f74206265207a65726f0000604482015290519081900360640190fd5b60008085139080806101268a8a8a8a610594565b9250925092505b80511580159061016d57508673ffffffffffffffffffffffffffffffffffffffff16816040015173ffffffffffffffffffffffffffffffffffffffff1614155b156103c25761017a61288b565b604082015173ffffffffffffffffffffffffffffffffffffffff16815260608201516101a9908c90868d61063d565b73ffffffffffffffffffffffffffffffffffffffff1660608401819052901515604080850191909152600292830b90920b602084015290830151610204916101f3908d908c6106d2565b6080850151855161ffff8816610753565b60c085015260a0840152608083015273ffffffffffffffffffffffffffffffffffffffff1660408301528415610273576102478160c00151826080015101610979565b825103825260a08101516102699061025e90610979565b6020840151906109ab565b60208301526102ae565b6102808160a00151610979565b825101825260c081015160808201516102a89161029d9101610979565b6020840151906109c1565b60208301525b806060015173ffffffffffffffffffffffffffffffffffffffff16826040015173ffffffffffffffffffffffffffffffffffffffff1614156103675780604001511561033e5760006103048c83602001516109d7565b5050505050509150508a15610317576000035b610325836080015182610aab565b6fffffffffffffffffffffffffffffffff166080840152505b8961034d578060200151610356565b60018160200151035b600290810b900b60608301526103bc565b806000015173ffffffffffffffffffffffffffffffffffffffff16826040015173ffffffffffffffffffffffffffffffffffffffff16146103bc576103af8260400151610bef565b600290810b900b60608301525b5061012d565b831515891515146103db576020810151815189036103e8565b8060000151880381602001515b909b909a5098505050505050505050565b60208101518151606083015160009273ffffffffffffffffffffffffffffffffffffffff808216908416109284926104319290610fbb565b905060008061049c83856104488960400151610979565b60808a015173ffffffffffffffffffffffffffffffffffffffff1615610472578960800151610054565b876104915773fffd8963efd1fc6a506488495d951d5263988d25610054565b6401000276a46100a3565b91509150836104ae57816000036104b3565b806000035b9450505050505b919050565b6000805b60008060006104d187610ff1565b92509250925060006105506040518060a001604052808673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1681526020018981526020018462ffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152506103f9565b9650506001909301928561056388611022565b15610578576105718861102a565b9750610585565b869550505050505061058e565b505050506104c3565b92915050565b60008061059f6128c7565b60006105aa8861105f565b90506105bb878683600001516111a8565b6105c4886112e1565b9350806040015192506040518060a0016040528087815260200160008152602001826000015173ffffffffffffffffffffffffffffffffffffffff168152602001826020015160020b815260200161061b8a61135b565b6fffffffffffffffffffffffffffffffff168152509150509450945094915050565b600080600061064e878787876113a3565b90935091507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff27618600284900b12156106a7577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2761892506106bd565b620d89e8600284900b13156106bd57620d89e892505b6106c6836113bf565b90509450945094915050565b60008361070d578173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161161073d565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16105b6107475782610749565b815b90505b9392505050565b600080808073ffffffffffffffffffffffffffffffffffffffff808916908a1610158187128015906107e55760006107998989620f42400362ffffff16620f4240611752565b9050826107b2576107ad8c8c8c600161181f565b6107bf565b6107bf8b8d8c60016118f2565b95508581106107d0578a96506107df565b6107dc8c8b8386611a0a565b96505b5061082f565b816107fc576107f78b8b8b60006118f2565b610809565b6108098a8c8b600061181f565b935083886000031061081d5789955061082f565b61082c8b8a8a60000385611a6c565b95505b73ffffffffffffffffffffffffffffffffffffffff8a811690871614821561089f5780801561085b5750815b6108715761086c878d8c60016118f2565b610873565b855b9550808015610880575081155b61089657610891878d8c600061181f565b610898565b845b94506108e9565b8080156108a95750815b6108bf576108ba8c888c600161181f565b6108c1565b855b95508080156108ce575081155b6108e4576108df8c888c60006118f2565b6108e6565b845b94505b811580156108f957508860000385115b15610905578860000394505b81801561093e57508a73ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614155b1561094d57858903935061096a565b610967868962ffffff168a620f42400362ffffff16611ace565b93505b50505095509550955095915050565b60007f800000000000000000000000000000000000000000000000000000000000000082106109a757600080fd5b5090565b8082038281131560008312151461058e57600080fd5b8181018281121560008312151461058e57600080fd5b6000806000806000806000808973ffffffffffffffffffffffffffffffffffffffff1663f30dba938a6040518263ffffffff1660e01b8152600401808260020b81526020019150506101006040518083038186803b158015610a3857600080fd5b505afa158015610a4c573d6000803e3d6000fd5b505050506040513d610100811015610a6357600080fd5b508051602082015160408301516060840151608085015160a086015160c087015160e090970151959e50939c50919a5098509650945090925090509295985092959890939650565b60008082600f0b1215610b5757826fffffffffffffffffffffffffffffffff168260000384039150816fffffffffffffffffffffffffffffffff1610610b5257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f4c53000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b61058e565b826fffffffffffffffffffffffffffffffff168284019150816fffffffffffffffffffffffffffffffff16101561058e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f4c41000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60006401000276a373ffffffffffffffffffffffffffffffffffffffff831610801590610c45575073fffd8963efd1fc6a506488495d951d5263988d2673ffffffffffffffffffffffffffffffffffffffff8316105b610cb057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f5200000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b77ffffffffffffffffffffffffffffffffffffffff00000000602083901b166fffffffffffffffffffffffffffffffff811160071b81811c67ffffffffffffffff811160061b90811c63ffffffff811160051b90811c61ffff811160041b90811c60ff8111600390811b91821c600f811160021b90811c918211600190811b92831c97908811961790941790921717909117171760808110610d5a57607f810383901c9150610d64565b80607f0383901b91505b908002607f81811c60ff83811c9190911c800280831c81831c1c800280841c81841c1c800280851c81851c1c800280861c81861c1c800280871c81871c1c800280881c81881c1c800280891c81891c1c8002808a1c818a1c1c8002808b1c818b1c1c8002808c1c818c1c1c8002808d1c818d1c1c8002808e1c9c81901c9c909c1c80029c8d901c9e9d7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808f0160401b60c09190911c678000000000000000161760c19b909b1c674000000000000000169a909a1760c29990991c672000000000000000169890981760c39790971c671000000000000000169690961760c49590951c670800000000000000169490941760c59390931c670400000000000000169290921760c69190911c670200000000000000161760c79190911c670100000000000000161760c89190911c6680000000000000161760c99190911c6640000000000000161760ca9190911c6620000000000000161760cb9190911c6610000000000000161760cc9190911c6608000000000000161760cd9190911c66040000000000001617693627a301d71055774c8581027ffffffffffffffffffffffffffffffffffd709b7e5480fba5a50fed5e62ffc5568101608090811d906fdb2df09e81959a81455e260799a0632f8301901d600281810b9083900b14610fac578873ffffffffffffffffffffffffffffffffffffffff16610f83826113bf565b73ffffffffffffffffffffffffffffffffffffffff161115610fa55781610fa7565b805b610fae565b815b9998505050505050505050565b60006107497f0000000000000000000000000000000000000000000000000000000000000000610fec868686611b26565b611ba3565b60008080610fff8482611cd9565b925061100c846014611dd9565b9050611019846017611cd9565b91509193909250565b516042111590565b805160609061058e9083906017907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe901611ec9565b6110676128f5565b8173ffffffffffffffffffffffffffffffffffffffff1663ddca3f436040518163ffffffff1660e01b815260040160206040518083038186803b1580156110ad57600080fd5b505afa1580156110c1573d6000803e3d6000fd5b505050506040513d60208110156110d757600080fd5b505161ffff1660408083019190915280517f3850c7bd000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff841691633850c7bd9160048083019260e0929190829003018186803b15801561114a57600080fd5b505afa15801561115e573d6000803e3d6000fd5b505050506040513d60e081101561117457600080fd5b508051602091820151600290810b900b9183019190915273ffffffffffffffffffffffffffffffffffffffff168152919050565b600083611218578173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16118015611213575073fffd8963efd1fc6a506488495d951d5263988d2673ffffffffffffffffffffffffffffffffffffffff8416105b61126d565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1610801561126d57506401000276a373ffffffffffffffffffffffffffffffffffffffff8416115b9050806112db57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f7371727450726963654c696d6974206f7574206f6620626f756e647300000000604482015290519081900360640190fd5b50505050565b60008173ffffffffffffffffffffffffffffffffffffffff1663d0c93a7c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561132957600080fd5b505afa15801561133d573d6000803e3d6000fd5b505050506040513d602081101561135357600080fd5b505192915050565b60008173ffffffffffffffffffffffffffffffffffffffff16631a6865026040518163ffffffff1660e01b815260040160206040518083038186803b15801561132957600080fd5b6000806113b2868686866120b0565b9150915094509492505050565b60008060008360020b126113d6578260020b6113de565b8260020b6000035b9050620d89e881111561145257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f5400000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60006001821661147357700100000000000000000000000000000000611485565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156114b9576ffff97272373d413259a46990580e213a0260801c5b60048216156114d8576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b60088216156114f7576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615611516576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615611535576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615611554576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615611573576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615611593576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b6102008216156115b3576ff987a7253ac413176f2b074cf7815e540260801c5b6104008216156115d3576ff3392b0822b70005940c7a398e4b70f30260801c5b6108008216156115f3576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615611613576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615611633576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615611653576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615611673576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615611694576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b620200008216156116b4576e5d6af8dedb81196699c329225ee6040260801c5b620400008216156116d3576d2216e584f5fa1ea926041bedfe980260801c5b620800008216156116f0576b048a170391f7dc42444e8fa20260801c5b60008460020b131561172957807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8161172557fe5b0490505b64010000000081061561173d576001611740565b60005b60ff16602082901c0192505050919050565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff858709868602925082811090839003039050806117a6576000841161179b57600080fd5b50829004905061074c565b8084116117b257600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161115611859579293925b816118a5576118a0836fffffffffffffffffffffffffffffffff1686860373ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000611752565b6118e7565b6118e7836fffffffffffffffffffffffffffffffff1686860373ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000611ace565b90505b949350505050565b60008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16111561192c579293925b7bffffffffffffffffffffffffffffffff000000000000000000000000606084901b1673ffffffffffffffffffffffffffffffffffffffff868603811690871661197557600080fd5b836119bf578673ffffffffffffffffffffffffffffffffffffffff166119b283838973ffffffffffffffffffffffffffffffffffffffff16611752565b816119b957fe5b046119ff565b6119ff6119e383838973ffffffffffffffffffffffffffffffffffffffff16611ace565b8873ffffffffffffffffffffffffffffffffffffffff1661231d565b979650505050505050565b6000808573ffffffffffffffffffffffffffffffffffffffff1611611a2e57600080fd5b6000846fffffffffffffffffffffffffffffffff1611611a4d57600080fd5b81611a5f576118a08585856001612328565b6118e78585856001612480565b6000808573ffffffffffffffffffffffffffffffffffffffff1611611a9057600080fd5b6000846fffffffffffffffffffffffffffffffff1611611aaf57600080fd5b81611ac1576118a08585856000612480565b6118e78585856000612328565b6000611adb848484611752565b905060008280611ae757fe5b848609111561074c577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8110611b1c57600080fd5b6001019392505050565b611b2e6128f5565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161115611b66579192915b506040805160608101825273ffffffffffffffffffffffffffffffffffffffff948516815292909316602083015262ffffff169181019190915290565b6000816020015173ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff1610611be557600080fd5b508051602080830151604093840151845173ffffffffffffffffffffffffffffffffffffffff94851681850152939091168385015262ffffff166060808401919091528351808403820181526080840185528051908301207fff0000000000000000000000000000000000000000000000000000000000000060a085015294901b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660a183015260b58201939093527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d5808301919091528251808303909101815260f5909101909152805191012090565b600081826014011015611d4d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f746f416464726573735f6f766572666c6f770000000000000000000000000000604482015290519081900360640190fd5b8160140183511015611dc057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f746f416464726573735f6f75744f66426f756e64730000000000000000000000604482015290519081900360640190fd5b5001602001516c01000000000000000000000000900490565b600081826003011015611e4d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f746f55696e7432345f6f766572666c6f77000000000000000000000000000000604482015290519081900360640190fd5b8160030183511015611ec057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f746f55696e7432345f6f75744f66426f756e6473000000000000000000000000604482015290519081900360640190fd5b50016003015190565b60608182601f011015611f3d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f736c6963655f6f766572666c6f77000000000000000000000000000000000000604482015290519081900360640190fd5b828284011015611fae57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f736c6963655f6f766572666c6f77000000000000000000000000000000000000604482015290519081900360640190fd5b8183018451101561202057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f736c6963655f6f75744f66426f756e6473000000000000000000000000000000604482015290519081900360640190fd5b60608215801561203f57604051915060008252602082016040526120a7565b6040519150601f8416801560200281840101858101878315602002848b0101015b81831015612078578051835260209283019201612060565b5050858452601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016604052505b50949350505050565b6000808581600286810b9088900b816120c557fe5b05905060008760020b1280156120ec57508560020b8760020b816120e557fe5b0760020b15155b15612114577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff015b841561222f57600080612126836125b6565b604080517f5339c296000000000000000000000000000000000000000000000000000000008152600184810b6004830152915193955091935060ff84161b80017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0191600091839173ffffffffffffffffffffffffffffffffffffffff891691635339c296916024808301926020929190829003018186803b1580156121cb57600080fd5b505afa1580156121df573d6000803e3d6000fd5b505050506040513d60208110156121f557600080fd5b505116801515975090508661221157898360ff16860302612224565b8961221b826125c8565b840360ff168603025b975050505050612312565b60008061223e836001016125b6565b91509150600060018260ff166001901b031990506000818673ffffffffffffffffffffffffffffffffffffffff16635339c296866040518263ffffffff1660e01b8152600401808260010b815260200191505060206040518083038186803b1580156122a957600080fd5b505afa1580156122bd573d6000803e3d6000fd5b505050506040513d60208110156122d357600080fd5b50511680151597509050866122f557898360ff0360ff1686600101010261230b565b898361230083612675565b0360ff168660010101025b9750505050505b505094509492505050565b808204910615150190565b600081156123d057600073ffffffffffffffffffffffffffffffffffffffff84111561237d57612378846c01000000000000000000000000876fffffffffffffffffffffffffffffffff16611752565b61239e565b6fffffffffffffffffffffffffffffffff8516606085901b8161239c57fe5b045b90506123c86123c373ffffffffffffffffffffffffffffffffffffffff881683612858565b612868565b9150506118ea565b600073ffffffffffffffffffffffffffffffffffffffff84111561241d57612418846c01000000000000000000000000876fffffffffffffffffffffffffffffffff16611ace565b61243d565b61243d606085901b6fffffffffffffffffffffffffffffffff871661231d565b9050808673ffffffffffffffffffffffffffffffffffffffff161161246157600080fd5b73ffffffffffffffffffffffffffffffffffffffff86160390506118ea565b60008261248e5750836118ea565b7bffffffffffffffffffffffffffffffff000000000000000000000000606085901b1682156125555773ffffffffffffffffffffffffffffffffffffffff8616848102908582816124db57fe5b041415612519578181018281106125175761250d838973ffffffffffffffffffffffffffffffffffffffff1683611ace565b93505050506118ea565b505b61254c82612547878a73ffffffffffffffffffffffffffffffffffffffff16868161254057fe5b0490612858565b61231d565b925050506118ea565b73ffffffffffffffffffffffffffffffffffffffff86168481029085828161257957fe5b0414801561258657508082115b61258f57600080fd5b80820361250d6123c38473ffffffffffffffffffffffffffffffffffffffff8b1684611ace565b60020b600881901d9161010090910790565b60008082116125d657600080fd5b70010000000000000000000000000000000082106125f657608091821c91015b68010000000000000000821061260e57604091821c91015b640100000000821061262257602091821c91015b62010000821061263457601091821c91015b610100821061264557600891821c91015b6010821061265557600491821c91015b6004821061266557600291821c91015b600282106104ba57600101919050565b600080821161268357600080fd5b5060ff6fffffffffffffffffffffffffffffffff8216156126c5577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80016126cd565b608082901c91505b67ffffffffffffffff821615612704577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00161270c565b604082901c91505b63ffffffff82161561273f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001612747565b602082901c91505b61ffff821615612778577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001612780565b601082901c91505b60ff8216156127b0577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8016127b8565b600882901c91505b600f8216156127e8577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc016127f0565b600482901c91505b6003821615612820577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01612828565b600282901c91505b60018216156104ba577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01919050565b8082018281101561058e57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff811681146104ba57600080fd5b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915290565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b604080516060810182526000808252602082018190529181019190915290565b80356104ba81612aea565b60008060008060808587031215612935578384fd5b843561294081612aea565b935060208501358015158114612954578384fd5b925060408501359150606085013561296b81612aea565b939692955090935050565b60008060408385031215612988578182fd5b823567ffffffffffffffff8082111561299f578384fd5b818501915085601f8301126129b2578384fd5b81356020828211156129c057fe5b6129f0817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f85011601612ac6565b92508183528781838601011115612a05578586fd5b818185018285013790820181019490945295939092013593505050565b600060a08284031215612a33578081fd5b60405160a0810181811067ffffffffffffffff82111715612a5057fe5b6040528235612a5e81612aea565b81526020830135612a6e81612aea565b602082015260408381013590820152606083013562ffffff81168114612a92578283fd5b6060820152612aa360808401612915565b60808201529392505050565b918252602082015260400190565b90815260200190565b60405181810167ffffffffffffffff81118282101715612ae257fe5b604052919050565b73ffffffffffffffffffffffffffffffffffffffff81168114612b0c57600080fd5b5056fea164736f6c6343000706000a", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c806390405d3614610046578063c6a5026a14610070578063cdca175314610090575b600080fd5b610059610054366004612920565b6100a3565b604051610067929190612aaf565b60405180910390f35b61008361007e366004612a22565b6103f9565b6040516100679190612abd565b61008361009e366004612976565b6104bf565b6000808361011257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f616d6f756e745370656369666965642063616e6e6f74206265207a65726f0000604482015290519081900360640190fd5b60008085139080806101268a8a8a8a610594565b9250925092505b80511580159061016d57508673ffffffffffffffffffffffffffffffffffffffff16816040015173ffffffffffffffffffffffffffffffffffffffff1614155b156103c25761017a61288b565b604082015173ffffffffffffffffffffffffffffffffffffffff16815260608201516101a9908c90868d61063d565b73ffffffffffffffffffffffffffffffffffffffff1660608401819052901515604080850191909152600292830b90920b602084015290830151610204916101f3908d908c6106d2565b6080850151855161ffff8816610753565b60c085015260a0840152608083015273ffffffffffffffffffffffffffffffffffffffff1660408301528415610273576102478160c00151826080015101610979565b825103825260a08101516102699061025e90610979565b6020840151906109ab565b60208301526102ae565b6102808160a00151610979565b825101825260c081015160808201516102a89161029d9101610979565b6020840151906109c1565b60208301525b806060015173ffffffffffffffffffffffffffffffffffffffff16826040015173ffffffffffffffffffffffffffffffffffffffff1614156103675780604001511561033e5760006103048c83602001516109d7565b5050505050509150508a15610317576000035b610325836080015182610aab565b6fffffffffffffffffffffffffffffffff166080840152505b8961034d578060200151610356565b60018160200151035b600290810b900b60608301526103bc565b806000015173ffffffffffffffffffffffffffffffffffffffff16826040015173ffffffffffffffffffffffffffffffffffffffff16146103bc576103af8260400151610bef565b600290810b900b60608301525b5061012d565b831515891515146103db576020810151815189036103e8565b8060000151880381602001515b909b909a5098505050505050505050565b60208101518151606083015160009273ffffffffffffffffffffffffffffffffffffffff808216908416109284926104319290610fbb565b905060008061049c83856104488960400151610979565b60808a015173ffffffffffffffffffffffffffffffffffffffff1615610472578960800151610054565b876104915773fffd8963efd1fc6a506488495d951d5263988d25610054565b6401000276a46100a3565b91509150836104ae57816000036104b3565b806000035b9450505050505b919050565b6000805b60008060006104d187610ff1565b92509250925060006105506040518060a001604052808673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1681526020018981526020018462ffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152506103f9565b9650506001909301928561056388611022565b15610578576105718861102a565b9750610585565b869550505050505061058e565b505050506104c3565b92915050565b60008061059f6128c7565b60006105aa8861105f565b90506105bb878683600001516111a8565b6105c4886112e1565b9350806040015192506040518060a0016040528087815260200160008152602001826000015173ffffffffffffffffffffffffffffffffffffffff168152602001826020015160020b815260200161061b8a61135b565b6fffffffffffffffffffffffffffffffff168152509150509450945094915050565b600080600061064e878787876113a3565b90935091507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff27618600284900b12156106a7577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2761892506106bd565b620d89e8600284900b13156106bd57620d89e892505b6106c6836113bf565b90509450945094915050565b60008361070d578173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161161073d565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16105b6107475782610749565b815b90505b9392505050565b600080808073ffffffffffffffffffffffffffffffffffffffff808916908a1610158187128015906107e55760006107998989620f42400362ffffff16620f4240611752565b9050826107b2576107ad8c8c8c600161181f565b6107bf565b6107bf8b8d8c60016118f2565b95508581106107d0578a96506107df565b6107dc8c8b8386611a0a565b96505b5061082f565b816107fc576107f78b8b8b60006118f2565b610809565b6108098a8c8b600061181f565b935083886000031061081d5789955061082f565b61082c8b8a8a60000385611a6c565b95505b73ffffffffffffffffffffffffffffffffffffffff8a811690871614821561089f5780801561085b5750815b6108715761086c878d8c60016118f2565b610873565b855b9550808015610880575081155b61089657610891878d8c600061181f565b610898565b845b94506108e9565b8080156108a95750815b6108bf576108ba8c888c600161181f565b6108c1565b855b95508080156108ce575081155b6108e4576108df8c888c60006118f2565b6108e6565b845b94505b811580156108f957508860000385115b15610905578860000394505b81801561093e57508a73ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614155b1561094d57858903935061096a565b610967868962ffffff168a620f42400362ffffff16611ace565b93505b50505095509550955095915050565b60007f800000000000000000000000000000000000000000000000000000000000000082106109a757600080fd5b5090565b8082038281131560008312151461058e57600080fd5b8181018281121560008312151461058e57600080fd5b6000806000806000806000808973ffffffffffffffffffffffffffffffffffffffff1663f30dba938a6040518263ffffffff1660e01b8152600401808260020b81526020019150506101006040518083038186803b158015610a3857600080fd5b505afa158015610a4c573d6000803e3d6000fd5b505050506040513d610100811015610a6357600080fd5b508051602082015160408301516060840151608085015160a086015160c087015160e090970151959e50939c50919a5098509650945090925090509295985092959890939650565b60008082600f0b1215610b5757826fffffffffffffffffffffffffffffffff168260000384039150816fffffffffffffffffffffffffffffffff1610610b5257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f4c53000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b61058e565b826fffffffffffffffffffffffffffffffff168284019150816fffffffffffffffffffffffffffffffff16101561058e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f4c41000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60006401000276a373ffffffffffffffffffffffffffffffffffffffff831610801590610c45575073fffd8963efd1fc6a506488495d951d5263988d2673ffffffffffffffffffffffffffffffffffffffff8316105b610cb057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f5200000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b77ffffffffffffffffffffffffffffffffffffffff00000000602083901b166fffffffffffffffffffffffffffffffff811160071b81811c67ffffffffffffffff811160061b90811c63ffffffff811160051b90811c61ffff811160041b90811c60ff8111600390811b91821c600f811160021b90811c918211600190811b92831c97908811961790941790921717909117171760808110610d5a57607f810383901c9150610d64565b80607f0383901b91505b908002607f81811c60ff83811c9190911c800280831c81831c1c800280841c81841c1c800280851c81851c1c800280861c81861c1c800280871c81871c1c800280881c81881c1c800280891c81891c1c8002808a1c818a1c1c8002808b1c818b1c1c8002808c1c818c1c1c8002808d1c818d1c1c8002808e1c9c81901c9c909c1c80029c8d901c9e9d7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808f0160401b60c09190911c678000000000000000161760c19b909b1c674000000000000000169a909a1760c29990991c672000000000000000169890981760c39790971c671000000000000000169690961760c49590951c670800000000000000169490941760c59390931c670400000000000000169290921760c69190911c670200000000000000161760c79190911c670100000000000000161760c89190911c6680000000000000161760c99190911c6640000000000000161760ca9190911c6620000000000000161760cb9190911c6610000000000000161760cc9190911c6608000000000000161760cd9190911c66040000000000001617693627a301d71055774c8581027ffffffffffffffffffffffffffffffffffd709b7e5480fba5a50fed5e62ffc5568101608090811d906fdb2df09e81959a81455e260799a0632f8301901d600281810b9083900b14610fac578873ffffffffffffffffffffffffffffffffffffffff16610f83826113bf565b73ffffffffffffffffffffffffffffffffffffffff161115610fa55781610fa7565b805b610fae565b815b9998505050505050505050565b60006107497f0000000000000000000000000000000000000000000000000000000000000000610fec868686611b26565b611ba3565b60008080610fff8482611cd9565b925061100c846014611dd9565b9050611019846017611cd9565b91509193909250565b516042111590565b805160609061058e9083906017907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe901611ec9565b6110676128f5565b8173ffffffffffffffffffffffffffffffffffffffff1663ddca3f436040518163ffffffff1660e01b815260040160206040518083038186803b1580156110ad57600080fd5b505afa1580156110c1573d6000803e3d6000fd5b505050506040513d60208110156110d757600080fd5b505161ffff1660408083019190915280517f3850c7bd000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff841691633850c7bd9160048083019260e0929190829003018186803b15801561114a57600080fd5b505afa15801561115e573d6000803e3d6000fd5b505050506040513d60e081101561117457600080fd5b508051602091820151600290810b900b9183019190915273ffffffffffffffffffffffffffffffffffffffff168152919050565b600083611218578173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16118015611213575073fffd8963efd1fc6a506488495d951d5263988d2673ffffffffffffffffffffffffffffffffffffffff8416105b61126d565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1610801561126d57506401000276a373ffffffffffffffffffffffffffffffffffffffff8416115b9050806112db57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f7371727450726963654c696d6974206f7574206f6620626f756e647300000000604482015290519081900360640190fd5b50505050565b60008173ffffffffffffffffffffffffffffffffffffffff1663d0c93a7c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561132957600080fd5b505afa15801561133d573d6000803e3d6000fd5b505050506040513d602081101561135357600080fd5b505192915050565b60008173ffffffffffffffffffffffffffffffffffffffff16631a6865026040518163ffffffff1660e01b815260040160206040518083038186803b15801561132957600080fd5b6000806113b2868686866120b0565b9150915094509492505050565b60008060008360020b126113d6578260020b6113de565b8260020b6000035b9050620d89e881111561145257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f5400000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60006001821661147357700100000000000000000000000000000000611485565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156114b9576ffff97272373d413259a46990580e213a0260801c5b60048216156114d8576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b60088216156114f7576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615611516576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615611535576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615611554576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615611573576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615611593576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b6102008216156115b3576ff987a7253ac413176f2b074cf7815e540260801c5b6104008216156115d3576ff3392b0822b70005940c7a398e4b70f30260801c5b6108008216156115f3576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615611613576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615611633576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615611653576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615611673576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615611694576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b620200008216156116b4576e5d6af8dedb81196699c329225ee6040260801c5b620400008216156116d3576d2216e584f5fa1ea926041bedfe980260801c5b620800008216156116f0576b048a170391f7dc42444e8fa20260801c5b60008460020b131561172957807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8161172557fe5b0490505b64010000000081061561173d576001611740565b60005b60ff16602082901c0192505050919050565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff858709868602925082811090839003039050806117a6576000841161179b57600080fd5b50829004905061074c565b8084116117b257600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161115611859579293925b816118a5576118a0836fffffffffffffffffffffffffffffffff1686860373ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000611752565b6118e7565b6118e7836fffffffffffffffffffffffffffffffff1686860373ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000611ace565b90505b949350505050565b60008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16111561192c579293925b7bffffffffffffffffffffffffffffffff000000000000000000000000606084901b1673ffffffffffffffffffffffffffffffffffffffff868603811690871661197557600080fd5b836119bf578673ffffffffffffffffffffffffffffffffffffffff166119b283838973ffffffffffffffffffffffffffffffffffffffff16611752565b816119b957fe5b046119ff565b6119ff6119e383838973ffffffffffffffffffffffffffffffffffffffff16611ace565b8873ffffffffffffffffffffffffffffffffffffffff1661231d565b979650505050505050565b6000808573ffffffffffffffffffffffffffffffffffffffff1611611a2e57600080fd5b6000846fffffffffffffffffffffffffffffffff1611611a4d57600080fd5b81611a5f576118a08585856001612328565b6118e78585856001612480565b6000808573ffffffffffffffffffffffffffffffffffffffff1611611a9057600080fd5b6000846fffffffffffffffffffffffffffffffff1611611aaf57600080fd5b81611ac1576118a08585856000612480565b6118e78585856000612328565b6000611adb848484611752565b905060008280611ae757fe5b848609111561074c577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8110611b1c57600080fd5b6001019392505050565b611b2e6128f5565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161115611b66579192915b506040805160608101825273ffffffffffffffffffffffffffffffffffffffff948516815292909316602083015262ffffff169181019190915290565b6000816020015173ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff1610611be557600080fd5b508051602080830151604093840151845173ffffffffffffffffffffffffffffffffffffffff94851681850152939091168385015262ffffff166060808401919091528351808403820181526080840185528051908301207fff0000000000000000000000000000000000000000000000000000000000000060a085015294901b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660a183015260b58201939093527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d5808301919091528251808303909101815260f5909101909152805191012090565b600081826014011015611d4d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f746f416464726573735f6f766572666c6f770000000000000000000000000000604482015290519081900360640190fd5b8160140183511015611dc057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f746f416464726573735f6f75744f66426f756e64730000000000000000000000604482015290519081900360640190fd5b5001602001516c01000000000000000000000000900490565b600081826003011015611e4d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f746f55696e7432345f6f766572666c6f77000000000000000000000000000000604482015290519081900360640190fd5b8160030183511015611ec057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f746f55696e7432345f6f75744f66426f756e6473000000000000000000000000604482015290519081900360640190fd5b50016003015190565b60608182601f011015611f3d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f736c6963655f6f766572666c6f77000000000000000000000000000000000000604482015290519081900360640190fd5b828284011015611fae57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f736c6963655f6f766572666c6f77000000000000000000000000000000000000604482015290519081900360640190fd5b8183018451101561202057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f736c6963655f6f75744f66426f756e6473000000000000000000000000000000604482015290519081900360640190fd5b60608215801561203f57604051915060008252602082016040526120a7565b6040519150601f8416801560200281840101858101878315602002848b0101015b81831015612078578051835260209283019201612060565b5050858452601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016604052505b50949350505050565b6000808581600286810b9088900b816120c557fe5b05905060008760020b1280156120ec57508560020b8760020b816120e557fe5b0760020b15155b15612114577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff015b841561222f57600080612126836125b6565b604080517f5339c296000000000000000000000000000000000000000000000000000000008152600184810b6004830152915193955091935060ff84161b80017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0191600091839173ffffffffffffffffffffffffffffffffffffffff891691635339c296916024808301926020929190829003018186803b1580156121cb57600080fd5b505afa1580156121df573d6000803e3d6000fd5b505050506040513d60208110156121f557600080fd5b505116801515975090508661221157898360ff16860302612224565b8961221b826125c8565b840360ff168603025b975050505050612312565b60008061223e836001016125b6565b91509150600060018260ff166001901b031990506000818673ffffffffffffffffffffffffffffffffffffffff16635339c296866040518263ffffffff1660e01b8152600401808260010b815260200191505060206040518083038186803b1580156122a957600080fd5b505afa1580156122bd573d6000803e3d6000fd5b505050506040513d60208110156122d357600080fd5b50511680151597509050866122f557898360ff0360ff1686600101010261230b565b898361230083612675565b0360ff168660010101025b9750505050505b505094509492505050565b808204910615150190565b600081156123d057600073ffffffffffffffffffffffffffffffffffffffff84111561237d57612378846c01000000000000000000000000876fffffffffffffffffffffffffffffffff16611752565b61239e565b6fffffffffffffffffffffffffffffffff8516606085901b8161239c57fe5b045b90506123c86123c373ffffffffffffffffffffffffffffffffffffffff881683612858565b612868565b9150506118ea565b600073ffffffffffffffffffffffffffffffffffffffff84111561241d57612418846c01000000000000000000000000876fffffffffffffffffffffffffffffffff16611ace565b61243d565b61243d606085901b6fffffffffffffffffffffffffffffffff871661231d565b9050808673ffffffffffffffffffffffffffffffffffffffff161161246157600080fd5b73ffffffffffffffffffffffffffffffffffffffff86160390506118ea565b60008261248e5750836118ea565b7bffffffffffffffffffffffffffffffff000000000000000000000000606085901b1682156125555773ffffffffffffffffffffffffffffffffffffffff8616848102908582816124db57fe5b041415612519578181018281106125175761250d838973ffffffffffffffffffffffffffffffffffffffff1683611ace565b93505050506118ea565b505b61254c82612547878a73ffffffffffffffffffffffffffffffffffffffff16868161254057fe5b0490612858565b61231d565b925050506118ea565b73ffffffffffffffffffffffffffffffffffffffff86168481029085828161257957fe5b0414801561258657508082115b61258f57600080fd5b80820361250d6123c38473ffffffffffffffffffffffffffffffffffffffff8b1684611ace565b60020b600881901d9161010090910790565b60008082116125d657600080fd5b70010000000000000000000000000000000082106125f657608091821c91015b68010000000000000000821061260e57604091821c91015b640100000000821061262257602091821c91015b62010000821061263457601091821c91015b610100821061264557600891821c91015b6010821061265557600491821c91015b6004821061266557600291821c91015b600282106104ba57600101919050565b600080821161268357600080fd5b5060ff6fffffffffffffffffffffffffffffffff8216156126c5577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80016126cd565b608082901c91505b67ffffffffffffffff821615612704577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00161270c565b604082901c91505b63ffffffff82161561273f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001612747565b602082901c91505b61ffff821615612778577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001612780565b601082901c91505b60ff8216156127b0577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8016127b8565b600882901c91505b600f8216156127e8577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc016127f0565b600482901c91505b6003821615612820577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01612828565b600282901c91505b60018216156104ba577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01919050565b8082018281101561058e57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff811681146104ba57600080fd5b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915290565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b604080516060810182526000808252602082018190529181019190915290565b80356104ba81612aea565b60008060008060808587031215612935578384fd5b843561294081612aea565b935060208501358015158114612954578384fd5b925060408501359150606085013561296b81612aea565b939692955090935050565b60008060408385031215612988578182fd5b823567ffffffffffffffff8082111561299f578384fd5b818501915085601f8301126129b2578384fd5b81356020828211156129c057fe5b6129f0817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f85011601612ac6565b92508183528781838601011115612a05578586fd5b818185018285013790820181019490945295939092013593505050565b600060a08284031215612a33578081fd5b60405160a0810181811067ffffffffffffffff82111715612a5057fe5b6040528235612a5e81612aea565b81526020830135612a6e81612aea565b602082015260408381013590820152606083013562ffffff81168114612a92578283fd5b6060820152612aa360808401612915565b60808201529392505050565b918252602082015260400190565b90815260200190565b60405181810167ffffffffffffffff81118282101715612ae257fe5b604052919050565b73ffffffffffffffffffffffffffffffffffffffff81168114612b0c57600080fd5b5056fea164736f6c6343000706000a", + "devdoc": { + "kind": "dev", + "methods": { + "quoteExactInput(bytes,uint256)": { + "params": { + "amountIn": "The amount of the first token to swap", + "path": "The path of the swap, i.e. each token pair and the pool fee" + }, + "returns": { + "amountOut": "The amount of the last token that would be received" + } + }, + "quoteExactInputSingle((address,address,uint256,uint24,uint160))": { + "params": { + "params": "The params for the quote, encoded as `QuoteExactInputSingleParams` tokenIn The token being swapped in tokenOut The token being swapped out fee The fee of the token pool to consider for the pair amountIn The desired input amount sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap" + }, + "returns": { + "amountOut": "The amount of `tokenOut` that would be received" + } + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "quoteExactInput(bytes,uint256)": { + "notice": "Returns the amount out received for a given exact input swap without executing the swap" + }, + "quoteExactInputSingle((address,address,uint256,uint24,uint160))": { + "notice": "Returns the amount out received for a given exact input but for a swap of a single pool" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/hardhat.config.ts b/hardhat.config.ts index 0b8e70c..33c2c36 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -10,17 +10,19 @@ import "hardhat-deploy-ethers"; dotenv.config(); function getExplorerApiKey() { - const networkNameForEnvKey: any = { - "avalanche": "SNOWTRACE_API_KEY", - "mainnet": "ETHERSCAN_API_KEY", - "arbitrum": "ARBISCAN_API_KEY", - "optimism": "OPSCAN_API_KEY", - "polygon": "POLYGONSCAN_API_KEY" - } - const [ networkName ] = process.argv.flatMap((e, i, a) => e == '--network' ? [ a[i+1] ] : []) - const envKey = networkNameForEnvKey[networkName] - if (envKey) - return process.env[envKey] + const networkNameForEnvKey: any = { + avalanche: "SNOWTRACE_API_KEY", + mainnet: "ETHERSCAN_API_KEY", + arbitrum: "ARBISCAN_API_KEY", + optimism: "OPSCAN_API_KEY", + polygon: "POLYGONSCAN_API_KEY", + bsc: "BSCSCAN_API_KEY", + }; + const [networkName] = process.argv.flatMap((e, i, a) => + e == "--network" ? [a[i + 1]] : [] + ); + const envKey = networkNameForEnvKey[networkName]; + if (envKey) return process.env[envKey]; } const ETHEREUM_RPC = process.env.ETHEREUM_RPC ?? ""; @@ -30,160 +32,185 @@ const AVALANCHE_RPC = process.env.AVALANCHE_RPC ?? ""; const DOGECHAIN_RPC = process.env.DOGECHAIN_RPC ?? ""; const POLYGON_RPC = process.env.POLYGON_RPC ?? ""; const BASE_RPC = process.env.BASE_RPC ?? ""; +const BSC_RPC = process.env.BSC_RPC ?? ""; const DEPLOYER_ADDRESS = process.env.DEPLOYER_ADDRESS as string; const DEPLOYER_PRIVATE_KEY = process.env.DEPLOYER_PRIVATE_KEY as string; const ETHERSCAN_API_KEY = getExplorerApiKey(); const mainnetConfig = { - url: ETHEREUM_RPC, - chainId: 1, - live: true, - saveDeployments: true, - accounts: [] as string[] + url: ETHEREUM_RPC, + chainId: 1, + live: true, + saveDeployments: true, + accounts: [] as string[], }; const optimismConfig = { - url: OPTIMISM_RPC, - chainId: 10, - live: true, - saveDeployments: true, - accounts: [] as string[] + url: OPTIMISM_RPC, + chainId: 10, + live: true, + saveDeployments: true, + accounts: [] as string[], }; const arbitrumConfig = { - url: ARBITRUM_RPC, - chainId: 42161, - live: true, - saveDeployments: true, - accounts: [] as string[] + url: ARBITRUM_RPC, + chainId: 42161, + live: true, + saveDeployments: true, + accounts: [] as string[], }; const dogechainConfig = { - url: DOGECHAIN_RPC, - chainId: 2000, - live: true, - saveDeployments: true, - accounts: [] as string[] + url: DOGECHAIN_RPC, + chainId: 2000, + live: true, + saveDeployments: true, + accounts: [] as string[], }; const avalancheConfig = { - url: AVALANCHE_RPC, - chainId: 43114, - live: true, - saveDeployments: true, - accounts: [] as string[] + url: AVALANCHE_RPC, + chainId: 43114, + live: true, + saveDeployments: true, + accounts: [] as string[], }; const polygonConfig = { - url: POLYGON_RPC, - chainId: 137, - live: true, - saveDeployments: true, - accounts: [] as string[] + url: POLYGON_RPC, + chainId: 137, + live: true, + saveDeployments: true, + accounts: [] as string[], }; const baseConfig = { - url: BASE_RPC, - chainId: 8453, - live: true, - saveDeployments: true, - accounts: [] as string[] + url: BASE_RPC, + chainId: 8453, + live: true, + saveDeployments: true, + accounts: [] as string[], +}; + +const bscConfig = { + url: BSC_RPC, + chainId: 56, + live: true, + saveDeployments: true, + accounts: [] as string[], }; if (DEPLOYER_PRIVATE_KEY) { - mainnetConfig.accounts.push(DEPLOYER_PRIVATE_KEY); - optimismConfig.accounts.push(DEPLOYER_PRIVATE_KEY); - arbitrumConfig.accounts.push(DEPLOYER_PRIVATE_KEY); - dogechainConfig.accounts.push(DEPLOYER_PRIVATE_KEY); - avalancheConfig.accounts.push(DEPLOYER_PRIVATE_KEY); - polygonConfig.accounts.push(DEPLOYER_PRIVATE_KEY); - baseConfig.accounts.push(DEPLOYER_PRIVATE_KEY); + mainnetConfig.accounts.push(DEPLOYER_PRIVATE_KEY); + optimismConfig.accounts.push(DEPLOYER_PRIVATE_KEY); + arbitrumConfig.accounts.push(DEPLOYER_PRIVATE_KEY); + dogechainConfig.accounts.push(DEPLOYER_PRIVATE_KEY); + avalancheConfig.accounts.push(DEPLOYER_PRIVATE_KEY); + polygonConfig.accounts.push(DEPLOYER_PRIVATE_KEY); + baseConfig.accounts.push(DEPLOYER_PRIVATE_KEY); + bscConfig.accounts.push(DEPLOYER_PRIVATE_KEY); } const config: HardhatUserConfig = { - solidity: { - version: "0.7.6", - settings: { - evmVersion: 'istanbul', - optimizer: { - enabled: true, - runs: 1_000_000, - }, - metadata: { - bytecodeHash: 'none', - }, - }, - }, - defaultNetwork: "hardhat", - networks: { - hardhat: { - live: false, - saveDeployments: false, - }, - mainnet: mainnetConfig, - optimism: optimismConfig, - arbitrum: arbitrumConfig, - dogechain: dogechainConfig, - avalanche: avalancheConfig, - polygon: polygonConfig, - base: baseConfig - }, - namedAccounts: { - deployer: { - default: 0, - 1: DEPLOYER_ADDRESS, - 10: DEPLOYER_ADDRESS, - 42161: DEPLOYER_ADDRESS - } + solidity: { + version: "0.7.6", + settings: { + evmVersion: "istanbul", + optimizer: { + enabled: true, + runs: 1_000_000, + }, + metadata: { + bytecodeHash: "none", + }, }, - abiExporter: { - path: './abis', - clear: true, - flat: true, - only: [':UniswapV3StaticQuoter'] + }, + defaultNetwork: "hardhat", + networks: { + hardhat: { + live: false, + saveDeployments: false, }, - etherscan: { - apiKey: ETHERSCAN_API_KEY, - customChains: [{ - network: "mainnet", - chainId: 1, - urls: { - apiURL: "https://api.etherscan.io/api", - browserURL: "https://etherscan.io" - } - }, { - network: "optimism", - chainId: 10, - urls: { - apiURL: "https://api-optimistic.etherscan.io/api", - browserURL: "https://optimistic.etherscan.io" - } - }, { - network: "arbitrum", - chainId: 42161, - urls: { - apiURL: "https://api.arbiscan.io/api", - browserURL: "https://arbiscan.io" - } - }, { - network: "avalanche", - chainId: 43114, - urls: { - apiURL: "https://api.snowtrace.io/api", - browserURL: "https://snowtrace.io" - } - }, { - network: "polygon", - chainId: 137, - urls: { - apiURL: "https://api.polygonscan.com/api", - browserURL: "https://polygonscan.com" - } - }] + mainnet: mainnetConfig, + optimism: optimismConfig, + arbitrum: arbitrumConfig, + dogechain: dogechainConfig, + avalanche: avalancheConfig, + polygon: polygonConfig, + base: baseConfig, + bsc: bscConfig, + }, + namedAccounts: { + deployer: { + default: 0, + 1: DEPLOYER_ADDRESS, + 10: DEPLOYER_ADDRESS, + 42161: DEPLOYER_ADDRESS, }, - mocha: { - timeout: 600000000 - } + }, + abiExporter: { + path: "./abis", + clear: true, + flat: true, + only: [":UniswapV3StaticQuoter"], + }, + etherscan: { + apiKey: ETHERSCAN_API_KEY, + customChains: [ + { + network: "mainnet", + chainId: 1, + urls: { + apiURL: "https://api.etherscan.io/api", + browserURL: "https://etherscan.io", + }, + }, + { + network: "optimism", + chainId: 10, + urls: { + apiURL: "https://api-optimistic.etherscan.io/api", + browserURL: "https://optimistic.etherscan.io", + }, + }, + { + network: "arbitrum", + chainId: 42161, + urls: { + apiURL: "https://api.arbiscan.io/api", + browserURL: "https://arbiscan.io", + }, + }, + { + network: "avalanche", + chainId: 43114, + urls: { + apiURL: "https://api.snowtrace.io/api", + browserURL: "https://snowtrace.io", + }, + }, + { + network: "polygon", + chainId: 137, + urls: { + apiURL: "https://api.polygonscan.com/api", + browserURL: "https://polygonscan.com", + }, + }, + { + network: "bsc", + chainId: 56, + urls: { + apiURL: "https://api.bscscan.com/api", + browserURL: "https://bscscan.com", + }, + }, + ], + }, + mocha: { + timeout: 600000000, + }, }; export default config; diff --git a/test/addresses.json b/test/addresses.json index e48cfd7..a1350e3 100644 --- a/test/addresses.json +++ b/test/addresses.json @@ -89,5 +89,13 @@ "factory": "0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD" } } + }, + "bsc": { + "protocols": { + "pancakeswapV3": { + "quoterV2": "0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997", + "factory": "0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865" + } + } } } \ No newline at end of file From dd5beb9736fe9e260491f3aea2bc4c0a316d75ca Mon Sep 17 00:00:00 2001 From: Maurizio Murru Date: Wed, 8 Nov 2023 17:05:43 +0100 Subject: [PATCH 2/2] PancakeswapV3 quoter tests and deployment ready --- README.md | 2 +- .../PancakeV3Quoter/PancakeV3QuoterCore.sol | 62 +++++ .../PancakeV3Quoter/PancakeV3StaticQuoter.sol | 93 +++++++ .../PancakeV3likeQuoterCore.sol | 219 ++++++++++++++++ .../interfaces/IPancakeV3StaticQuoter.sol | 34 +++ contracts/PancakeV3Quoter/lib/TickBitmap.sol | 73 ++++++ deploy/pancakeV3.ts | 58 ++--- deployments/bsc/PancakeV3StaticQuoter.json | 188 ++++++++++++++ package.json | 3 + test/addresses.json | 194 +++++++------- test/helpers.ts | 142 ++++++----- test/spec/pancakeV3.spec.ts | 149 +++++++++++ test/spec/uniswapV3.spec.ts | 236 +++++++++--------- yarn.lock | 156 +++++++++++- 14 files changed, 1315 insertions(+), 294 deletions(-) create mode 100644 contracts/PancakeV3Quoter/PancakeV3QuoterCore.sol create mode 100644 contracts/PancakeV3Quoter/PancakeV3StaticQuoter.sol create mode 100644 contracts/PancakeV3Quoter/PancakeV3likeQuoterCore.sol create mode 100644 contracts/PancakeV3Quoter/interfaces/IPancakeV3StaticQuoter.sol create mode 100644 contracts/PancakeV3Quoter/lib/TickBitmap.sol create mode 100644 deployments/bsc/PancakeV3StaticQuoter.json create mode 100644 test/spec/pancakeV3.spec.ts diff --git a/README.md b/README.md index 0e93627..d21bf58 100644 --- a/README.md +++ b/README.md @@ -27,4 +27,4 @@ Has similar interface to the official [QuoterV2](https://docs.uniswap.org/protoc | Dogechain | Quickswap | `0x4a6c794192831fB9F4782E61Bec05d6C5cC9F3eA` | | Polygon | Quickswap | `0x2E0A046481c676235B806Bd004C4b492C850fb34` | | Arbitrum | Camelot | `0x11E68A3CE9A5A0F95ca9c4B0B8F17849752e24DD` | -| BSC | PancakeswapV3| `0xeB281D33A975CbF17c2Ac13063F6C38B50e05540` | \ No newline at end of file +| BSC | PancakeswapV3| `0x3dcF802B76105748CC3749CD72a05579b018cD32` | \ No newline at end of file diff --git a/contracts/PancakeV3Quoter/PancakeV3QuoterCore.sol b/contracts/PancakeV3Quoter/PancakeV3QuoterCore.sol new file mode 100644 index 0000000..c47f265 --- /dev/null +++ b/contracts/PancakeV3Quoter/PancakeV3QuoterCore.sol @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +pragma solidity =0.7.6; + +import "./PancakeV3likeQuoterCore.sol"; +import "./lib/TickBitmap.sol"; + +contract PancakeV3QuoterCore is PancakeV3likeQuoterCore { + function getPoolGlobalState( + address pool + ) internal view override returns (GlobalState memory gs) { + gs.fee = uint16(IPancakeV3Pool(pool).fee()); + (gs.startPrice, gs.startTick, , , , , ) = IPancakeV3Pool(pool).slot0(); + } + + function getTickSpacing( + address pool + ) internal view override returns (int24) { + return IPancakeV3Pool(pool).tickSpacing(); + } + + function getLiquidity( + address pool + ) internal view override returns (uint128) { + return IPancakeV3Pool(pool).liquidity(); + } + + function nextInitializedTickWithinOneWord( + address poolAddress, + int24 tick, + int24 tickSpacing, + bool zeroForOne + ) internal view override returns (int24 next, bool initialized) { + return + TickBitmap.nextInitializedTickWithinOneWord( + poolAddress, + tick, + tickSpacing, + zeroForOne + ); + } + + function getTicks( + address pool, + int24 tick + ) + internal + view + override + returns ( + uint128 liquidityTotal, + int128 liquidityDelta, + uint256 outerFeeGrowth0Token, + uint256 outerFeeGrowth1Token, + int56 outerTickCumulative, + uint160 outerSecondsPerLiquidity, + uint32 outerSecondsSpent, + bool initialized + ) + { + return IPancakeV3Pool(pool).ticks(tick); + } +} diff --git a/contracts/PancakeV3Quoter/PancakeV3StaticQuoter.sol b/contracts/PancakeV3Quoter/PancakeV3StaticQuoter.sol new file mode 100644 index 0000000..7b97c67 --- /dev/null +++ b/contracts/PancakeV3Quoter/PancakeV3StaticQuoter.sol @@ -0,0 +1,93 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +pragma solidity =0.7.6; +pragma abicoder v2; + +import "@pancakeswap/v3-periphery/contracts/base/PeripheryImmutableState.sol"; +import "@pancakeswap/v3-periphery/contracts/libraries/PoolAddress.sol"; +import "@pancakeswap/v3-periphery/contracts/libraries/Path.sol"; + +import "./interfaces/IPancakeV3StaticQuoter.sol"; +import "./PancakeV3QuoterCore.sol"; + +contract PancakeV3StaticQuoter is IPancakeV3StaticQuoter, PancakeV3QuoterCore { + using LowGasSafeMath for uint256; + using LowGasSafeMath for int256; + using SafeCast for uint256; + using SafeCast for int256; + using Path for bytes; + + address immutable factory; + + constructor(address _factory) { + factory = _factory; + } + + function getPool( + address tokenA, + address tokenB, + uint24 fee + ) private view returns (IPancakeV3Pool) { + return + IPancakeV3Pool( + PoolAddress.computeAddress( + factory, + PoolAddress.getPoolKey(tokenA, tokenB, fee) + ) + ); + } + + function quoteExactInputSingle( + QuoteExactInputSingleParams memory params + ) public view override returns (uint256 amountOut) { + bool zeroForOne = params.tokenIn < params.tokenOut; + IPancakeV3Pool pool = getPool( + params.tokenIn, + params.tokenOut, + params.fee + ); + (int256 amount0, int256 amount1) = quote( + address(pool), + zeroForOne, + params.amountIn.toInt256(), + params.sqrtPriceLimitX96 == 0 + ? ( + zeroForOne + ? TickMath.MIN_SQRT_RATIO + 1 + : TickMath.MAX_SQRT_RATIO - 1 + ) + : params.sqrtPriceLimitX96 + ); + + return zeroForOne ? uint256(-amount1) : uint256(-amount0); + } + + function quoteExactInput( + bytes memory path, + uint256 amountIn + ) public view override returns (uint256 amountOut) { + uint256 i = 0; + while (true) { + (address tokenIn, address tokenOut, uint24 fee) = path + .decodeFirstPool(); + // the outputs of prior swaps become the inputs to subsequent ones + uint256 _amountOut = quoteExactInputSingle( + QuoteExactInputSingleParams({ + tokenIn: tokenIn, + tokenOut: tokenOut, + fee: fee, + amountIn: amountIn, + sqrtPriceLimitX96: 0 + }) + ); + amountIn = _amountOut; + i++; + + // decide whether to continue or terminate + if (path.hasMultiplePools()) { + path = path.skipToken(); + } else { + return amountIn; + } + } + } +} diff --git a/contracts/PancakeV3Quoter/PancakeV3likeQuoterCore.sol b/contracts/PancakeV3Quoter/PancakeV3likeQuoterCore.sol new file mode 100644 index 0000000..9ff62fb --- /dev/null +++ b/contracts/PancakeV3Quoter/PancakeV3likeQuoterCore.sol @@ -0,0 +1,219 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +pragma solidity =0.7.6; + +import "@pancakeswap/v3-core/contracts/libraries/LowGasSafeMath.sol"; +import "@pancakeswap/v3-core/contracts/libraries/LiquidityMath.sol"; +import "@pancakeswap/v3-core/contracts/libraries/FixedPoint128.sol"; +import "@pancakeswap/v3-core/contracts/libraries/SafeCast.sol"; +import "@pancakeswap/v3-core/contracts/libraries/TickMath.sol"; +import "@pancakeswap/v3-core/contracts/libraries/FullMath.sol"; +import "@pancakeswap/v3-core/contracts/libraries/SwapMath.sol"; +import "../IUniV3likeQuoterCore.sol"; + +abstract contract PancakeV3likeQuoterCore { + using LowGasSafeMath for int256; + using SafeCast for uint256; + using SafeCast for int256; + + function quote( + address poolAddress, + bool zeroForOne, + int256 amountSpecified, + uint160 sqrtPriceLimitX96 + ) public view virtual returns (int256 amount0, int256 amount1) { + require(amountSpecified != 0, "amountSpecified cannot be zero"); + bool exactInput = amountSpecified > 0; + (int24 tickSpacing, uint16 fee, SwapState memory state) = getInitState( + poolAddress, + zeroForOne, + amountSpecified, + sqrtPriceLimitX96 + ); + // continue swapping as long as we haven't used the entire input/output and haven't reached the price limit + while ( + state.amountSpecifiedRemaining != 0 && + state.sqrtPriceX96 != sqrtPriceLimitX96 + ) { + StepComputations memory step; + step.sqrtPriceStartX96 = state.sqrtPriceX96; + + ( + step.tickNext, + step.initialized, + step.sqrtPriceNextX96 + ) = nextInitializedTickAndPrice( + poolAddress, + state.tick, + tickSpacing, + zeroForOne + ); + // compute values to swap to the target tick, price limit, or point where input/output amount is exhausted + ( + state.sqrtPriceX96, + step.amountIn, + step.amountOut, + step.feeAmount + ) = SwapMath.computeSwapStep( + state.sqrtPriceX96, + getSqrtRatioTargetX96( + zeroForOne, + step.sqrtPriceNextX96, + sqrtPriceLimitX96 + ), + state.liquidity, + state.amountSpecifiedRemaining, + fee + ); + if (exactInput) { + state.amountSpecifiedRemaining -= (step.amountIn + + step.feeAmount).toInt256(); + state.amountCalculated = state.amountCalculated.sub( + step.amountOut.toInt256() + ); + } else { + state.amountSpecifiedRemaining += step.amountOut.toInt256(); + state.amountCalculated = state.amountCalculated.add( + (step.amountIn + step.feeAmount).toInt256() + ); + } + // shift tick if we reached the next price + if (state.sqrtPriceX96 == step.sqrtPriceNextX96) { + // if the tick is initialized, run the tick transition + if (step.initialized) { + (, int128 liquidityNet, , , , , , ) = getTicks( + poolAddress, + step.tickNext + ); + // if we're moving leftward, we interpret liquidityNet as the opposite sign + // safe because liquidityNet cannot be type(int128).min + if (zeroForOne) liquidityNet = -liquidityNet; + state.liquidity = LiquidityMath.addDelta( + state.liquidity, + liquidityNet + ); + } + state.tick = zeroForOne ? step.tickNext - 1 : step.tickNext; + } else if (state.sqrtPriceX96 != step.sqrtPriceStartX96) { + // recompute unless we're on a lower tick boundary (i.e. already transitioned ticks), and haven't moved + state.tick = TickMath.getTickAtSqrtRatio(state.sqrtPriceX96); + } + } + + (amount0, amount1) = zeroForOne == exactInput + ? ( + amountSpecified - state.amountSpecifiedRemaining, + state.amountCalculated + ) + : ( + state.amountCalculated, + amountSpecified - state.amountSpecifiedRemaining + ); + } + + function getInitState( + address poolAddress, + bool zeroForOne, + int256 amountSpecified, + uint160 sqrtPriceLimitX96 + ) internal view returns (int24 ts, uint16 fee, SwapState memory state) { + GlobalState memory gs = getPoolGlobalState(poolAddress); + checkSqrtPriceLimitWithinAllowed( + zeroForOne, + sqrtPriceLimitX96, + gs.startPrice + ); + ts = getTickSpacing(poolAddress); + fee = gs.fee; + state = SwapState({ + amountSpecifiedRemaining: amountSpecified, + liquidity: getLiquidity(poolAddress), + sqrtPriceX96: gs.startPrice, + amountCalculated: 0, + tick: gs.startTick + }); + } + + function checkSqrtPriceLimitWithinAllowed( + bool zeroForOne, + uint160 sqrtPriceLimit, + uint160 startPrice + ) internal pure { + bool withinAllowed = zeroForOne + ? sqrtPriceLimit < startPrice && + sqrtPriceLimit > TickMath.MIN_SQRT_RATIO + : sqrtPriceLimit > startPrice && + sqrtPriceLimit < TickMath.MAX_SQRT_RATIO; + require(withinAllowed, "sqrtPriceLimit out of bounds"); + } + + function nextInitializedTickAndPrice( + address pool, + int24 tick, + int24 tickSpacing, + bool zeroForOne + ) + internal + view + returns (int24 tickNext, bool initialized, uint160 sqrtPriceNextX96) + { + (tickNext, initialized) = nextInitializedTickWithinOneWord( + pool, + tick, + tickSpacing, + zeroForOne + ); + // ensure that we do not overshoot the min/max tick, as the tick bitmap is not aware of these bounds + if (tickNext < TickMath.MIN_TICK) tickNext = TickMath.MIN_TICK; + else if (tickNext > TickMath.MAX_TICK) tickNext = TickMath.MAX_TICK; + // get the price for the next tick + sqrtPriceNextX96 = TickMath.getSqrtRatioAtTick(tickNext); + } + + function getSqrtRatioTargetX96( + bool zeroForOne, + uint160 sqrtPriceNextX96, + uint160 sqrtPriceLimitX96 + ) internal pure returns (uint160) { + return + ( + zeroForOne + ? sqrtPriceNextX96 < sqrtPriceLimitX96 + : sqrtPriceNextX96 > sqrtPriceLimitX96 + ) + ? sqrtPriceLimitX96 + : sqrtPriceNextX96; + } + + function getPoolGlobalState( + address pool + ) internal view virtual returns (GlobalState memory); + + function getLiquidity(address pool) internal view virtual returns (uint128); + + function getTickSpacing(address pool) internal view virtual returns (int24); + + function nextInitializedTickWithinOneWord( + address poolAddress, + int24 tick, + int24 tickSpacing, + bool zeroForOne + ) internal view virtual returns (int24 next, bool initialized); + + function getTicks( + address pool, + int24 tick + ) + internal + view + virtual + returns ( + uint128 liquidityTotal, + int128 liquidityDelta, + uint256 outerFeeGrowth0Token, + uint256 outerFeeGrowth1Token, + int56 outerTickCumulative, + uint160 outerSecondsPerLiquidity, + uint32 outerSecondsSpent, + bool initialized + ); +} diff --git a/contracts/PancakeV3Quoter/interfaces/IPancakeV3StaticQuoter.sol b/contracts/PancakeV3Quoter/interfaces/IPancakeV3StaticQuoter.sol new file mode 100644 index 0000000..afd8174 --- /dev/null +++ b/contracts/PancakeV3Quoter/interfaces/IPancakeV3StaticQuoter.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +pragma solidity >=0.7.5; +pragma abicoder v2; + +interface IPancakeV3StaticQuoter { + /// @notice Returns the amount out received for a given exact input swap without executing the swap + /// @param path The path of the swap, i.e. each token pair and the pool fee + /// @param amountIn The amount of the first token to swap + /// @return amountOut The amount of the last token that would be received + function quoteExactInput( + bytes memory path, + uint256 amountIn + ) external view returns (uint256 amountOut); + + struct QuoteExactInputSingleParams { + address tokenIn; + address tokenOut; + uint256 amountIn; + uint24 fee; + uint160 sqrtPriceLimitX96; + } + + /// @notice Returns the amount out received for a given exact input but for a swap of a single pool + /// @param params The params for the quote, encoded as `QuoteExactInputSingleParams` + /// tokenIn The token being swapped in + /// tokenOut The token being swapped out + /// fee The fee of the token pool to consider for the pair + /// amountIn The desired input amount + /// sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap + /// @return amountOut The amount of `tokenOut` that would be received + function quoteExactInputSingle( + QuoteExactInputSingleParams memory params + ) external view returns (uint256 amountOut); +} diff --git a/contracts/PancakeV3Quoter/lib/TickBitmap.sol b/contracts/PancakeV3Quoter/lib/TickBitmap.sol new file mode 100644 index 0000000..9736d1d --- /dev/null +++ b/contracts/PancakeV3Quoter/lib/TickBitmap.sol @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +pragma solidity =0.7.6; + +import "@pancakeswap/v3-core/contracts/interfaces/IPancakeV3Pool.sol"; +import "@pancakeswap/v3-core/contracts/libraries/BitMath.sol"; + +/// @title Packed tick initialized state library +/// @notice Stores a packed mapping of tick index to its initialized state +/// @dev The mapping uses int16 for keys since ticks are represented as int24 and there are 256 (2^8) values per word. +library TickBitmap { + /// @notice Computes the position in the mapping where the initialized bit for a tick lives + /// @param tick The tick for which to compute the position + /// @return wordPos The key in the mapping containing the word in which the bit is stored + /// @return bitPos The bit position in the word where the flag is stored + function position( + int24 tick + ) private pure returns (int16 wordPos, uint8 bitPos) { + wordPos = int16(tick >> 8); + bitPos = uint8(tick % 256); + } + + /// @notice Returns the next initialized tick contained in the same word (or adjacent word) as the tick that is either + /// to the left (less than or equal to) or right (greater than) of the given tick + /// @param poolAddress Pool containing the mapping in which to compute the next initialized tick + /// @param tick The starting tick + /// @param tickSpacing The spacing between usable ticks + /// @param lte Whether to search for the next initialized tick to the left (less than or equal to the starting tick) + /// @return next The next initialized or Pancakenitialized tick up to 256 ticks away from the current tick + /// @return initialized Whether the next tick is initialized, as the function only searches within up to 256 ticks + function nextInitializedTickWithinOneWord( + address poolAddress, + int24 tick, + int24 tickSpacing, + bool lte + ) internal view returns (int24 next, bool initialized) { + IPancakeV3Pool pool = IPancakeV3Pool(poolAddress); + int24 compressed = tick / tickSpacing; + if (tick < 0 && tick % tickSpacing != 0) compressed--; // round towards negative infinity + + if (lte) { + (int16 wordPos, uint8 bitPos) = position(compressed); + // all the 1s at or to the right of the current bitPos + uint256 mask = (1 << bitPos) - 1 + (1 << bitPos); + uint256 masked = pool.tickBitmap(wordPos) & mask; + + // if there are no initialized ticks to the right of or at the current tick, return rightmost in the word + initialized = masked != 0; + // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick + next = initialized + ? (compressed - + int24(bitPos - BitMath.mostSignificantBit(masked))) * + tickSpacing + : (compressed - int24(bitPos)) * tickSpacing; + } else { + // start from the word of the next tick, since the current tick state doesn't matter + (int16 wordPos, uint8 bitPos) = position(compressed + 1); + // all the 1s at or to the left of the bitPos + uint256 mask = ~((1 << bitPos) - 1); + uint256 masked = pool.tickBitmap(wordPos) & mask; + + // if there are no initialized ticks to the left of the current tick, return leftmost in the word + initialized = masked != 0; + // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick + next = initialized + ? (compressed + + 1 + + int24(BitMath.leastSignificantBit(masked) - bitPos)) * + tickSpacing + : (compressed + 1 + int24(type(uint8).max - bitPos)) * + tickSpacing; + } + } +} diff --git a/deploy/pancakeV3.ts b/deploy/pancakeV3.ts index 2d4faf3..c80743b 100644 --- a/deploy/pancakeV3.ts +++ b/deploy/pancakeV3.ts @@ -4,35 +4,35 @@ import { DeployFunction } from "hardhat-deploy/types"; import addresses from "../test/addresses.json"; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const { deployments, getNamedAccounts, network } = hre; - const { deploy, log } = deployments; - - - const allowedNetworks = ["bsc"]; - if (!allowedNetworks.includes(network.name)) - throw new Error(`Wrong network! Only "${allowedNetworks}" supported`); - - const contractName = "UniswapV3StaticQuoter"; - let factory; - factory = addresses.bsc.protocols.pancakeswapV3.factory; - - const args = [ factory ] - const { deployer } = await getNamedAccounts(); - - log("1) Deploy contract"); - const deployResult: any = await deploy(contractName, { - from: deployer, - contract: contractName, - skipIfAlreadyDeployed: true, - log: true, - args - }); - - if (deployResult.newlyDeployed) - log(`- 🎉 Deployed at: ${deployResult.address}`); - else - log(`- ⏩ Deployment skipped, using previous deployment at: ${deployResult.address}`); + const { deployments, getNamedAccounts, network } = hre; + const { deploy, log } = deployments; + + const allowedNetworks = ["bsc"]; + if (!allowedNetworks.includes(network.name)) + throw new Error(`Wrong network! Only "${allowedNetworks}" supported`); + + const contractName = "PancakeV3StaticQuoter"; + let pancakeDeployer = addresses.bsc.protocols.pancakeswapV3.pancakeDeployer; + + const args = [pancakeDeployer]; + const { deployer } = await getNamedAccounts(); + + log("1) Deploy contract"); + const deployResult: any = await deploy(contractName, { + from: deployer, + contract: contractName, + skipIfAlreadyDeployed: true, + log: true, + args, + }); + + if (deployResult.newlyDeployed) + log(`- 🎉 Deployed at: ${deployResult.address}`); + else + log( + `- ⏩ Deployment skipped, using previous deployment at: ${deployResult.address}` + ); }; export default func; -func.tags = [ "pancakeswapV3" ] \ No newline at end of file +func.tags = ["pancakeswapV3"]; diff --git a/deployments/bsc/PancakeV3StaticQuoter.json b/deployments/bsc/PancakeV3StaticQuoter.json new file mode 100644 index 0000000..3e05c8b --- /dev/null +++ b/deployments/bsc/PancakeV3StaticQuoter.json @@ -0,0 +1,188 @@ +{ + "address": "0x3dcF802B76105748CC3749CD72a05579b018cD32", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_factory", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "internalType": "bool", + "name": "zeroForOne", + "type": "bool" + }, + { + "internalType": "int256", + "name": "amountSpecified", + "type": "int256" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + } + ], + "name": "quote", + "outputs": [ + { + "internalType": "int256", + "name": "amount0", + "type": "int256" + }, + { + "internalType": "int256", + "name": "amount1", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "path", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "name": "quoteExactInput", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint24", + "name": "fee", + "type": "uint24" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + } + ], + "internalType": "struct IPancakeV3StaticQuoter.QuoteExactInputSingleParams", + "name": "params", + "type": "tuple" + } + ], + "name": "quoteExactInputSingle", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x7b4b4198e7d754f82bbf88ded4d6dd0f47cf215829f4251339e333f16978aca4", + "receipt": { + "to": null, + "from": "0x64966bc22648dd5f3682FeA4fB093f88eb8C2920", + "contractAddress": "0x3dcF802B76105748CC3749CD72a05579b018cD32", + "transactionIndex": 141, + "gasUsed": "2427861", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xe96282e4dda8ad3eda9f1eabb4fe2ed0a9d3fe443d10e9a10d076d8a18c4d301", + "transactionHash": "0x7b4b4198e7d754f82bbf88ded4d6dd0f47cf215829f4251339e333f16978aca4", + "logs": [], + "blockNumber": 33317806, + "cumulativeGasUsed": "40343558", + "status": 1, + "byzantium": true + }, + "args": [ + "0x41ff9AA7e16B8B1a8a8dc4f0eFacd93D02d071c9" + ], + "numDeployments": 1, + "solcInputHash": "4997e7dfada5eed4be5e38bbd195338b", + "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_factory\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"poolAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"zeroForOne\",\"type\":\"bool\"},{\"internalType\":\"int256\",\"name\":\"amountSpecified\",\"type\":\"int256\"},{\"internalType\":\"uint160\",\"name\":\"sqrtPriceLimitX96\",\"type\":\"uint160\"}],\"name\":\"quote\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"amount0\",\"type\":\"int256\"},{\"internalType\":\"int256\",\"name\":\"amount1\",\"type\":\"int256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"path\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"}],\"name\":\"quoteExactInput\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"tokenIn\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenOut\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"uint24\",\"name\":\"fee\",\"type\":\"uint24\"},{\"internalType\":\"uint160\",\"name\":\"sqrtPriceLimitX96\",\"type\":\"uint160\"}],\"internalType\":\"struct IPancakeV3StaticQuoter.QuoteExactInputSingleParams\",\"name\":\"params\",\"type\":\"tuple\"}],\"name\":\"quoteExactInputSingle\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"quoteExactInput(bytes,uint256)\":{\"params\":{\"amountIn\":\"The amount of the first token to swap\",\"path\":\"The path of the swap, i.e. each token pair and the pool fee\"},\"returns\":{\"amountOut\":\"The amount of the last token that would be received\"}},\"quoteExactInputSingle((address,address,uint256,uint24,uint160))\":{\"params\":{\"params\":\"The params for the quote, encoded as `QuoteExactInputSingleParams` tokenIn The token being swapped in tokenOut The token being swapped out fee The fee of the token pool to consider for the pair amountIn The desired input amount sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap\"},\"returns\":{\"amountOut\":\"The amount of `tokenOut` that would be received\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"quoteExactInput(bytes,uint256)\":{\"notice\":\"Returns the amount out received for a given exact input swap without executing the swap\"},\"quoteExactInputSingle((address,address,uint256,uint24,uint160))\":{\"notice\":\"Returns the amount out received for a given exact input but for a swap of a single pool\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/PancakeV3Quoter/PancakeV3StaticQuoter.sol\":\"PancakeV3StaticQuoter\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"none\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@pancakeswap/v3-core/contracts/interfaces/IPancakeV3Pool.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\nimport './pool/IPancakeV3PoolImmutables.sol';\\nimport './pool/IPancakeV3PoolState.sol';\\nimport './pool/IPancakeV3PoolDerivedState.sol';\\nimport './pool/IPancakeV3PoolActions.sol';\\nimport './pool/IPancakeV3PoolOwnerActions.sol';\\nimport './pool/IPancakeV3PoolEvents.sol';\\n\\n/// @title The interface for a PancakeSwap V3 Pool\\n/// @notice A PancakeSwap 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 IPancakeV3Pool is\\n IPancakeV3PoolImmutables,\\n IPancakeV3PoolState,\\n IPancakeV3PoolDerivedState,\\n IPancakeV3PoolActions,\\n IPancakeV3PoolOwnerActions,\\n IPancakeV3PoolEvents\\n{\\n\\n}\\n\",\"keccak256\":\"0x4f22208838b7b85d2d48e9a92a0cee1e5bf5f12fe0f2f5cc521ab1adabb68fbb\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/v3-core/contracts/interfaces/pool/IPancakeV3PoolActions.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 IPancakeV3PoolActions {\\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 IPancakeV3MintCallback#pancakeV3MintCallback\\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 IPancakeV3SwapCallback#pancakeV3SwapCallback\\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 IPancakeV3FlashCallback#pancakeV3FlashCallback\\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\":\"0x78ed1c130111169f443c55618ff2d290ce0630b1d016cdeda3a66e12816041f6\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/v3-core/contracts/interfaces/pool/IPancakeV3PoolDerivedState.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 IPancakeV3PoolDerivedState {\\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\":\"0x45a9f30f562b5d0d55b311149c32df5cbcf0c7cfcb72aff2637a29794b06d4b6\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/v3-core/contracts/interfaces/pool/IPancakeV3PoolEvents.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 IPancakeV3PoolEvents {\\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 /// @param protocolFeesToken0 The protocol fee of token0 in the swap\\n /// @param protocolFeesToken1 The protocol fee of token1 in 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 uint128 protocolFeesToken0,\\n uint128 protocolFeesToken1\\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(\\n uint32 feeProtocol0Old,\\n uint32 feeProtocol1Old,\\n uint32 feeProtocol0New,\\n uint32 feeProtocol1New\\n );\\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\":\"0xab6ac5bd9ceadd20e3b60bb079489a2942c60f2697a6e145c585ee49b281534c\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/v3-core/contracts/interfaces/pool/IPancakeV3PoolImmutables.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 IPancakeV3PoolImmutables {\\n /// @notice The contract that deployed the pool, which must adhere to the IPancakeV3Factory 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\":\"0x8cde7ad64b4dced2fa40e91e3c8ffd0eaaf86954c65a1c0f7abc35f1af3a89d0\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/v3-core/contracts/interfaces/pool/IPancakeV3PoolOwnerActions.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 IPancakeV3PoolOwnerActions {\\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(uint32 feeProtocol0, uint32 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 /// @notice Set the LM pool to enable liquidity mining\\n function setLmPool(address lmPool) external;\\n}\\n\",\"keccak256\":\"0x5c522018f94c194608fd0f3f6bb1c7373d53496f5b6cb5e916b7a8d61fc7caf1\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/v3-core/contracts/interfaces/pool/IPancakeV3PoolState.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 IPancakeV3PoolState {\\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 uint32 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\":\"0xbf4a0b7b13de3cb73722a74cfee8b34fa250855373cd17e54a093f9054efbc61\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/v3-core/contracts/libraries/BitMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title BitMath\\n/// @dev This library provides functionality for computing bit properties of an unsigned integer\\nlibrary BitMath {\\n /// @notice Returns the index of the most significant bit of the number,\\n /// where the least significant bit is at index 0 and the most significant bit is at index 255\\n /// @dev The function satisfies the property:\\n /// x >= 2**mostSignificantBit(x) and x < 2**(mostSignificantBit(x)+1)\\n /// @param x the value for which to compute the most significant bit, must be greater than 0\\n /// @return r the index of the most significant bit\\n function mostSignificantBit(uint256 x) internal pure returns (uint8 r) {\\n require(x > 0);\\n\\n if (x >= 0x100000000000000000000000000000000) {\\n x >>= 128;\\n r += 128;\\n }\\n if (x >= 0x10000000000000000) {\\n x >>= 64;\\n r += 64;\\n }\\n if (x >= 0x100000000) {\\n x >>= 32;\\n r += 32;\\n }\\n if (x >= 0x10000) {\\n x >>= 16;\\n r += 16;\\n }\\n if (x >= 0x100) {\\n x >>= 8;\\n r += 8;\\n }\\n if (x >= 0x10) {\\n x >>= 4;\\n r += 4;\\n }\\n if (x >= 0x4) {\\n x >>= 2;\\n r += 2;\\n }\\n if (x >= 0x2) r += 1;\\n }\\n\\n /// @notice Returns the index of the least significant bit of the number,\\n /// where the least significant bit is at index 0 and the most significant bit is at index 255\\n /// @dev The function satisfies the property:\\n /// (x & 2**leastSignificantBit(x)) != 0 and (x & (2**(leastSignificantBit(x)) - 1)) == 0)\\n /// @param x the value for which to compute the least significant bit, must be greater than 0\\n /// @return r the index of the least significant bit\\n function leastSignificantBit(uint256 x) internal pure returns (uint8 r) {\\n require(x > 0);\\n\\n r = 255;\\n if (x & type(uint128).max > 0) {\\n r -= 128;\\n } else {\\n x >>= 128;\\n }\\n if (x & type(uint64).max > 0) {\\n r -= 64;\\n } else {\\n x >>= 64;\\n }\\n if (x & type(uint32).max > 0) {\\n r -= 32;\\n } else {\\n x >>= 32;\\n }\\n if (x & type(uint16).max > 0) {\\n r -= 16;\\n } else {\\n x >>= 16;\\n }\\n if (x & type(uint8).max > 0) {\\n r -= 8;\\n } else {\\n x >>= 8;\\n }\\n if (x & 0xf > 0) {\\n r -= 4;\\n } else {\\n x >>= 4;\\n }\\n if (x & 0x3 > 0) {\\n r -= 2;\\n } else {\\n x >>= 2;\\n }\\n if (x & 0x1 > 0) r -= 1;\\n }\\n}\\n\",\"keccak256\":\"0x82e425066110aac05ed8a9fc90f9ee85142b6f434769447e49d4438a8d9fcd82\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/v3-core/contracts/libraries/FixedPoint128.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.4.0;\\n\\n/// @title FixedPoint128\\n/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)\\nlibrary FixedPoint128 {\\n uint256 internal constant Q128 = 0x100000000000000000000000000000000;\\n}\\n\",\"keccak256\":\"0x2d1f4f73ae0d8f0a210b8d30084659b57c56ac8f2f96011fca36f00a6d417178\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/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\"},\"@pancakeswap/v3-core/contracts/libraries/FullMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.4.0 <0.8.0;\\n\\n/// @title Contains 512-bit math functions\\n/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision\\n/// @dev Handles \\\"phantom overflow\\\" i.e., allows multiplication and division where an intermediate value overflows 256 bits\\nlibrary FullMath {\\n /// @notice Calculates floor(a\\u00d7b\\u00f7denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n /// @param a The multiplicand\\n /// @param b The multiplier\\n /// @param denominator The divisor\\n /// @return result The 256-bit result\\n /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv\\n function mulDiv(\\n uint256 a,\\n uint256 b,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n // 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\":\"0xbefbff1aed686bac4be2ed1569a29f88649cfa17c45f417db81d6a2202fc1518\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/v3-core/contracts/libraries/LiquidityMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\n/// @title Math library for liquidity\\nlibrary LiquidityMath {\\n /// @notice Add a signed liquidity delta to liquidity and revert if it overflows or underflows\\n /// @param x The liquidity before change\\n /// @param y The delta by which liquidity should be changed\\n /// @return z The liquidity delta\\n function addDelta(uint128 x, int128 y) internal pure returns (uint128 z) {\\n if (y < 0) {\\n require((z = x - uint128(-y)) < x, 'LS');\\n } else {\\n require((z = x + uint128(y)) >= x, 'LA');\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd53041349718d5bce4a89e87cd911879d41ba42ba3fab0614e5e8b742f352b88\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/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\"},\"@pancakeswap/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\"},\"@pancakeswap/v3-core/contracts/libraries/SqrtPriceMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\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 amount <= type(uint160).max\\n ? (amount << FixedPoint96.RESOLUTION) / liquidity\\n : FullMath.mulDiv(amount, FixedPoint96.Q96, liquidity)\\n );\\n\\n return uint256(sqrtPX96).add(quotient).toUint160();\\n } else {\\n uint256 quotient = (\\n amount <= type(uint160).max\\n ? UnsafeMath.divRoundingUp(amount << FixedPoint96.RESOLUTION, liquidity)\\n : FullMath.mulDivRoundingUp(amount, FixedPoint96.Q96, liquidity)\\n );\\n\\n require(sqrtPX96 > quotient);\\n // always fits 160 bits\\n return uint160(sqrtPX96 - quotient);\\n }\\n }\\n\\n /// @notice Gets the next sqrt price given an input amount of token0 or token1\\n /// @dev Throws if price or liquidity are 0, or if the next price is out of bounds\\n /// @param sqrtPX96 The starting price, i.e., before accounting for the input amount\\n /// @param liquidity The amount of usable liquidity\\n /// @param amountIn How much of token0, or token1, is being swapped in\\n /// @param zeroForOne Whether the amount in is token0 or token1\\n /// @return sqrtQX96 The price after adding the input amount to token0 or token1\\n function getNextSqrtPriceFromInput(\\n uint160 sqrtPX96,\\n uint128 liquidity,\\n uint256 amountIn,\\n bool zeroForOne\\n ) internal pure returns (uint160 sqrtQX96) {\\n require(sqrtPX96 > 0);\\n require(liquidity > 0);\\n\\n // round to make sure that we don't pass the target price\\n return\\n zeroForOne\\n ? getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountIn, true)\\n : getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountIn, true);\\n }\\n\\n /// @notice Gets the next sqrt price given an output amount of token0 or token1\\n /// @dev Throws if price or liquidity are 0 or the next price is out of bounds\\n /// @param sqrtPX96 The starting price before accounting for the output amount\\n /// @param liquidity The amount of usable liquidity\\n /// @param amountOut How much of token0, or token1, is being swapped out\\n /// @param zeroForOne Whether the amount out is token0 or token1\\n /// @return sqrtQX96 The price after removing the output amount of token0 or token1\\n function getNextSqrtPriceFromOutput(\\n uint160 sqrtPX96,\\n uint128 liquidity,\\n uint256 amountOut,\\n bool zeroForOne\\n ) internal pure returns (uint160 sqrtQX96) {\\n require(sqrtPX96 > 0);\\n require(liquidity > 0);\\n\\n // round to make sure that we pass the target price\\n return\\n zeroForOne\\n ? getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountOut, false)\\n : getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountOut, false);\\n }\\n\\n /// @notice Gets the amount0 delta between two prices\\n /// @dev Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper),\\n /// i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower))\\n /// @param sqrtRatioAX96 A sqrt price\\n /// @param sqrtRatioBX96 Another sqrt price\\n /// @param liquidity The amount of usable liquidity\\n /// @param roundUp Whether to round the amount up or down\\n /// @return amount0 Amount of token0 required to cover a position of size liquidity between the two passed prices\\n function getAmount0Delta(\\n uint160 sqrtRatioAX96,\\n uint160 sqrtRatioBX96,\\n uint128 liquidity,\\n bool roundUp\\n ) internal pure returns (uint256 amount0) {\\n if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\\n\\n uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;\\n uint256 numerator2 = sqrtRatioBX96 - sqrtRatioAX96;\\n\\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\":\"0xc90227beb40a1d7a21ee9bf7ad31daa4f60ae9884c02e907e4dce24bb7115903\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/v3-core/contracts/libraries/SwapMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0;\\n\\nimport './FullMath.sol';\\nimport './SqrtPriceMath.sol';\\n\\n/// @title Computes the result of a swap within ticks\\n/// @notice Contains methods for computing the result of a swap within a single tick price range, i.e., a single tick.\\nlibrary SwapMath {\\n /// @notice Computes the result of swapping some amount in, or amount out, given the parameters of the swap\\n /// @dev The fee, plus the amount in, will never exceed the amount remaining if the swap's `amountSpecified` is positive\\n /// @param sqrtRatioCurrentX96 The current sqrt price of the pool\\n /// @param sqrtRatioTargetX96 The price that cannot be exceeded, from which the direction of the swap is inferred\\n /// @param liquidity The usable liquidity\\n /// @param amountRemaining How much input or output amount is remaining to be swapped in/out\\n /// @param feePips The fee taken from the input amount, expressed in hundredths of a bip\\n /// @return sqrtRatioNextX96 The price after swapping the amount in/out, not to exceed the price target\\n /// @return amountIn The amount to be swapped in, of either token0 or token1, based on the direction of the swap\\n /// @return amountOut The amount to be received, of either token0 or token1, based on the direction of the swap\\n /// @return feeAmount The amount of input that will be taken as a fee\\n function computeSwapStep(\\n uint160 sqrtRatioCurrentX96,\\n uint160 sqrtRatioTargetX96,\\n uint128 liquidity,\\n int256 amountRemaining,\\n uint24 feePips\\n )\\n internal\\n pure\\n returns (\\n uint160 sqrtRatioNextX96,\\n uint256 amountIn,\\n uint256 amountOut,\\n uint256 feeAmount\\n )\\n {\\n bool zeroForOne = sqrtRatioCurrentX96 >= sqrtRatioTargetX96;\\n bool exactIn = amountRemaining >= 0;\\n\\n if (exactIn) {\\n uint256 amountRemainingLessFee = FullMath.mulDiv(uint256(amountRemaining), 1e6 - feePips, 1e6);\\n amountIn = zeroForOne\\n ? SqrtPriceMath.getAmount0Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, true)\\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, true);\\n if (amountRemainingLessFee >= amountIn) sqrtRatioNextX96 = sqrtRatioTargetX96;\\n else\\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromInput(\\n sqrtRatioCurrentX96,\\n liquidity,\\n amountRemainingLessFee,\\n zeroForOne\\n );\\n } else {\\n amountOut = zeroForOne\\n ? SqrtPriceMath.getAmount1Delta(sqrtRatioTargetX96, sqrtRatioCurrentX96, liquidity, false)\\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, false);\\n if (uint256(-amountRemaining) >= amountOut) sqrtRatioNextX96 = sqrtRatioTargetX96;\\n else\\n sqrtRatioNextX96 = SqrtPriceMath.getNextSqrtPriceFromOutput(\\n sqrtRatioCurrentX96,\\n liquidity,\\n uint256(-amountRemaining),\\n zeroForOne\\n );\\n }\\n\\n bool max = sqrtRatioTargetX96 == sqrtRatioNextX96;\\n\\n // get the input/output amounts\\n if (zeroForOne) {\\n amountIn = max && exactIn\\n ? amountIn\\n : SqrtPriceMath.getAmount0Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, true);\\n amountOut = max && !exactIn\\n ? amountOut\\n : SqrtPriceMath.getAmount1Delta(sqrtRatioNextX96, sqrtRatioCurrentX96, liquidity, false);\\n } else {\\n amountIn = max && exactIn\\n ? amountIn\\n : SqrtPriceMath.getAmount1Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, true);\\n amountOut = max && !exactIn\\n ? amountOut\\n : SqrtPriceMath.getAmount0Delta(sqrtRatioCurrentX96, sqrtRatioNextX96, liquidity, false);\\n }\\n\\n // cap the output amount to not exceed the remaining output amount\\n if (!exactIn && amountOut > uint256(-amountRemaining)) {\\n amountOut = uint256(-amountRemaining);\\n }\\n\\n if (exactIn && sqrtRatioNextX96 != sqrtRatioTargetX96) {\\n // we didn't reach the target, so take the remainder of the maximum input as fee\\n feeAmount = uint256(amountRemaining) - amountIn;\\n } else {\\n feeAmount = FullMath.mulDivRoundingUp(amountIn, feePips, 1e6 - feePips);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe34ff649c19bcd33925935028c099621bb44cab2d782cf43e92d98a471bc7274\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/v3-core/contracts/libraries/TickMath.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.5.0 <0.8.0;\\n\\n/// @title Math library for computing sqrt prices from ticks and vice versa\\n/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports\\n/// prices between 2**-128 and 2**128\\nlibrary TickMath {\\n /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128\\n int24 internal constant MIN_TICK = -887272;\\n /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128\\n int24 internal constant MAX_TICK = -MIN_TICK;\\n\\n /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\\n uint160 internal constant MIN_SQRT_RATIO = 4295128739;\\n /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\\n uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\\n\\n /// @notice Calculates sqrt(1.0001^tick) * 2^96\\n /// @dev Throws if |tick| > max tick\\n /// @param tick The input tick for the above formula\\n /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)\\n /// at the given tick\\n function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {\\n 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\":\"0xda8c2c0b12d2976acfd364453ba5f5bf0117ba3c91175ee9e1067d3fb26944d9\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/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\"},\"@pancakeswap/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 deployer;\\n /// @inheritdoc IPeripheryImmutableState\\n address public immutable override factory;\\n /// @inheritdoc IPeripheryImmutableState\\n address public immutable override WETH9;\\n\\n constructor(address _deployer, address _factory, address _WETH9) {\\n deployer = _deployer;\\n factory = _factory;\\n WETH9 = _WETH9;\\n }\\n}\\n\",\"keccak256\":\"0xbe690f025403c72781fddde9cb1a88a5602f4caf50bfa943977ab9444e46224f\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/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 PancakeSwap V3 deployer\\n function deployer() external view returns (address);\\n\\n /// @return Returns the address of the PancakeSwap 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\":\"0x72e2d91b64685e4c4725cb3d144626e770842c2d2e0525816f9dd2044f6c9483\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/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\\u00e7alo S\\u00e1 \\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\",\"keccak256\":\"0x68629e5b1a30b6490c6ae721c28117f6f963745462b007da0769758eb67f10d4\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/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\",\"keccak256\":\"0xb22c562b5175d50dbcc2224325666090d985f052abdcfe275c8dfc884e34de61\",\"license\":\"GPL-2.0-or-later\"},\"@pancakeswap/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 = 0x6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2;\\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 deployer The PancakeSwap V3 deployer contract address\\n /// @param key The PoolKey\\n /// @return pool The contract address of the V3 pool\\n function computeAddress(address deployer, 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 deployer,\\n keccak256(abi.encode(key.token0, key.token1, key.fee)),\\n POOL_INIT_CODE_HASH\\n )\\n )\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x0854c03bdfda086e5bc3c6f041c20d133aac468ab4cfa85cb9b55b41cbaf7ff3\",\"license\":\"GPL-2.0-or-later\"},\"contracts/IUniV3likeQuoterCore.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity =0.7.6;\\n\\nstruct GlobalState {\\n uint160 startPrice;\\n int24 startTick;\\n uint16 fee;\\n}\\n\\n// the top level state of the swap, the results of which are recorded in storage at the end\\nstruct SwapState {\\n // the amount remaining to be swapped in/out of the input/output asset\\n int256 amountSpecifiedRemaining;\\n // the amount already swapped out/in of the output/input asset\\n int256 amountCalculated;\\n // current sqrt(price)\\n uint160 sqrtPriceX96;\\n // the tick associated with the current price\\n int24 tick;\\n // the current liquidity in range\\n uint128 liquidity;\\n}\\n\\nstruct StepComputations {\\n // the price at the beginning of the step\\n uint160 sqrtPriceStartX96;\\n // the next tick to swap to from the current tick in the swap direction\\n int24 tickNext;\\n // whether tickNext is initialized or not\\n bool initialized;\\n // sqrt(price) for the next tick (1/0)\\n uint160 sqrtPriceNextX96;\\n // how much is being swapped in in this step\\n uint256 amountIn;\\n // how much is being swapped out\\n uint256 amountOut;\\n // how much fee is being paid in\\n uint256 feeAmount;\\n}\\n\\ninterface IUniV3likeQuoterCore {\\n\\n function quote(\\n address poolAddress,\\n bool zeroForOne,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96\\n ) external view returns (int256 amount0, int256 amount1);\\n\\n}\",\"keccak256\":\"0xd269f4631d3efa8658798ad07678df11843fe3f0e2045d85a7666c514fa0b943\",\"license\":\"GPL-2.0-or-later\"},\"contracts/PancakeV3Quoter/PancakeV3QuoterCore.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity =0.7.6;\\n\\nimport './PancakeV3likeQuoterCore.sol';\\nimport './lib/TickBitmap.sol';\\n\\ncontract PancakeV3QuoterCore is PancakeV3likeQuoterCore {\\n\\n function getPoolGlobalState(\\n address pool\\n ) internal override view returns (GlobalState memory gs) {\\n gs.fee = uint16(IPancakeV3Pool(pool).fee());\\n (gs.startPrice, gs.startTick,,,,,) = IPancakeV3Pool(pool).slot0();\\n }\\n \\n function getTickSpacing(\\n address pool\\n ) internal override view returns (int24) {\\n return IPancakeV3Pool(pool).tickSpacing();\\n }\\n \\n function getLiquidity(address pool) internal override view returns (uint128) {\\n return IPancakeV3Pool(pool).liquidity();\\n }\\n \\n function nextInitializedTickWithinOneWord(\\n address poolAddress,\\n int24 tick,\\n int24 tickSpacing,\\n bool zeroForOne\\n ) internal override view returns (int24 next, bool initialized) {\\n return TickBitmap.nextInitializedTickWithinOneWord(\\n poolAddress,\\n tick,\\n tickSpacing,\\n zeroForOne\\n );\\n }\\n \\n function getTicks(address pool, int24 tick) internal override view returns (\\n uint128 liquidityTotal,\\n int128 liquidityDelta,\\n uint256 outerFeeGrowth0Token,\\n uint256 outerFeeGrowth1Token,\\n int56 outerTickCumulative,\\n uint160 outerSecondsPerLiquidity,\\n uint32 outerSecondsSpent,\\n bool initialized\\n ) {\\n return IPancakeV3Pool(pool).ticks(tick);\\n }\\n\\n}\\n\",\"keccak256\":\"0xa073fb53e28d243e67f7a4e7191894f8be42ae56edbbfed2941730d203fdf5f2\",\"license\":\"GPL-2.0-or-later\"},\"contracts/PancakeV3Quoter/PancakeV3StaticQuoter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity =0.7.6;\\npragma abicoder v2;\\n\\nimport '@pancakeswap/v3-periphery/contracts/base/PeripheryImmutableState.sol';\\nimport '@pancakeswap/v3-periphery/contracts/libraries/PoolAddress.sol';\\nimport '@pancakeswap/v3-periphery/contracts/libraries/Path.sol';\\n\\nimport './interfaces/IPancakeV3StaticQuoter.sol';\\nimport './PancakeV3QuoterCore.sol';\\n\\ncontract PancakeV3StaticQuoter is IPancakeV3StaticQuoter, PancakeV3QuoterCore {\\n using LowGasSafeMath for uint256;\\n using LowGasSafeMath for int256;\\n using SafeCast for uint256;\\n using SafeCast for int256;\\n using Path for bytes;\\n\\n address immutable factory;\\n\\n constructor(address _factory) {\\n factory = _factory;\\n }\\n\\n function getPool(\\n address tokenA,\\n address tokenB,\\n uint24 fee\\n ) private view returns (IPancakeV3Pool) {\\n return IPancakeV3Pool(PoolAddress.computeAddress(factory, PoolAddress.getPoolKey(tokenA, tokenB, fee)));\\n }\\n\\n function quoteExactInputSingle(QuoteExactInputSingleParams memory params)\\n public\\n view\\n override\\n returns (uint256 amountOut)\\n {\\n bool zeroForOne = params.tokenIn < params.tokenOut;\\n IPancakeV3Pool pool = getPool(params.tokenIn, params.tokenOut, params.fee);\\n (int256 amount0, int256 amount1) = quote(\\n address(pool),\\n zeroForOne,\\n params.amountIn.toInt256(),\\n params.sqrtPriceLimitX96 == 0\\n ? (zeroForOne ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1)\\n : params.sqrtPriceLimitX96\\n );\\n\\n return zeroForOne ? uint256(-amount1) : uint256(-amount0);\\n }\\n\\n function quoteExactInput(bytes memory path, uint256 amountIn)\\n public\\n view\\n override\\n returns (uint256 amountOut)\\n {\\n uint256 i = 0;\\n while (true) {\\n (address tokenIn, address tokenOut, uint24 fee) = path.decodeFirstPool();\\n // the outputs of prior swaps become the inputs to subsequent ones\\n uint256 _amountOut =\\n quoteExactInputSingle(\\n QuoteExactInputSingleParams({\\n tokenIn: tokenIn,\\n tokenOut: tokenOut,\\n fee: fee,\\n amountIn: amountIn,\\n sqrtPriceLimitX96: 0\\n })\\n );\\n amountIn = _amountOut;\\n i++;\\n\\n // decide whether to continue or terminate\\n if (path.hasMultiplePools()) {\\n path = path.skipToken();\\n } else {\\n return amountIn;\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9bc854b39662d27fdde7bcdead1c0b367b0d76e8bc012d03984340e4a97ca744\",\"license\":\"GPL-2.0-or-later\"},\"contracts/PancakeV3Quoter/PancakeV3likeQuoterCore.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity =0.7.6;\\n\\nimport '@pancakeswap/v3-core/contracts/libraries/LowGasSafeMath.sol';\\nimport '@pancakeswap/v3-core/contracts/libraries/LiquidityMath.sol';\\nimport '@pancakeswap/v3-core/contracts/libraries/FixedPoint128.sol';\\nimport '@pancakeswap/v3-core/contracts/libraries/SafeCast.sol';\\nimport '@pancakeswap/v3-core/contracts/libraries/TickMath.sol';\\nimport '@pancakeswap/v3-core/contracts/libraries/FullMath.sol';\\nimport '@pancakeswap/v3-core/contracts/libraries/SwapMath.sol';\\nimport '../IUniV3likeQuoterCore.sol';\\n\\n\\nabstract contract PancakeV3likeQuoterCore {\\n using LowGasSafeMath for int256;\\n using SafeCast for uint256;\\n using SafeCast for int256;\\n\\n function quote(\\n address poolAddress,\\n bool zeroForOne,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96\\n ) public virtual view returns (int256 amount0, int256 amount1) {\\n require(amountSpecified != 0, 'amountSpecified cannot be zero');\\n bool exactInput = amountSpecified > 0;\\n (int24 tickSpacing, uint16 fee, SwapState memory state) = getInitState(\\n poolAddress,\\n zeroForOne,\\n amountSpecified,\\n sqrtPriceLimitX96\\n );\\n // continue swapping as long as we haven't used the entire input/output and haven't reached the price limit\\n while (state.amountSpecifiedRemaining != 0 && state.sqrtPriceX96 != sqrtPriceLimitX96) {\\n StepComputations memory step;\\n step.sqrtPriceStartX96 = state.sqrtPriceX96;\\n\\n (step.tickNext, step.initialized, step.sqrtPriceNextX96) = nextInitializedTickAndPrice(\\n poolAddress,\\n state.tick,\\n tickSpacing,\\n zeroForOne\\n );\\n // compute values to swap to the target tick, price limit, or point where input/output amount is exhausted\\n (state.sqrtPriceX96, step.amountIn, step.amountOut, step.feeAmount) = SwapMath.computeSwapStep(\\n state.sqrtPriceX96,\\n getSqrtRatioTargetX96(zeroForOne, step.sqrtPriceNextX96, sqrtPriceLimitX96),\\n state.liquidity,\\n state.amountSpecifiedRemaining,\\n fee\\n );\\n if (exactInput) {\\n state.amountSpecifiedRemaining -= (step.amountIn + step.feeAmount).toInt256();\\n state.amountCalculated = state.amountCalculated.sub(step.amountOut.toInt256());\\n } else {\\n state.amountSpecifiedRemaining += step.amountOut.toInt256();\\n state.amountCalculated = state.amountCalculated.add((step.amountIn + step.feeAmount).toInt256());\\n }\\n // shift tick if we reached the next price\\n if (state.sqrtPriceX96 == step.sqrtPriceNextX96) {\\n // if the tick is initialized, run the tick transition\\n if (step.initialized) {\\n (,int128 liquidityNet,,,,,,) = getTicks(poolAddress, step.tickNext);\\n // if we're moving leftward, we interpret liquidityNet as the opposite sign\\n // safe because liquidityNet cannot be type(int128).min\\n if (zeroForOne)\\n liquidityNet = -liquidityNet;\\n state.liquidity = LiquidityMath.addDelta(state.liquidity, liquidityNet);\\n }\\n state.tick = zeroForOne ? step.tickNext - 1 : step.tickNext;\\n } else if (state.sqrtPriceX96 != step.sqrtPriceStartX96) {\\n // recompute unless we're on a lower tick boundary (i.e. already transitioned ticks), and haven't moved\\n state.tick = TickMath.getTickAtSqrtRatio(state.sqrtPriceX96);\\n }\\n }\\n\\n (amount0, amount1) = zeroForOne == exactInput\\n ? (amountSpecified - state.amountSpecifiedRemaining, state.amountCalculated)\\n : (state.amountCalculated, amountSpecified - state.amountSpecifiedRemaining);\\n }\\n\\n function getInitState(\\n address poolAddress,\\n bool zeroForOne,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96\\n ) internal view returns (int24 ts, uint16 fee, SwapState memory state) {\\n GlobalState memory gs = getPoolGlobalState(poolAddress);\\n checkSqrtPriceLimitWithinAllowed(zeroForOne, sqrtPriceLimitX96, gs.startPrice);\\n ts = getTickSpacing(poolAddress);\\n fee = gs.fee;\\n state = SwapState({\\n amountSpecifiedRemaining: amountSpecified,\\n liquidity: getLiquidity(poolAddress),\\n sqrtPriceX96: gs.startPrice,\\n amountCalculated: 0,\\n tick: gs.startTick\\n });\\n }\\n\\n function checkSqrtPriceLimitWithinAllowed(\\n bool zeroForOne,\\n uint160 sqrtPriceLimit, \\n uint160 startPrice\\n ) internal pure {\\n bool withinAllowed = zeroForOne\\n ? sqrtPriceLimit < startPrice && sqrtPriceLimit > TickMath.MIN_SQRT_RATIO\\n : sqrtPriceLimit > startPrice && sqrtPriceLimit < TickMath.MAX_SQRT_RATIO;\\n require(withinAllowed, 'sqrtPriceLimit out of bounds');\\n }\\n\\n function nextInitializedTickAndPrice(\\n address pool, \\n int24 tick, \\n int24 tickSpacing,\\n bool zeroForOne\\n ) internal view returns (int24 tickNext, bool initialized, uint160 sqrtPriceNextX96) {\\n (tickNext, initialized) = nextInitializedTickWithinOneWord(pool, tick, tickSpacing, zeroForOne);\\n // ensure that we do not overshoot the min/max tick, as the tick bitmap is not aware of these bounds\\n if (tickNext < TickMath.MIN_TICK)\\n tickNext = TickMath.MIN_TICK;\\n else if (tickNext > TickMath.MAX_TICK)\\n tickNext = TickMath.MAX_TICK;\\n // get the price for the next tick\\n sqrtPriceNextX96 = TickMath.getSqrtRatioAtTick(tickNext);\\n }\\n\\n function getSqrtRatioTargetX96(\\n bool zeroForOne,\\n uint160 sqrtPriceNextX96,\\n uint160 sqrtPriceLimitX96\\n ) internal pure returns (uint160) {\\n return (zeroForOne ? sqrtPriceNextX96sqrtPriceLimitX96)\\n ? sqrtPriceLimitX96\\n : sqrtPriceNextX96;\\n }\\n\\n function getPoolGlobalState(address pool) internal virtual view returns (GlobalState memory);\\n \\n function getLiquidity(address pool) internal virtual view returns (uint128);\\n\\n function getTickSpacing(address pool) internal virtual view returns (int24);\\n \\n function nextInitializedTickWithinOneWord(\\n address poolAddress,\\n int24 tick,\\n int24 tickSpacing,\\n bool zeroForOne\\n ) internal virtual view returns (int24 next, bool initialized);\\n \\n function getTicks(address pool, int24 tick) internal virtual view returns (\\n uint128 liquidityTotal,\\n int128 liquidityDelta,\\n uint256 outerFeeGrowth0Token,\\n uint256 outerFeeGrowth1Token,\\n int56 outerTickCumulative,\\n uint160 outerSecondsPerLiquidity,\\n uint32 outerSecondsSpent,\\n bool initialized\\n );\\n\\n}\",\"keccak256\":\"0xe43a2562275d885f7651909533b4ecbe7aa3d14b96fdd2b685c284681eb3fc51\",\"license\":\"GPL-2.0-or-later\"},\"contracts/PancakeV3Quoter/interfaces/IPancakeV3StaticQuoter.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity >=0.7.5;\\npragma abicoder v2;\\n\\ninterface IPancakeV3StaticQuoter {\\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)\\n external\\n view\\n returns (uint256 amountOut);\\n\\n struct QuoteExactInputSingleParams {\\n address tokenIn;\\n address tokenOut;\\n uint256 amountIn;\\n uint24 fee;\\n uint160 sqrtPriceLimitX96;\\n }\\n\\n /// @notice Returns the amount out received for a given exact input but for a swap of a single pool\\n /// @param params The params for the quote, encoded as `QuoteExactInputSingleParams`\\n /// tokenIn The token being swapped in\\n /// tokenOut The token being swapped out\\n /// fee The fee of the token pool to consider for the pair\\n /// amountIn The desired input amount\\n /// 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(QuoteExactInputSingleParams memory params)\\n external\\n view\\n returns (uint256 amountOut);\\n}\",\"keccak256\":\"0x1d92b0d7bc7743a56afcefbd5f10c36e503a9ac4771eeb335bb3acb762002156\",\"license\":\"GPL-2.0-or-later\"},\"contracts/PancakeV3Quoter/lib/TickBitmap.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-2.0-or-later\\npragma solidity =0.7.6;\\n\\nimport '@pancakeswap/v3-core/contracts/interfaces/IPancakeV3Pool.sol';\\nimport '@pancakeswap/v3-core/contracts/libraries/BitMath.sol';\\n\\n/// @title Packed tick initialized state library\\n/// @notice Stores a packed mapping of tick index to its initialized state\\n/// @dev The mapping uses int16 for keys since ticks are represented as int24 and there are 256 (2^8) values per word.\\nlibrary TickBitmap {\\n /// @notice Computes the position in the mapping where the initialized bit for a tick lives\\n /// @param tick The tick for which to compute the position\\n /// @return wordPos The key in the mapping containing the word in which the bit is stored\\n /// @return bitPos The bit position in the word where the flag is stored\\n function position(int24 tick) private pure returns (int16 wordPos, uint8 bitPos) {\\n wordPos = int16(tick >> 8);\\n bitPos = uint8(tick % 256);\\n }\\n\\n /// @notice Returns the next initialized tick contained in the same word (or adjacent word) as the tick that is either\\n /// to the left (less than or equal to) or right (greater than) of the given tick\\n /// @param poolAddress Pool containing the mapping in which to compute the next initialized tick\\n /// @param tick The starting tick\\n /// @param tickSpacing The spacing between usable ticks\\n /// @param lte Whether to search for the next initialized tick to the left (less than or equal to the starting tick)\\n /// @return next The next initialized or Pancakenitialized tick up to 256 ticks away from the current tick\\n /// @return initialized Whether the next tick is initialized, as the function only searches within up to 256 ticks\\n function nextInitializedTickWithinOneWord(\\n address poolAddress,\\n int24 tick,\\n int24 tickSpacing,\\n bool lte\\n ) internal view returns (int24 next, bool initialized) {\\n IPancakeV3Pool pool = IPancakeV3Pool(poolAddress);\\n int24 compressed = tick / tickSpacing;\\n if (tick < 0 && tick % tickSpacing != 0) compressed--; // round towards negative infinity\\n\\n if (lte) {\\n (int16 wordPos, uint8 bitPos) = position(compressed);\\n // all the 1s at or to the right of the current bitPos\\n uint256 mask = (1 << bitPos) - 1 + (1 << bitPos);\\n uint256 masked = pool.tickBitmap(wordPos) & mask;\\n\\n // if there are no initialized ticks to the right of or at the current tick, return rightmost in the word\\n initialized = masked != 0;\\n // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick\\n next = initialized\\n ? (compressed - int24(bitPos - BitMath.mostSignificantBit(masked))) * tickSpacing\\n : (compressed - int24(bitPos)) * tickSpacing;\\n } else {\\n // start from the word of the next tick, since the current tick state doesn't matter\\n (int16 wordPos, uint8 bitPos) = position(compressed + 1);\\n // all the 1s at or to the left of the bitPos\\n uint256 mask = ~((1 << bitPos) - 1);\\n uint256 masked = pool.tickBitmap(wordPos) & mask;\\n\\n // if there are no initialized ticks to the left of the current tick, return leftmost in the word\\n initialized = masked != 0;\\n // overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick\\n next = initialized\\n ? (compressed + 1 + int24(BitMath.leastSignificantBit(masked) - bitPos)) * tickSpacing\\n : (compressed + 1 + int24(type(uint8).max - bitPos)) * tickSpacing;\\n }\\n }\\n}\",\"keccak256\":\"0x7d18d9a221d1615416ee210b4cf9e74a774508a3b90a88a29e5b4db75ae2a04f\",\"license\":\"GPL-2.0-or-later\"}},\"version\":1}", + "bytecode": "0x60a06040523480156200001157600080fd5b5060405162002bb438038062002bb483398101604081905262000034916200004a565b60601b6001600160601b0319166080526200007a565b6000602082840312156200005c578081fd5b81516001600160a01b038116811462000073578182fd5b9392505050565b60805160601c612b1c6200009860003980610fc25250612b1c6000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806390405d3614610046578063c6a5026a14610070578063cdca175314610090575b600080fd5b610059610054366004612920565b6100a3565b604051610067929190612aaf565b60405180910390f35b61008361007e366004612a22565b6103f9565b6040516100679190612abd565b61008361009e366004612976565b6104bf565b6000808361011257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f616d6f756e745370656369666965642063616e6e6f74206265207a65726f0000604482015290519081900360640190fd5b60008085139080806101268a8a8a8a610594565b9250925092505b80511580159061016d57508673ffffffffffffffffffffffffffffffffffffffff16816040015173ffffffffffffffffffffffffffffffffffffffff1614155b156103c25761017a61288b565b604082015173ffffffffffffffffffffffffffffffffffffffff16815260608201516101a9908c90868d61063d565b73ffffffffffffffffffffffffffffffffffffffff1660608401819052901515604080850191909152600292830b90920b602084015290830151610204916101f3908d908c6106d2565b6080850151855161ffff8816610753565b60c085015260a0840152608083015273ffffffffffffffffffffffffffffffffffffffff1660408301528415610273576102478160c00151826080015101610979565b825103825260a08101516102699061025e90610979565b6020840151906109ab565b60208301526102ae565b6102808160a00151610979565b825101825260c081015160808201516102a89161029d9101610979565b6020840151906109c1565b60208301525b806060015173ffffffffffffffffffffffffffffffffffffffff16826040015173ffffffffffffffffffffffffffffffffffffffff1614156103675780604001511561033e5760006103048c83602001516109d7565b5050505050509150508a15610317576000035b610325836080015182610aab565b6fffffffffffffffffffffffffffffffff166080840152505b8961034d578060200151610356565b60018160200151035b600290810b900b60608301526103bc565b806000015173ffffffffffffffffffffffffffffffffffffffff16826040015173ffffffffffffffffffffffffffffffffffffffff16146103bc576103af8260400151610bef565b600290810b900b60608301525b5061012d565b831515891515146103db576020810151815189036103e8565b8060000151880381602001515b909b909a5098505050505050505050565b60208101518151606083015160009273ffffffffffffffffffffffffffffffffffffffff808216908416109284926104319290610fbb565b905060008061049c83856104488960400151610979565b60808a015173ffffffffffffffffffffffffffffffffffffffff1615610472578960800151610054565b876104915773fffd8963efd1fc6a506488495d951d5263988d25610054565b6401000276a46100a3565b91509150836104ae57816000036104b3565b806000035b9450505050505b919050565b6000805b60008060006104d187610ff1565b92509250925060006105506040518060a001604052808673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1681526020018981526020018462ffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152506103f9565b9650506001909301928561056388611022565b15610578576105718861102a565b9750610585565b869550505050505061058e565b505050506104c3565b92915050565b60008061059f6128c7565b60006105aa8861105f565b90506105bb878683600001516111a8565b6105c4886112e1565b9350806040015192506040518060a0016040528087815260200160008152602001826000015173ffffffffffffffffffffffffffffffffffffffff168152602001826020015160020b815260200161061b8a61135b565b6fffffffffffffffffffffffffffffffff168152509150509450945094915050565b600080600061064e878787876113a3565b90935091507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff27618600284900b12156106a7577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2761892506106bd565b620d89e8600284900b13156106bd57620d89e892505b6106c6836113bf565b90509450945094915050565b60008361070d578173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161161073d565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16105b6107475782610749565b815b90505b9392505050565b600080808073ffffffffffffffffffffffffffffffffffffffff808916908a1610158187128015906107e55760006107998989620f42400362ffffff16620f4240611752565b9050826107b2576107ad8c8c8c600161181f565b6107bf565b6107bf8b8d8c60016118f2565b95508581106107d0578a96506107df565b6107dc8c8b8386611a0a565b96505b5061082f565b816107fc576107f78b8b8b60006118f2565b610809565b6108098a8c8b600061181f565b935083886000031061081d5789955061082f565b61082c8b8a8a60000385611a6c565b95505b73ffffffffffffffffffffffffffffffffffffffff8a811690871614821561089f5780801561085b5750815b6108715761086c878d8c60016118f2565b610873565b855b9550808015610880575081155b61089657610891878d8c600061181f565b610898565b845b94506108e9565b8080156108a95750815b6108bf576108ba8c888c600161181f565b6108c1565b855b95508080156108ce575081155b6108e4576108df8c888c60006118f2565b6108e6565b845b94505b811580156108f957508860000385115b15610905578860000394505b81801561093e57508a73ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614155b1561094d57858903935061096a565b610967868962ffffff168a620f42400362ffffff16611ace565b93505b50505095509550955095915050565b60007f800000000000000000000000000000000000000000000000000000000000000082106109a757600080fd5b5090565b8082038281131560008312151461058e57600080fd5b8181018281121560008312151461058e57600080fd5b6000806000806000806000808973ffffffffffffffffffffffffffffffffffffffff1663f30dba938a6040518263ffffffff1660e01b8152600401808260020b81526020019150506101006040518083038186803b158015610a3857600080fd5b505afa158015610a4c573d6000803e3d6000fd5b505050506040513d610100811015610a6357600080fd5b508051602082015160408301516060840151608085015160a086015160c087015160e090970151959e50939c50919a5098509650945090925090509295985092959890939650565b60008082600f0b1215610b5757826fffffffffffffffffffffffffffffffff168260000384039150816fffffffffffffffffffffffffffffffff1610610b5257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f4c53000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b61058e565b826fffffffffffffffffffffffffffffffff168284019150816fffffffffffffffffffffffffffffffff16101561058e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f4c41000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60006401000276a373ffffffffffffffffffffffffffffffffffffffff831610801590610c45575073fffd8963efd1fc6a506488495d951d5263988d2673ffffffffffffffffffffffffffffffffffffffff8316105b610cb057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f5200000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b77ffffffffffffffffffffffffffffffffffffffff00000000602083901b166fffffffffffffffffffffffffffffffff811160071b81811c67ffffffffffffffff811160061b90811c63ffffffff811160051b90811c61ffff811160041b90811c60ff8111600390811b91821c600f811160021b90811c918211600190811b92831c97908811961790941790921717909117171760808110610d5a57607f810383901c9150610d64565b80607f0383901b91505b908002607f81811c60ff83811c9190911c800280831c81831c1c800280841c81841c1c800280851c81851c1c800280861c81861c1c800280871c81871c1c800280881c81881c1c800280891c81891c1c8002808a1c818a1c1c8002808b1c818b1c1c8002808c1c818c1c1c8002808d1c818d1c1c8002808e1c9c81901c9c909c1c80029c8d901c9e9d7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808f0160401b60c09190911c678000000000000000161760c19b909b1c674000000000000000169a909a1760c29990991c672000000000000000169890981760c39790971c671000000000000000169690961760c49590951c670800000000000000169490941760c59390931c670400000000000000169290921760c69190911c670200000000000000161760c79190911c670100000000000000161760c89190911c6680000000000000161760c99190911c6640000000000000161760ca9190911c6620000000000000161760cb9190911c6610000000000000161760cc9190911c6608000000000000161760cd9190911c66040000000000001617693627a301d71055774c8581027ffffffffffffffffffffffffffffffffffd709b7e5480fba5a50fed5e62ffc5568101608090811d906fdb2df09e81959a81455e260799a0632f8301901d600281810b9083900b14610fac578873ffffffffffffffffffffffffffffffffffffffff16610f83826113bf565b73ffffffffffffffffffffffffffffffffffffffff161115610fa55781610fa7565b805b610fae565b815b9998505050505050505050565b60006107497f0000000000000000000000000000000000000000000000000000000000000000610fec868686611b26565b611ba3565b60008080610fff8482611cd9565b925061100c846014611dd9565b9050611019846017611cd9565b91509193909250565b516042111590565b805160609061058e9083906017907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe901611ec9565b6110676128f5565b8173ffffffffffffffffffffffffffffffffffffffff1663ddca3f436040518163ffffffff1660e01b815260040160206040518083038186803b1580156110ad57600080fd5b505afa1580156110c1573d6000803e3d6000fd5b505050506040513d60208110156110d757600080fd5b505161ffff1660408083019190915280517f3850c7bd000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff841691633850c7bd9160048083019260e0929190829003018186803b15801561114a57600080fd5b505afa15801561115e573d6000803e3d6000fd5b505050506040513d60e081101561117457600080fd5b508051602091820151600290810b900b9183019190915273ffffffffffffffffffffffffffffffffffffffff168152919050565b600083611218578173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16118015611213575073fffd8963efd1fc6a506488495d951d5263988d2673ffffffffffffffffffffffffffffffffffffffff8416105b61126d565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1610801561126d57506401000276a373ffffffffffffffffffffffffffffffffffffffff8416115b9050806112db57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f7371727450726963654c696d6974206f7574206f6620626f756e647300000000604482015290519081900360640190fd5b50505050565b60008173ffffffffffffffffffffffffffffffffffffffff1663d0c93a7c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561132957600080fd5b505afa15801561133d573d6000803e3d6000fd5b505050506040513d602081101561135357600080fd5b505192915050565b60008173ffffffffffffffffffffffffffffffffffffffff16631a6865026040518163ffffffff1660e01b815260040160206040518083038186803b15801561132957600080fd5b6000806113b2868686866120b0565b9150915094509492505050565b60008060008360020b126113d6578260020b6113de565b8260020b6000035b9050620d89e881111561145257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f5400000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60006001821661147357700100000000000000000000000000000000611485565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156114b9576ffff97272373d413259a46990580e213a0260801c5b60048216156114d8576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b60088216156114f7576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615611516576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615611535576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615611554576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615611573576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615611593576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b6102008216156115b3576ff987a7253ac413176f2b074cf7815e540260801c5b6104008216156115d3576ff3392b0822b70005940c7a398e4b70f30260801c5b6108008216156115f3576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615611613576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615611633576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615611653576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615611673576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615611694576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b620200008216156116b4576e5d6af8dedb81196699c329225ee6040260801c5b620400008216156116d3576d2216e584f5fa1ea926041bedfe980260801c5b620800008216156116f0576b048a170391f7dc42444e8fa20260801c5b60008460020b131561172957807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8161172557fe5b0490505b64010000000081061561173d576001611740565b60005b60ff16602082901c0192505050919050565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff858709868602925082811090839003039050806117a6576000841161179b57600080fd5b50829004905061074c565b8084116117b257600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161115611859579293925b816118a5576118a0836fffffffffffffffffffffffffffffffff1686860373ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000611752565b6118e7565b6118e7836fffffffffffffffffffffffffffffffff1686860373ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000611ace565b90505b949350505050565b60008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16111561192c579293925b7bffffffffffffffffffffffffffffffff000000000000000000000000606084901b1673ffffffffffffffffffffffffffffffffffffffff868603811690871661197557600080fd5b836119bf578673ffffffffffffffffffffffffffffffffffffffff166119b283838973ffffffffffffffffffffffffffffffffffffffff16611752565b816119b957fe5b046119ff565b6119ff6119e383838973ffffffffffffffffffffffffffffffffffffffff16611ace565b8873ffffffffffffffffffffffffffffffffffffffff1661231d565b979650505050505050565b6000808573ffffffffffffffffffffffffffffffffffffffff1611611a2e57600080fd5b6000846fffffffffffffffffffffffffffffffff1611611a4d57600080fd5b81611a5f576118a08585856001612328565b6118e78585856001612480565b6000808573ffffffffffffffffffffffffffffffffffffffff1611611a9057600080fd5b6000846fffffffffffffffffffffffffffffffff1611611aaf57600080fd5b81611ac1576118a08585856000612480565b6118e78585856000612328565b6000611adb848484611752565b905060008280611ae757fe5b848609111561074c577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8110611b1c57600080fd5b6001019392505050565b611b2e6128f5565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161115611b66579192915b506040805160608101825273ffffffffffffffffffffffffffffffffffffffff948516815292909316602083015262ffffff169181019190915290565b6000816020015173ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff1610611be557600080fd5b508051602080830151604093840151845173ffffffffffffffffffffffffffffffffffffffff94851681850152939091168385015262ffffff166060808401919091528351808403820181526080840185528051908301207fff0000000000000000000000000000000000000000000000000000000000000060a085015294901b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660a183015260b58201939093527f6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e260d5808301919091528251808303909101815260f5909101909152805191012090565b600081826014011015611d4d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f746f416464726573735f6f766572666c6f770000000000000000000000000000604482015290519081900360640190fd5b8160140183511015611dc057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f746f416464726573735f6f75744f66426f756e64730000000000000000000000604482015290519081900360640190fd5b5001602001516c01000000000000000000000000900490565b600081826003011015611e4d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f746f55696e7432345f6f766572666c6f77000000000000000000000000000000604482015290519081900360640190fd5b8160030183511015611ec057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f746f55696e7432345f6f75744f66426f756e6473000000000000000000000000604482015290519081900360640190fd5b50016003015190565b60608182601f011015611f3d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f736c6963655f6f766572666c6f77000000000000000000000000000000000000604482015290519081900360640190fd5b828284011015611fae57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f736c6963655f6f766572666c6f77000000000000000000000000000000000000604482015290519081900360640190fd5b8183018451101561202057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f736c6963655f6f75744f66426f756e6473000000000000000000000000000000604482015290519081900360640190fd5b60608215801561203f57604051915060008252602082016040526120a7565b6040519150601f8416801560200281840101858101878315602002848b0101015b81831015612078578051835260209283019201612060565b5050858452601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016604052505b50949350505050565b6000808581600286810b9088900b816120c557fe5b05905060008760020b1280156120ec57508560020b8760020b816120e557fe5b0760020b15155b15612114577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff015b841561222f57600080612126836125b6565b604080517f5339c296000000000000000000000000000000000000000000000000000000008152600184810b6004830152915193955091935060ff84161b80017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0191600091839173ffffffffffffffffffffffffffffffffffffffff891691635339c296916024808301926020929190829003018186803b1580156121cb57600080fd5b505afa1580156121df573d6000803e3d6000fd5b505050506040513d60208110156121f557600080fd5b505116801515975090508661221157898360ff16860302612224565b8961221b826125c8565b840360ff168603025b975050505050612312565b60008061223e836001016125b6565b91509150600060018260ff166001901b031990506000818673ffffffffffffffffffffffffffffffffffffffff16635339c296866040518263ffffffff1660e01b8152600401808260010b815260200191505060206040518083038186803b1580156122a957600080fd5b505afa1580156122bd573d6000803e3d6000fd5b505050506040513d60208110156122d357600080fd5b50511680151597509050866122f557898360ff0360ff1686600101010261230b565b898361230083612675565b0360ff168660010101025b9750505050505b505094509492505050565b808204910615150190565b600081156123d057600073ffffffffffffffffffffffffffffffffffffffff84111561237d57612378846c01000000000000000000000000876fffffffffffffffffffffffffffffffff16611752565b61239e565b6fffffffffffffffffffffffffffffffff8516606085901b8161239c57fe5b045b90506123c86123c373ffffffffffffffffffffffffffffffffffffffff881683612858565b612868565b9150506118ea565b600073ffffffffffffffffffffffffffffffffffffffff84111561241d57612418846c01000000000000000000000000876fffffffffffffffffffffffffffffffff16611ace565b61243d565b61243d606085901b6fffffffffffffffffffffffffffffffff871661231d565b9050808673ffffffffffffffffffffffffffffffffffffffff161161246157600080fd5b73ffffffffffffffffffffffffffffffffffffffff86160390506118ea565b60008261248e5750836118ea565b7bffffffffffffffffffffffffffffffff000000000000000000000000606085901b1682156125555773ffffffffffffffffffffffffffffffffffffffff8616848102908582816124db57fe5b041415612519578181018281106125175761250d838973ffffffffffffffffffffffffffffffffffffffff1683611ace565b93505050506118ea565b505b61254c82612547878a73ffffffffffffffffffffffffffffffffffffffff16868161254057fe5b0490612858565b61231d565b925050506118ea565b73ffffffffffffffffffffffffffffffffffffffff86168481029085828161257957fe5b0414801561258657508082115b61258f57600080fd5b80820361250d6123c38473ffffffffffffffffffffffffffffffffffffffff8b1684611ace565b60020b600881901d9161010090910790565b60008082116125d657600080fd5b70010000000000000000000000000000000082106125f657608091821c91015b68010000000000000000821061260e57604091821c91015b640100000000821061262257602091821c91015b62010000821061263457601091821c91015b610100821061264557600891821c91015b6010821061265557600491821c91015b6004821061266557600291821c91015b600282106104ba57600101919050565b600080821161268357600080fd5b5060ff6fffffffffffffffffffffffffffffffff8216156126c5577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80016126cd565b608082901c91505b67ffffffffffffffff821615612704577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00161270c565b604082901c91505b63ffffffff82161561273f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001612747565b602082901c91505b61ffff821615612778577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001612780565b601082901c91505b60ff8216156127b0577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8016127b8565b600882901c91505b600f8216156127e8577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc016127f0565b600482901c91505b6003821615612820577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01612828565b600282901c91505b60018216156104ba577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01919050565b8082018281101561058e57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff811681146104ba57600080fd5b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915290565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b604080516060810182526000808252602082018190529181019190915290565b80356104ba81612aea565b60008060008060808587031215612935578384fd5b843561294081612aea565b935060208501358015158114612954578384fd5b925060408501359150606085013561296b81612aea565b939692955090935050565b60008060408385031215612988578182fd5b823567ffffffffffffffff8082111561299f578384fd5b818501915085601f8301126129b2578384fd5b81356020828211156129c057fe5b6129f0817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f85011601612ac6565b92508183528781838601011115612a05578586fd5b818185018285013790820181019490945295939092013593505050565b600060a08284031215612a33578081fd5b60405160a0810181811067ffffffffffffffff82111715612a5057fe5b6040528235612a5e81612aea565b81526020830135612a6e81612aea565b602082015260408381013590820152606083013562ffffff81168114612a92578283fd5b6060820152612aa360808401612915565b60808201529392505050565b918252602082015260400190565b90815260200190565b60405181810167ffffffffffffffff81118282101715612ae257fe5b604052919050565b73ffffffffffffffffffffffffffffffffffffffff81168114612b0c57600080fd5b5056fea164736f6c6343000706000a", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c806390405d3614610046578063c6a5026a14610070578063cdca175314610090575b600080fd5b610059610054366004612920565b6100a3565b604051610067929190612aaf565b60405180910390f35b61008361007e366004612a22565b6103f9565b6040516100679190612abd565b61008361009e366004612976565b6104bf565b6000808361011257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f616d6f756e745370656369666965642063616e6e6f74206265207a65726f0000604482015290519081900360640190fd5b60008085139080806101268a8a8a8a610594565b9250925092505b80511580159061016d57508673ffffffffffffffffffffffffffffffffffffffff16816040015173ffffffffffffffffffffffffffffffffffffffff1614155b156103c25761017a61288b565b604082015173ffffffffffffffffffffffffffffffffffffffff16815260608201516101a9908c90868d61063d565b73ffffffffffffffffffffffffffffffffffffffff1660608401819052901515604080850191909152600292830b90920b602084015290830151610204916101f3908d908c6106d2565b6080850151855161ffff8816610753565b60c085015260a0840152608083015273ffffffffffffffffffffffffffffffffffffffff1660408301528415610273576102478160c00151826080015101610979565b825103825260a08101516102699061025e90610979565b6020840151906109ab565b60208301526102ae565b6102808160a00151610979565b825101825260c081015160808201516102a89161029d9101610979565b6020840151906109c1565b60208301525b806060015173ffffffffffffffffffffffffffffffffffffffff16826040015173ffffffffffffffffffffffffffffffffffffffff1614156103675780604001511561033e5760006103048c83602001516109d7565b5050505050509150508a15610317576000035b610325836080015182610aab565b6fffffffffffffffffffffffffffffffff166080840152505b8961034d578060200151610356565b60018160200151035b600290810b900b60608301526103bc565b806000015173ffffffffffffffffffffffffffffffffffffffff16826040015173ffffffffffffffffffffffffffffffffffffffff16146103bc576103af8260400151610bef565b600290810b900b60608301525b5061012d565b831515891515146103db576020810151815189036103e8565b8060000151880381602001515b909b909a5098505050505050505050565b60208101518151606083015160009273ffffffffffffffffffffffffffffffffffffffff808216908416109284926104319290610fbb565b905060008061049c83856104488960400151610979565b60808a015173ffffffffffffffffffffffffffffffffffffffff1615610472578960800151610054565b876104915773fffd8963efd1fc6a506488495d951d5263988d25610054565b6401000276a46100a3565b91509150836104ae57816000036104b3565b806000035b9450505050505b919050565b6000805b60008060006104d187610ff1565b92509250925060006105506040518060a001604052808673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1681526020018981526020018462ffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152506103f9565b9650506001909301928561056388611022565b15610578576105718861102a565b9750610585565b869550505050505061058e565b505050506104c3565b92915050565b60008061059f6128c7565b60006105aa8861105f565b90506105bb878683600001516111a8565b6105c4886112e1565b9350806040015192506040518060a0016040528087815260200160008152602001826000015173ffffffffffffffffffffffffffffffffffffffff168152602001826020015160020b815260200161061b8a61135b565b6fffffffffffffffffffffffffffffffff168152509150509450945094915050565b600080600061064e878787876113a3565b90935091507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff27618600284900b12156106a7577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2761892506106bd565b620d89e8600284900b13156106bd57620d89e892505b6106c6836113bf565b90509450945094915050565b60008361070d578173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161161073d565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16105b6107475782610749565b815b90505b9392505050565b600080808073ffffffffffffffffffffffffffffffffffffffff808916908a1610158187128015906107e55760006107998989620f42400362ffffff16620f4240611752565b9050826107b2576107ad8c8c8c600161181f565b6107bf565b6107bf8b8d8c60016118f2565b95508581106107d0578a96506107df565b6107dc8c8b8386611a0a565b96505b5061082f565b816107fc576107f78b8b8b60006118f2565b610809565b6108098a8c8b600061181f565b935083886000031061081d5789955061082f565b61082c8b8a8a60000385611a6c565b95505b73ffffffffffffffffffffffffffffffffffffffff8a811690871614821561089f5780801561085b5750815b6108715761086c878d8c60016118f2565b610873565b855b9550808015610880575081155b61089657610891878d8c600061181f565b610898565b845b94506108e9565b8080156108a95750815b6108bf576108ba8c888c600161181f565b6108c1565b855b95508080156108ce575081155b6108e4576108df8c888c60006118f2565b6108e6565b845b94505b811580156108f957508860000385115b15610905578860000394505b81801561093e57508a73ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614155b1561094d57858903935061096a565b610967868962ffffff168a620f42400362ffffff16611ace565b93505b50505095509550955095915050565b60007f800000000000000000000000000000000000000000000000000000000000000082106109a757600080fd5b5090565b8082038281131560008312151461058e57600080fd5b8181018281121560008312151461058e57600080fd5b6000806000806000806000808973ffffffffffffffffffffffffffffffffffffffff1663f30dba938a6040518263ffffffff1660e01b8152600401808260020b81526020019150506101006040518083038186803b158015610a3857600080fd5b505afa158015610a4c573d6000803e3d6000fd5b505050506040513d610100811015610a6357600080fd5b508051602082015160408301516060840151608085015160a086015160c087015160e090970151959e50939c50919a5098509650945090925090509295985092959890939650565b60008082600f0b1215610b5757826fffffffffffffffffffffffffffffffff168260000384039150816fffffffffffffffffffffffffffffffff1610610b5257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f4c53000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b61058e565b826fffffffffffffffffffffffffffffffff168284019150816fffffffffffffffffffffffffffffffff16101561058e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600260248201527f4c41000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60006401000276a373ffffffffffffffffffffffffffffffffffffffff831610801590610c45575073fffd8963efd1fc6a506488495d951d5263988d2673ffffffffffffffffffffffffffffffffffffffff8316105b610cb057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f5200000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b77ffffffffffffffffffffffffffffffffffffffff00000000602083901b166fffffffffffffffffffffffffffffffff811160071b81811c67ffffffffffffffff811160061b90811c63ffffffff811160051b90811c61ffff811160041b90811c60ff8111600390811b91821c600f811160021b90811c918211600190811b92831c97908811961790941790921717909117171760808110610d5a57607f810383901c9150610d64565b80607f0383901b91505b908002607f81811c60ff83811c9190911c800280831c81831c1c800280841c81841c1c800280851c81851c1c800280861c81861c1c800280871c81871c1c800280881c81881c1c800280891c81891c1c8002808a1c818a1c1c8002808b1c818b1c1c8002808c1c818c1c1c8002808d1c818d1c1c8002808e1c9c81901c9c909c1c80029c8d901c9e9d7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808f0160401b60c09190911c678000000000000000161760c19b909b1c674000000000000000169a909a1760c29990991c672000000000000000169890981760c39790971c671000000000000000169690961760c49590951c670800000000000000169490941760c59390931c670400000000000000169290921760c69190911c670200000000000000161760c79190911c670100000000000000161760c89190911c6680000000000000161760c99190911c6640000000000000161760ca9190911c6620000000000000161760cb9190911c6610000000000000161760cc9190911c6608000000000000161760cd9190911c66040000000000001617693627a301d71055774c8581027ffffffffffffffffffffffffffffffffffd709b7e5480fba5a50fed5e62ffc5568101608090811d906fdb2df09e81959a81455e260799a0632f8301901d600281810b9083900b14610fac578873ffffffffffffffffffffffffffffffffffffffff16610f83826113bf565b73ffffffffffffffffffffffffffffffffffffffff161115610fa55781610fa7565b805b610fae565b815b9998505050505050505050565b60006107497f0000000000000000000000000000000000000000000000000000000000000000610fec868686611b26565b611ba3565b60008080610fff8482611cd9565b925061100c846014611dd9565b9050611019846017611cd9565b91509193909250565b516042111590565b805160609061058e9083906017907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe901611ec9565b6110676128f5565b8173ffffffffffffffffffffffffffffffffffffffff1663ddca3f436040518163ffffffff1660e01b815260040160206040518083038186803b1580156110ad57600080fd5b505afa1580156110c1573d6000803e3d6000fd5b505050506040513d60208110156110d757600080fd5b505161ffff1660408083019190915280517f3850c7bd000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff841691633850c7bd9160048083019260e0929190829003018186803b15801561114a57600080fd5b505afa15801561115e573d6000803e3d6000fd5b505050506040513d60e081101561117457600080fd5b508051602091820151600290810b900b9183019190915273ffffffffffffffffffffffffffffffffffffffff168152919050565b600083611218578173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16118015611213575073fffd8963efd1fc6a506488495d951d5263988d2673ffffffffffffffffffffffffffffffffffffffff8416105b61126d565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1610801561126d57506401000276a373ffffffffffffffffffffffffffffffffffffffff8416115b9050806112db57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f7371727450726963654c696d6974206f7574206f6620626f756e647300000000604482015290519081900360640190fd5b50505050565b60008173ffffffffffffffffffffffffffffffffffffffff1663d0c93a7c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561132957600080fd5b505afa15801561133d573d6000803e3d6000fd5b505050506040513d602081101561135357600080fd5b505192915050565b60008173ffffffffffffffffffffffffffffffffffffffff16631a6865026040518163ffffffff1660e01b815260040160206040518083038186803b15801561132957600080fd5b6000806113b2868686866120b0565b9150915094509492505050565b60008060008360020b126113d6578260020b6113de565b8260020b6000035b9050620d89e881111561145257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f5400000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60006001821661147357700100000000000000000000000000000000611485565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156114b9576ffff97272373d413259a46990580e213a0260801c5b60048216156114d8576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b60088216156114f7576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615611516576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615611535576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615611554576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615611573576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615611593576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b6102008216156115b3576ff987a7253ac413176f2b074cf7815e540260801c5b6104008216156115d3576ff3392b0822b70005940c7a398e4b70f30260801c5b6108008216156115f3576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615611613576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615611633576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615611653576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615611673576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615611694576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b620200008216156116b4576e5d6af8dedb81196699c329225ee6040260801c5b620400008216156116d3576d2216e584f5fa1ea926041bedfe980260801c5b620800008216156116f0576b048a170391f7dc42444e8fa20260801c5b60008460020b131561172957807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8161172557fe5b0490505b64010000000081061561173d576001611740565b60005b60ff16602082901c0192505050919050565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff858709868602925082811090839003039050806117a6576000841161179b57600080fd5b50829004905061074c565b8084116117b257600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161115611859579293925b816118a5576118a0836fffffffffffffffffffffffffffffffff1686860373ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000611752565b6118e7565b6118e7836fffffffffffffffffffffffffffffffff1686860373ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000611ace565b90505b949350505050565b60008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16111561192c579293925b7bffffffffffffffffffffffffffffffff000000000000000000000000606084901b1673ffffffffffffffffffffffffffffffffffffffff868603811690871661197557600080fd5b836119bf578673ffffffffffffffffffffffffffffffffffffffff166119b283838973ffffffffffffffffffffffffffffffffffffffff16611752565b816119b957fe5b046119ff565b6119ff6119e383838973ffffffffffffffffffffffffffffffffffffffff16611ace565b8873ffffffffffffffffffffffffffffffffffffffff1661231d565b979650505050505050565b6000808573ffffffffffffffffffffffffffffffffffffffff1611611a2e57600080fd5b6000846fffffffffffffffffffffffffffffffff1611611a4d57600080fd5b81611a5f576118a08585856001612328565b6118e78585856001612480565b6000808573ffffffffffffffffffffffffffffffffffffffff1611611a9057600080fd5b6000846fffffffffffffffffffffffffffffffff1611611aaf57600080fd5b81611ac1576118a08585856000612480565b6118e78585856000612328565b6000611adb848484611752565b905060008280611ae757fe5b848609111561074c577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8110611b1c57600080fd5b6001019392505050565b611b2e6128f5565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161115611b66579192915b506040805160608101825273ffffffffffffffffffffffffffffffffffffffff948516815292909316602083015262ffffff169181019190915290565b6000816020015173ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff1610611be557600080fd5b508051602080830151604093840151845173ffffffffffffffffffffffffffffffffffffffff94851681850152939091168385015262ffffff166060808401919091528351808403820181526080840185528051908301207fff0000000000000000000000000000000000000000000000000000000000000060a085015294901b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660a183015260b58201939093527f6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e260d5808301919091528251808303909101815260f5909101909152805191012090565b600081826014011015611d4d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f746f416464726573735f6f766572666c6f770000000000000000000000000000604482015290519081900360640190fd5b8160140183511015611dc057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f746f416464726573735f6f75744f66426f756e64730000000000000000000000604482015290519081900360640190fd5b5001602001516c01000000000000000000000000900490565b600081826003011015611e4d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f746f55696e7432345f6f766572666c6f77000000000000000000000000000000604482015290519081900360640190fd5b8160030183511015611ec057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f746f55696e7432345f6f75744f66426f756e6473000000000000000000000000604482015290519081900360640190fd5b50016003015190565b60608182601f011015611f3d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f736c6963655f6f766572666c6f77000000000000000000000000000000000000604482015290519081900360640190fd5b828284011015611fae57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f736c6963655f6f766572666c6f77000000000000000000000000000000000000604482015290519081900360640190fd5b8183018451101561202057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f736c6963655f6f75744f66426f756e6473000000000000000000000000000000604482015290519081900360640190fd5b60608215801561203f57604051915060008252602082016040526120a7565b6040519150601f8416801560200281840101858101878315602002848b0101015b81831015612078578051835260209283019201612060565b5050858452601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016604052505b50949350505050565b6000808581600286810b9088900b816120c557fe5b05905060008760020b1280156120ec57508560020b8760020b816120e557fe5b0760020b15155b15612114577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff015b841561222f57600080612126836125b6565b604080517f5339c296000000000000000000000000000000000000000000000000000000008152600184810b6004830152915193955091935060ff84161b80017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0191600091839173ffffffffffffffffffffffffffffffffffffffff891691635339c296916024808301926020929190829003018186803b1580156121cb57600080fd5b505afa1580156121df573d6000803e3d6000fd5b505050506040513d60208110156121f557600080fd5b505116801515975090508661221157898360ff16860302612224565b8961221b826125c8565b840360ff168603025b975050505050612312565b60008061223e836001016125b6565b91509150600060018260ff166001901b031990506000818673ffffffffffffffffffffffffffffffffffffffff16635339c296866040518263ffffffff1660e01b8152600401808260010b815260200191505060206040518083038186803b1580156122a957600080fd5b505afa1580156122bd573d6000803e3d6000fd5b505050506040513d60208110156122d357600080fd5b50511680151597509050866122f557898360ff0360ff1686600101010261230b565b898361230083612675565b0360ff168660010101025b9750505050505b505094509492505050565b808204910615150190565b600081156123d057600073ffffffffffffffffffffffffffffffffffffffff84111561237d57612378846c01000000000000000000000000876fffffffffffffffffffffffffffffffff16611752565b61239e565b6fffffffffffffffffffffffffffffffff8516606085901b8161239c57fe5b045b90506123c86123c373ffffffffffffffffffffffffffffffffffffffff881683612858565b612868565b9150506118ea565b600073ffffffffffffffffffffffffffffffffffffffff84111561241d57612418846c01000000000000000000000000876fffffffffffffffffffffffffffffffff16611ace565b61243d565b61243d606085901b6fffffffffffffffffffffffffffffffff871661231d565b9050808673ffffffffffffffffffffffffffffffffffffffff161161246157600080fd5b73ffffffffffffffffffffffffffffffffffffffff86160390506118ea565b60008261248e5750836118ea565b7bffffffffffffffffffffffffffffffff000000000000000000000000606085901b1682156125555773ffffffffffffffffffffffffffffffffffffffff8616848102908582816124db57fe5b041415612519578181018281106125175761250d838973ffffffffffffffffffffffffffffffffffffffff1683611ace565b93505050506118ea565b505b61254c82612547878a73ffffffffffffffffffffffffffffffffffffffff16868161254057fe5b0490612858565b61231d565b925050506118ea565b73ffffffffffffffffffffffffffffffffffffffff86168481029085828161257957fe5b0414801561258657508082115b61258f57600080fd5b80820361250d6123c38473ffffffffffffffffffffffffffffffffffffffff8b1684611ace565b60020b600881901d9161010090910790565b60008082116125d657600080fd5b70010000000000000000000000000000000082106125f657608091821c91015b68010000000000000000821061260e57604091821c91015b640100000000821061262257602091821c91015b62010000821061263457601091821c91015b610100821061264557600891821c91015b6010821061265557600491821c91015b6004821061266557600291821c91015b600282106104ba57600101919050565b600080821161268357600080fd5b5060ff6fffffffffffffffffffffffffffffffff8216156126c5577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80016126cd565b608082901c91505b67ffffffffffffffff821615612704577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00161270c565b604082901c91505b63ffffffff82161561273f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001612747565b602082901c91505b61ffff821615612778577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001612780565b601082901c91505b60ff8216156127b0577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8016127b8565b600882901c91505b600f8216156127e8577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc016127f0565b600482901c91505b6003821615612820577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01612828565b600282901c91505b60018216156104ba577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01919050565b8082018281101561058e57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff811681146104ba57600080fd5b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915290565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b604080516060810182526000808252602082018190529181019190915290565b80356104ba81612aea565b60008060008060808587031215612935578384fd5b843561294081612aea565b935060208501358015158114612954578384fd5b925060408501359150606085013561296b81612aea565b939692955090935050565b60008060408385031215612988578182fd5b823567ffffffffffffffff8082111561299f578384fd5b818501915085601f8301126129b2578384fd5b81356020828211156129c057fe5b6129f0817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f85011601612ac6565b92508183528781838601011115612a05578586fd5b818185018285013790820181019490945295939092013593505050565b600060a08284031215612a33578081fd5b60405160a0810181811067ffffffffffffffff82111715612a5057fe5b6040528235612a5e81612aea565b81526020830135612a6e81612aea565b602082015260408381013590820152606083013562ffffff81168114612a92578283fd5b6060820152612aa360808401612915565b60808201529392505050565b918252602082015260400190565b90815260200190565b60405181810167ffffffffffffffff81118282101715612ae257fe5b604052919050565b73ffffffffffffffffffffffffffffffffffffffff81168114612b0c57600080fd5b5056fea164736f6c6343000706000a", + "devdoc": { + "kind": "dev", + "methods": { + "quoteExactInput(bytes,uint256)": { + "params": { + "amountIn": "The amount of the first token to swap", + "path": "The path of the swap, i.e. each token pair and the pool fee" + }, + "returns": { + "amountOut": "The amount of the last token that would be received" + } + }, + "quoteExactInputSingle((address,address,uint256,uint24,uint160))": { + "params": { + "params": "The params for the quote, encoded as `QuoteExactInputSingleParams` tokenIn The token being swapped in tokenOut The token being swapped out fee The fee of the token pool to consider for the pair amountIn The desired input amount sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap" + }, + "returns": { + "amountOut": "The amount of `tokenOut` that would be received" + } + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "quoteExactInput(bytes,uint256)": { + "notice": "Returns the amount out received for a given exact input swap without executing the swap" + }, + "quoteExactInputSingle((address,address,uint256,uint24,uint160))": { + "notice": "Returns the amount out received for a given exact input but for a swap of a single pool" + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [], + "types": null + } +} \ No newline at end of file diff --git a/package.json b/package.json index fbcf694..886be41 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "@nomiclabs/hardhat-ethers": "^2.0.4", "@nomiclabs/hardhat-etherscan": "^3.0.0", "@nomiclabs/hardhat-waffle": "^2.0.1", + "@pancakeswap/v3-sdk": "^3.5.4", "@types/chai": "^4.3.0", "@types/mocha": "^9.0.0", "@types/node": "^17.0.8", @@ -25,6 +26,8 @@ "typescript": "^4.5.4" }, "dependencies": { + "@pancakeswap/v3-core": "^1.0.2", + "@pancakeswap/v3-periphery": "^1.0.2", "@uniswap/v3-core": "^1.0.1", "@uniswap/v3-periphery": "^1.4.1" } diff --git a/test/addresses.json b/test/addresses.json index a1350e3..f0c78ea 100644 --- a/test/addresses.json +++ b/test/addresses.json @@ -1,101 +1,107 @@ { - "mainnet": { - "tokens": { - "weth": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", - "usdc": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", - "comp": "0xc00e94Cb662C3520282E6f5717214004A7f26888" - }, - "protocols": { - "uniswapV3": { - "quoterV2": "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", - "factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984" - }, - "kyber": { - "factory": "0xC7a590291e07B9fe9E64b86c58fD8fC764308C4A" - } - } + "mainnet": { + "tokens": { + "weth": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", + "usdc": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + "comp": "0xc00e94Cb662C3520282E6f5717214004A7f26888" }, - "base": { - "tokens": { - "weth": "0x4200000000000000000000000000000000000006", - "usdc": "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA" - }, - "protocols": { - "sushiV3": { - "quoterV2": "0xb1E835Dc2785b52265711e17fCCb0fd018226a6e", - "factory": "0xc35DADB65012eC5796536bD9864eD8773aBc74C4" - }, - "uniswapV3": { - "quoterV2": "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a", - "factory": "0x33128a8fC17869897dcE68Ed026d694621f6FDfD" - } - } + "protocols": { + "uniswapV3": { + "quoterV2": "0x61fFE014bA17989E743c5F6cB21bF9697530B21e", + "factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984" + }, + "kyber": { + "factory": "0xC7a590291e07B9fe9E64b86c58fD8fC764308C4A" + } + } + }, + "base": { + "tokens": { + "weth": "0x4200000000000000000000000000000000000006", + "usdc": "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA" }, - "dogechain": { - "tokens": { - "wwdoge": "0xB7ddC6414bf4F5515b52D8BdD69973Ae205ff101", - "usdc": "0x765277EebeCA2e31912C9946eAe1021199B39C61", - "usdt": "0xE3F5a90F9cb311505cd691a46596599aA1A0AD7D", - "eth": "0xB44a9B6905aF7c801311e8F4E76932ee959c663C", - "dc": "0x7B4328c127B85369D9f82ca0503B000D09CF9180" - }, - "protocols": { - "quickswap": { - "pools": {}, - "quoterV2": "0xd8E1E7009802c914b0d39B31Fc1759A865b727B1", - "factory": "0xd2480162Aa7F02Ead7BF4C127465446150D58452" - } - } + "protocols": { + "sushiV3": { + "quoterV2": "0xb1E835Dc2785b52265711e17fCCb0fd018226a6e", + "factory": "0xc35DADB65012eC5796536bD9864eD8773aBc74C4" + }, + "uniswapV3": { + "quoterV2": "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a", + "factory": "0x33128a8fC17869897dcE68Ed026d694621f6FDfD" + } + } + }, + "dogechain": { + "tokens": { + "wwdoge": "0xB7ddC6414bf4F5515b52D8BdD69973Ae205ff101", + "usdc": "0x765277EebeCA2e31912C9946eAe1021199B39C61", + "usdt": "0xE3F5a90F9cb311505cd691a46596599aA1A0AD7D", + "eth": "0xB44a9B6905aF7c801311e8F4E76932ee959c663C", + "dc": "0x7B4328c127B85369D9f82ca0503B000D09CF9180" }, - "polygon": { - "protocols": { - "quickswap": { - "factory": "0x411b0fAcC3489691f28ad58c47006AF5E3Ab3A28" - }, - "kyber": { - "factory": "0xC7a590291e07B9fe9E64b86c58fD8fC764308C4A" - } - } - }, - "arbitrum": { - "tokens": { - "usdt": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9", - "usdc": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", - "arb": "0x912CE59144191C1204E64559FE8253a0e49E6548" - }, - "protocols": { - "camelot": { - "factory": "0xd490F2F6990C0291597fd1247651b4E0dCF684Dd" - }, - "kyber": { - "quoterV2": "0x4d47fd5a29904Dae0Ef51b1c450C9750F15D7856", - "factory": "0xC7a590291e07B9fe9E64b86c58fD8fC764308C4A" - } - } - }, - "optimism": { - "protocols": { - "kyber": { - "factory": "0xC7a590291e07B9fe9E64b86c58fD8fC764308C4A" - } - } + "protocols": { + "quickswap": { + "pools": {}, + "quoterV2": "0xd8E1E7009802c914b0d39B31Fc1759A865b727B1", + "factory": "0xd2480162Aa7F02Ead7BF4C127465446150D58452" + } + } + }, + "polygon": { + "protocols": { + "quickswap": { + "factory": "0x411b0fAcC3489691f28ad58c47006AF5E3Ab3A28" + }, + "kyber": { + "factory": "0xC7a590291e07B9fe9E64b86c58fD8fC764308C4A" + } + } + }, + "arbitrum": { + "tokens": { + "usdt": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9", + "usdc": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", + "arb": "0x912CE59144191C1204E64559FE8253a0e49E6548" }, - "avalanche": { - "protocols": { - "kyber": { - "factory": "0xC7a590291e07B9fe9E64b86c58fD8fC764308C4A" - }, - "uniswapV3": { - "factory": "0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD" - } - } + "protocols": { + "camelot": { + "factory": "0xd490F2F6990C0291597fd1247651b4E0dCF684Dd" + }, + "kyber": { + "quoterV2": "0x4d47fd5a29904Dae0Ef51b1c450C9750F15D7856", + "factory": "0xC7a590291e07B9fe9E64b86c58fD8fC764308C4A" + } + } + }, + "optimism": { + "protocols": { + "kyber": { + "factory": "0xC7a590291e07B9fe9E64b86c58fD8fC764308C4A" + } + } + }, + "avalanche": { + "protocols": { + "kyber": { + "factory": "0xC7a590291e07B9fe9E64b86c58fD8fC764308C4A" + }, + "uniswapV3": { + "factory": "0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD" + } + } + }, + "bsc": { + "tokens": { + "wbnb": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", + "busd": "0x55d398326f99059ff775485246999027b3197955", + "weth": "0x2170Ed0880ac9A755fd29B2688956BD959F933F8" }, - "bsc": { - "protocols": { - "pancakeswapV3": { - "quoterV2": "0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997", - "factory": "0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865" - } - } + "protocols": { + "pancakeswapV3": { + "quoterV2": "0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997", + "factory": "0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865", + "pancakeDeployer": "0x41ff9AA7e16B8B1a8a8dc4f0eFacd93D02d071c9" + } } -} \ No newline at end of file + } +} diff --git a/test/helpers.ts b/test/helpers.ts index c0b0750..bf82acd 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -1,75 +1,105 @@ import { ethers, network, config } from "hardhat"; import { FeeAmount } from "@uniswap/v3-sdk"; +import { FeeAmount as FeeAmountPancake } from "@pancakeswap/v3-sdk"; import { Signer } from "ethers"; -export const setHardhatNetwork = async ( - { forkBlockNumber, chainId, rpcUrl }: - { forkBlockNumber: number, chainId: number, rpcUrl: string } -) => { - return network.provider.request({ - method: "hardhat_reset", - params: [ - { - chainId: chainId, - forking: { - blockNumber: forkBlockNumber, - jsonRpcUrl: rpcUrl, - }, - }, - ], - }); -} +export const setHardhatNetwork = async ({ + forkBlockNumber, + chainId, + rpcUrl, +}: { + forkBlockNumber: number; + chainId: number; + rpcUrl: string; +}) => { + return network.provider.request({ + method: "hardhat_reset", + params: [ + { + chainId: chainId, + forking: { + blockNumber: forkBlockNumber, + jsonRpcUrl: rpcUrl, + }, + }, + ], + }); +}; export type ThenArgRecursive = T extends PromiseLike - ? ThenArgRecursive - : T; + ? ThenArgRecursive + : T; export async function forkNetwork(networkName: string, blockNumber: number) { - const networkConfig = config.networks[networkName]; - await setHardhatNetwork({ - rpcUrl: (networkConfig as any).url, - forkBlockNumber: blockNumber, - chainId: (networkConfig as any).chainId, - }) + const networkConfig = config.networks[networkName]; + await setHardhatNetwork({ + rpcUrl: (networkConfig as any).url, + forkBlockNumber: blockNumber, + chainId: (networkConfig as any).chainId, + }); } export async function deployContract( - deployer: Signer, - contract: string, - args?: any[] + deployer: Signer, + contract: string, + args?: any[] ) { - return ethers.getContractFactory(contract) - .then(f => f.connect(deployer).deploy(...(args || []))) + return ethers + .getContractFactory(contract) + .then((f) => f.connect(deployer).deploy(...(args || []))); } export function encodePath(path: string[], fees: FeeAmount[]): string { - const FEE_SIZE = 3; + const FEE_SIZE = 3; + + if (path.length != fees.length + 1) { + throw new Error("path/fee lengths do not match"); + } + + let encoded = "0x"; + for (let i = 0; i < fees.length; i++) { + // 20 byte encoding of the address + encoded += path[i].slice(2); + // 3 byte encoding of the fee + encoded += fees[i].toString(16).padStart(2 * FEE_SIZE, "0"); + } + // encode the final token + encoded += path[path.length - 1].slice(2); + + return encoded.toLowerCase(); +} - if (path.length != fees.length + 1) { - throw new Error("path/fee lengths do not match") - } - - let encoded = "0x" - for (let i = 0; i < fees.length; i++) { - // 20 byte encoding of the address - encoded += path[i].slice(2) - // 3 byte encoding of the fee - encoded += fees[i].toString(16).padStart(2 * FEE_SIZE, "0") - } - // encode the final token - encoded += path[path.length - 1].slice(2) - - return encoded.toLowerCase() +export function encodePathPancake( + path: string[], + fees: FeeAmountPancake[] +): string { + const FEE_SIZE = 3; + + if (path.length != fees.length + 1) { + throw new Error("path/fee lengths do not match"); + } + + let encoded = "0x"; + for (let i = 0; i < fees.length; i++) { + // 20 byte encoding of the address + encoded += path[i].slice(2); + // 3 byte encoding of the fee + encoded += fees[i].toString(16).padStart(2 * FEE_SIZE, "0"); + } + // encode the final token + encoded += path[path.length - 1].slice(2); + + return encoded.toLowerCase(); } export function encodePathNoFees(path: string[]): string { - let encoded = "0x" - for (let i = 0; i < (path.length-1); i++) { - // 20 byte encoding of the address - encoded += path[i].slice(2) - } - // encode the final token - encoded += path[path.length - 1].slice(2) - - return encoded.toLowerCase() -} \ No newline at end of file + let encoded = "0x"; + for (let i = 0; i < path.length - 1; i++) { + // 20 byte encoding of the address + encoded += path[i].slice(2); + } + // encode the final token + encoded += path[path.length - 1].slice(2); + + return encoded.toLowerCase(); +} diff --git a/test/spec/pancakeV3.spec.ts b/test/spec/pancakeV3.spec.ts new file mode 100644 index 0000000..63dca56 --- /dev/null +++ b/test/spec/pancakeV3.spec.ts @@ -0,0 +1,149 @@ +import { abi as QUOTERV2_ABI } from "@pancakeswap/v3-periphery/artifacts/contracts/lens/QuoterV2.sol/QuoterV2.json"; +import { FeeAmount } from "@pancakeswap/v3-sdk"; +import { BigNumber, Signer } from "ethers"; +import { ethers } from "hardhat"; +import { expect } from "chai"; + +import { + encodePath, + forkNetwork, + deployContract, + ThenArgRecursive, + encodePathPancake, +} from "../helpers"; +import addresses from "../addresses.json"; + +const { pancakeswapV3 } = addresses.bsc.protocols; +const { tokens } = addresses.bsc; + +async function fixture() { + const [deployer] = await ethers.getSigners(); + const reference = await getQuoterV2(); + const quoter = await deployPancakeV3StaticQuoter(deployer); + return { + deployer, + quoter, + reference, + }; +} + +async function getQuoterV2() { + return ethers.getContractAt(QUOTERV2_ABI, pancakeswapV3.quoterV2); +} + +async function deployPancakeV3StaticQuoter(deployer: Signer) { + return deployContract(deployer, "PancakeV3StaticQuoter", [ + pancakeswapV3.pancakeDeployer, + ]); +} + +async function bscFixture(blockNumber: number) { + await forkNetwork("bsc", blockNumber); + return fixture(); +} + +describe("quoter", async () => { + context("bsc", () => { + context("33312606", async () => { + let fix: ThenArgRecursive>; + + beforeEach(async () => { + fix = await bscFixture(33312606); + }); + + it("wbnb .3% busd: 31337 ether", async () => { + const amountIn = ethers.utils.parseEther("31337"); + const amountOut = BigNumber.from("2928637544428191710891"); + + const params = { + tokenIn: tokens.wbnb, + tokenOut: tokens.busd, + amountIn, + fee: FeeAmount.MEDIUM, + sqrtPriceLimitX96: 0, + }; + const referenceOut = + await fix.reference.callStatic.quoteExactInputSingle(params); + expect(referenceOut.amountOut).equals(amountOut); + + const quoterOut = await fix.quoter.quoteExactInputSingle(params); + expect(quoterOut).equals(amountOut); + }); + + it("wbnb .3% busd: 1 wei", async () => { + const amountIn = 1; + const amountOut = 0; + + const params = { + tokenIn: tokens.wbnb, + tokenOut: tokens.busd, + amountIn, + fee: FeeAmount.LOW, + sqrtPriceLimitX96: 0, + }; + + const referenceOut = + await fix.reference.callStatic.quoteExactInputSingle(params); + expect(referenceOut.amountOut).equals(amountOut); + + const quoterOut = await fix.quoter.quoteExactInputSingle(params); + expect(quoterOut).equals(amountOut); + }); + + it("wbnb .3% busd: max", async () => { + const params = { + tokenIn: tokens.wbnb, + tokenOut: tokens.busd, + amountIn: ethers.constants.MaxUint256, + fee: FeeAmount.LOW, + sqrtPriceLimitX96: 0, + }; + + await expect(fix.reference.callStatic.quoteExactInputSingle(params)) + .reverted; + await expect(fix.quoter.quoteExactInputSingle(params)).reverted; + }); + + it("invalid token", async () => { + const params = { + tokenIn: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc3", + tokenOut: tokens.busd, + amountIn: ethers.utils.parseEther("1337"), + fee: FeeAmount.LOW, + sqrtPriceLimitX96: 0, + }; + + await expect(fix.reference.callStatic.quoteExactInputSingle(params)) + .reverted; + await expect(fix.quoter.quoteExactInputSingle(params)).reverted; + }); + }); + + context("33312606", async () => { + let fix: ThenArgRecursive>; + + beforeEach(async () => { + fix = await bscFixture(33312606); + }); + + it("busd .05% wbnb .3% comp: 31337 busd", async () => { + const amountIn = ethers.utils.parseUnits("31337", 6); + const amountOut = BigNumber.from("16553461"); + + const path = encodePathPancake( + [tokens.busd, tokens.wbnb, tokens.weth], + [FeeAmount.LOW, FeeAmount.MEDIUM] + ); + + const referenceOut = await fix.reference.callStatic.quoteExactInput( + path, + amountIn + ); + expect(referenceOut.amountOut).equals(amountOut); + + const quoterOut = await fix.quoter.quoteExactInput(path, amountIn); + expect(quoterOut).equals(amountOut); + }); + }); + }); +}); diff --git a/test/spec/uniswapV3.spec.ts b/test/spec/uniswapV3.spec.ts index 0933f18..d8ad462 100644 --- a/test/spec/uniswapV3.spec.ts +++ b/test/spec/uniswapV3.spec.ts @@ -4,134 +4,144 @@ import { BigNumber, Signer } from "ethers"; import { ethers } from "hardhat"; import { expect } from "chai"; -import { encodePath, forkNetwork, deployContract, ThenArgRecursive } from "../helpers"; +import { + encodePath, + forkNetwork, + deployContract, + ThenArgRecursive, +} from "../helpers"; import addresses from "../addresses.json"; -const { uniswapV3 } = addresses.ethereum.protocols; -const { tokens } = addresses.ethereum; +const { uniswapV3 } = addresses.mainnet.protocols; +const { tokens } = addresses.mainnet; async function fixture() { - const [ deployer ] = await ethers.getSigners(); - const reference = await getQuoterV2(); - const quoter = await deployUniswapV3StaticQuoter(deployer); - return { - deployer, - quoter, - reference - }; + const [deployer] = await ethers.getSigners(); + const reference = await getQuoterV2(); + const quoter = await deployUniswapV3StaticQuoter(deployer); + return { + deployer, + quoter, + reference, + }; } async function getQuoterV2() { - return ethers.getContractAt(QUOTERV2_ABI, uniswapV3.quoterV2); + return ethers.getContractAt(QUOTERV2_ABI, uniswapV3.quoterV2); } async function deployUniswapV3StaticQuoter(deployer: Signer) { - return deployContract( - deployer, - "UniswapV3StaticQuoter", - [uniswapV3.factory] - ) + return deployContract(deployer, "UniswapV3StaticQuoter", [uniswapV3.factory]); } async function ethereumFixture(blockNumber: number) { - await forkNetwork("mainnet", blockNumber); - return fixture(); + await forkNetwork("mainnet", blockNumber); + return fixture(); } describe("quoter", async () => { - context("ethereum", () => { - - context("15013603", async () => { - let fix: ThenArgRecursive>; - - beforeEach(async () => { - fix = await ethereumFixture(15013603); - }); - - it("weth .3% usdc: 31337 eth", async () => { - const amountIn = ethers.utils.parseEther("31337"); - const amountOut = BigNumber.from("31206401855667"); - - const params = { - tokenIn: tokens.weth, - tokenOut: tokens.usdc, - amountIn, - fee: FeeAmount.MEDIUM, - sqrtPriceLimitX96: 0 - }; - - const referenceOut = await fix.reference.callStatic.quoteExactInputSingle(params); - expect(referenceOut.amountOut).equals(amountOut); - - const quoterOut = await fix.quoter.quoteExactInputSingle(params); - expect(quoterOut).equals(amountOut); - }); - - it("weth .3% usdc: 1 wei", async () => { - const amountIn = 1; - const amountOut = 0; - - const params = { - tokenIn: tokens.weth, - tokenOut: tokens.usdc, - amountIn, - fee: FeeAmount.MEDIUM, - sqrtPriceLimitX96: 0 - }; - - const referenceOut = await fix.reference.callStatic.quoteExactInputSingle(params); - expect(referenceOut.amountOut).equals(amountOut); - - const quoterOut = await fix.quoter.quoteExactInputSingle(params); - expect(quoterOut).equals(amountOut); - }); - - it("weth .3% usdc: max", async () => { - const params = { - tokenIn: tokens.weth, - tokenOut: tokens.usdc, - amountIn: ethers.constants.MaxUint256, - fee: FeeAmount.MEDIUM, - sqrtPriceLimitX96: 0 - }; - - await expect(fix.reference.callStatic.quoteExactInputSingle(params)).reverted; - await expect(fix.quoter.quoteExactInputSingle(params)).reverted; - }); - - it("invalid token", async () => { - const params = { - tokenIn: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc3", - tokenOut: tokens.usdc, - amountIn: ethers.utils.parseEther("1337"), - fee: FeeAmount.MEDIUM, - sqrtPriceLimitX96: 0 - }; - - await expect(fix.reference.callStatic.quoteExactInputSingle(params)).reverted; - await expect(fix.quoter.quoteExactInputSingle(params)).reverted; - }); - }); - - context("15014353", async () => { - let fix: ThenArgRecursive>; - - beforeEach(async () => { - fix = await ethereumFixture(15014353); - }); - - it("usdc .05% weth .3% comp: 31337 usdc", async () => { - const amountIn = ethers.utils.parseUnits("31337", 6); - const amountOut = BigNumber.from("687578004838424621671"); - - const path = encodePath([tokens.usdc, tokens.weth, tokens.comp], [FeeAmount.LOW, FeeAmount.MEDIUM]); - - const referenceOut = await fix.reference.callStatic.quoteExactInput(path, amountIn); - expect(referenceOut.amountOut).equals(amountOut); - - const quoterOut = await fix.quoter.quoteExactInput(path, amountIn); - expect(quoterOut).equals(amountOut); - }); - }); + context("ethereum", () => { + context("15013603", async () => { + let fix: ThenArgRecursive>; + + beforeEach(async () => { + fix = await ethereumFixture(15013603); + }); + + it("weth .3% usdc: 31337 eth", async () => { + const amountIn = ethers.utils.parseEther("31337"); + const amountOut = BigNumber.from("31206401855667"); + + const params = { + tokenIn: tokens.weth, + tokenOut: tokens.usdc, + amountIn, + fee: FeeAmount.MEDIUM, + sqrtPriceLimitX96: 0, + }; + + const referenceOut = + await fix.reference.callStatic.quoteExactInputSingle(params); + expect(referenceOut.amountOut).equals(amountOut); + + const quoterOut = await fix.quoter.quoteExactInputSingle(params); + expect(quoterOut).equals(amountOut); + }); + + it("weth .3% usdc: 1 wei", async () => { + const amountIn = 1; + const amountOut = 0; + + const params = { + tokenIn: tokens.weth, + tokenOut: tokens.usdc, + amountIn, + fee: FeeAmount.MEDIUM, + sqrtPriceLimitX96: 0, + }; + + const referenceOut = + await fix.reference.callStatic.quoteExactInputSingle(params); + expect(referenceOut.amountOut).equals(amountOut); + + const quoterOut = await fix.quoter.quoteExactInputSingle(params); + expect(quoterOut).equals(amountOut); + }); + + it("weth .3% usdc: max", async () => { + const params = { + tokenIn: tokens.weth, + tokenOut: tokens.usdc, + amountIn: ethers.constants.MaxUint256, + fee: FeeAmount.MEDIUM, + sqrtPriceLimitX96: 0, + }; + + await expect(fix.reference.callStatic.quoteExactInputSingle(params)) + .reverted; + await expect(fix.quoter.quoteExactInputSingle(params)).reverted; + }); + + it("invalid token", async () => { + const params = { + tokenIn: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc3", + tokenOut: tokens.usdc, + amountIn: ethers.utils.parseEther("1337"), + fee: FeeAmount.MEDIUM, + sqrtPriceLimitX96: 0, + }; + + await expect(fix.reference.callStatic.quoteExactInputSingle(params)) + .reverted; + await expect(fix.quoter.quoteExactInputSingle(params)).reverted; + }); }); + + context("15014353", async () => { + let fix: ThenArgRecursive>; + + beforeEach(async () => { + fix = await ethereumFixture(15014353); + }); + + it("usdc .05% weth .3% comp: 31337 usdc", async () => { + const amountIn = ethers.utils.parseUnits("31337", 6); + const amountOut = BigNumber.from("687578004838424621671"); + + const path = encodePath( + [tokens.usdc, tokens.weth, tokens.comp], + [FeeAmount.LOW, FeeAmount.MEDIUM] + ); + + const referenceOut = await fix.reference.callStatic.quoteExactInput( + path, + amountIn + ); + expect(referenceOut.amountOut).equals(amountOut); + + const quoterOut = await fix.quoter.quoteExactInput(path, amountIn); + expect(quoterOut).equals(amountOut); + }); + }); + }); }); diff --git a/yarn.lock b/yarn.lock index e59a15f..fe53857 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@adraffy/ens-normalize@1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.9.4.tgz#aae21cb858bbb0411949d5b7b3051f4209043f62" + integrity sha512-UK0bHA7hh9cR39V+4gl2/NnBBjoXIxkuWAPCaY4X7fbH4L/azIi7ilWOCjMUYfpJgraLUAqkRi2BqrjME8Rynw== + "@chainsafe/as-sha256@^0.3.1": version "0.3.1" resolved "https://registry.yarnpkg.com/@chainsafe/as-sha256/-/as-sha256-0.3.1.tgz#3639df0e1435cab03f4d9870cc3ac079e57a6fc9" @@ -841,11 +846,23 @@ tweetnacl "^1.0.3" tweetnacl-util "^0.15.1" +"@noble/curves@1.2.0", "@noble/curves@~1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35" + integrity sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw== + dependencies: + "@noble/hashes" "1.3.2" + "@noble/hashes@1.2.0", "@noble/hashes@~1.2.0": version "1.2.0" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.2.0.tgz#a3150eeb09cc7ab207ebf6d7b9ad311a9bdbed12" integrity sha512-FZfhjEDbT5GRswV3C6uvLPHMiVD6lQBmpoX5+eSiPaMTXte/IKqI5dykDxzZB/WBeK/CDuQRBWarPdi3FNY2zQ== +"@noble/hashes@1.3.2", "@noble/hashes@~1.3.0", "@noble/hashes@~1.3.2": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" + integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== + "@noble/secp256k1@1.7.1", "@noble/secp256k1@~1.7.0": version "1.7.1" resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.1.tgz#b251c70f824ce3ca7f8dc3df08d58f005cc0507c" @@ -1080,6 +1097,11 @@ "@types/sinon-chai" "^3.2.3" "@types/web3" "1.0.19" +"@openzeppelin/contracts-upgradeable@3.4.2-solc-0.7": + version "3.4.2-solc-0.7" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-3.4.2-solc-0.7.tgz#9a5cdaf9f65bcd9a3b7e865f44a6f672afe7785e" + integrity sha512-I5iKKS8U9L1XdSxsNAIBQekN0U9hTgdleoyntIdR7Jy3U/z/NZ/1oUM0v5HnUMrmn/bXLvYL94rBvaLF++Ndnw== + "@openzeppelin/contracts@3.4.1-solc-0.7-2": version "3.4.1-solc-0.7-2" resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.1-solc-0.7-2.tgz#371c67ebffe50f551c3146a9eec5fe6ffe862e92" @@ -1090,6 +1112,87 @@ resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.2-solc-0.7.tgz#38f4dbab672631034076ccdf2f3201fab1726635" integrity sha512-W6QmqgkADuFcTLzHL8vVoNBtkwjvQRpYIAom7KiUNoLKghyx3FgH0GBjt8NRvigV1ZmMOBllvE1By1C+bi8WpA== +"@pancakeswap/chains@0.3.0", "@pancakeswap/chains@^0.3.0": + version "0.3.0" + resolved "https://registry.yarnpkg.com/@pancakeswap/chains/-/chains-0.3.0.tgz#e509dfd9c8387f76b893e3a0a5b835331752b32c" + integrity sha512-a4U8pzfxQsnS0nUpvi8qL2X6l2C/IUTFJcmt3UNAQv2L2CPUSryt1rLarG91O1Bb/UMfv90UCPrXJcHWpaYSMg== + +"@pancakeswap/sdk@5.7.2": + version "5.7.2" + resolved "https://registry.yarnpkg.com/@pancakeswap/sdk/-/sdk-5.7.2.tgz#d3923142227e04514927098ebd69733621d36891" + integrity sha512-hn1ZWA8uKFqs2GjW5AMv1smnnlJcKugbwyZRPWTftogch/wQYatvXwmolnTFFUrrvAEKHSsEsxNP4dxrbYq6Vw== + dependencies: + "@pancakeswap/chains" "^0.3.0" + "@pancakeswap/swap-sdk-core" "1.0.0" + big.js "^5.2.2" + decimal.js-light "^2.5.0" + tiny-invariant "^1.1.0" + tiny-warning "^1.0.3" + toformat "^2.0.0" + viem "^1.15.1" + +"@pancakeswap/swap-sdk-core@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@pancakeswap/swap-sdk-core/-/swap-sdk-core-1.0.0.tgz#30ab333943ecca5484cd10cbc493841fb553728d" + integrity sha512-MZBF8FHpCX/ffY8/gd2zz6TpiftwqRouVPr1kB88wm7desYh+E2y4kWPcZX1roWR38UkjBv4/DoXVSDeSTBgRg== + dependencies: + big.js "^5.2.2" + decimal.js-light "^2.5.0" + tiny-invariant "^1.1.0" + tiny-warning "^1.0.3" + toformat "^2.0.0" + +"@pancakeswap/token-lists@0.0.9": + version "0.0.9" + resolved "https://registry.yarnpkg.com/@pancakeswap/token-lists/-/token-lists-0.0.9.tgz#ffa2e7eb4e8d0ef1b8984b22d8b2fb529787693f" + integrity sha512-V11cFNucyiTeEPsS7fyLldr1XsQqPNzdXQDmeGB54M4dESA/bBi9xaWYCVUihyW3lImNoqr2X1fds7SltfFHOQ== + dependencies: + "@pancakeswap/swap-sdk-core" "1.0.0" + ajv "^6.12.3" + lodash "^4.17.21" + +"@pancakeswap/tokens@0.5.4": + version "0.5.4" + resolved "https://registry.yarnpkg.com/@pancakeswap/tokens/-/tokens-0.5.4.tgz#1508b2b71a259a534ddf18ec120d79b8e6e44945" + integrity sha512-NRc8OIiwL1fNbGRQgcTdpaxbjZfTz6sAnkGZlmaLUt9yCGmGF0hK8uqc4B1YGYSVUkgamd3UJS9z7j673PVbxQ== + dependencies: + "@pancakeswap/chains" "0.3.0" + "@pancakeswap/sdk" "5.7.2" + "@pancakeswap/token-lists" "0.0.9" + +"@pancakeswap/v3-core@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@pancakeswap/v3-core/-/v3-core-1.0.2.tgz#f5abf6a98535f33edebbfc11ab40b4fdcee51420" + integrity sha512-9aZU8I1J6SbZOSW7NcNxuyaAC17tGkOaZJM9aJgvl6MMUOExpq0i0EC/jc3HxWbpC8sbZL+8eG544NEJs8CS+w== + +"@pancakeswap/v3-periphery@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@pancakeswap/v3-periphery/-/v3-periphery-1.0.2.tgz#f5b899c60bae0fadcfff1cc2b72c802b9d5a5596" + integrity sha512-kWQhJsAG5Ij1cubKlX0JuJ3GEPFiPBR+NQt77SxHNjk62eallLyfbWJYk2NMnTO0crbjBFO5GKKQAXfp2n76vg== + dependencies: + "@openzeppelin/contracts" "3.4.2-solc-0.7" + "@openzeppelin/contracts-upgradeable" "3.4.2-solc-0.7" + "@uniswap/lib" "^4.0.1-alpha" + "@uniswap/v2-core" "1.0.1" + base64-sol "1.0.1" + +"@pancakeswap/v3-sdk@^3.5.4": + version "3.5.4" + resolved "https://registry.yarnpkg.com/@pancakeswap/v3-sdk/-/v3-sdk-3.5.4.tgz#d3a3b99b92a42b9f1d22b48eddd2b7ca1c6a63ec" + integrity sha512-0ct8VS74aOdfP9RB7+FefnB7IxspMJOp92DcyYISSAUkdoLQ1TDFJqobZjg3782Sv4J5jUvd3I4slOv5r5zcSg== + dependencies: + "@pancakeswap/chains" "0.3.0" + "@pancakeswap/sdk" "5.7.2" + "@pancakeswap/swap-sdk-core" "1.0.0" + "@pancakeswap/tokens" "0.5.4" + "@uniswap/v3-staker" "1.0.0" + big.js "^5.2.2" + decimal.js-light "^2.5.0" + tiny-invariant "^1.1.0" + tiny-warning "^1.0.3" + toformat "^2.0.0" + viem "^1.15.1" + "@resolver-engine/core@^0.3.3": version "0.3.3" resolved "https://registry.yarnpkg.com/@resolver-engine/core/-/core-0.3.3.tgz#590f77d85d45bc7ecc4e06c654f41345db6ca967" @@ -1132,6 +1235,11 @@ resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.1.tgz#ebb651ee52ff84f420097055f4bf46cfba403938" integrity sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA== +"@scure/base@~1.1.2": + version "1.1.3" + resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.3.tgz#8584115565228290a6c6c4961973e0903bb3df2f" + integrity sha512-/+SgoRjLq7Xlf0CWuLHq2LUZeL/w65kfzAPG5NH9pcmBhs+nunQTn4gvdwgMTIXnt9b2C/1SeL2XiysZEyIC9Q== + "@scure/bip32@1.1.5": version "1.1.5" resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.1.5.tgz#d2ccae16dcc2e75bc1d75f5ef3c66a338d1ba300" @@ -1141,6 +1249,15 @@ "@noble/secp256k1" "~1.7.0" "@scure/base" "~1.1.0" +"@scure/bip32@1.3.2": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.3.2.tgz#90e78c027d5e30f0b22c1f8d50ff12f3fb7559f8" + integrity sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA== + dependencies: + "@noble/curves" "~1.2.0" + "@noble/hashes" "~1.3.2" + "@scure/base" "~1.1.2" + "@scure/bip39@1.1.1": version "1.1.1" resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.1.1.tgz#b54557b2e86214319405db819c4b6a370cf340c5" @@ -1149,6 +1266,14 @@ "@noble/hashes" "~1.2.0" "@scure/base" "~1.1.0" +"@scure/bip39@1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.2.1.tgz#5cee8978656b272a917b7871c981e0541ad6ac2a" + integrity sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg== + dependencies: + "@noble/hashes" "~1.3.0" + "@scure/base" "~1.1.0" + "@sentry/core@5.30.0": version "5.30.0" resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.30.0.tgz#6b203664f69e75106ee8b5a2fe1d717379b331f3" @@ -1463,6 +1588,11 @@ resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31" integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ== +abitype@0.9.8: + version "0.9.8" + resolved "https://registry.yarnpkg.com/abitype/-/abitype-0.9.8.tgz#1f120b6b717459deafd213dfbf3a3dd1bf10ae8c" + integrity sha512-puLifILdm+8sjyss4S+fsUN09obiT1g2YW6CtcQF+QDzxR0euzgEB29MZujC6zMk2a6SVmtttq1fc6+YFA7WYQ== + abort-controller@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" @@ -5339,6 +5469,11 @@ isobject@^3.0.0, isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg== +isows@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.3.tgz#93c1cf0575daf56e7120bab5c8c448b0809d0d74" + integrity sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg== + isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" @@ -5783,7 +5918,7 @@ lodash@4.17.20: resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== -lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4: +lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.21, lodash@^4.17.4: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -8309,6 +8444,20 @@ verror@1.10.0: core-util-is "1.0.2" extsprintf "^1.2.0" +viem@^1.15.1: + version "1.18.9" + resolved "https://registry.yarnpkg.com/viem/-/viem-1.18.9.tgz#8be8fe3148b1c6c3bccc853001df98f91a8aeb30" + integrity sha512-eAXtoTwAFA3YEgjTYMb5ZTQrDC0UPx5qyZ4sv90TirVKepcM9mBPksTkC1SSWya0UdxhBmhEBL/CiYMjmGCTWg== + dependencies: + "@adraffy/ens-normalize" "1.9.4" + "@noble/curves" "1.2.0" + "@noble/hashes" "1.3.2" + "@scure/bip32" "1.3.2" + "@scure/bip39" "1.2.1" + abitype "0.9.8" + isows "1.0.3" + ws "8.13.0" + web3-bzz@1.2.11: version "1.2.11" resolved "https://registry.yarnpkg.com/web3-bzz/-/web3-bzz-1.2.11.tgz#41bc19a77444bd5365744596d778b811880f707f" @@ -8701,6 +8850,11 @@ ws@7.4.6: resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c" integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== +ws@8.13.0: + version "8.13.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.13.0.tgz#9a9fb92f93cf41512a0735c8f4dd09b8a1211cd0" + integrity sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA== + ws@^3.0.0: version "3.3.3" resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2"