@juiceswapxyz/v4-sdk 0.0.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/PositionManager.d.ts +169 -0
- package/dist/actionConstants.d.ts +1 -0
- package/dist/entities/index.d.ts +4 -0
- package/dist/entities/pool.d.ts +103 -0
- package/dist/entities/position.d.ts +144 -0
- package/dist/entities/route.d.ts +28 -0
- package/dist/entities/trade.d.ts +220 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/dist/internalConstants.d.ts +46 -0
- package/dist/multicall.d.ts +10 -0
- package/dist/utils/calldata.d.ts +20 -0
- package/dist/utils/currencyMap.d.ts +2 -0
- package/dist/utils/encodeRouteToPath.d.ts +10 -0
- package/dist/utils/hook.d.ts +45 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/pathCurrency.d.ts +4 -0
- package/dist/utils/positionManagerAbi.d.ts +102 -0
- package/dist/utils/priceTickConversions.d.ts +20 -0
- package/dist/utils/sortsBefore.d.ts +2 -0
- package/dist/utils/v4BaseActionsParser.d.ts +45 -0
- package/dist/utils/v4Planner.d.ts +55 -0
- package/dist/utils/v4PositionPlanner.d.ts +12 -0
- package/dist/v4-sdk.cjs.development.js +3511 -0
- package/dist/v4-sdk.cjs.development.js.map +1 -0
- package/dist/v4-sdk.cjs.production.min.js +2 -0
- package/dist/v4-sdk.cjs.production.min.js.map +1 -0
- package/dist/v4-sdk.esm.js +3494 -0
- package/dist/v4-sdk.esm.js.map +1 -0
- package/package.json +98 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v4-sdk.cjs.development.js","sources":["../src/utils/sortsBefore.ts","../src/utils/hook.ts","../src/internalConstants.ts","../src/entities/pool.ts","../src/utils/pathCurrency.ts","../src/entities/route.ts","../src/entities/trade.ts","../src/utils/priceTickConversions.ts","../src/entities/position.ts","../src/utils/encodeRouteToPath.ts","../src/utils/v4Planner.ts","../src/utils/currencyMap.ts","../src/utils/v4PositionPlanner.ts","../src/utils/calldata.ts","../src/utils/v4BaseActionsParser.ts","../src/actionConstants.ts","../src/multicall.ts","../src/utils/positionManagerAbi.ts","../src/PositionManager.ts"],"sourcesContent":["import { Currency } from '@juiceswapxyz/sdk-core'\n\nexport function sortsBefore(currencyA: Currency, currencyB: Currency): boolean {\n if (currencyA.isNative) return true\n if (currencyB.isNative) return false\n return currencyA.wrapped.sortsBefore(currencyB.wrapped)\n}\n","import invariant from 'tiny-invariant'\nimport { isAddress } from 'ethers/lib/utils'\n\nexport type HookPermissions = { [key in HookOptions]: boolean }\n\nexport enum HookOptions {\n AfterRemoveLiquidityReturnsDelta = 'afterRemoveLiquidityReturnsDelta',\n AfterAddLiquidityReturnsDelta = 'afterAddLiquidityReturnsDelta',\n AfterSwapReturnsDelta = 'afterSwapReturnsDelta',\n BeforeSwapReturnsDelta = 'beforeSwapReturnsDelta',\n AfterDonate = 'afterDonate',\n BeforeDonate = 'beforeDonate',\n AfterSwap = 'afterSwap',\n BeforeSwap = 'beforeSwap',\n AfterRemoveLiquidity = 'afterRemoveLiquidity',\n BeforeRemoveLiquidity = 'beforeRemoveLiquidity',\n AfterAddLiquidity = 'afterAddLiquidity',\n BeforeAddLiquidity = 'beforeAddLiquidity',\n AfterInitialize = 'afterInitialize',\n BeforeInitialize = 'beforeInitialize',\n}\n\nexport const hookFlagIndex = {\n [HookOptions.AfterRemoveLiquidityReturnsDelta]: 0,\n [HookOptions.AfterAddLiquidityReturnsDelta]: 1,\n [HookOptions.AfterSwapReturnsDelta]: 2,\n [HookOptions.BeforeSwapReturnsDelta]: 3,\n [HookOptions.AfterDonate]: 4,\n [HookOptions.BeforeDonate]: 5,\n [HookOptions.AfterSwap]: 6,\n [HookOptions.BeforeSwap]: 7,\n [HookOptions.AfterRemoveLiquidity]: 8,\n [HookOptions.BeforeRemoveLiquidity]: 9,\n [HookOptions.AfterAddLiquidity]: 10,\n [HookOptions.BeforeAddLiquidity]: 11,\n [HookOptions.AfterInitialize]: 12,\n [HookOptions.BeforeInitialize]: 13,\n}\n\nexport class Hook {\n public static permissions(address: string): HookPermissions {\n this._checkAddress(address)\n return {\n beforeInitialize: this._hasPermission(address, HookOptions.BeforeInitialize),\n afterInitialize: this._hasPermission(address, HookOptions.AfterInitialize),\n beforeAddLiquidity: this._hasPermission(address, HookOptions.BeforeAddLiquidity),\n afterAddLiquidity: this._hasPermission(address, HookOptions.AfterAddLiquidity),\n beforeRemoveLiquidity: this._hasPermission(address, HookOptions.BeforeRemoveLiquidity),\n afterRemoveLiquidity: this._hasPermission(address, HookOptions.AfterRemoveLiquidity),\n beforeSwap: this._hasPermission(address, HookOptions.BeforeSwap),\n afterSwap: this._hasPermission(address, HookOptions.AfterSwap),\n beforeDonate: this._hasPermission(address, HookOptions.BeforeDonate),\n afterDonate: this._hasPermission(address, HookOptions.AfterDonate),\n beforeSwapReturnsDelta: this._hasPermission(address, HookOptions.BeforeSwapReturnsDelta),\n afterSwapReturnsDelta: this._hasPermission(address, HookOptions.AfterSwapReturnsDelta),\n afterAddLiquidityReturnsDelta: this._hasPermission(address, HookOptions.AfterAddLiquidityReturnsDelta),\n afterRemoveLiquidityReturnsDelta: this._hasPermission(address, HookOptions.AfterRemoveLiquidityReturnsDelta),\n }\n }\n\n public static hasPermission(address: string, hookOption: HookOptions) {\n this._checkAddress(address)\n return this._hasPermission(address, hookOption)\n }\n\n public static hasInitializePermissions(address: string) {\n this._checkAddress(address)\n return (\n this._hasPermission(address, HookOptions.BeforeInitialize) ||\n Hook._hasPermission(address, HookOptions.AfterInitialize)\n )\n }\n\n public static hasLiquidityPermissions(address: string) {\n this._checkAddress(address)\n // this implicitly encapsulates liquidity delta permissions\n return (\n this._hasPermission(address, HookOptions.BeforeAddLiquidity) ||\n Hook._hasPermission(address, HookOptions.AfterAddLiquidity) ||\n Hook._hasPermission(address, HookOptions.BeforeRemoveLiquidity) ||\n Hook._hasPermission(address, HookOptions.AfterRemoveLiquidity)\n )\n }\n\n public static hasSwapPermissions(address: string) {\n this._checkAddress(address)\n // this implicitly encapsulates swap delta permissions\n return this._hasPermission(address, HookOptions.BeforeSwap) || Hook._hasPermission(address, HookOptions.AfterSwap)\n }\n\n public static hasDonatePermissions(address: string) {\n this._checkAddress(address)\n return (\n this._hasPermission(address, HookOptions.BeforeDonate) || Hook._hasPermission(address, HookOptions.AfterDonate)\n )\n }\n\n private static _hasPermission(address: string, hookOption: HookOptions) {\n return !!(parseInt(address, 16) & (1 << hookFlagIndex[hookOption]))\n }\n\n private static _checkAddress(address: string) {\n invariant(isAddress(address), 'invalid address')\n }\n}\n","import JSBI from 'jsbi'\nimport { constants } from 'ethers'\nimport { encodeSqrtRatioX96 } from '@juiceswapxyz/v3-sdk'\n\n// constants used internally but not expected to be used externally\nexport const ADDRESS_ZERO = constants.AddressZero\nexport const NEGATIVE_ONE = JSBI.BigInt(-1)\nexport const ZERO = JSBI.BigInt(0)\nexport const ONE = JSBI.BigInt(1)\nexport const ONE_ETHER = JSBI.exponentiate(JSBI.BigInt(10), JSBI.BigInt(18))\nexport const EMPTY_BYTES = '0x'\n\n// used in liquidity amount math\nexport const Q96 = JSBI.exponentiate(JSBI.BigInt(2), JSBI.BigInt(96))\nexport const Q192 = JSBI.exponentiate(Q96, JSBI.BigInt(2))\n\n// pool setup\nexport const FEE_AMOUNT_LOW = 100\nexport const FEE_AMOUNT_MEDIUM = 3000\nexport const FEE_AMOUNT_HIGHEST = 10_000\nexport const TICK_SPACING_TEN = 10\nexport const TICK_SPACING_SIXTY = 60\n\n// used in position manager math\nexport const MIN_SLIPPAGE_DECREASE = 0\n\n// used when unwrapping weth in positon manager\nexport const OPEN_DELTA = constants.Zero\n\n// default prices\nexport const SQRT_PRICE_1_1 = encodeSqrtRatioX96(1, 1)\n\n// default hook addresses\nexport const EMPTY_HOOK = '0x0000000000000000000000000000000000000000'\n\n// error constants\nexport const NATIVE_NOT_SET = 'NATIVE_NOT_SET'\nexport const ZERO_LIQUIDITY = 'ZERO_LIQUIDITY'\nexport const NO_SQRT_PRICE = 'NO_SQRT_PRICE'\nexport const CANNOT_BURN = 'CANNOT_BURN'\n\n/**\n * Function fragments that exist on the PositionManager contract.\n */\nexport enum PositionFunctions {\n INITIALIZE_POOL = 'initializePool',\n MODIFY_LIQUIDITIES = 'modifyLiquidities',\n // Inherited from PermitForwarder\n PERMIT_BATCH = '0x002a3e3a', // \"permitBatch(address,((address,uint160,uint48,uint48)[],address,uint256),bytes)\"\n // Inherited from ERC721Permit\n ERC721PERMIT_PERMIT = '0x0f5730f1', // \"permit(address,uint256,uint256,uint256,bytes)\"\n}\n\n/**\n * The default factory enabled fee amounts, denominated in hundredths of bips.\n */\nexport enum FeeAmount {\n LOWEST = 100,\n LOW = 500,\n MEDIUM = 3000,\n HIGH = 10000,\n}\n\n/**\n * The default factory tick spacings by fee amount.\n */\nexport const TICK_SPACINGS: { [amount in FeeAmount]: number } = {\n [FeeAmount.LOWEST]: 1,\n [FeeAmount.LOW]: 10,\n [FeeAmount.MEDIUM]: 60,\n [FeeAmount.HIGH]: 200,\n}\n","import invariant from 'tiny-invariant'\nimport { keccak256 } from '@ethersproject/solidity'\nimport { BigintIsh, Currency, CurrencyAmount, Price } from '@juiceswapxyz/sdk-core'\nimport {\n v3Swap,\n NoTickDataProvider,\n Tick,\n TickConstructorArgs,\n TickDataProvider,\n TickListDataProvider,\n TickMath,\n} from '@juiceswapxyz/v3-sdk'\nimport { defaultAbiCoder, isAddress } from 'ethers/lib/utils'\nimport { sortsBefore } from '../utils/sortsBefore'\nimport { Hook } from '../utils/hook'\nimport { ADDRESS_ZERO, NEGATIVE_ONE, Q192 } from '../internalConstants'\nimport JSBI from 'jsbi'\n\nexport const DYNAMIC_FEE_FLAG = 0x800000\nconst NO_TICK_DATA_PROVIDER_DEFAULT = new NoTickDataProvider()\n\nexport type PoolKey = {\n currency0: string\n currency1: string\n fee: number\n tickSpacing: number\n hooks: string\n}\n\n/**\n * Represents a V4 pool\n */\nexport class Pool {\n public readonly currency0: Currency\n public readonly currency1: Currency\n public readonly fee: number\n public readonly tickSpacing: number\n public readonly sqrtRatioX96: JSBI\n public readonly hooks: string // address\n public readonly liquidity: JSBI\n public readonly tickCurrent: number\n public readonly tickDataProvider: TickDataProvider\n public readonly poolKey: PoolKey\n public readonly poolId: string\n\n private _currency0Price?: Price<Currency, Currency>\n private _currency1Price?: Price<Currency, Currency>\n\n public static getPoolKey(\n currencyA: Currency,\n currencyB: Currency,\n fee: number,\n tickSpacing: number,\n hooks: string\n ): PoolKey {\n invariant(isAddress(hooks), 'Invalid hook address')\n\n const [currency0, currency1] = sortsBefore(currencyA, currencyB) ? [currencyA, currencyB] : [currencyB, currencyA]\n const currency0Addr = currency0.isNative ? ADDRESS_ZERO : currency0.wrapped.address\n const currency1Addr = currency1.isNative ? ADDRESS_ZERO : currency1.wrapped.address\n\n return {\n currency0: currency0Addr,\n currency1: currency1Addr,\n fee,\n tickSpacing,\n hooks,\n }\n }\n\n public static getPoolId(\n currencyA: Currency,\n currencyB: Currency,\n fee: number,\n tickSpacing: number,\n hooks: string\n ): string {\n const [currency0, currency1] = sortsBefore(currencyA, currencyB) ? [currencyA, currencyB] : [currencyB, currencyA]\n const currency0Addr = currency0.isNative ? ADDRESS_ZERO : currency0.wrapped.address\n const currency1Addr = currency1.isNative ? ADDRESS_ZERO : currency1.wrapped.address\n return keccak256(\n ['bytes'],\n [\n defaultAbiCoder.encode(\n ['address', 'address', 'uint24', 'int24', 'address'],\n [currency0Addr, currency1Addr, fee, tickSpacing, hooks]\n ),\n ]\n )\n }\n\n /**\n * Construct a pool\n * @param currencyA One of the currencys in the pool\n * @param currencyB The other currency in the pool\n * @param fee The fee in hundredths of a bips of the input amount of every swap that is collected by the pool\n * @param tickSpacing The tickSpacing of the pool\n * @param hooks The address of the hook contract\n * @param sqrtRatioX96 The sqrt of the current ratio of amounts of currency1 to currency0\n * @param liquidity The current value of in range liquidity\n * @param tickCurrent The current tick of the pool\n */\n public constructor(\n currencyA: Currency,\n currencyB: Currency,\n fee: number,\n tickSpacing: number,\n hooks: string,\n sqrtRatioX96: BigintIsh,\n liquidity: BigintIsh,\n tickCurrent: number,\n ticks: TickDataProvider | (Tick | TickConstructorArgs)[] = NO_TICK_DATA_PROVIDER_DEFAULT\n ) {\n invariant(isAddress(hooks), 'Invalid hook address')\n invariant(Number.isInteger(fee) && (fee === DYNAMIC_FEE_FLAG || fee < 1_000_000), 'FEE')\n if (fee === DYNAMIC_FEE_FLAG) {\n invariant(Number(hooks) > 0, 'Dynamic fee pool requires a hook')\n }\n const tickCurrentSqrtRatioX96 = TickMath.getSqrtRatioAtTick(tickCurrent)\n const nextTickSqrtRatioX96 = TickMath.getSqrtRatioAtTick(tickCurrent + 1)\n invariant(\n JSBI.greaterThanOrEqual(JSBI.BigInt(sqrtRatioX96), tickCurrentSqrtRatioX96) &&\n JSBI.lessThanOrEqual(JSBI.BigInt(sqrtRatioX96), nextTickSqrtRatioX96),\n 'PRICE_BOUNDS'\n )\n\n // always create a copy of the list since we want the pool's tick list to be immutable\n ;[this.currency0, this.currency1] = sortsBefore(currencyA, currencyB)\n ? [currencyA, currencyB]\n : [currencyB, currencyA]\n this.fee = fee\n this.sqrtRatioX96 = JSBI.BigInt(sqrtRatioX96)\n this.tickSpacing = tickSpacing\n this.hooks = hooks\n this.liquidity = JSBI.BigInt(liquidity)\n this.tickCurrent = tickCurrent\n this.tickDataProvider = Array.isArray(ticks) ? new TickListDataProvider(ticks, tickSpacing) : ticks\n this.poolKey = Pool.getPoolKey(this.currency0, this.currency1, this.fee, this.tickSpacing, this.hooks)\n this.poolId = Pool.getPoolId(this.currency0, this.currency1, this.fee, this.tickSpacing, this.hooks)\n }\n\n /** backwards compatibility with v2/3 sdks */\n public get token0(): Currency {\n return this.currency0\n }\n public get token1(): Currency {\n return this.currency1\n }\n\n /**\n * Returns true if the currency is either currency0 or currency1\n * @param currency The currency to check\n * @returns True if currency is either currency0 or currency1\n */\n public involvesCurrency(currency: Currency): boolean {\n return currency.equals(this.currency0) || currency.equals(this.currency1)\n }\n /** backwards compatibility with v2/3 sdks */\n public involvesToken(currency: Currency): boolean {\n return this.involvesCurrency(currency)\n }\n\n /**\n * v4-only involvesToken convenience method, used for mixed route ETH <-> WETH connection only\n * @param currency\n */\n public v4InvolvesToken(currency: Currency): boolean {\n return (\n this.involvesCurrency(currency) ||\n currency.wrapped.equals(this.currency0) ||\n currency.wrapped.equals(this.currency1) ||\n currency.wrapped.equals(this.currency0.wrapped) ||\n currency.wrapped.equals(this.currency1.wrapped)\n )\n }\n\n /**\n * Returns the current mid price of the pool in terms of currency0, i.e. the ratio of currency1 over currency0\n */\n public get currency0Price(): Price<Currency, Currency> {\n return (\n this._currency0Price ??\n (this._currency0Price = new Price(\n this.currency0,\n this.currency1,\n Q192,\n JSBI.multiply(this.sqrtRatioX96, this.sqrtRatioX96)\n ))\n )\n }\n /** backwards compatibility with v2/3 sdks */\n public get token0Price(): Price<Currency, Currency> {\n return this.currency0Price\n }\n\n /**\n * Returns the current mid price of the pool in terms of currency1, i.e. the ratio of currency0 over currency1\n */\n public get currency1Price(): Price<Currency, Currency> {\n return (\n this._currency1Price ??\n (this._currency1Price = new Price(\n this.currency1,\n this.currency0,\n JSBI.multiply(this.sqrtRatioX96, this.sqrtRatioX96),\n Q192\n ))\n )\n }\n /** backwards compatibility with v2/3 sdks */\n public get token1Price(): Price<Currency, Currency> {\n return this.currency1Price\n }\n\n /**\n * Return the price of the given currency in terms of the other currency in the pool.\n * @param currency The currency to return price of\n * @returns The price of the given currency, in terms of the other.\n */\n public priceOf(currency: Currency): Price<Currency, Currency> {\n invariant(this.involvesCurrency(currency), 'CURRENCY')\n return currency.equals(this.currency0) ? this.currency0Price : this.currency1Price\n }\n\n /**\n * Returns the chain ID of the currencies in the pool.\n */\n public get chainId(): number {\n return this.currency0.chainId\n }\n\n /** Works only for vanilla hookless v3 pools, otherwise throws an error */\n public async getOutputAmount(\n inputAmount: CurrencyAmount<Currency>,\n sqrtPriceLimitX96?: JSBI\n ): Promise<[CurrencyAmount<Currency>, Pool]> {\n invariant(this.involvesCurrency(inputAmount.currency), 'CURRENCY')\n\n const zeroForOne = inputAmount.currency.equals(this.currency0)\n\n const {\n amountCalculated: outputAmount,\n sqrtRatioX96,\n liquidity,\n tickCurrent,\n } = await this.swap(zeroForOne, inputAmount.quotient, sqrtPriceLimitX96)\n const outputCurrency = zeroForOne ? this.currency1 : this.currency0\n return [\n CurrencyAmount.fromRawAmount(outputCurrency, JSBI.multiply(outputAmount, NEGATIVE_ONE)),\n new Pool(\n this.currency0,\n this.currency1,\n this.fee,\n this.tickSpacing,\n this.hooks,\n sqrtRatioX96,\n liquidity,\n tickCurrent,\n this.tickDataProvider\n ),\n ]\n }\n\n /**\n * Given a desired output amount of a currency, return the computed input amount and a pool with state updated after the trade\n * Works only for vanilla hookless v3 pools, otherwise throws an error\n * @param outputAmount the output amount for which to quote the input amount\n * @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this value after the swap. If one for zero, the price cannot be greater than this value after the swap\n * @returns The input amount and the pool with updated state\n */\n public async getInputAmount(\n outputAmount: CurrencyAmount<Currency>,\n sqrtPriceLimitX96?: JSBI\n ): Promise<[CurrencyAmount<Currency>, Pool]> {\n invariant(this.involvesCurrency(outputAmount.currency), 'CURRENCY')\n\n const zeroForOne = outputAmount.currency.equals(this.currency1)\n\n const {\n amountCalculated: inputAmount,\n sqrtRatioX96,\n liquidity,\n tickCurrent,\n } = await this.swap(zeroForOne, JSBI.multiply(outputAmount.quotient, NEGATIVE_ONE), sqrtPriceLimitX96)\n const inputCurrency = zeroForOne ? this.currency0 : this.currency1\n return [\n CurrencyAmount.fromRawAmount(inputCurrency, inputAmount),\n new Pool(\n this.currency0,\n this.currency1,\n this.fee,\n this.tickSpacing,\n this.hooks,\n sqrtRatioX96,\n liquidity,\n tickCurrent,\n this.tickDataProvider\n ),\n ]\n }\n\n /**\n * Executes a swap\n * @param zeroForOne Whether the amount in is token0 or token1\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 value after the swap. If one for zero, the price cannot be greater than this value after the swap\n * @returns amountCalculated\n * @returns sqrtRatioX96\n * @returns liquidity\n * @returns tickCurrent\n */\n private async swap(\n zeroForOne: boolean,\n amountSpecified: JSBI,\n sqrtPriceLimitX96?: JSBI\n ): Promise<{ amountCalculated: JSBI; sqrtRatioX96: JSBI; liquidity: JSBI; tickCurrent: number }> {\n if (!this.hookImpactsSwap()) {\n return v3Swap(\n JSBI.BigInt(this.fee),\n this.sqrtRatioX96,\n this.tickCurrent,\n this.liquidity,\n this.tickSpacing,\n this.tickDataProvider,\n zeroForOne,\n amountSpecified,\n sqrtPriceLimitX96\n )\n } else {\n throw new Error('Unsupported hook')\n }\n }\n\n private hookImpactsSwap(): boolean {\n // could use this function to clear certain hooks that may have swap Permissions, but we know they don't interfere\n // in the swap outcome\n return Hook.hasSwapPermissions(this.hooks)\n }\n}\n","import { Currency, CurrencyAmount } from '@juiceswapxyz/sdk-core'\nimport { Pool } from '../entities/pool'\n\nexport function amountWithPathCurrency(amount: CurrencyAmount<Currency>, pool: Pool): CurrencyAmount<Currency> {\n return CurrencyAmount.fromFractionalAmount(\n getPathCurrency(amount.currency, pool),\n amount.numerator,\n amount.denominator\n )\n}\n\nexport function getPathCurrency(currency: Currency, pool: Pool): Currency {\n if (pool.involvesCurrency(currency)) {\n return currency\n } else if (pool.involvesCurrency(currency.wrapped)) {\n return currency.wrapped\n } else if (pool.currency0.wrapped.equals(currency)) {\n return pool.currency0\n } else if (pool.currency1.wrapped.equals(currency)) {\n return pool.currency1\n } else {\n throw new Error(\n `Expected currency ${currency.symbol} to be either ${pool.currency0.symbol} or ${pool.currency1.symbol}`\n )\n }\n}\n","import invariant from 'tiny-invariant'\n\nimport { Currency, Price } from '@juiceswapxyz/sdk-core'\nimport { Pool } from './pool'\nimport { getPathCurrency } from '../utils/pathCurrency'\n\n/**\n * Represents a list of pools through which a swap can occur\n * @template TInput The input currency\n * @template TOutput The output currency\n */\nexport class Route<TInput extends Currency, TOutput extends Currency> {\n public readonly pools: Pool[]\n public readonly currencyPath: Currency[]\n public readonly input: TInput\n public readonly output: TOutput\n public readonly pathInput: Currency // equivalent or wrapped/unwrapped input to match pool\n public readonly pathOutput: Currency // equivalent or wrapped/unwrapped output to match pool\n\n private _midPrice: Price<TInput, TOutput> | null = null\n\n /**\n * Creates an instance of route.\n * @param pools An array of `Pool` objects, ordered by the route the swap will take\n * @param input The input currency\n * @param output The output currency\n */\n public constructor(pools: Pool[], input: TInput, output: TOutput) {\n invariant(pools.length > 0, 'POOLS')\n\n const chainId = pools[0].chainId\n const allOnSameChain = pools.every((pool) => pool.chainId === chainId)\n invariant(allOnSameChain, 'CHAIN_IDS')\n\n /**\n * function throws if pools do not involve the input and output currency or the native/wrapped equivalent\n **/\n this.pathInput = getPathCurrency(input, pools[0])\n this.pathOutput = getPathCurrency(output, pools[pools.length - 1])\n\n /**\n * Normalizes currency0-currency1 order and selects the next currency/fee step to add to the path\n * */\n const currencyPath: Currency[] = [this.pathInput]\n for (const [i, pool] of pools.entries()) {\n const currentInputCurrency = currencyPath[i]\n invariant(currentInputCurrency.equals(pool.currency0) || currentInputCurrency.equals(pool.currency1), 'PATH')\n const nextCurrency = currentInputCurrency.equals(pool.currency0) ? pool.currency1 : pool.currency0\n currencyPath.push(nextCurrency)\n }\n\n this.pools = pools\n this.currencyPath = currencyPath\n this.input = input\n this.output = output ?? currencyPath[currencyPath.length - 1]\n }\n\n public get chainId(): number {\n return this.pools[0].chainId\n }\n\n /**\n * Returns the mid price of the route\n */\n public get midPrice(): Price<TInput, TOutput> {\n if (this._midPrice !== null) return this._midPrice\n\n const price = this.pools.slice(1).reduce(\n ({ nextInput, price }, pool) => {\n return nextInput.equals(pool.currency0)\n ? {\n nextInput: pool.currency1,\n price: price.multiply(pool.currency0Price),\n }\n : {\n nextInput: pool.currency0,\n price: price.multiply(pool.currency1Price),\n }\n },\n this.pools[0].currency0.equals(this.input)\n ? {\n nextInput: this.pools[0].currency1,\n price: this.pools[0].currency0Price,\n }\n : {\n nextInput: this.pools[0].currency0,\n price: this.pools[0].currency1Price,\n }\n ).price\n\n return (this._midPrice = new Price(this.input, this.output, price.denominator, price.numerator))\n }\n}\n","import { Currency, Fraction, Percent, Price, sortedInsert, CurrencyAmount, TradeType, Token } from '@juiceswapxyz/sdk-core'\nimport invariant from 'tiny-invariant'\nimport { ONE, ZERO } from '../internalConstants'\nimport { Pool } from './pool'\nimport { Route } from './route'\nimport { amountWithPathCurrency } from '../utils/pathCurrency'\n\n/**\n * Trades comparator, an extension of the input output comparator that also considers other dimensions of the trade in ranking them\n * @template TInput The input currency, either Ether or an ERC-20\n * @template TOutput The output currency, either Ether or an ERC-20\n * @template TTradeType The trade type, either exact input or exact output\n * @param a The first trade to compare\n * @param b The second trade to compare\n * @returns A sorted ordering for two neighboring elements in a trade array\n */\nexport function tradeComparator<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(\n a: Trade<TInput, TOutput, TTradeType>,\n b: Trade<TInput, TOutput, TTradeType>\n) {\n // must have same input and output currency for comparison\n invariant(a.inputAmount.currency.equals(b.inputAmount.currency), 'INPUT_CURRENCY')\n invariant(a.outputAmount.currency.equals(b.outputAmount.currency), 'OUTPUT_CURRENCY')\n if (a.outputAmount.equalTo(b.outputAmount)) {\n if (a.inputAmount.equalTo(b.inputAmount)) {\n // consider the number of hops since each hop costs gas\n const aHops = a.swaps.reduce((total, cur) => total + cur.route.currencyPath.length, 0)\n const bHops = b.swaps.reduce((total, cur) => total + cur.route.currencyPath.length, 0)\n return aHops - bHops\n }\n // trade A requires less input than trade B, so A should come first\n if (a.inputAmount.lessThan(b.inputAmount)) {\n return -1\n } else {\n return 1\n }\n } else {\n // tradeA has less output than trade B, so should come second\n if (a.outputAmount.lessThan(b.outputAmount)) {\n return 1\n } else {\n return -1\n }\n }\n}\n\nexport interface BestTradeOptions {\n // how many results to return\n maxNumResults?: number\n // the maximum number of hops a trade should contain\n maxHops?: number\n}\n\n/**\n * Represents a trade executed against a set of routes where some percentage of the input is\n * split across each route.\n *\n * Each route has its own set of pools. Pools can not be re-used across routes.\n *\n * Does not account for slippage, i.e., changes in price environment that can occur between\n * the time the trade is submitted and when it is executed.\n * @template TInput The input currency, either Ether or an ERC-20\n * @template TOutput The output currency, either Ether or an ERC-20\n * @template TTradeType The trade type, either exact input or exact output\n */\nexport class Trade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType> {\n /**\n * @deprecated Deprecated in favor of 'swaps' property. If the trade consists of multiple routes\n * this will return an error.\n *\n * When the trade consists of just a single route, this returns the route of the trade,\n * i.e. which pools the trade goes through.\n */\n public get route(): Route<TInput, TOutput> {\n invariant(this.swaps.length === 1, 'MULTIPLE_ROUTES')\n return this.swaps[0].route\n }\n\n /**\n * The swaps of the trade, i.e. which routes and how much is swapped in each that\n * make up the trade.\n */\n public readonly swaps: {\n route: Route<TInput, TOutput>\n inputAmount: CurrencyAmount<TInput>\n outputAmount: CurrencyAmount<TOutput>\n }[]\n\n /**\n * The type of the trade, either exact in or exact out.\n */\n public readonly tradeType: TTradeType\n\n /**\n * The cached result of the input amount computation\n * @private\n */\n private _inputAmount: CurrencyAmount<TInput> | undefined\n\n /**\n * The input amount for the trade assuming no slippage.\n */\n public get inputAmount(): CurrencyAmount<TInput> {\n if (this._inputAmount) {\n return this._inputAmount\n }\n\n const inputCurrency = this.swaps[0].inputAmount.currency\n const totalInputFromRoutes = this.swaps\n .map(({ inputAmount }) => inputAmount)\n .reduce((total, cur) => total.add(cur), CurrencyAmount.fromRawAmount(inputCurrency, 0))\n\n this._inputAmount = totalInputFromRoutes\n return this._inputAmount\n }\n\n /**\n * The cached result of the output amount computation\n * @private\n */\n private _outputAmount: CurrencyAmount<TOutput> | undefined\n\n /**\n * The output amount for the trade assuming no slippage.\n */\n public get outputAmount(): CurrencyAmount<TOutput> {\n if (this._outputAmount) {\n return this._outputAmount\n }\n\n const outputCurrency = this.swaps[0].outputAmount.currency\n const totalOutputFromRoutes = this.swaps\n .map(({ outputAmount }) => outputAmount)\n .reduce((total, cur) => total.add(cur), CurrencyAmount.fromRawAmount(outputCurrency, 0))\n\n this._outputAmount = totalOutputFromRoutes\n return this._outputAmount\n }\n\n /**\n * The cached result of the computed execution price\n * @private\n */\n private _executionPrice: Price<TInput, TOutput> | undefined\n\n /**\n * The price expressed in terms of output amount/input amount.\n */\n public get executionPrice(): Price<TInput, TOutput> {\n return (\n this._executionPrice ??\n (this._executionPrice = new Price(\n this.inputAmount.currency,\n this.outputAmount.currency,\n this.inputAmount.quotient,\n this.outputAmount.quotient\n ))\n )\n }\n\n /**\n * The cached result of the price impact computation\n * @private\n */\n private _priceImpact: Percent | undefined\n\n /**\n * Returns the percent difference between the route's mid price and the price impact\n */\n public get priceImpact(): Percent {\n if (this._priceImpact) {\n return this._priceImpact\n }\n\n let spotOutputAmount = CurrencyAmount.fromRawAmount(this.outputAmount.currency, 0)\n for (const { route, inputAmount } of this.swaps) {\n const midPrice = route.midPrice\n spotOutputAmount = spotOutputAmount.add(midPrice.quote(inputAmount))\n }\n\n const priceImpact = spotOutputAmount.subtract(this.outputAmount).divide(spotOutputAmount)\n this._priceImpact = new Percent(priceImpact.numerator, priceImpact.denominator)\n\n return this._priceImpact\n }\n\n /**\n * Constructs an exact in trade with the given amount in and route\n * @template TInput The input currency, either Ether or an ERC-20\n * @template TOutput The output currency, either Ether or an ERC-20\n * @param route The route of the exact in trade\n * @param amountIn The amount being passed in\n * @returns The exact in trade\n */\n public static async exactIn<TInput extends Currency, TOutput extends Currency>(\n route: Route<TInput, TOutput>,\n amountIn: CurrencyAmount<TInput>\n ): Promise<Trade<TInput, TOutput, TradeType.EXACT_INPUT>> {\n return Trade.fromRoute(route, amountIn, TradeType.EXACT_INPUT)\n }\n\n /**\n * Constructs an exact out trade with the given amount out and route\n * @template TInput The input currency, either Ether or an ERC-20\n * @template TOutput The output currency, either Ether or an ERC-20\n * @param route The route of the exact out trade\n * @param amountOut The amount returned by the trade\n * @returns The exact out trade\n */\n public static async exactOut<TInput extends Currency, TOutput extends Currency>(\n route: Route<TInput, TOutput>,\n amountOut: CurrencyAmount<TOutput>\n ): Promise<Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>> {\n return Trade.fromRoute(route, amountOut, TradeType.EXACT_OUTPUT)\n }\n\n /**\n * Constructs a trade by simulating swaps through the given route\n * @template TInput The input currency, either Ether or an ERC-20.\n * @template TOutput The output currency, either Ether or an ERC-20.\n * @template TTradeType The type of the trade, either exact in or exact out.\n * @param route route to swap through\n * @param amount the amount specified, either input or output, depending on tradeType\n * @param tradeType whether the trade is an exact input or exact output swap\n * @returns The route\n */\n public static async fromRoute<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(\n route: Route<TInput, TOutput>,\n amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>,\n tradeType: TTradeType\n ): Promise<Trade<TInput, TOutput, TTradeType>> {\n let inputAmount: CurrencyAmount<TInput>\n let outputAmount: CurrencyAmount<TOutput>\n if (tradeType === TradeType.EXACT_INPUT) {\n invariant(amount.currency.equals(route.input), 'INPUT')\n // Account for trades that wrap/unwrap as a first step\n let tokenAmount: CurrencyAmount<Currency> = amountWithPathCurrency(amount, route.pools[0])\n for (let i = 0; i < route.pools.length; i++) {\n const pool = route.pools[i]\n ;[tokenAmount] = await pool.getOutputAmount(tokenAmount)\n }\n inputAmount = CurrencyAmount.fromFractionalAmount(route.input, amount.numerator, amount.denominator)\n outputAmount = CurrencyAmount.fromFractionalAmount(route.output, tokenAmount.numerator, tokenAmount.denominator)\n } else {\n invariant(amount.currency.equals(route.output), 'OUTPUT')\n // Account for trades that wrap/unwrap as a last step\n let tokenAmount: CurrencyAmount<Currency> = amountWithPathCurrency(amount, route.pools[route.pools.length - 1])\n for (let i = route.pools.length - 1; i >= 0; i--) {\n const pool = route.pools[i]\n ;[tokenAmount] = await pool.getInputAmount(tokenAmount)\n }\n inputAmount = CurrencyAmount.fromFractionalAmount(route.input, tokenAmount.numerator, tokenAmount.denominator)\n outputAmount = CurrencyAmount.fromFractionalAmount(route.output, amount.numerator, amount.denominator)\n }\n\n return new Trade({\n routes: [{ inputAmount, outputAmount, route }],\n tradeType,\n })\n }\n\n /**\n * Constructs a trade from routes by simulating swaps\n *\n * @template TInput The input currency, either Ether or an ERC-20.\n * @template TOutput The output currency, either Ether or an ERC-20.\n * @template TTradeType The type of the trade, either exact in or exact out.\n * @param routes the routes to swap through and how much of the amount should be routed through each\n * @param tradeType whether the trade is an exact input or exact output swap\n * @returns The trade\n */\n public static async fromRoutes<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(\n routes: {\n amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>\n route: Route<TInput, TOutput>\n }[],\n tradeType: TTradeType\n ): Promise<Trade<TInput, TOutput, TTradeType>> {\n const swaps: {\n route: Route<TInput, TOutput>\n inputAmount: CurrencyAmount<TInput>\n outputAmount: CurrencyAmount<TOutput>\n }[] = await Promise.all(\n routes.map(async ({ amount, route }) => {\n const trade = await Trade.fromRoute(route, amount, tradeType)\n return trade.swaps[0]\n })\n )\n\n return new Trade({\n routes: swaps,\n tradeType,\n })\n }\n\n /**\n * Creates a trade without computing the result of swapping through the route. Useful when you have simulated the trade\n * elsewhere and do not have any tick data\n * @template TInput The input currency, either Ether or an ERC-20\n * @template TOutput The output currency, either Ether or an ERC-20\n * @template TTradeType The type of the trade, either exact in or exact out\n * @param constructorArguments The arguments passed to the trade constructor\n * @returns The unchecked trade\n */\n public static createUncheckedTrade<\n TInput extends Currency,\n TOutput extends Currency,\n TTradeType extends TradeType\n >(constructorArguments: {\n route: Route<TInput, TOutput>\n inputAmount: CurrencyAmount<TInput>\n outputAmount: CurrencyAmount<TOutput>\n tradeType: TTradeType\n }): Trade<TInput, TOutput, TTradeType> {\n return new Trade({\n ...constructorArguments,\n routes: [\n {\n inputAmount: constructorArguments.inputAmount,\n outputAmount: constructorArguments.outputAmount,\n route: constructorArguments.route,\n },\n ],\n })\n }\n\n /**\n * Creates a trade without computing the result of swapping through the routes. Useful when you have simulated the trade\n * elsewhere and do not have any tick data\n * @template TInput The input currency, either Ether or an ERC-20\n * @template TOutput The output currency, either Ether or an ERC-20\n * @template TTradeType The type of the trade, either exact in or exact out\n * @param constructorArguments The arguments passed to the trade constructor\n * @returns The unchecked trade\n */\n public static createUncheckedTradeWithMultipleRoutes<\n TInput extends Currency,\n TOutput extends Currency,\n TTradeType extends TradeType\n >(constructorArguments: {\n routes: {\n route: Route<TInput, TOutput>\n inputAmount: CurrencyAmount<TInput>\n outputAmount: CurrencyAmount<TOutput>\n }[]\n tradeType: TTradeType\n }): Trade<TInput, TOutput, TTradeType> {\n return new Trade(constructorArguments)\n }\n\n /**\n * Construct a trade by passing in the pre-computed property values\n * @param routes The routes through which the trade occurs\n * @param tradeType The type of trade, exact input or exact output\n */\n private constructor({\n routes,\n tradeType,\n }: {\n routes: {\n route: Route<TInput, TOutput>\n inputAmount: CurrencyAmount<TInput>\n outputAmount: CurrencyAmount<TOutput>\n }[]\n tradeType: TTradeType\n }) {\n const inputCurrency = routes[0].inputAmount.currency\n const outputCurrency = routes[0].outputAmount.currency\n invariant(\n routes.every(({ route }) => inputCurrency.equals(route.input)),\n 'INPUT_CURRENCY_MATCH'\n )\n invariant(\n routes.every(({ route }) => outputCurrency.equals(route.output)),\n 'OUTPUT_CURRENCY_MATCH'\n )\n\n const numPools = routes.map(({ route }) => route.pools.length).reduce((total, cur) => total + cur, 0)\n const poolIDSet = new Set<string>()\n for (const { route } of routes) {\n for (const pool of route.pools) {\n poolIDSet.add(Pool.getPoolId(pool.currency0, pool.currency1, pool.fee, pool.tickSpacing, pool.hooks))\n }\n }\n\n invariant(numPools === poolIDSet.size, 'POOLS_DUPLICATED')\n\n this.swaps = routes\n this.tradeType = tradeType\n }\n\n /**\n * Get the minimum amount that must be received from this trade for the given slippage tolerance\n * @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade\n * @returns The amount out\n */\n public minimumAmountOut(slippageTolerance: Percent, amountOut = this.outputAmount): CurrencyAmount<TOutput> {\n invariant(!slippageTolerance.lessThan(ZERO), 'SLIPPAGE_TOLERANCE')\n if (this.tradeType === TradeType.EXACT_OUTPUT) {\n return amountOut\n } else {\n const slippageAdjustedAmountOut = new Fraction(ONE)\n .add(slippageTolerance)\n .invert()\n .multiply(amountOut.quotient).quotient\n return CurrencyAmount.fromRawAmount(amountOut.currency, slippageAdjustedAmountOut)\n }\n }\n\n /**\n * Get the maximum amount in that can be spent via this trade for the given slippage tolerance\n * @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade\n * @returns The amount in\n */\n public maximumAmountIn(slippageTolerance: Percent, amountIn = this.inputAmount): CurrencyAmount<TInput> {\n invariant(!slippageTolerance.lessThan(ZERO), 'SLIPPAGE_TOLERANCE')\n if (this.tradeType === TradeType.EXACT_INPUT) {\n return amountIn\n } else {\n const slippageAdjustedAmountIn = new Fraction(ONE).add(slippageTolerance).multiply(amountIn.quotient).quotient\n return CurrencyAmount.fromRawAmount(amountIn.currency, slippageAdjustedAmountIn)\n }\n }\n\n /**\n * Return the execution price after accounting for slippage tolerance\n * @param slippageTolerance the allowed tolerated slippage\n * @returns The execution price\n */\n public worstExecutionPrice(slippageTolerance: Percent): Price<TInput, TOutput> {\n return new Price(\n this.inputAmount.currency,\n this.outputAmount.currency,\n this.maximumAmountIn(slippageTolerance).quotient,\n this.minimumAmountOut(slippageTolerance).quotient\n )\n }\n\n /**\n * Given a list of pools, and a fixed amount in, returns the top `maxNumResults` trades that go from an input currency\n * amount to an output currency, making at most `maxHops` hops.\n * Note this does not consider aggregation, as routes are linear. It's possible a better route exists by splitting\n * the amount in among multiple routes.\n * @param pools the pools to consider in finding the best trade\n * @param nextAmountIn exact amount of input currency to spend\n * @param currencyOut the desired currency out\n * @param maxNumResults maximum number of results to return\n * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pool\n * @param currentPools used in recursion; the current list of pools\n * @param currencyAmountIn used in recursion; the original value of the currencyAmountIn parameter\n * @param bestTrades used in recursion; the current list of best trades\n * @returns The exact in trade\n */\n public static async bestTradeExactIn<TInput extends Currency, TOutput extends Currency>(\n pools: Pool[],\n currencyAmountIn: CurrencyAmount<TInput>,\n currencyOut: TOutput,\n { maxNumResults = 3, maxHops = 3 }: BestTradeOptions = {},\n // used in recursion.\n currentPools: Pool[] = [],\n nextAmountIn: CurrencyAmount<Currency> = currencyAmountIn,\n bestTrades: Trade<TInput, TOutput, TradeType.EXACT_INPUT>[] = []\n ): Promise<Trade<TInput, TOutput, TradeType.EXACT_INPUT>[]> {\n invariant(pools.length > 0, 'POOLS')\n invariant(maxHops > 0, 'MAX_HOPS')\n invariant(currencyAmountIn === nextAmountIn || currentPools.length > 0, 'INVALID_RECURSION')\n\n const amountIn = nextAmountIn\n for (let i = 0; i < pools.length; i++) {\n const pool = pools[i]\n // pool irrelevant\n if (!pool.currency0.equals(amountIn.currency) && !pool.currency1.equals(amountIn.currency)) continue\n\n let amountOut: CurrencyAmount<Token | Currency>\n try {\n ;[amountOut] = await pool.getOutputAmount(amountIn)\n } catch (error) {\n // input too low\n if ((error as any).isInsufficientInputAmountError) {\n continue\n }\n throw error\n }\n // we have arrived at the output currency, so this is the final trade of one of the paths\n if (amountOut.currency.equals(currencyOut)) {\n sortedInsert(\n bestTrades,\n await Trade.fromRoute(\n new Route([...currentPools, pool], currencyAmountIn.currency, currencyOut),\n currencyAmountIn,\n TradeType.EXACT_INPUT\n ),\n maxNumResults,\n tradeComparator\n )\n } else if (maxHops > 1 && pools.length > 1) {\n const poolsExcludingThisPool = pools.slice(0, i).concat(pools.slice(i + 1, pools.length))\n\n // otherwise, consider all the other paths that lead from this currency as long as we have not exceeded maxHops\n await Trade.bestTradeExactIn(\n poolsExcludingThisPool,\n currencyAmountIn,\n currencyOut,\n {\n maxNumResults,\n maxHops: maxHops - 1,\n },\n [...currentPools, pool],\n amountOut,\n bestTrades\n )\n }\n }\n return bestTrades\n }\n\n /**\n * similar to the above method but instead targets a fixed output amount\n * given a list of pools, and a fixed amount out, returns the top `maxNumResults` trades that go from an input currency\n * to an output currency amount, making at most `maxHops` hops\n * note this does not consider aggregation, as routes are linear. it's possible a better route exists by splitting\n * the amount in among multiple routes.\n * @param pools the pools to consider in finding the best trade\n * @param currencyIn the currency to spend\n * @param currencyAmountOut the desired currency amount out\n * @param nextAmountOut the exact amount of currency out\n * @param maxNumResults maximum number of results to return\n * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pool\n * @param currentPools used in recursion; the current list of pools\n * @param bestTrades used in recursion; the current list of best trades\n * @returns The exact out trade\n */\n public static async bestTradeExactOut<TInput extends Currency, TOutput extends Currency>(\n pools: Pool[],\n currencyIn: TInput,\n currencyAmountOut: CurrencyAmount<TOutput>,\n { maxNumResults = 3, maxHops = 3 }: BestTradeOptions = {},\n // used in recursion.\n currentPools: Pool[] = [],\n nextAmountOut: CurrencyAmount<Currency> = currencyAmountOut,\n bestTrades: Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>[] = []\n ): Promise<Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>[]> {\n invariant(pools.length > 0, 'POOLS')\n invariant(maxHops > 0, 'MAX_HOPS')\n invariant(currencyAmountOut === nextAmountOut || currentPools.length > 0, 'INVALID_RECURSION')\n\n const amountOut = nextAmountOut\n for (let i = 0; i < pools.length; i++) {\n const pool = pools[i]\n // pool irrelevant\n if (!pool.currency0.equals(amountOut.currency) && !pool.currency1.equals(amountOut.currency)) continue\n\n let amountIn: CurrencyAmount<Token | Currency>\n try {\n ;[amountIn] = await pool.getInputAmount(amountOut)\n } catch (error) {\n // not enough liquidity in this pool\n if ((error as any).isInsufficientReservesError) {\n continue\n }\n throw error\n }\n // we have arrived at the input currency, so this is the first trade of one of the paths\n if (amountIn.currency.equals(currencyIn)) {\n sortedInsert(\n bestTrades,\n await Trade.fromRoute(\n new Route([pool, ...currentPools], currencyIn, currencyAmountOut.currency),\n currencyAmountOut,\n TradeType.EXACT_OUTPUT\n ),\n maxNumResults,\n tradeComparator\n )\n } else if (maxHops > 1 && pools.length > 1) {\n const poolsExcludingThisPool = pools.slice(0, i).concat(pools.slice(i + 1, pools.length))\n\n // otherwise, consider all the other paths that arrive at this currency as long as we have not exceeded maxHops\n await Trade.bestTradeExactOut(\n poolsExcludingThisPool,\n currencyIn,\n currencyAmountOut,\n {\n maxNumResults,\n maxHops: maxHops - 1,\n },\n [pool, ...currentPools],\n amountIn,\n bestTrades\n )\n }\n }\n\n return bestTrades\n }\n}\n","import { Price, Currency } from '@juiceswapxyz/sdk-core'\nimport JSBI from 'jsbi'\nimport { Q192 } from '../internalConstants'\nimport { TickMath, encodeSqrtRatioX96 } from '@juiceswapxyz/v3-sdk'\nimport { sortsBefore } from '../utils/sortsBefore'\n\n/**\n * This library is the almost the same as v3-sdk priceTickConversion except\n * that it accepts a Currency type instead of a Token type,\n * and thus uses some helper functions defined for the Currency type over the Token type.\n */\n\n/**\n * Returns a price object corresponding to the input tick and the base/quote token\n * Inputs must be tokens because the address order is used to interpret the price represented by the tick\n * @param baseToken the base token of the price\n * @param quoteToken the quote token of the price\n * @param tick the tick for which to return the price\n */\nexport function tickToPrice(baseCurrency: Currency, quoteCurrency: Currency, tick: number): Price<Currency, Currency> {\n const sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick)\n\n const ratioX192 = JSBI.multiply(sqrtRatioX96, sqrtRatioX96)\n\n return sortsBefore(baseCurrency, quoteCurrency)\n ? new Price(baseCurrency, quoteCurrency, Q192, ratioX192)\n : new Price(baseCurrency, quoteCurrency, ratioX192, Q192)\n}\n\n/**\n * Returns the first tick for which the given price is greater than or equal to the tick price\n * @param price for which to return the closest tick that represents a price less than or equal to the input price,\n * i.e. the price of the returned tick is less than or equal to the input price\n */\nexport function priceToClosestTick(price: Price<Currency, Currency>): number {\n const sorted = sortsBefore(price.baseCurrency, price.quoteCurrency)\n\n const sqrtRatioX96 = sorted\n ? encodeSqrtRatioX96(price.numerator, price.denominator)\n : encodeSqrtRatioX96(price.denominator, price.numerator)\n\n let tick = TickMath.getTickAtSqrtRatio(sqrtRatioX96)\n const nextTickPrice = tickToPrice(price.baseCurrency, price.quoteCurrency, tick + 1)\n if (sorted) {\n if (!price.lessThan(nextTickPrice)) {\n tick++\n }\n } else {\n if (!price.greaterThan(nextTickPrice)) {\n tick++\n }\n }\n return tick\n}\n","import { BigintIsh, Percent, Price, CurrencyAmount, Currency, MaxUint256 } from '@juiceswapxyz/sdk-core'\nimport JSBI from 'jsbi'\nimport invariant from 'tiny-invariant'\nimport { Pool } from './pool'\nimport { encodeSqrtRatioX96, maxLiquidityForAmounts, SqrtPriceMath, TickMath } from '@juiceswapxyz/v3-sdk'\nimport { ZERO } from '../internalConstants'\nimport { tickToPrice } from '../utils/priceTickConversions'\nimport { AllowanceTransferPermitBatch } from '../PositionManager'\n\ninterface PositionConstructorArgs {\n pool: Pool\n liquidity: BigintIsh\n tickLower: number\n tickUpper: number\n}\n\n/**\n * Represents a position on a Uniswap V4 Pool\n * @dev Similar to the V3 implementation\n * - using Currency instead of Token\n * - keep in mind that Pool and liquidity must be fetched from the pool manager\n */\nexport class Position {\n public readonly pool: Pool\n public readonly tickLower: number\n public readonly tickUpper: number\n public readonly liquidity: JSBI // TODO: needs to be fetched from pool manager\n\n // cached resuts for the getters\n private _token0Amount: CurrencyAmount<Currency> | null = null\n private _token1Amount: CurrencyAmount<Currency> | null = null\n private _mintAmounts: Readonly<{ amount0: JSBI; amount1: JSBI }> | null = null\n\n /**\n * Constructs a position for a given pool with the given liquidity\n * @param pool For which pool the liquidity is assigned\n * @param liquidity The amount of liquidity that is in the position\n * @param tickLower The lower tick of the position\n * @param tickUpper The upper tick of the position\n */\n public constructor({ pool, liquidity, tickLower, tickUpper }: PositionConstructorArgs) {\n invariant(tickLower < tickUpper, 'TICK_ORDER')\n invariant(tickLower >= TickMath.MIN_TICK && tickLower % pool.tickSpacing === 0, 'TICK_LOWER')\n invariant(tickUpper <= TickMath.MAX_TICK && tickUpper % pool.tickSpacing === 0, 'TICK_UPPER')\n\n this.pool = pool\n this.tickLower = tickLower\n this.tickUpper = tickUpper\n this.liquidity = JSBI.BigInt(liquidity)\n }\n\n /**\n * Returns the price of token0 at the lower tick\n */\n public get token0PriceLower(): Price<Currency, Currency> {\n return tickToPrice(this.pool.currency0, this.pool.currency1, this.tickLower)\n }\n\n /**\n * Returns the price of token0 at the upper tick\n */\n public get token0PriceUpper(): Price<Currency, Currency> {\n return tickToPrice(this.pool.currency0, this.pool.currency1, this.tickUpper)\n }\n\n /**\n * Returns the amount of token0 that this position's liquidity could be burned for at the current pool price\n */\n public get amount0(): CurrencyAmount<Currency> {\n if (!this._token0Amount) {\n if (this.pool.tickCurrent < this.tickLower) {\n this._token0Amount = CurrencyAmount.fromRawAmount(\n this.pool.currency0,\n SqrtPriceMath.getAmount0Delta(\n TickMath.getSqrtRatioAtTick(this.tickLower),\n TickMath.getSqrtRatioAtTick(this.tickUpper),\n this.liquidity,\n false\n )\n )\n } else if (this.pool.tickCurrent < this.tickUpper) {\n this._token0Amount = CurrencyAmount.fromRawAmount(\n this.pool.currency0,\n SqrtPriceMath.getAmount0Delta(\n this.pool.sqrtRatioX96,\n TickMath.getSqrtRatioAtTick(this.tickUpper),\n this.liquidity,\n false\n )\n )\n } else {\n this._token0Amount = CurrencyAmount.fromRawAmount(this.pool.currency0, ZERO)\n }\n }\n return this._token0Amount\n }\n\n /**\n * Returns the amount of token1 that this position's liquidity could be burned for at the current pool price\n */\n public get amount1(): CurrencyAmount<Currency> {\n if (!this._token1Amount) {\n if (this.pool.tickCurrent < this.tickLower) {\n this._token1Amount = CurrencyAmount.fromRawAmount(this.pool.currency1, ZERO)\n } else if (this.pool.tickCurrent < this.tickUpper) {\n this._token1Amount = CurrencyAmount.fromRawAmount(\n this.pool.currency1,\n SqrtPriceMath.getAmount1Delta(\n TickMath.getSqrtRatioAtTick(this.tickLower),\n this.pool.sqrtRatioX96,\n this.liquidity,\n false\n )\n )\n } else {\n this._token1Amount = CurrencyAmount.fromRawAmount(\n this.pool.currency1,\n SqrtPriceMath.getAmount1Delta(\n TickMath.getSqrtRatioAtTick(this.tickLower),\n TickMath.getSqrtRatioAtTick(this.tickUpper),\n this.liquidity,\n false\n )\n )\n }\n }\n return this._token1Amount\n }\n\n /**\n * Returns the lower and upper sqrt ratios if the price 'slips' up to slippage tolerance percentage\n * @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert\n * @returns The sqrt ratios after slippage\n */\n private ratiosAfterSlippage(slippageTolerance: Percent): { sqrtRatioX96Lower: JSBI; sqrtRatioX96Upper: JSBI } {\n const priceLower = this.pool.token0Price.asFraction.multiply(new Percent(1).subtract(slippageTolerance))\n const priceUpper = this.pool.token0Price.asFraction.multiply(slippageTolerance.add(1))\n let sqrtRatioX96Lower = encodeSqrtRatioX96(priceLower.numerator, priceLower.denominator)\n if (JSBI.lessThanOrEqual(sqrtRatioX96Lower, TickMath.MIN_SQRT_RATIO)) {\n sqrtRatioX96Lower = JSBI.add(TickMath.MIN_SQRT_RATIO, JSBI.BigInt(1))\n }\n let sqrtRatioX96Upper = encodeSqrtRatioX96(priceUpper.numerator, priceUpper.denominator)\n if (JSBI.greaterThanOrEqual(sqrtRatioX96Upper, TickMath.MAX_SQRT_RATIO)) {\n sqrtRatioX96Upper = JSBI.subtract(TickMath.MAX_SQRT_RATIO, JSBI.BigInt(1))\n }\n return {\n sqrtRatioX96Lower,\n sqrtRatioX96Upper,\n }\n }\n\n /**\n * Returns the maximum amount of token0 and token1 that must be sent in order to safely mint the amount of liquidity held by the position\n * with the given slippage tolerance\n * @param slippageTolerance Tolerance of unfavorable slippage from the current price\n * @returns The amounts, with slippage\n * @dev In v4, minting and increasing is protected by maximum amounts of token0 and token1.\n */\n public mintAmountsWithSlippage(slippageTolerance: Percent): Readonly<{ amount0: JSBI; amount1: JSBI }> {\n // get lower/upper prices\n // these represent the lowest and highest prices that the pool is allowed to \"slip\" to\n const { sqrtRatioX96Upper, sqrtRatioX96Lower } = this.ratiosAfterSlippage(slippageTolerance)\n\n // construct counterfactual pools from the lower bounded price and the upper bounded price\n const poolLower = new Pool(\n this.pool.token0,\n this.pool.token1,\n this.pool.fee,\n this.pool.tickSpacing,\n this.pool.hooks,\n sqrtRatioX96Lower,\n 0 /* liquidity doesn't matter */,\n TickMath.getTickAtSqrtRatio(sqrtRatioX96Lower)\n )\n const poolUpper = new Pool(\n this.pool.token0,\n this.pool.token1,\n this.pool.fee,\n this.pool.tickSpacing,\n this.pool.hooks,\n sqrtRatioX96Upper,\n 0 /* liquidity doesn't matter */,\n TickMath.getTickAtSqrtRatio(sqrtRatioX96Upper)\n )\n\n // Note: Slippage derivation in v4 is different from v3.\n // When creating a position (minting) or adding to a position (increasing) slippage is bounded by the MAXIMUM amount in in token0 and token1.\n // The largest amount of token1 will happen when the price slips up, so we use the poolUpper to get amount1.\n // The largest amount of token0 will happen when the price slips down, so we use the poolLower to get amount0.\n // Ie...We want the larger amounts, which occurs at the upper price for amount1...\n const { amount1 } = new Position({\n pool: poolUpper,\n liquidity: this.liquidity, // The precise liquidity calculated offchain\n tickLower: this.tickLower,\n tickUpper: this.tickUpper,\n }).mintAmounts\n // ...and the lower for amount0\n const { amount0 } = new Position({\n pool: poolLower,\n liquidity: this.liquidity, // The precise liquidity calculated offchain\n tickLower: this.tickLower,\n tickUpper: this.tickUpper,\n }).mintAmounts\n\n return { amount0, amount1 }\n }\n\n /**\n * Returns the minimum amounts that should be requested in order to safely burn the amount of liquidity held by the\n * position with the given slippage tolerance\n * @param slippageTolerance tolerance of unfavorable slippage from the current price\n * @returns The amounts, with slippage\n */\n public burnAmountsWithSlippage(slippageTolerance: Percent): Readonly<{ amount0: JSBI; amount1: JSBI }> {\n // get lower/upper prices\n const { sqrtRatioX96Upper, sqrtRatioX96Lower } = this.ratiosAfterSlippage(slippageTolerance)\n\n // construct counterfactual pools\n const poolLower = new Pool(\n this.pool.currency0,\n this.pool.currency1,\n this.pool.fee,\n this.pool.tickSpacing,\n this.pool.hooks,\n sqrtRatioX96Lower,\n 0 /* liquidity doesn't matter */,\n TickMath.getTickAtSqrtRatio(sqrtRatioX96Lower)\n )\n const poolUpper = new Pool(\n this.pool.currency0,\n this.pool.currency1,\n this.pool.fee,\n this.pool.tickSpacing,\n this.pool.hooks,\n sqrtRatioX96Upper,\n 0 /* liquidity doesn't matter */,\n TickMath.getTickAtSqrtRatio(sqrtRatioX96Upper)\n )\n\n // we want the smaller amounts...\n // ...which occurs at the upper price for amount0...\n const amount0 = new Position({\n pool: poolUpper,\n liquidity: this.liquidity,\n tickLower: this.tickLower,\n tickUpper: this.tickUpper,\n }).amount0\n // ...and the lower for amount1\n const amount1 = new Position({\n pool: poolLower,\n liquidity: this.liquidity,\n tickLower: this.tickLower,\n tickUpper: this.tickUpper,\n }).amount1\n\n return { amount0: amount0.quotient, amount1: amount1.quotient }\n }\n\n /**\n * Returns the minimum amounts that must be sent in order to mint the amount of liquidity held by the position at\n * the current price for the pool\n */\n public get mintAmounts(): Readonly<{ amount0: JSBI; amount1: JSBI }> {\n if (this._mintAmounts === null) {\n if (this.pool.tickCurrent < this.tickLower) {\n return {\n amount0: SqrtPriceMath.getAmount0Delta(\n TickMath.getSqrtRatioAtTick(this.tickLower),\n TickMath.getSqrtRatioAtTick(this.tickUpper),\n this.liquidity,\n true\n ),\n amount1: ZERO,\n }\n } else if (this.pool.tickCurrent < this.tickUpper) {\n return {\n amount0: SqrtPriceMath.getAmount0Delta(\n this.pool.sqrtRatioX96,\n TickMath.getSqrtRatioAtTick(this.tickUpper),\n this.liquidity,\n true\n ),\n amount1: SqrtPriceMath.getAmount1Delta(\n TickMath.getSqrtRatioAtTick(this.tickLower),\n this.pool.sqrtRatioX96,\n this.liquidity,\n true\n ),\n }\n } else {\n return {\n amount0: ZERO,\n amount1: SqrtPriceMath.getAmount1Delta(\n TickMath.getSqrtRatioAtTick(this.tickLower),\n TickMath.getSqrtRatioAtTick(this.tickUpper),\n this.liquidity,\n true\n ),\n }\n }\n }\n return this._mintAmounts\n }\n\n /**\n * Returns the AllowanceTransferPermitBatch for adding liquidity to a position\n * @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert\n * @param spender The spender of the permit (should usually be the PositionManager)\n * @param nonce A valid permit2 nonce\n * @param deadline The deadline for the permit\n */\n public permitBatchData(\n slippageTolerance: Percent,\n spender: string,\n nonce: BigintIsh,\n deadline: BigintIsh\n ): AllowanceTransferPermitBatch {\n const { amount0, amount1 } = this.mintAmountsWithSlippage(slippageTolerance)\n return {\n details: [\n {\n token: this.pool.currency0.wrapped.address,\n amount: amount0,\n expiration: deadline,\n nonce: nonce,\n },\n {\n token: this.pool.currency1.wrapped.address,\n amount: amount1,\n expiration: deadline,\n nonce: nonce,\n },\n ],\n spender,\n sigDeadline: deadline,\n }\n }\n\n /**\n * Computes the maximum amount of liquidity received for a given amount of token0, token1,\n * and the prices at the tick boundaries.\n * @param pool The pool for which the position should be created\n * @param tickLower The lower tick of the position\n * @param tickUpper The upper tick of the position\n * @param amount0 token0 amountzw\n * @param amount1 token1 amount\n * @param useFullPrecision If false, liquidity will be maximized according to what the router can calculate,\n * not what core can theoretically support\n * @returns The amount of liquidity for the position\n */\n public static fromAmounts({\n pool,\n tickLower,\n tickUpper,\n amount0,\n amount1,\n useFullPrecision,\n }: {\n pool: Pool\n tickLower: number\n tickUpper: number\n amount0: BigintIsh\n amount1: BigintIsh\n useFullPrecision: boolean\n }) {\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower)\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper)\n return new Position({\n pool,\n tickLower,\n tickUpper,\n liquidity: maxLiquidityForAmounts(\n pool.sqrtRatioX96,\n sqrtRatioAX96,\n sqrtRatioBX96,\n amount0,\n amount1,\n useFullPrecision\n ),\n })\n }\n\n /**\n * Computes a position with the maximum amount of liquidity received for a given amount of token0, assuming an unlimited amount of token1\n * @param pool The pool for which the position is created\n * @param tickLower The lower tick\n * @param tickUpper The upper tick\n * @param amount0 The desired amount of token0\n * @param useFullPrecision If true, liquidity will be maximized according to what the router can calculate,\n * not what core can theoretically support\n * @returns The position\n */\n public static fromAmount0({\n pool,\n tickLower,\n tickUpper,\n amount0,\n useFullPrecision,\n }: {\n pool: Pool\n tickLower: number\n tickUpper: number\n amount0: BigintIsh\n useFullPrecision: boolean\n }) {\n return Position.fromAmounts({ pool, tickLower, tickUpper, amount0, amount1: MaxUint256, useFullPrecision })\n }\n\n /**\n * Computes a position with the maximum amount of liquidity received for a given amount of token1, assuming an unlimited amount of token0\n * @param pool The pool for which the position is created\n * @param tickLower The lower tick\n * @param tickUpper The upper tick\n * @param amount1 The desired amount of token1\n * @returns The position\n */\n public static fromAmount1({\n pool,\n tickLower,\n tickUpper,\n amount1,\n }: {\n pool: Pool\n tickLower: number\n tickUpper: number\n amount1: BigintIsh\n }) {\n // this function always uses full precision,\n return Position.fromAmounts({ pool, tickLower, tickUpper, amount0: MaxUint256, amount1, useFullPrecision: true })\n }\n}\n","import { Currency } from '@juiceswapxyz/sdk-core'\nimport { Route } from '../entities/route'\nimport { ADDRESS_ZERO } from '../internalConstants'\n\nexport type PathKey = {\n intermediateCurrency: string // address\n fee: number\n tickSpacing: number\n hooks: string // address\n hookData: string // bytes\n}\n\nexport const encodeRouteToPath = (route: Route<Currency, Currency>, exactOutput?: boolean): PathKey[] => {\n // create a deep copy of pools so that we don't tamper with pool array on route\n let pools = route.pools.map((p) => p)\n if (exactOutput) pools = pools.reverse()\n let startingCurrency = exactOutput ? route.pathOutput : route.pathInput\n let pathKeys: PathKey[] = []\n\n for (let pool of pools) {\n const nextCurrency = startingCurrency.equals(pool.currency0) ? pool.currency1 : pool.currency0\n\n pathKeys.push({\n intermediateCurrency: nextCurrency.isNative ? ADDRESS_ZERO : nextCurrency.address,\n fee: pool.fee,\n tickSpacing: pool.tickSpacing,\n hooks: pool.hooks,\n hookData: '0x',\n })\n\n startingCurrency = nextCurrency\n }\n\n return exactOutput ? pathKeys.reverse() : pathKeys\n}\n","import invariant from 'tiny-invariant'\nimport { defaultAbiCoder } from 'ethers/lib/utils'\nimport { BigNumber } from 'ethers'\nimport { Currency, Percent, TradeType } from '@juiceswapxyz/sdk-core'\nimport { Trade } from '../entities/trade'\nimport { ADDRESS_ZERO, EMPTY_BYTES } from '../internalConstants'\nimport { encodeRouteToPath } from './encodeRouteToPath'\n/**\n * Actions\n * @description Constants that define what action to perform\n * Not all actions are supported yet.\n * @enum {number}\n */\nexport enum Actions {\n // pool actions\n // liquidity actions\n INCREASE_LIQUIDITY = 0x00,\n DECREASE_LIQUIDITY = 0x01,\n MINT_POSITION = 0x02,\n BURN_POSITION = 0x03,\n\n // for fee on transfer tokens\n // INCREASE_LIQUIDITY_FROM_DELTAS = 0x04,\n // MINT_POSITION_FROM_DELTAS = 0x05,\n\n // swapping\n SWAP_EXACT_IN_SINGLE = 0x06,\n SWAP_EXACT_IN = 0x07,\n SWAP_EXACT_OUT_SINGLE = 0x08,\n SWAP_EXACT_OUT = 0x09,\n\n // closing deltas on the pool manager\n // settling\n SETTLE = 0x0b,\n SETTLE_ALL = 0x0c,\n SETTLE_PAIR = 0x0d,\n // taking\n TAKE = 0x0e,\n TAKE_ALL = 0x0f,\n TAKE_PORTION = 0x10,\n TAKE_PAIR = 0x11,\n\n CLOSE_CURRENCY = 0x12,\n // CLEAR_OR_TAKE = 0x13,\n SWEEP = 0x14,\n\n // for wrapping/unwrapping native\n // WRAP = 0x15,\n UNWRAP = 0x16,\n}\n\nexport enum Subparser {\n V4SwapExactInSingle,\n V4SwapExactIn,\n V4SwapExactOutSingle,\n V4SwapExactOut,\n PoolKey,\n}\n\nexport type ParamType = {\n readonly name: string\n readonly type: string\n readonly subparser?: Subparser\n}\n\nconst POOL_KEY_STRUCT = '(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)'\n\nconst PATH_KEY_STRUCT = '(address intermediateCurrency,uint256 fee,int24 tickSpacing,address hooks,bytes hookData)'\n\nconst SWAP_EXACT_IN_SINGLE_STRUCT =\n '(' + POOL_KEY_STRUCT + ' poolKey,bool zeroForOne,uint128 amountIn,uint128 amountOutMinimum,bytes hookData)'\n\nconst SWAP_EXACT_IN_STRUCT =\n '(address currencyIn,' + PATH_KEY_STRUCT + '[] path,uint128 amountIn,uint128 amountOutMinimum)'\n\nconst SWAP_EXACT_OUT_SINGLE_STRUCT =\n '(' + POOL_KEY_STRUCT + ' poolKey,bool zeroForOne,uint128 amountOut,uint128 amountInMaximum,bytes hookData)'\n\nconst SWAP_EXACT_OUT_STRUCT =\n '(address currencyOut,' + PATH_KEY_STRUCT + '[] path,uint128 amountOut,uint128 amountInMaximum)'\n\nexport const V4_BASE_ACTIONS_ABI_DEFINITION: { [key in Actions]: readonly ParamType[] } = {\n // Liquidity commands\n [Actions.INCREASE_LIQUIDITY]: [\n { name: 'tokenId', type: 'uint256' },\n { name: 'liquidity', type: 'uint256' },\n { name: 'amount0Max', type: 'uint128' },\n { name: 'amount1Max', type: 'uint128' },\n { name: 'hookData', type: 'bytes' },\n ],\n [Actions.DECREASE_LIQUIDITY]: [\n { name: 'tokenId', type: 'uint256' },\n { name: 'liquidity', type: 'uint256' },\n { name: 'amount0Min', type: 'uint128' },\n { name: 'amount1Min', type: 'uint128' },\n { name: 'hookData', type: 'bytes' },\n ],\n [Actions.MINT_POSITION]: [\n { name: 'poolKey', type: POOL_KEY_STRUCT, subparser: Subparser.PoolKey },\n { name: 'tickLower', type: 'int24' },\n { name: 'tickUpper', type: 'int24' },\n { name: 'liquidity', type: 'uint256' },\n { name: 'amount0Max', type: 'uint128' },\n { name: 'amount1Max', type: 'uint128' },\n { name: 'owner', type: 'address' },\n { name: 'hookData', type: 'bytes' },\n ],\n [Actions.BURN_POSITION]: [\n { name: 'tokenId', type: 'uint256' },\n { name: 'amount0Min', type: 'uint128' },\n { name: 'amount1Min', type: 'uint128' },\n { name: 'hookData', type: 'bytes' },\n ],\n\n // Swapping commands\n [Actions.SWAP_EXACT_IN_SINGLE]: [\n { name: 'swap', type: SWAP_EXACT_IN_SINGLE_STRUCT, subparser: Subparser.V4SwapExactInSingle },\n ],\n [Actions.SWAP_EXACT_IN]: [{ name: 'swap', type: SWAP_EXACT_IN_STRUCT, subparser: Subparser.V4SwapExactIn }],\n [Actions.SWAP_EXACT_OUT_SINGLE]: [\n { name: 'swap', type: SWAP_EXACT_OUT_SINGLE_STRUCT, subparser: Subparser.V4SwapExactOutSingle },\n ],\n [Actions.SWAP_EXACT_OUT]: [{ name: 'swap', type: SWAP_EXACT_OUT_STRUCT, subparser: Subparser.V4SwapExactOut }],\n\n // Payments commands\n [Actions.SETTLE]: [\n { name: 'currency', type: 'address' },\n { name: 'amount', type: 'uint256' },\n { name: 'payerIsUser', type: 'bool' },\n ],\n [Actions.SETTLE_ALL]: [\n { name: 'currency', type: 'address' },\n { name: 'maxAmount', type: 'uint256' },\n ],\n [Actions.SETTLE_PAIR]: [\n { name: 'currency0', type: 'address' },\n { name: 'currency1', type: 'address' },\n ],\n [Actions.TAKE]: [\n { name: 'currency', type: 'address' },\n { name: 'recipient', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n [Actions.TAKE_ALL]: [\n { name: 'currency', type: 'address' },\n { name: 'minAmount', type: 'uint256' },\n ],\n [Actions.TAKE_PORTION]: [\n { name: 'currency', type: 'address' },\n { name: 'recipient', type: 'address' },\n { name: 'bips', type: 'uint256' },\n ],\n [Actions.TAKE_PAIR]: [\n { name: 'currency0', type: 'address' },\n { name: 'currency1', type: 'address' },\n { name: 'recipient', type: 'address' },\n ],\n [Actions.CLOSE_CURRENCY]: [{ name: 'currency', type: 'address' }],\n [Actions.SWEEP]: [\n { name: 'currency', type: 'address' },\n { name: 'recipient', type: 'address' },\n ],\n [Actions.UNWRAP]: [{ name: 'amount', type: 'uint256' }],\n}\n\nconst FULL_DELTA_AMOUNT = 0\n\nexport class V4Planner {\n actions: string\n params: string[]\n\n constructor() {\n this.actions = EMPTY_BYTES\n this.params = []\n }\n\n addAction(type: Actions, parameters: any[]): V4Planner {\n let command = createAction(type, parameters)\n this.params.push(command.encodedInput)\n this.actions = this.actions.concat(command.action.toString(16).padStart(2, '0'))\n return this\n }\n\n addTrade(trade: Trade<Currency, Currency, TradeType>, slippageTolerance?: Percent): V4Planner {\n const exactOutput = trade.tradeType === TradeType.EXACT_OUTPUT\n\n // exactInput we sometimes perform aggregated slippage checks, but not with exactOutput\n if (exactOutput) invariant(!!slippageTolerance, 'ExactOut requires slippageTolerance')\n invariant(trade.swaps.length === 1, 'Only accepts Trades with 1 swap (must break swaps into individual trades)')\n\n const actionType = exactOutput ? Actions.SWAP_EXACT_OUT : Actions.SWAP_EXACT_IN\n\n const currencyIn = currencyAddress(trade.route.pathInput)\n const currencyOut = currencyAddress(trade.route.pathOutput)\n\n this.addAction(actionType, [\n exactOutput\n ? {\n currencyOut,\n path: encodeRouteToPath(trade.route, exactOutput),\n amountInMaximum: trade.maximumAmountIn(slippageTolerance ?? new Percent(0)).quotient.toString(),\n amountOut: trade.outputAmount.quotient.toString(),\n }\n : {\n currencyIn,\n path: encodeRouteToPath(trade.route, exactOutput),\n amountIn: trade.inputAmount.quotient.toString(),\n amountOutMinimum: slippageTolerance ? trade.minimumAmountOut(slippageTolerance).quotient.toString() : 0,\n },\n ])\n return this\n }\n\n addSettle(currency: Currency, payerIsUser: boolean, amount?: BigNumber): V4Planner {\n this.addAction(Actions.SETTLE, [currencyAddress(currency), amount ?? FULL_DELTA_AMOUNT, payerIsUser])\n return this\n }\n\n addTake(currency: Currency, recipient: string, amount?: BigNumber): V4Planner {\n const takeAmount = amount ?? FULL_DELTA_AMOUNT\n this.addAction(Actions.TAKE, [currencyAddress(currency), recipient, takeAmount])\n return this\n }\n\n addUnwrap(amount: BigNumber): V4Planner {\n this.addAction(Actions.UNWRAP, [amount])\n return this\n }\n\n finalize(): string {\n return defaultAbiCoder.encode(['bytes', 'bytes[]'], [this.actions, this.params])\n }\n}\n\nfunction currencyAddress(currency: Currency): string {\n return currency.isNative ? ADDRESS_ZERO : currency.wrapped.address\n}\n\ntype RouterAction = {\n action: Actions\n encodedInput: string\n}\n\nfunction createAction(action: Actions, parameters: any[]): RouterAction {\n const encodedInput = defaultAbiCoder.encode(\n V4_BASE_ACTIONS_ABI_DEFINITION[action].map((v) => v.type),\n parameters\n )\n return { action, encodedInput }\n}\n","import { Currency } from '@juiceswapxyz/sdk-core'\nimport { ADDRESS_ZERO } from '../internalConstants'\n\n// Uniswap v4 supports native pools. Those currencies are represented by the zero address.\n// TODO: Figure out if this is how we should be handling weird edge case tokens like CELO/Polygon/etc..\n// Does interface treat those like ERC20 tokens or NATIVE tokens?\nexport function toAddress(currency: Currency): string {\n if (currency.isNative) return ADDRESS_ZERO\n else return currency.wrapped.address\n}\n","import { Actions, V4Planner } from './v4Planner'\nimport { Pool } from '../entities'\nimport { BigintIsh, Currency } from '@juiceswapxyz/sdk-core'\nimport { toAddress } from '../utils/currencyMap'\nimport { EMPTY_BYTES } from '../internalConstants'\n\n// A wrapper around V4Planner to help handle PositionManager actions\nexport class V4PositionPlanner extends V4Planner {\n // MINT_POSITION\n addMint(\n pool: Pool,\n tickLower: number,\n tickUpper: number,\n liquidity: BigintIsh,\n amount0Max: BigintIsh,\n amount1Max: BigintIsh,\n owner: string,\n hookData: string = EMPTY_BYTES\n ): void {\n const inputs = [\n Pool.getPoolKey(pool.currency0, pool.currency1, pool.fee, pool.tickSpacing, pool.hooks),\n tickLower,\n tickUpper,\n liquidity.toString(),\n amount0Max.toString(),\n amount1Max.toString(),\n owner,\n hookData,\n ]\n this.addAction(Actions.MINT_POSITION, inputs)\n }\n\n // INCREASE_LIQUIDITY\n addIncrease(\n tokenId: BigintIsh,\n liquidity: BigintIsh,\n amount0Max: BigintIsh,\n amount1Max: BigintIsh,\n hookData: string = EMPTY_BYTES\n ): void {\n const inputs = [tokenId.toString(), liquidity.toString(), amount0Max.toString(), amount1Max.toString(), hookData]\n this.addAction(Actions.INCREASE_LIQUIDITY, inputs)\n }\n\n // DECREASE_LIQUIDITY\n addDecrease(\n tokenId: BigintIsh,\n liquidity: BigintIsh,\n amount0Min: BigintIsh,\n amount1Min: BigintIsh,\n hookData: string = EMPTY_BYTES\n ): void {\n const inputs = [tokenId.toString(), liquidity.toString(), amount0Min.toString(), amount1Min.toString(), hookData]\n this.addAction(Actions.DECREASE_LIQUIDITY, inputs)\n }\n\n // BURN_POSITION\n addBurn(tokenId: BigintIsh, amount0Min: BigintIsh, amount1Min: BigintIsh, hookData: string = EMPTY_BYTES): void {\n const inputs = [tokenId.toString(), amount0Min.toString(), amount1Min.toString(), hookData]\n this.addAction(Actions.BURN_POSITION, inputs)\n }\n\n // SETTLE_PAIR\n addSettlePair(currency0: Currency, currency1: Currency): void {\n const inputs = [toAddress(currency0), toAddress(currency1)]\n this.addAction(Actions.SETTLE_PAIR, inputs)\n }\n\n // TAKE_PAIR\n addTakePair(currency0: Currency, currency1: Currency, recipient: string): void {\n const inputs = [toAddress(currency0), toAddress(currency1), recipient]\n this.addAction(Actions.TAKE_PAIR, inputs)\n }\n\n // SWEEP\n addSweep(currency: Currency, to: string): void {\n const inputs = [toAddress(currency), to]\n this.addAction(Actions.SWEEP, inputs)\n }\n}\n","import { BigintIsh } from '@juiceswapxyz/sdk-core'\nimport JSBI from 'jsbi'\n\n/**\n * Generated method parameters for executing a call.\n */\nexport interface MethodParameters {\n /**\n * The hex encoded calldata to perform the given operation\n */\n calldata: string\n /**\n * The amount of ether (wei) to send in hex.\n */\n value: string\n}\n\n/**\n * Converts a big int to a hex string\n * @param bigintIsh\n * @returns The hex encoded calldata\n */\nexport function toHex(bigintIsh: BigintIsh) {\n const bigInt = JSBI.BigInt(bigintIsh)\n let hex = bigInt.toString(16)\n if (hex.length % 2 !== 0) {\n hex = `0${hex}`\n }\n return `0x${hex}`\n}\n","import { ethers } from 'ethers'\nimport { PoolKey } from '../entities/pool'\nimport { PathKey } from './encodeRouteToPath'\nimport { Actions, Subparser, V4_BASE_ACTIONS_ABI_DEFINITION } from './v4Planner'\n\nexport type Param = {\n readonly name: string\n readonly value: any\n}\n\nexport type V4RouterAction = {\n readonly actionName: string\n readonly actionType: Actions\n readonly params: readonly Param[]\n}\n\nexport type V4RouterCall = {\n readonly actions: readonly V4RouterAction[]\n}\n\nexport type SwapExactInSingle = {\n readonly poolKey: PoolKey\n readonly zeroForOne: boolean\n readonly amountIn: string\n readonly amountOutMinimum: string\n readonly hookData: string\n}\n\nexport type SwapExactIn = {\n readonly currencyIn: string\n readonly path: readonly PathKey[]\n readonly amountIn: string\n readonly amountOutMinimum: string\n}\n\nexport type SwapExactOutSingle = {\n readonly poolKey: PoolKey\n readonly zeroForOne: boolean\n readonly amountOut: string\n readonly amountInMaximum: string\n readonly hookData: string\n}\n\nexport type SwapExactOut = {\n readonly currencyOut: string\n readonly path: readonly PathKey[]\n readonly amountOut: string\n readonly amountInMaximum: string\n}\n\n// Parses V4Router actions\nexport abstract class V4BaseActionsParser {\n public static parseCalldata(calldata: string): V4RouterCall {\n const [actions, inputs] = ethers.utils.defaultAbiCoder.decode(['bytes', 'bytes[]'], calldata)\n\n const actionTypes = V4BaseActionsParser.getActions(actions)\n\n return {\n actions: actionTypes.map((actionType: Actions, i: number) => {\n const abiDef = V4_BASE_ACTIONS_ABI_DEFINITION[actionType]\n const rawParams = ethers.utils.defaultAbiCoder.decode(\n abiDef.map((command) => command.type),\n inputs[i]\n )\n const params = rawParams.map((param, j) => {\n switch (abiDef[j].subparser) {\n case Subparser.V4SwapExactInSingle:\n return {\n name: abiDef[j].name,\n value: parseV4ExactInSingle(param),\n }\n case Subparser.V4SwapExactIn:\n return {\n name: abiDef[j].name,\n value: parseV4ExactIn(param),\n }\n case Subparser.V4SwapExactOutSingle:\n return {\n name: abiDef[j].name,\n value: parseV4ExactOutSingle(param),\n }\n case Subparser.V4SwapExactOut:\n return {\n name: abiDef[j].name,\n value: parseV4ExactOut(param),\n }\n case Subparser.PoolKey:\n return {\n name: abiDef[j].name,\n value: parsePoolKey(param),\n }\n default:\n return {\n name: abiDef[j].name,\n value: param,\n }\n }\n })\n\n return {\n actionName: Actions[actionType],\n actionType,\n params,\n }\n }),\n }\n }\n\n // parse command types from bytes string\n private static getActions(actions: string): Actions[] {\n const actionTypes = []\n\n for (let i = 2; i < actions.length; i += 2) {\n const byte = actions.substring(i, i + 2)\n actionTypes.push(parseInt(byte, 16) as Actions)\n }\n\n return actionTypes\n }\n}\n\nfunction parsePoolKey(data: string): PoolKey {\n const [currency0, currency1, fee, tickSpacing, hooks] = data\n\n return {\n currency0,\n currency1,\n fee: parseInt(fee),\n tickSpacing: parseInt(tickSpacing),\n hooks,\n }\n}\n\nfunction parsePathKey(data: string): PathKey {\n const [intermediateCurrency, fee, tickSpacing, hooks, hookData] = data\n\n return {\n intermediateCurrency,\n fee: parseInt(fee),\n tickSpacing: parseInt(tickSpacing),\n hooks,\n hookData,\n }\n}\n\nfunction parseV4ExactInSingle(data: any[]): SwapExactInSingle {\n const [poolKey, zeroForOne, amountIn, amountOutMinimum, hookData] = data\n const [currency0, currency1, fee, tickSpacing, hooks] = poolKey\n return {\n poolKey: {\n currency0,\n currency1,\n fee,\n tickSpacing,\n hooks,\n },\n zeroForOne,\n amountIn,\n amountOutMinimum,\n hookData,\n }\n}\n\nfunction parseV4ExactIn(data: any[]): SwapExactIn {\n const [currencyIn, path, amountIn, amountOutMinimum] = data\n const paths: readonly PathKey[] = path.map((pathKey: string) => parsePathKey(pathKey))\n\n return {\n path: paths,\n currencyIn,\n amountIn,\n amountOutMinimum,\n }\n}\n\nfunction parseV4ExactOutSingle(data: any[]): SwapExactOutSingle {\n const [poolKey, zeroForOne, amountOut, amountInMaximum, hookData] = data\n const { currency0, currency1, fee, tickSpacing, hooks } = poolKey\n\n return {\n poolKey: {\n currency0,\n currency1,\n fee,\n tickSpacing,\n hooks,\n },\n zeroForOne,\n amountOut,\n amountInMaximum,\n hookData,\n }\n}\n\nfunction parseV4ExactOut(data: any[]): SwapExactOut {\n const [currencyOut, path, amountOut, amountInMaximum] = data\n const paths: readonly PathKey[] = path.map((pathKey: string) => parsePathKey(pathKey))\n\n return {\n path: paths,\n currencyOut,\n amountOut,\n amountInMaximum,\n }\n}\n","// Shared Action Constants used in the v4 Router and v4 position manager\nexport const MSG_SENDER = '0x0000000000000000000000000000000000000001'\n","import { Interface } from '@ethersproject/abi'\nimport IMulticall from '@uniswap/v3-periphery/artifacts/contracts/interfaces/IMulticall.sol/IMulticall.json'\n\nexport abstract class Multicall {\n public static INTERFACE: Interface = new Interface(IMulticall.abi)\n\n /**\n * Cannot be constructed.\n */\n private constructor() {}\n\n public static encodeMulticall(calldataList: string | string[]): string {\n if (!Array.isArray(calldataList)) {\n calldataList = [calldataList]\n }\n\n return calldataList.length === 1\n ? calldataList[0]\n : Multicall.INTERFACE.encodeFunctionData('multicall', [calldataList])\n }\n\n public static decodeMulticall(encodedCalldata: string): string[] {\n return Multicall.INTERFACE.decodeFunctionData('multicall', encodedCalldata)[0]\n }\n}\n","// TODO: import this from npm\nexport const positionManagerAbi = [\n {\n type: 'constructor',\n inputs: [\n {\n name: '_poolManager',\n type: 'address',\n internalType: 'contract IPoolManager',\n },\n {\n name: '_permit2',\n type: 'address',\n internalType: 'contract IAllowanceTransfer',\n },\n {\n name: '_unsubscribeGasLimit',\n type: 'uint256',\n internalType: 'uint256',\n },\n {\n name: '_tokenDescriptor',\n type: 'address',\n internalType: 'contract IPositionDescriptor',\n },\n {\n name: '_weth9',\n type: 'address',\n internalType: 'contract IWETH9',\n },\n ],\n stateMutability: 'nonpayable',\n },\n {\n type: 'receive',\n stateMutability: 'payable',\n },\n {\n type: 'function',\n name: 'DOMAIN_SEPARATOR',\n inputs: [],\n outputs: [\n {\n name: '',\n type: 'bytes32',\n internalType: 'bytes32',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'WETH9',\n inputs: [],\n outputs: [\n {\n name: '',\n type: 'address',\n internalType: 'contract IWETH9',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'approve',\n inputs: [\n {\n name: 'spender',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'id',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n outputs: [],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'balanceOf',\n inputs: [\n {\n name: 'owner',\n type: 'address',\n internalType: 'address',\n },\n ],\n outputs: [\n {\n name: '',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'getApproved',\n inputs: [\n {\n name: '',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n outputs: [\n {\n name: '',\n type: 'address',\n internalType: 'address',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'getPoolAndPositionInfo',\n inputs: [\n {\n name: 'tokenId',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n outputs: [\n {\n name: 'poolKey',\n type: 'tuple',\n internalType: 'struct PoolKey',\n components: [\n {\n name: 'currency0',\n type: 'address',\n internalType: 'Currency',\n },\n {\n name: 'currency1',\n type: 'address',\n internalType: 'Currency',\n },\n {\n name: 'fee',\n type: 'uint24',\n internalType: 'uint24',\n },\n {\n name: 'tickSpacing',\n type: 'int24',\n internalType: 'int24',\n },\n {\n name: 'hooks',\n type: 'address',\n internalType: 'contract IHooks',\n },\n ],\n },\n {\n name: 'info',\n type: 'uint256',\n internalType: 'PositionInfo',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'getPositionLiquidity',\n inputs: [\n {\n name: 'tokenId',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n outputs: [\n {\n name: 'liquidity',\n type: 'uint128',\n internalType: 'uint128',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'initializePool',\n inputs: [\n {\n name: 'key',\n type: 'tuple',\n internalType: 'struct PoolKey',\n components: [\n {\n name: 'currency0',\n type: 'address',\n internalType: 'Currency',\n },\n {\n name: 'currency1',\n type: 'address',\n internalType: 'Currency',\n },\n {\n name: 'fee',\n type: 'uint24',\n internalType: 'uint24',\n },\n {\n name: 'tickSpacing',\n type: 'int24',\n internalType: 'int24',\n },\n {\n name: 'hooks',\n type: 'address',\n internalType: 'contract IHooks',\n },\n ],\n },\n {\n name: 'sqrtPriceX96',\n type: 'uint160',\n internalType: 'uint160',\n },\n ],\n outputs: [\n {\n name: '',\n type: 'int24',\n internalType: 'int24',\n },\n ],\n stateMutability: 'payable',\n },\n {\n type: 'function',\n name: 'isApprovedForAll',\n inputs: [\n {\n name: '',\n type: 'address',\n internalType: 'address',\n },\n {\n name: '',\n type: 'address',\n internalType: 'address',\n },\n ],\n outputs: [\n {\n name: '',\n type: 'bool',\n internalType: 'bool',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'modifyLiquidities',\n inputs: [\n {\n name: 'unlockData',\n type: 'bytes',\n internalType: 'bytes',\n },\n {\n name: 'deadline',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n outputs: [],\n stateMutability: 'payable',\n },\n {\n type: 'function',\n name: 'modifyLiquiditiesWithoutUnlock',\n inputs: [\n {\n name: 'actions',\n type: 'bytes',\n internalType: 'bytes',\n },\n {\n name: 'params',\n type: 'bytes[]',\n internalType: 'bytes[]',\n },\n ],\n outputs: [],\n stateMutability: 'payable',\n },\n {\n type: 'function',\n name: 'msgSender',\n inputs: [],\n outputs: [\n {\n name: '',\n type: 'address',\n internalType: 'address',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'multicall',\n inputs: [\n {\n name: 'data',\n type: 'bytes[]',\n internalType: 'bytes[]',\n },\n ],\n outputs: [\n {\n name: 'results',\n type: 'bytes[]',\n internalType: 'bytes[]',\n },\n ],\n stateMutability: 'payable',\n },\n {\n type: 'function',\n name: 'name',\n inputs: [],\n outputs: [\n {\n name: '',\n type: 'string',\n internalType: 'string',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'nextTokenId',\n inputs: [],\n outputs: [\n {\n name: '',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'nonces',\n inputs: [\n {\n name: 'owner',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'word',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n outputs: [\n {\n name: 'bitmap',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'ownerOf',\n inputs: [\n {\n name: 'id',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n outputs: [\n {\n name: 'owner',\n type: 'address',\n internalType: 'address',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'permit',\n inputs: [\n {\n name: 'spender',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'tokenId',\n type: 'uint256',\n internalType: 'uint256',\n },\n {\n name: 'deadline',\n type: 'uint256',\n internalType: 'uint256',\n },\n {\n name: 'nonce',\n type: 'uint256',\n internalType: 'uint256',\n },\n {\n name: 'signature',\n type: 'bytes',\n internalType: 'bytes',\n },\n ],\n outputs: [],\n stateMutability: 'payable',\n },\n {\n type: 'function',\n name: 'permit',\n inputs: [\n {\n name: 'owner',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'permitSingle',\n type: 'tuple',\n internalType: 'struct IAllowanceTransfer.PermitSingle',\n components: [\n {\n name: 'details',\n type: 'tuple',\n internalType: 'struct IAllowanceTransfer.PermitDetails',\n components: [\n {\n name: 'token',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'amount',\n type: 'uint160',\n internalType: 'uint160',\n },\n {\n name: 'expiration',\n type: 'uint48',\n internalType: 'uint48',\n },\n {\n name: 'nonce',\n type: 'uint48',\n internalType: 'uint48',\n },\n ],\n },\n {\n name: 'spender',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'sigDeadline',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n },\n {\n name: 'signature',\n type: 'bytes',\n internalType: 'bytes',\n },\n ],\n outputs: [\n {\n name: 'err',\n type: 'bytes',\n internalType: 'bytes',\n },\n ],\n stateMutability: 'payable',\n },\n {\n type: 'function',\n name: 'permit2',\n inputs: [],\n outputs: [\n {\n name: '',\n type: 'address',\n internalType: 'contract IAllowanceTransfer',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'permitBatch',\n inputs: [\n {\n name: 'owner',\n type: 'address',\n internalType: 'address',\n },\n {\n name: '_permitBatch',\n type: 'tuple',\n internalType: 'struct IAllowanceTransfer.PermitBatch',\n components: [\n {\n name: 'details',\n type: 'tuple[]',\n internalType: 'struct IAllowanceTransfer.PermitDetails[]',\n components: [\n {\n name: 'token',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'amount',\n type: 'uint160',\n internalType: 'uint160',\n },\n {\n name: 'expiration',\n type: 'uint48',\n internalType: 'uint48',\n },\n {\n name: 'nonce',\n type: 'uint48',\n internalType: 'uint48',\n },\n ],\n },\n {\n name: 'spender',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'sigDeadline',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n },\n {\n name: 'signature',\n type: 'bytes',\n internalType: 'bytes',\n },\n ],\n outputs: [\n {\n name: 'err',\n type: 'bytes',\n internalType: 'bytes',\n },\n ],\n stateMutability: 'payable',\n },\n {\n type: 'function',\n name: 'permitForAll',\n inputs: [\n {\n name: 'owner',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'operator',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'approved',\n type: 'bool',\n internalType: 'bool',\n },\n {\n name: 'deadline',\n type: 'uint256',\n internalType: 'uint256',\n },\n {\n name: 'nonce',\n type: 'uint256',\n internalType: 'uint256',\n },\n {\n name: 'signature',\n type: 'bytes',\n internalType: 'bytes',\n },\n ],\n outputs: [],\n stateMutability: 'payable',\n },\n {\n type: 'function',\n name: 'poolKeys',\n inputs: [\n {\n name: 'poolId',\n type: 'bytes25',\n internalType: 'bytes25',\n },\n ],\n outputs: [\n {\n name: 'currency0',\n type: 'address',\n internalType: 'Currency',\n },\n {\n name: 'currency1',\n type: 'address',\n internalType: 'Currency',\n },\n {\n name: 'fee',\n type: 'uint24',\n internalType: 'uint24',\n },\n {\n name: 'tickSpacing',\n type: 'int24',\n internalType: 'int24',\n },\n {\n name: 'hooks',\n type: 'address',\n internalType: 'contract IHooks',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'poolManager',\n inputs: [],\n outputs: [\n {\n name: '',\n type: 'address',\n internalType: 'contract IPoolManager',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'positionInfo',\n inputs: [\n {\n name: 'tokenId',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n outputs: [\n {\n name: 'info',\n type: 'uint256',\n internalType: 'PositionInfo',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'revokeNonce',\n inputs: [\n {\n name: 'nonce',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n outputs: [],\n stateMutability: 'payable',\n },\n {\n type: 'function',\n name: 'safeTransferFrom',\n inputs: [\n {\n name: 'from',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'to',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'id',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n outputs: [],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'safeTransferFrom',\n inputs: [\n {\n name: 'from',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'to',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'id',\n type: 'uint256',\n internalType: 'uint256',\n },\n {\n name: 'data',\n type: 'bytes',\n internalType: 'bytes',\n },\n ],\n outputs: [],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'setApprovalForAll',\n inputs: [\n {\n name: 'operator',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'approved',\n type: 'bool',\n internalType: 'bool',\n },\n ],\n outputs: [],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'subscribe',\n inputs: [\n {\n name: 'tokenId',\n type: 'uint256',\n internalType: 'uint256',\n },\n {\n name: 'newSubscriber',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'data',\n type: 'bytes',\n internalType: 'bytes',\n },\n ],\n outputs: [],\n stateMutability: 'payable',\n },\n {\n type: 'function',\n name: 'subscriber',\n inputs: [\n {\n name: 'tokenId',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n outputs: [\n {\n name: 'subscriber',\n type: 'address',\n internalType: 'contract ISubscriber',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'supportsInterface',\n inputs: [\n {\n name: 'interfaceId',\n type: 'bytes4',\n internalType: 'bytes4',\n },\n ],\n outputs: [\n {\n name: '',\n type: 'bool',\n internalType: 'bool',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'symbol',\n inputs: [],\n outputs: [\n {\n name: '',\n type: 'string',\n internalType: 'string',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'tokenDescriptor',\n inputs: [],\n outputs: [\n {\n name: '',\n type: 'address',\n internalType: 'contract IPositionDescriptor',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'tokenURI',\n inputs: [\n {\n name: 'tokenId',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n outputs: [\n {\n name: '',\n type: 'string',\n internalType: 'string',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'function',\n name: 'transferFrom',\n inputs: [\n {\n name: 'from',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'to',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'id',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n outputs: [],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'unlockCallback',\n inputs: [\n {\n name: 'data',\n type: 'bytes',\n internalType: 'bytes',\n },\n ],\n outputs: [\n {\n name: '',\n type: 'bytes',\n internalType: 'bytes',\n },\n ],\n stateMutability: 'nonpayable',\n },\n {\n type: 'function',\n name: 'unsubscribe',\n inputs: [\n {\n name: 'tokenId',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n outputs: [],\n stateMutability: 'payable',\n },\n {\n type: 'function',\n name: 'unsubscribeGasLimit',\n inputs: [],\n outputs: [\n {\n name: '',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n stateMutability: 'view',\n },\n {\n type: 'event',\n name: 'Approval',\n inputs: [\n {\n name: 'owner',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n {\n name: 'spender',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n {\n name: 'id',\n type: 'uint256',\n indexed: true,\n internalType: 'uint256',\n },\n ],\n anonymous: false,\n },\n {\n type: 'event',\n name: 'ApprovalForAll',\n inputs: [\n {\n name: 'owner',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n {\n name: 'operator',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n {\n name: 'approved',\n type: 'bool',\n indexed: false,\n internalType: 'bool',\n },\n ],\n anonymous: false,\n },\n {\n type: 'event',\n name: 'Subscription',\n inputs: [\n {\n name: 'tokenId',\n type: 'uint256',\n indexed: true,\n internalType: 'uint256',\n },\n {\n name: 'subscriber',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n ],\n anonymous: false,\n },\n {\n type: 'event',\n name: 'Transfer',\n inputs: [\n {\n name: 'from',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n {\n name: 'to',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n {\n name: 'id',\n type: 'uint256',\n indexed: true,\n internalType: 'uint256',\n },\n ],\n anonymous: false,\n },\n {\n type: 'event',\n name: 'Unsubscription',\n inputs: [\n {\n name: 'tokenId',\n type: 'uint256',\n indexed: true,\n internalType: 'uint256',\n },\n {\n name: 'subscriber',\n type: 'address',\n indexed: true,\n internalType: 'address',\n },\n ],\n anonymous: false,\n },\n {\n type: 'error',\n name: 'AlreadySubscribed',\n inputs: [\n {\n name: 'tokenId',\n type: 'uint256',\n internalType: 'uint256',\n },\n {\n name: 'subscriber',\n type: 'address',\n internalType: 'address',\n },\n ],\n },\n {\n type: 'error',\n name: 'BurnNotificationReverted',\n inputs: [\n {\n name: 'subscriber',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'reason',\n type: 'bytes',\n internalType: 'bytes',\n },\n ],\n },\n {\n type: 'error',\n name: 'ContractLocked',\n inputs: [],\n },\n {\n type: 'error',\n name: 'DeadlinePassed',\n inputs: [\n {\n name: 'deadline',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n },\n {\n type: 'error',\n name: 'DeltaNotNegative',\n inputs: [\n {\n name: 'currency',\n type: 'address',\n internalType: 'Currency',\n },\n ],\n },\n {\n type: 'error',\n name: 'DeltaNotPositive',\n inputs: [\n {\n name: 'currency',\n type: 'address',\n internalType: 'Currency',\n },\n ],\n },\n {\n type: 'error',\n name: 'GasLimitTooLow',\n inputs: [],\n },\n {\n type: 'error',\n name: 'InputLengthMismatch',\n inputs: [],\n },\n {\n type: 'error',\n name: 'InsufficientBalance',\n inputs: [],\n },\n {\n type: 'error',\n name: 'InvalidContractSignature',\n inputs: [],\n },\n {\n type: 'error',\n name: 'InvalidEthSender',\n inputs: [],\n },\n {\n type: 'error',\n name: 'InvalidSignature',\n inputs: [],\n },\n {\n type: 'error',\n name: 'InvalidSignatureLength',\n inputs: [],\n },\n {\n type: 'error',\n name: 'InvalidSigner',\n inputs: [],\n },\n {\n type: 'error',\n name: 'MaximumAmountExceeded',\n inputs: [\n {\n name: 'maximumAmount',\n type: 'uint128',\n internalType: 'uint128',\n },\n {\n name: 'amountRequested',\n type: 'uint128',\n internalType: 'uint128',\n },\n ],\n },\n {\n type: 'error',\n name: 'MinimumAmountInsufficient',\n inputs: [\n {\n name: 'minimumAmount',\n type: 'uint128',\n internalType: 'uint128',\n },\n {\n name: 'amountReceived',\n type: 'uint128',\n internalType: 'uint128',\n },\n ],\n },\n {\n type: 'error',\n name: 'ModifyLiquidityNotificationReverted',\n inputs: [\n {\n name: 'subscriber',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'reason',\n type: 'bytes',\n internalType: 'bytes',\n },\n ],\n },\n {\n type: 'error',\n name: 'NoCodeSubscriber',\n inputs: [],\n },\n {\n type: 'error',\n name: 'NoSelfPermit',\n inputs: [],\n },\n {\n type: 'error',\n name: 'NonceAlreadyUsed',\n inputs: [],\n },\n {\n type: 'error',\n name: 'NotApproved',\n inputs: [\n {\n name: 'caller',\n type: 'address',\n internalType: 'address',\n },\n ],\n },\n {\n type: 'error',\n name: 'NotPoolManager',\n inputs: [],\n },\n {\n type: 'error',\n name: 'NotSubscribed',\n inputs: [],\n },\n {\n type: 'error',\n name: 'PoolManagerMustBeLocked',\n inputs: [],\n },\n {\n type: 'error',\n name: 'SignatureDeadlineExpired',\n inputs: [],\n },\n {\n type: 'error',\n name: 'SubscriptionReverted',\n inputs: [\n {\n name: 'subscriber',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'reason',\n type: 'bytes',\n internalType: 'bytes',\n },\n ],\n },\n {\n type: 'error',\n name: 'TransferNotificationReverted',\n inputs: [\n {\n name: 'subscriber',\n type: 'address',\n internalType: 'address',\n },\n {\n name: 'reason',\n type: 'bytes',\n internalType: 'bytes',\n },\n ],\n },\n {\n type: 'error',\n name: 'Unauthorized',\n inputs: [],\n },\n {\n type: 'error',\n name: 'UnsupportedAction',\n inputs: [\n {\n name: 'action',\n type: 'uint256',\n internalType: 'uint256',\n },\n ],\n },\n]\n","import { BigintIsh, Percent, validateAndParseAddress, NativeCurrency } from '@juiceswapxyz/sdk-core'\nimport { TypedDataDomain, TypedDataField } from '@ethersproject/abstract-signer'\nimport JSBI from 'jsbi'\nimport { Position } from './entities/position'\nimport { MethodParameters, toHex } from './utils/calldata'\nimport { MSG_SENDER } from './actionConstants'\nimport { Interface } from '@ethersproject/abi'\nimport { PoolKey } from './entities'\nimport { Multicall } from './multicall'\nimport invariant from 'tiny-invariant'\nimport {\n EMPTY_BYTES,\n CANNOT_BURN,\n NATIVE_NOT_SET,\n NO_SQRT_PRICE,\n ONE,\n OPEN_DELTA,\n PositionFunctions,\n ZERO,\n ZERO_LIQUIDITY,\n} from './internalConstants'\nimport { V4PositionPlanner } from './utils'\nimport { positionManagerAbi } from './utils/positionManagerAbi'\n\nexport interface CommonOptions {\n /**\n * How much the pool price is allowed to move from the specified action.\n */\n slippageTolerance: Percent\n /**\n * Optional data to pass to hooks\n */\n hookData?: string\n\n /**\n * When the transaction expires, in epoch seconds.\n */\n deadline: BigintIsh\n}\n\nexport interface ModifyPositionSpecificOptions {\n /**\n * Indicates the ID of the position to increase liquidity for.\n */\n tokenId: BigintIsh\n}\n\nexport interface MintSpecificOptions {\n /**\n * The account that should receive the minted NFT.\n */\n recipient: string\n\n /**\n * Creates pool if not initialized before mint.\n */\n createPool?: boolean\n\n /**\n * Initial price to set on the pool if creating\n */\n sqrtPriceX96?: BigintIsh\n\n /**\n * Whether the mint is part of a migration from V3 to V4.\n */\n migrate?: boolean\n}\n\n/**\n * Options for producing the calldata to add liquidity.\n */\nexport interface CommonAddLiquidityOptions {\n /**\n * Whether to spend ether. If true, one of the currencies must be the NATIVE currency.\n */\n useNative?: NativeCurrency\n\n /**\n * The optional permit2 batch permit parameters for spending token0 and token1\n */\n batchPermit?: BatchPermitOptions\n}\n\n/**\n * Options for producing the calldata to exit a position.\n */\nexport interface RemoveLiquiditySpecificOptions {\n /**\n * The percentage of position liquidity to exit.\n */\n liquidityPercentage: Percent\n\n /**\n * Whether the NFT should be burned if the entire position is being exited, by default false.\n */\n burnToken?: boolean\n\n /**\n * The optional permit of the token ID being exited, in case the exit transaction is being sent by an account that does not own the NFT\n */\n permit?: NFTPermitOptions\n}\n\nexport interface CollectSpecificOptions {\n /**\n * Indicates the ID of the position to collect for.\n */\n tokenId: BigintIsh\n\n /**\n * The account that should receive the tokens.\n */\n recipient: string\n}\n\nexport interface TransferOptions {\n /**\n * The account sending the NFT.\n */\n sender: string\n\n /**\n * The account that should receive the NFT.\n */\n recipient: string\n\n /**\n * The id of the token being sent.\n */\n tokenId: BigintIsh\n}\n\nexport interface PermitDetails {\n token: string\n amount: BigintIsh\n expiration: BigintIsh\n nonce: BigintIsh\n}\n\nexport interface AllowanceTransferPermitSingle {\n details: PermitDetails\n spender: string\n sigDeadline: BigintIsh\n}\n\nexport interface AllowanceTransferPermitBatch {\n details: PermitDetails[]\n spender: string\n sigDeadline: BigintIsh\n}\n\nexport interface BatchPermitOptions {\n owner: string\n permitBatch: AllowanceTransferPermitBatch\n signature: string\n}\n\nconst NFT_PERMIT_TYPES = {\n Permit: [\n { name: 'spender', type: 'address' },\n { name: 'tokenId', type: 'uint256' },\n { name: 'nonce', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n}\n\nexport interface NFTPermitValues {\n spender: string\n tokenId: BigintIsh\n deadline: BigintIsh\n nonce: BigintIsh\n}\n\nexport interface NFTPermitOptions extends NFTPermitValues {\n signature: string\n}\n\nexport interface NFTPermitData {\n domain: TypedDataDomain\n types: Record<string, TypedDataField[]>\n values: NFTPermitValues\n}\n\nexport type MintOptions = CommonOptions & CommonAddLiquidityOptions & MintSpecificOptions\nexport type IncreaseLiquidityOptions = CommonOptions & CommonAddLiquidityOptions & ModifyPositionSpecificOptions\n\nexport type AddLiquidityOptions = MintOptions | IncreaseLiquidityOptions\n\nexport type RemoveLiquidityOptions = CommonOptions & RemoveLiquiditySpecificOptions & ModifyPositionSpecificOptions\n\nexport type CollectOptions = CommonOptions & CollectSpecificOptions\n\n// type guard\nfunction isMint(options: AddLiquidityOptions): options is MintOptions {\n return Object.keys(options).some((k) => k === 'recipient')\n}\n\nfunction shouldCreatePool(options: MintOptions): boolean {\n if (options.createPool) {\n invariant(options.sqrtPriceX96 !== undefined, NO_SQRT_PRICE)\n return true\n }\n return false\n}\n\nexport abstract class V4PositionManager {\n public static INTERFACE: Interface = new Interface(positionManagerAbi)\n\n /**\n * Cannot be constructed.\n */\n private constructor() {}\n\n /**\n * Public methods to encode method parameters for different actions on the PositionManager contract\n */\n public static createCallParameters(poolKey: PoolKey, sqrtPriceX96: BigintIsh): MethodParameters {\n return {\n calldata: this.encodeInitializePool(poolKey, sqrtPriceX96),\n value: toHex(0),\n }\n }\n\n public static addCallParameters(position: Position, options: AddLiquidityOptions): MethodParameters {\n /**\n * Cases:\n * - if pool does not exist yet, encode initializePool\n * then,\n * - if is mint, encode MINT_POSITION. If migrating, encode a SETTLE and SWEEP for both currencies. Else, encode a SETTLE_PAIR. If on a NATIVE pool, encode a SWEEP.\n * - else, encode INCREASE_LIQUIDITY and SETTLE_PAIR. If it is on a NATIVE pool, encode a SWEEP.\n */\n invariant(JSBI.greaterThan(position.liquidity, ZERO), ZERO_LIQUIDITY)\n\n const calldataList: string[] = []\n const planner = new V4PositionPlanner()\n\n // Encode initialize pool.\n if (isMint(options) && shouldCreatePool(options)) {\n // No planner used here because initializePool is not supported as an Action\n calldataList.push(V4PositionManager.encodeInitializePool(position.pool.poolKey, options.sqrtPriceX96!))\n }\n\n // position.pool.currency0 is native if and only if options.useNative is set\n invariant(\n position.pool.currency0 === options.useNative ||\n (!position.pool.currency0.isNative && options.useNative === undefined),\n NATIVE_NOT_SET\n )\n\n // adjust for slippage\n const maximumAmounts = position.mintAmountsWithSlippage(options.slippageTolerance)\n const amount0Max = toHex(maximumAmounts.amount0)\n const amount1Max = toHex(maximumAmounts.amount1)\n\n // We use permit2 to approve tokens to the position manager\n if (options.batchPermit) {\n calldataList.push(\n V4PositionManager.encodePermitBatch(\n options.batchPermit.owner,\n options.batchPermit.permitBatch,\n options.batchPermit.signature\n )\n )\n }\n\n // mint\n if (isMint(options)) {\n const recipient: string = validateAndParseAddress(options.recipient)\n planner.addMint(\n position.pool,\n position.tickLower,\n position.tickUpper,\n position.liquidity,\n amount0Max,\n amount1Max,\n recipient,\n options.hookData\n )\n } else {\n // increase\n planner.addIncrease(options.tokenId, position.liquidity, amount0Max, amount1Max, options.hookData)\n }\n\n let value: string = toHex(0)\n\n // If migrating, we need to settle and sweep both currencies individually\n if (isMint(options) && options.migrate) {\n if (options.useNative) {\n // unwrap the exact amount needed to send to the pool manager\n planner.addUnwrap(OPEN_DELTA)\n // payer is v4 position manager\n planner.addSettle(position.pool.currency0, false)\n planner.addSettle(position.pool.currency1, false)\n // sweep any leftover wrapped native that was not unwrapped\n // recipient will be same as the v4 lp token recipient\n planner.addSweep(position.pool.currency0.wrapped, options.recipient)\n planner.addSweep(position.pool.currency1, options.recipient)\n } else {\n // payer is v4 position manager\n planner.addSettle(position.pool.currency0, false)\n planner.addSettle(position.pool.currency1, false)\n // recipient will be same as the v4 lp token recipient\n planner.addSweep(position.pool.currency0, options.recipient)\n planner.addSweep(position.pool.currency1, options.recipient)\n }\n } else {\n // need to settle both currencies when minting / adding liquidity (user is the payer)\n planner.addSettlePair(position.pool.currency0, position.pool.currency1)\n // When not migrating and adding native currency, add a final sweep\n if (options.useNative) {\n // Any sweeping must happen after the settling.\n // native currency will always be currency0 in v4\n value = toHex(amount0Max)\n planner.addSweep(position.pool.currency0, MSG_SENDER)\n }\n }\n\n calldataList.push(V4PositionManager.encodeModifyLiquidities(planner.finalize(), options.deadline))\n\n return {\n calldata: Multicall.encodeMulticall(calldataList),\n value,\n }\n }\n\n /**\n * Produces the calldata for completely or partially exiting a position\n * @param position The position to exit\n * @param options Additional information necessary for generating the calldata\n * @returns The call parameters\n */\n public static removeCallParameters(position: Position, options: RemoveLiquidityOptions): MethodParameters {\n /**\n * cases:\n * - if liquidityPercentage is 100%, encode BURN_POSITION and then TAKE_PAIR\n * - else, encode DECREASE_LIQUIDITY and then TAKE_PAIR\n */\n const calldataList: string[] = []\n const planner = new V4PositionPlanner()\n\n const tokenId = toHex(options.tokenId)\n\n if (options.burnToken) {\n // if burnToken is true, the specified liquidity percentage must be 100%\n invariant(options.liquidityPercentage.equalTo(ONE), CANNOT_BURN)\n\n // if there is a permit, encode the ERC721Permit permit call\n if (options.permit) {\n calldataList.push(\n V4PositionManager.encodeERC721Permit(\n options.permit.spender,\n options.permit.tokenId,\n options.permit.deadline,\n options.permit.nonce,\n options.permit.signature\n )\n )\n }\n\n // slippage-adjusted amounts derived from current position liquidity\n const { amount0: amount0Min, amount1: amount1Min } = position.burnAmountsWithSlippage(options.slippageTolerance)\n planner.addBurn(tokenId, amount0Min, amount1Min, options.hookData)\n } else {\n // construct a partial position with a percentage of liquidity\n const partialPosition = new Position({\n pool: position.pool,\n liquidity: options.liquidityPercentage.multiply(position.liquidity).quotient,\n tickLower: position.tickLower,\n tickUpper: position.tickUpper,\n })\n\n // If the partial position has liquidity=0, this is a collect call and collectCallParameters should be used\n invariant(JSBI.greaterThan(partialPosition.liquidity, ZERO), ZERO_LIQUIDITY)\n\n // slippage-adjusted underlying amounts\n const { amount0: amount0Min, amount1: amount1Min } = partialPosition.burnAmountsWithSlippage(\n options.slippageTolerance\n )\n\n planner.addDecrease(\n tokenId,\n partialPosition.liquidity.toString(),\n amount0Min.toString(),\n amount1Min.toString(),\n options.hookData ?? EMPTY_BYTES\n )\n }\n\n planner.addTakePair(position.pool.currency0, position.pool.currency1, MSG_SENDER)\n\n calldataList.push(V4PositionManager.encodeModifyLiquidities(planner.finalize(), options.deadline))\n\n return {\n calldata: Multicall.encodeMulticall(calldataList),\n value: toHex(0),\n }\n }\n\n /**\n * Produces the calldata for collecting fees from a position\n * @param position The position to collect fees from\n * @param options Additional information necessary for generating the calldata\n * @returns The call parameters\n */\n public static collectCallParameters(position: Position, options: CollectOptions): MethodParameters {\n const calldataList: string[] = []\n const planner = new V4PositionPlanner()\n\n const tokenId = toHex(options.tokenId)\n const recipient = validateAndParseAddress(options.recipient)\n\n /**\n * To collect fees in V4, we need to:\n * - encode a decrease liquidity by 0\n * - and encode a TAKE_PAIR\n */\n\n planner.addDecrease(tokenId, '0', '0', '0', options.hookData)\n\n planner.addTakePair(position.pool.currency0, position.pool.currency1, recipient)\n\n calldataList.push(V4PositionManager.encodeModifyLiquidities(planner.finalize(), options.deadline))\n\n return {\n calldata: Multicall.encodeMulticall(calldataList),\n value: toHex(0),\n }\n }\n\n // Initialize a pool\n private static encodeInitializePool(poolKey: PoolKey, sqrtPriceX96: BigintIsh): string {\n return V4PositionManager.INTERFACE.encodeFunctionData(PositionFunctions.INITIALIZE_POOL, [\n poolKey,\n sqrtPriceX96.toString(),\n ])\n }\n\n // Encode a modify liquidities call\n public static encodeModifyLiquidities(unlockData: string, deadline: BigintIsh): string {\n return V4PositionManager.INTERFACE.encodeFunctionData(PositionFunctions.MODIFY_LIQUIDITIES, [unlockData, deadline])\n }\n\n // Encode a permit batch call\n public static encodePermitBatch(owner: string, permitBatch: AllowanceTransferPermitBatch, signature: string): string {\n return V4PositionManager.INTERFACE.encodeFunctionData(PositionFunctions.PERMIT_BATCH, [\n owner,\n permitBatch,\n signature,\n ])\n }\n\n // Encode a ERC721Permit permit call\n public static encodeERC721Permit(\n spender: string,\n tokenId: BigintIsh,\n deadline: BigintIsh,\n nonce: BigintIsh,\n signature: string\n ): string {\n return V4PositionManager.INTERFACE.encodeFunctionData(PositionFunctions.ERC721PERMIT_PERMIT, [\n spender,\n tokenId,\n deadline,\n nonce,\n signature,\n ])\n }\n\n // Prepare the params for an EIP712 signTypedData request\n public static getPermitData(permit: NFTPermitValues, positionManagerAddress: string, chainId: number): NFTPermitData {\n return {\n domain: {\n name: 'Uniswap V4 Positions NFT',\n chainId,\n verifyingContract: positionManagerAddress,\n },\n types: NFT_PERMIT_TYPES,\n values: permit,\n }\n }\n}\n"],"names":["sortsBefore","currencyA","currencyB","isNative","wrapped","HookOptions","hookFlagIndex","_hookFlagIndex","AfterRemoveLiquidityReturnsDelta","AfterAddLiquidityReturnsDelta","AfterSwapReturnsDelta","BeforeSwapReturnsDelta","AfterDonate","BeforeDonate","AfterSwap","BeforeSwap","AfterRemoveLiquidity","BeforeRemoveLiquidity","AfterAddLiquidity","BeforeAddLiquidity","AfterInitialize","BeforeInitialize","Hook","permissions","address","_checkAddress","beforeInitialize","_hasPermission","afterInitialize","beforeAddLiquidity","afterAddLiquidity","beforeRemoveLiquidity","afterRemoveLiquidity","beforeSwap","afterSwap","beforeDonate","afterDonate","beforeSwapReturnsDelta","afterSwapReturnsDelta","afterAddLiquidityReturnsDelta","afterRemoveLiquidityReturnsDelta","hasPermission","hookOption","hasInitializePermissions","hasLiquidityPermissions","hasSwapPermissions","hasDonatePermissions","parseInt","isAddress","process","invariant","ADDRESS_ZERO","constants","AddressZero","NEGATIVE_ONE","JSBI","BigInt","ZERO","ONE","EMPTY_BYTES","Q96","exponentiate","Q192","OPEN_DELTA","Zero","NATIVE_NOT_SET","ZERO_LIQUIDITY","NO_SQRT_PRICE","CANNOT_BURN","PositionFunctions","FeeAmount","TICK_SPACINGS","_TICK_SPACINGS","LOWEST","LOW","MEDIUM","HIGH","DYNAMIC_FEE_FLAG","NO_TICK_DATA_PROVIDER_DEFAULT","NoTickDataProvider","Pool","fee","tickSpacing","hooks","sqrtRatioX96","liquidity","tickCurrent","ticks","Number","isInteger","tickCurrentSqrtRatioX96","TickMath","getSqrtRatioAtTick","nextTickSqrtRatioX96","greaterThanOrEqual","lessThanOrEqual","_ref","currency0","currency1","tickDataProvider","Array","isArray","TickListDataProvider","poolKey","getPoolKey","poolId","getPoolId","_ref2","currency0Addr","currency1Addr","_ref3","keccak256","defaultAbiCoder","encode","_proto","prototype","involvesCurrency","currency","equals","involvesToken","v4InvolvesToken","priceOf","currency0Price","currency1Price","getOutputAmount","_getOutputAmount","_asyncToGenerator","_regenerator","m","_callee","inputAmount","sqrtPriceLimitX96","zeroForOne","_yield$this$swap","outputAmount","outputCurrency","w","_context","n","swap","quotient","v","amountCalculated","a","CurrencyAmount","fromRawAmount","multiply","_x","_x2","apply","arguments","getInputAmount","_getInputAmount","_callee2","_yield$this$swap2","inputCurrency","_context2","_x3","_x4","_swap","_callee3","amountSpecified","_context3","hookImpactsSwap","v3Swap","Error","_x5","_x6","_x7","_createClass","key","get","_this$_currency0Price","_currency0Price","Price","_this$_currency1Price","_currency1Price","chainId","amountWithPathCurrency","amount","pool","fromFractionalAmount","getPathCurrency","numerator","denominator","symbol","Route","pools","input","output","length","allOnSameChain","every","pathInput","pathOutput","currencyPath","_iterator","_createForOfIteratorHelperLoose","entries","_step","done","_step$value","value","i","currentInputCurrency","nextCurrency","push","_midPrice","price","slice","reduce","nextInput","tradeComparator","b","equalTo","aHops","swaps","total","cur","route","bHops","lessThan","Trade","routes","tradeType","numPools","map","_ref4","poolIDSet","Set","_iterator2","_step2","add","size","exactIn","_exactIn","amountIn","fromRoute","TradeType","EXACT_INPUT","exactOut","_exactOut","amountOut","EXACT_OUTPUT","_fromRoute","tokenAmount","_yield$pool$getOutput","_tokenAmount","_i","_pool","_yield$_pool$getInput","fromRoutes","_fromRoutes","_callee5","_context5","Promise","all","_ref6","_callee4","_ref5","trade","_context4","_x0","_x8","_x9","createUncheckedTrade","constructorArguments","_extends","createUncheckedTradeWithMultipleRoutes","minimumAmountOut","slippageTolerance","slippageAdjustedAmountOut","Fraction","invert","maximumAmountIn","slippageAdjustedAmountIn","worstExecutionPrice","bestTradeExactIn","_bestTradeExactIn","_callee6","currencyAmountIn","currencyOut","_temp","currentPools","nextAmountIn","bestTrades","_ref7$maxNumResults","_ref7","maxNumResults","_ref7$maxHops","maxHops","_context6","p","_yield$pool$getOutput2","_t","isInsufficientInputAmountError","_t2","sortedInsert","_t3","concat","poolsExcludingThisPool","_x1","_x10","_x11","_x12","_x13","_x14","_x15","bestTradeExactOut","_bestTradeExactOut","_callee7","currencyIn","currencyAmountOut","_temp2","nextAmountOut","_ref8$maxNumResults","_ref8","_ref8$maxHops","_context7","_yield$pool$getInputA","_t4","isInsufficientReservesError","_t5","_t6","_x16","_x17","_x18","_x19","_x20","_x21","_x22","_inputAmount","totalInputFromRoutes","_ref9","_outputAmount","totalOutputFromRoutes","_ref0","_this$_executionPrice","_executionPrice","_priceImpact","spotOutputAmount","_iterator3","_step3","_step3$value","midPrice","quote","priceImpact","subtract","divide","Percent","tickToPrice","baseCurrency","quoteCurrency","tick","ratioX192","priceToClosestTick","sorted","encodeSqrtRatioX96","getTickAtSqrtRatio","nextTickPrice","greaterThan","Position","tickLower","tickUpper","MIN_TICK","MAX_TICK","ratiosAfterSlippage","priceLower","token0Price","asFraction","priceUpper","sqrtRatioX96Lower","MIN_SQRT_RATIO","sqrtRatioX96Upper","MAX_SQRT_RATIO","mintAmountsWithSlippage","_this$ratiosAfterSlip","poolLower","token0","token1","poolUpper","amount1","mintAmounts","amount0","burnAmountsWithSlippage","_this$ratiosAfterSlip2","permitBatchData","spender","nonce","deadline","_this$mintAmountsWith","details","token","expiration","sigDeadline","fromAmounts","useFullPrecision","sqrtRatioAX96","sqrtRatioBX96","maxLiquidityForAmounts","fromAmount0","MaxUint256","fromAmount1","_token0Amount","SqrtPriceMath","getAmount0Delta","_token1Amount","getAmount1Delta","_mintAmounts","encodeRouteToPath","exactOutput","reverse","startingCurrency","pathKeys","intermediateCurrency","hookData","Actions","Subparser","POOL_KEY_STRUCT","PATH_KEY_STRUCT","SWAP_EXACT_IN_SINGLE_STRUCT","SWAP_EXACT_IN_STRUCT","SWAP_EXACT_OUT_SINGLE_STRUCT","SWAP_EXACT_OUT_STRUCT","V4_BASE_ACTIONS_ABI_DEFINITION","_V4_BASE_ACTIONS_ABI_","INCREASE_LIQUIDITY","name","type","DECREASE_LIQUIDITY","MINT_POSITION","subparser","PoolKey","BURN_POSITION","SWAP_EXACT_IN_SINGLE","V4SwapExactInSingle","SWAP_EXACT_IN","V4SwapExactIn","SWAP_EXACT_OUT_SINGLE","V4SwapExactOutSingle","SWAP_EXACT_OUT","V4SwapExactOut","SETTLE","SETTLE_ALL","SETTLE_PAIR","TAKE","TAKE_ALL","TAKE_PORTION","TAKE_PAIR","CLOSE_CURRENCY","SWEEP","UNWRAP","FULL_DELTA_AMOUNT","V4Planner","actions","params","addAction","parameters","command","createAction","encodedInput","action","toString","padStart","addTrade","actionType","currencyAddress","path","amountInMaximum","amountOutMinimum","addSettle","payerIsUser","addTake","recipient","takeAmount","addUnwrap","finalize","toAddress","V4PositionPlanner","_V4Planner","_inheritsLoose","addMint","amount0Max","amount1Max","owner","inputs","addIncrease","tokenId","addDecrease","amount0Min","amount1Min","addBurn","addSettlePair","addTakePair","addSweep","to","toHex","bigintIsh","bigInt","hex","V4BaseActionsParser","parseCalldata","calldata","_ethers$utils$default","ethers","utils","decode","actionTypes","getActions","abiDef","rawParams","param","j","parseV4ExactInSingle","parseV4ExactIn","parseV4ExactOutSingle","parseV4ExactOut","parsePoolKey","actionName","byte","substring","data","parsePathKey","paths","pathKey","MSG_SENDER","Multicall","encodeMulticall","calldataList","INTERFACE","encodeFunctionData","decodeMulticall","encodedCalldata","decodeFunctionData","Interface","IMulticall","abi","positionManagerAbi","internalType","stateMutability","outputs","components","indexed","anonymous","NFT_PERMIT_TYPES","Permit","isMint","options","Object","keys","some","k","shouldCreatePool","createPool","sqrtPriceX96","undefined","V4PositionManager","createCallParameters","encodeInitializePool","addCallParameters","position","planner","useNative","maximumAmounts","batchPermit","encodePermitBatch","permitBatch","signature","validateAndParseAddress","migrate","encodeModifyLiquidities","removeCallParameters","burnToken","liquidityPercentage","permit","encodeERC721Permit","_position$burnAmounts","_options$hookData","partialPosition","_partialPosition$burn","collectCallParameters","INITIALIZE_POOL","unlockData","MODIFY_LIQUIDITIES","PERMIT_BATCH","ERC721PERMIT_PERMIT","getPermitData","positionManagerAddress","domain","verifyingContract","types","values"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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