{"version":3,"sources":["jsdelivr-header.js","/npm/@pancakeswap/v2-sdk@1.1.7/src/constants.ts","/npm/@pancakeswap/v2-sdk@1.1.7/src/entities/pair.ts","/npm/@pancakeswap/v2-sdk@1.1.7/src/entities/route.ts","/npm/@pancakeswap/v2-sdk@1.1.7/src/entities/trade.ts","/npm/@pancakeswap/v2-sdk@1.1.7/src/abis/IPancakePair.ts","/npm/@pancakeswap/v2-sdk@1.1.7/src/router.ts","/npm/@pancakeswap/v2-sdk@1.1.7/src/fetcher.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,aCHO,IAAM,OAAA,QAAA,uBAEP,YAAA,QAAsB,8BAEf,WAAA,QAAA,6BACV,WAAQ,QAAW,kBACnB,KAAQ,QAAM,QACd,SAAW,QAAG,eACQ,SACtB,gBAAuB,GAAA,OAAA,KAAA,WAAA,EAAA,CAAA,QAAA,EAAA,CACG,IAC1B,oBAAwB,gBAAA,YAGxB,gBAAQ,6CACR,oBAAgB,6CAChB,oBAAqB,CACtB,CAAC,OAAA,QAAa,UAAG,oBACjB,CAAC,OAAA,QAAQ,QAAgB,oBACzB,CAAC,OAAA,QAAe,KAAA,gBAChB,CAAC,OAAA,QAAQ,aAAe,6CACxB,CAAC,OAAA,QAAQ,cAAiB,6CAC1B,CAAC,OAAA,QAAe,iBAAG,6CACnB,CAAC,OAAA,QAAQ,eAAmB,6CAC5B,CAAC,OAAA,QAAQ,uBAAe,6CACxB,CAAC,OAAA,QAAQ,QAAgB,6CAC3B,CAAA,OAAA,QAAA,gBAAA,6CAEO,CAAA,OAAM,QAAA,OAAiB,6CAE9B,CAAA,OAAM,QAAA,eAAqB,6CACpB,CAAA,OAAM,QAAA,OAAqB,6CAChC,CAAC,OAAA,QAAQ,eAAW,6CACpB,CAAC,OAAA,QAAc,MAAG,6CAClB,CAAC,OAAA,QAAc,cAAA,6CACf,CAAC,OAAA,QAAQ,gBAAc,6CACvB,CAAC,OAAA,QAAQ,SAAe,6CACxB,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,UACE,KAAA,UACA,KAAA,WACM,CAER,SAAA,EACA,aAAA,UACE,KAAA,UACA,KAAA,YAEM,KACR,OAAA,KACA,SACW,CACK,WACR,EAAA,OACN,CACF,CACF,SAAA,EACA,aAAM,UACN,KAAM,SACR,KAAA,WAEE,CACA,SAAQ,EACN,aAAA,UACE,KAAA,YACA,KAAA,WACM,CAER,SAAA,EACA,aAAA,UACE,KAAA,YACA,KAAA,WACM,CAER,SAAA,EACA,aAAA,UACE,KAAA,aACA,KAAA,WACM,CAER,SAAA,EACF,aAAA,UACA,KAAM,aACN,KAAM,WAER,CACE,SAAW,EACX,aAAQ,UACN,KAAA,KACE,KAAA,YAEM,KACN,OAAM,KACR,SACA,CACW,WACT,EAAc,OACd,CAAM,CAER,SAAA,EACA,aAAA,UACE,KAAA,WACA,KAAA,WACM,CAER,SAAA,EACA,aAAA,UACE,KAAA,WACA,KAAA,YAEM,KACR,OAAA,KACA,SACW,CACK,WACR,EAAA,OACN,CACF,CACA,SAAA,EACE,aAAS,UACT,KAAA,OACA,KAAM,WAER,CACF,SAAA,EACA,aAAM,UACN,KAAM,KACR,KAAA,WAEE,CACA,SAAQ,EACN,aAAA,UACE,KAAA,QACA,KAAA,YAEM,KACR,WAAA,KACA,SACW,CACK,UACR,EAAA,OACN,GAAM,KACR,mBACF,QAAA,CACA,CACA,aAAM,UACR,KAAA,GACA,KAAA,YAEU,SACN,EAAA,gBACW,OAAA,KACT,YACM,CACA,UACR,EAAA,OACA,GAAA,KACE,oBAAS,QACT,CAAc,CAEd,aAAM,UACR,KAAA,GACA,KAAA,YAEgB,SACd,EAAM,gBACA,OAAA,KACR,YACF,CAEA,UAAM,EACR,OAAA,GACA,KAAA,kBACE,QAAA,CACA,CACA,aAAM,UACN,KAAS,GACP,KAAA,YAEQ,SACN,EAAM,gBACR,OACF,KAAA,YACS,CAET,UAAM,EACR,OAAA,CACA,CACE,aAAU,UACV,KAAS,QACT,KAAM,WAEJ,CACE,aAAc,UACd,KAAM,UACN,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BACR,aAAA,KACA,YACgB,CACR,UACA,EAAA,OACR,GAAA,KACA,QAAA,QACE,CAAc,CAEd,aAAM,UACR,KAAA,GACF,KAAA,YAGA,SAAM,EACR,gBAAA,OACA,KAAA,YACY,CACF,UACN,EAAA,OACE,CAAc,CAEd,aAAM,UACR,KAAA,KACA,KAAA,YAEQ,KACN,OAAM,QACR,CACF,CACA,aAAM,UACN,KAAU,YACV,KAAS,YAGX,SAAA,EACA,gBAAA,aACE,KAAA,YACS,CAET,UAAS,EAAA,OACP,GAAA,KACE,OAAc,QACd,CAAM,CAER,aAAA,SACF,KAAA,GACA,KAAS,WAGX,SAAA,EACA,gBAAA,OACE,KAAA,YACQ,CACN,UACE,EAAc,OACd,CAAM,CAER,aAAA,UACF,KAAA,QACA,KAAM,YAEJ,KACE,SAAc,QACd,CAAM,CAER,aAAA,UACF,KAAA,GACA,KAAS,YAGX,SAAA,EACA,gBAAA,OACE,KAAA,YACS,CAET,UAAS,EAAA,OACP,EAEE,aAAM,UACN,KAAM,QACR,KAAA,WAEF,CACA,aAAiB,UACjB,KAAM,UACR,KAAA,WAEE,CACA,aAAQ,UACN,KAAA,QACE,KAAA,WACM,CAER,aAAA,UACF,KAAA,WACA,KAAM,WAEJ,CACE,aAAc,QACd,KAAM,IACN,KAAM,SAEV,CACA,aAAS,UACT,KAAA,IACA,KAAM,WAER,CACE,aAAU,UACV,KAAQ,IACN,KAAA,YAEQ,KACN,SAAM,QACR,GAAA,SACA,EAAA,gBACE,aAAc,KACd,YACM,CACR,UACA,EAAA,OACE,GAAc,KACd,uBAAM,QACN,CACF,CACA,aAAA,UACE,KAAA,GACA,KAAM,YAER,SACA,EAAA,gBACE,OAAc,KACd,YACM,CACR,UACA,EAAA,OACE,GAAc,KACd,uBAAM,QACN,CACF,CACA,aAAA,UACE,KAAA,GACA,KAAM,YAGV,SAAA,EACA,gBAAM,OACN,KAAA,YACS,CAET,UAAM,EACR,OAAA,CACA,CACE,aAAU,UACV,KAAS,KACT,KAAM,YAEJ,KACE,OAAc,QACd,GAAM,SACN,EAAM,gBACR,aACF,KAAA,YACS,CAET,UAAM,EACR,OAAA,CACA,CACE,aAAU,UACV,KAAS,aACT,KAAM,WAEJ,CACE,aAAc,UACd,KAAM,aACN,KAAM,WAEV,CACA,aAAS,UACT,KAAA,KACA,KAAM,WAER,CACE,aAAU,QACV,KAAQ,OACN,KAAA,UAEQ,KACN,OAAM,QACR,GACF,SAAA,EACA,gBAAM,aACN,KAAA,YACS,CAET,UAAM,EACR,OAAA,GACA,KAAA,SACE,QAAA,CACA,CACE,aAAA,SACE,KAAA,GACA,KAAM,WAER,SACA,EAAA,gBACE,OAAc,KACd,YACM,CACR,UACA,EAAA,OACE,GAAc,KACd,OAAM,QACN,GAAM,SACR,EAAA,gBACA,aAAA,KACE,YACM,CACA,UACR,EACF,OAAA,GACA,KAAM,SACN,QAAS,CACT,CACA,aAAiB,UACjB,KAAM,GACR,KAAA,YAGE,SAAS,EACT,gBAAM,OACN,KAAA,YACE,CACgB,UACR,EAAA,OACN,GAAM,KACR,SACF,QAAA,CACA,CACA,aAAiB,UACjB,KAAM,GACR,KAAA,YAGE,SAAS,EACT,gBAAM,OACN,KAAA,YACS,CAET,UAAM,EACR,OAAA,GACA,KAAA,cACE,QAAA,CACA,CACA,aAAM,UACN,KAAS,GACP,KAAA,YAEQ,SACN,EAAM,gBACR,OACF,KAAA,YACS,CAET,UAAM,EACR,OAAA,CACA,CACE,aAAU,UACV,KAAS,KACT,KAAM,WAEJ,CACE,aAAc,UACd,KAAM,QACN,KAAM,YAGV,KAAA,WACA,QAAA,CACA,CACF,aAAA,OACA,KAAA,GACE,KAAU,SAGV,SAAS,EAAA,gBACP,aAAA,KACE,YACM,CACA,UACR,EACF,OAAA,CACA,CACA,aAAiB,UACjB,KAAM,OACR,KAAA,WAEE,CACA,aAAQ,UACN,KAAA,KACE,KAAA,WACM,CAER,aAAA,UACA,KAAA,QACE,KAAA,YAEM,KACR,eACF,QAAA,CACA,CACA,a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SAAA,OAAA,EAAA,YAAA,YAAA,EAAA,aAAA,SAAA,OAAA,EAAA,aAAA,UAAA,MACxB,IAAK,MAAA,6BACL,OACA,EAAQ,QAAA,WAAA,cACT,EAAA,eAAA,SAAA,EAAA,gBAKO,EAAA,eAAuB,WAAA,SAAA,EAAA,IAAA,WAAA,sBAAA,SAAA,EAAA,eAhBb,CAgBa,CAEV,QAAA,gBACN,gBAA8B,QAAA,oBACtB,oBAAA,QACb,gBAAA,QACF,8BACA,QAAA,mBAAO,mBAAA,QACR,UACP,QAAA,MAAW,MAAoD,QACjE,cAAA,QAAA,YAAA,QAAA,sCAAA,QAAA,4CAAA,QAAA,4BAAA,QAAA,kCAAA,QAAA","file":"/npm/@pancakeswap/v2-sdk@1.1.7/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@pancakeswap/v2-sdk@1.1.7/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { ChainId } from '@pancakeswap/chains'\nimport type { Address, Hash } from 'viem'\n\nexport const FACTORY_ADDRESS = '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73'\n\nconst FACTORY_ADDRESS_ETH = '0x1097053Fd2ea711dad45caCcc45EfF7548fCB362'\n\nexport const FACTORY_ADDRESS_MAP = {\n  [ChainId.ETHEREUM]: FACTORY_ADDRESS_ETH,\n  [ChainId.GOERLI]: FACTORY_ADDRESS_ETH,\n  [ChainId.BSC]: FACTORY_ADDRESS,\n  [ChainId.BSC_TESTNET]: '0x6725F303b657a9451d8BA641348b6761A6CC7a17',\n  [ChainId.ARBITRUM_ONE]: '0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E',\n  [ChainId.ARBITRUM_GOERLI]: '0x333EAE459075b1d7dE8eb57997b5d4eee5F1070a',\n  [ChainId.POLYGON_ZKEVM]: '0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E',\n  [ChainId.POLYGON_ZKEVM_TESTNET]: '0xBA40c83026213F9cbc79998752721a0312bdB74a',\n  [ChainId.ZKSYNC]: '0xd03D8D566183F0086d8D09A84E1e30b58Dd5619d',\n  [ChainId.ZKSYNC_TESTNET]: '0x48a33610Cd0E130af2024D55F67aE72a8C51aC27',\n  [ChainId.LINEA]: '0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E',\n  [ChainId.LINEA_TESTNET]: '0xB6FAfd4ADbCd21cF665909767e0eD0D05709abfB',\n  [ChainId.OPBNB]: '0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E',\n  [ChainId.OPBNB_TESTNET]: '0x776e4bD2f72de2176A59465e316335aaf8ed4E8F',\n  [ChainId.BASE]: '0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E',\n  [ChainId.BASE_TESTNET]: '0x715303D2eF7dA7FFAbF637651D71FD11d41fAf7F',\n  [ChainId.SCROLL_SEPOLIA]: '0x2B3C5df29F73dbF028BA82C33e0A5A6e5800F75e',\n  [ChainId.SEPOLIA]: '0x1bdc540dEB9Ed1fA29964DeEcCc524A8f5e2198e',\n  [ChainId.ARBITRUM_SEPOLIA]: '0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E',\n  [ChainId.BASE_SEPOLIA]: '0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E',\n  [ChainId.MONAD_TESTNET]: '0x82438CE666d9403e488bA720c7424434e8Aa47CD',\n} as const satisfies Record<ChainId, Address>\n\nexport const INIT_CODE_HASH = '0x00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a84f69bd5'\n\nconst INIT_CODE_HASH_ETH = '0x57224589c67f3f30a6b0d7a1b54cf3153ab84563bc609ef41dfb34f8b2974d2d'\nexport const INIT_CODE_HASH_MAP = {\n  [ChainId.ETHEREUM]: INIT_CODE_HASH_ETH,\n  [ChainId.GOERLI]: INIT_CODE_HASH_ETH,\n  [ChainId.BSC]: INIT_CODE_HASH,\n  [ChainId.BSC_TESTNET]: '0xd0d4c4cd0848c93cb4fd1f498d7013ee6bfb25783ea21593d5834f5d250ece66',\n  [ChainId.ARBITRUM_ONE]: INIT_CODE_HASH_ETH,\n  [ChainId.ARBITRUM_GOERLI]: INIT_CODE_HASH_ETH,\n  [ChainId.POLYGON_ZKEVM]: INIT_CODE_HASH_ETH,\n  [ChainId.POLYGON_ZKEVM_TESTNET]: INIT_CODE_HASH_ETH,\n  [ChainId.ZKSYNC]: '0x0100045707a42494392b3558029b9869f865ff9df8f375dc1bf20b0555093f43',\n  [ChainId.ZKSYNC_TESTNET]: '0x0100045707a42494392b3558029b9869f865ff9df8f375dc1bf20b0555093f43',\n  [ChainId.LINEA]: INIT_CODE_HASH_ETH,\n  [ChainId.LINEA_TESTNET]: INIT_CODE_HASH_ETH,\n  [ChainId.OPBNB]: INIT_CODE_HASH_ETH,\n  [ChainId.OPBNB_TESTNET]: INIT_CODE_HASH_ETH,\n  [ChainId.BASE]: INIT_CODE_HASH_ETH,\n  [ChainId.BASE_TESTNET]: '0xa5934690703a592a07e841ca29d5e5c79b5e22ed4749057bb216dc31100be1c0',\n  [ChainId.SCROLL_SEPOLIA]: INIT_CODE_HASH_ETH,\n  [ChainId.SEPOLIA]: INIT_CODE_HASH_ETH,\n  [ChainId.ARBITRUM_SEPOLIA]: INIT_CODE_HASH_ETH,\n  [ChainId.BASE_SEPOLIA]: INIT_CODE_HASH_ETH,\n  [ChainId.MONAD_TESTNET]: '0xa5934690703a592a07e841ca29d5e5c79b5e22ed4749057bb216dc31100be1c0',\n} as const satisfies Record<ChainId, Hash>\n","import { ChainId } from '@pancakeswap/chains'\nimport {\n  _10000,\n  _9975,\n  BigintIsh,\n  CurrencyAmount,\n  FIVE,\n  InsufficientInputAmountError,\n  InsufficientReservesError,\n  MINIMUM_LIQUIDITY,\n  ONE,\n  Price,\n  sqrt,\n  ZERO,\n} from '@pancakeswap/swap-sdk-core'\nimport { ERC20Token } from '@pancakeswap/swap-sdk-evm'\nimport invariant from 'tiny-invariant'\nimport {\n  Address,\n  ByteArray,\n  concat,\n  encodePacked,\n  getAddress,\n  GetCreate2AddressOptions,\n  Hex,\n  isBytes,\n  keccak256,\n  pad,\n  slice,\n  toBytes,\n} from 'viem'\n\nimport { FACTORY_ADDRESS_MAP, INIT_CODE_HASH_MAP } from '../constants'\n\nlet PAIR_ADDRESS_CACHE: { [key: string]: Address } = {}\n\nconst composeKey = (token0: ERC20Token, token1: ERC20Token) => `${token0.chainId}-${token0.address}-${token1.address}`\n\nfunction getCreate2Address(\n  from_: GetCreate2AddressOptions['from'],\n  salt_: GetCreate2AddressOptions['salt'],\n  initCodeHash: Hex,\n) {\n  const from = toBytes(getAddress(from_))\n  const salt = pad(isBytes(salt_) ? salt_ : toBytes(salt_ as Hex), {\n    size: 32,\n  }) as ByteArray\n\n  return getAddress(slice(keccak256(concat([toBytes('0xff'), from, salt, toBytes(initCodeHash)])), 12))\n}\n\nconst EMPTY_INPU_HASH = '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'\nconst ZKSYNC_PREFIX = '0x2020dba91b30cc0006188af794c2fb30dd8520db7e2c088b7fc7c103c00ca494' // keccak256('zksyncCreate2')\n\nfunction getCreate2AddressZkSync(from: Address, salt: `0x${string}`, initCodeHash: `0x${string}`): `0x${string}` {\n  return getAddress(\n    `0x${keccak256(concat([ZKSYNC_PREFIX, pad(from, { size: 32 }), salt, initCodeHash, EMPTY_INPU_HASH])).slice(26)}`,\n  )\n}\n\nexport const computePairAddress = ({\n  factoryAddress,\n  tokenA,\n  tokenB,\n}: {\n  factoryAddress: Address\n  tokenA: ERC20Token\n  tokenB: ERC20Token\n}): Address => {\n  const [token0, token1] = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA] // does safety checks\n  const key = composeKey(token0, token1)\n\n  if (PAIR_ADDRESS_CACHE?.[key] === undefined) {\n    const getCreate2Address_ =\n      token0.chainId === ChainId.ZKSYNC_TESTNET || token1.chainId === ChainId.ZKSYNC\n        ? getCreate2AddressZkSync\n        : getCreate2Address\n    PAIR_ADDRESS_CACHE = {\n      ...PAIR_ADDRESS_CACHE,\n      [key]: getCreate2Address_(\n        factoryAddress,\n        keccak256(encodePacked(['address', 'address'], [token0.address, token1.address])),\n        INIT_CODE_HASH_MAP[token0.chainId as keyof typeof INIT_CODE_HASH_MAP],\n      ),\n    }\n  }\n\n  return PAIR_ADDRESS_CACHE[key]\n}\n\nexport class Pair {\n  public readonly liquidityToken: ERC20Token\n\n  private readonly tokenAmounts: [CurrencyAmount<ERC20Token>, CurrencyAmount<ERC20Token>]\n\n  public static getAddress(tokenA: ERC20Token, tokenB: ERC20Token): Address {\n    return computePairAddress({\n      factoryAddress: FACTORY_ADDRESS_MAP[tokenA.chainId as keyof typeof FACTORY_ADDRESS_MAP],\n      tokenA,\n      tokenB,\n    })\n  }\n\n  public constructor(currencyAmountA: CurrencyAmount<ERC20Token>, tokenAmountB: CurrencyAmount<ERC20Token>) {\n    const tokenAmounts = currencyAmountA.currency.sortsBefore(tokenAmountB.currency) // does safety checks\n      ? [currencyAmountA, tokenAmountB]\n      : [tokenAmountB, currencyAmountA]\n    this.liquidityToken = new ERC20Token(\n      tokenAmounts[0].currency.chainId,\n      Pair.getAddress(tokenAmounts[0].currency, tokenAmounts[1].currency),\n      18,\n      'Cake-LP',\n      'Pancake LPs',\n    )\n    this.tokenAmounts = tokenAmounts as [CurrencyAmount<ERC20Token>, CurrencyAmount<ERC20Token>]\n  }\n\n  /**\n   * Returns true if the token is either token0 or token1\n   * @param token to check\n   */\n  public involvesToken(token: ERC20Token): boolean {\n    return token.equals(this.token0) || token.equals(this.token1)\n  }\n\n  /**\n   * Returns the current mid price of the pair in terms of token0, i.e. the ratio of reserve1 to reserve0\n   */\n  public get token0Price(): Price<ERC20Token, ERC20Token> {\n    const result = this.tokenAmounts[1].divide(this.tokenAmounts[0])\n    return new Price(this.token0, this.token1, result.denominator, result.numerator)\n  }\n\n  /**\n   * Returns the current mid price of the pair in terms of token1, i.e. the ratio of reserve0 to reserve1\n   */\n  public get token1Price(): Price<ERC20Token, ERC20Token> {\n    const result = this.tokenAmounts[0].divide(this.tokenAmounts[1])\n    return new Price(this.token1, this.token0, result.denominator, result.numerator)\n  }\n\n  /**\n   * Return the price of the given token in terms of the other token in the pair.\n   * @param token token to return price of\n   */\n  public priceOf(token: ERC20Token): Price<ERC20Token, ERC20Token> {\n    invariant(this.involvesToken(token), 'TOKEN')\n    return token.equals(this.token0) ? this.token0Price : this.token1Price\n  }\n\n  /**\n   * Returns the chain ID of the tokens in the pair.\n   */\n  public get chainId(): number {\n    return this.token0.chainId\n  }\n\n  public get token0(): ERC20Token {\n    return this.tokenAmounts[0].currency\n  }\n\n  public get token1(): ERC20Token {\n    return this.tokenAmounts[1].currency\n  }\n\n  public get reserve0(): CurrencyAmount<ERC20Token> {\n    return this.tokenAmounts[0]\n  }\n\n  public get reserve1(): CurrencyAmount<ERC20Token> {\n    return this.tokenAmounts[1]\n  }\n\n  public reserveOf(token: ERC20Token): CurrencyAmount<ERC20Token> {\n    invariant(this.involvesToken(token), 'TOKEN')\n    return token.equals(this.token0) ? this.reserve0 : this.reserve1\n  }\n\n  public getOutputAmount(inputAmount: CurrencyAmount<ERC20Token>): [CurrencyAmount<ERC20Token>, Pair] {\n    invariant(this.involvesToken(inputAmount.currency), 'TOKEN')\n    if (this.reserve0.quotient === ZERO || this.reserve1.quotient === ZERO) {\n      throw new InsufficientReservesError()\n    }\n    const inputReserve = this.reserveOf(inputAmount.currency)\n    const outputReserve = this.reserveOf(inputAmount.currency.equals(this.token0) ? this.token1 : this.token0)\n    const inputAmountWithFee = inputAmount.quotient * _9975\n    const numerator = inputAmountWithFee * outputReserve.quotient\n    const denominator = inputReserve.quotient * _10000 + inputAmountWithFee\n    const outputAmount = CurrencyAmount.fromRawAmount(\n      inputAmount.currency.equals(this.token0) ? this.token1 : this.token0,\n      numerator / denominator,\n    )\n    if (outputAmount.quotient === ZERO) {\n      throw new InsufficientInputAmountError()\n    }\n    return [outputAmount, new Pair(inputReserve.add(inputAmount), outputReserve.subtract(outputAmount))]\n  }\n\n  public getInputAmount(outputAmount: CurrencyAmount<ERC20Token>): [CurrencyAmount<ERC20Token>, Pair] {\n    invariant(this.involvesToken(outputAmount.currency), 'TOKEN')\n    if (\n      this.reserve0.quotient === ZERO ||\n      this.reserve1.quotient === ZERO ||\n      outputAmount.quotient >= this.reserveOf(outputAmount.currency).quotient\n    ) {\n      throw new InsufficientReservesError()\n    }\n\n    const outputReserve = this.reserveOf(outputAmount.currency)\n    const inputReserve = this.reserveOf(outputAmount.currency.equals(this.token0) ? this.token1 : this.token0)\n    const numerator = inputReserve.quotient * outputAmount.quotient * _10000\n    const denominator = (outputReserve.quotient - outputAmount.quotient) * _9975\n    const inputAmount = CurrencyAmount.fromRawAmount(\n      outputAmount.currency.equals(this.token0) ? this.token1 : this.token0,\n      numerator / denominator + ONE,\n    )\n    return [inputAmount, new Pair(inputReserve.add(inputAmount), outputReserve.subtract(outputAmount))]\n  }\n\n  public getLiquidityMinted(\n    totalSupply: CurrencyAmount<ERC20Token>,\n    tokenAmountA: CurrencyAmount<ERC20Token>,\n    tokenAmountB: CurrencyAmount<ERC20Token>,\n  ): CurrencyAmount<ERC20Token> {\n    invariant(totalSupply.currency.equals(this.liquidityToken), 'LIQUIDITY')\n    const tokenAmounts = tokenAmountA.currency.sortsBefore(tokenAmountB.currency) // does safety checks\n      ? [tokenAmountA, tokenAmountB]\n      : [tokenAmountB, tokenAmountA]\n    invariant(tokenAmounts[0].currency.equals(this.token0) && tokenAmounts[1].currency.equals(this.token1), 'TOKEN')\n\n    let liquidity: bigint\n    if (totalSupply.quotient === ZERO) {\n      liquidity = sqrt(tokenAmounts[0].quotient * tokenAmounts[1].quotient) - MINIMUM_LIQUIDITY\n    } else {\n      const amount0 = (tokenAmounts[0].quotient * totalSupply.quotient) / this.reserve0.quotient\n      const amount1 = (tokenAmounts[1].quotient * totalSupply.quotient) / this.reserve1.quotient\n      liquidity = amount0 <= amount1 ? amount0 : amount1\n    }\n    if (!(liquidity > ZERO)) {\n      throw new InsufficientInputAmountError()\n    }\n    return CurrencyAmount.fromRawAmount(this.liquidityToken, liquidity)\n  }\n\n  public getLiquidityValue(\n    token: ERC20Token,\n    totalSupply: CurrencyAmount<ERC20Token>,\n    liquidity: CurrencyAmount<ERC20Token>,\n    feeOn = false,\n    kLast?: BigintIsh,\n  ): CurrencyAmount<ERC20Token> {\n    invariant(this.involvesToken(token), 'TOKEN')\n    invariant(totalSupply.currency.equals(this.liquidityToken), 'TOTAL_SUPPLY')\n    invariant(liquidity.currency.equals(this.liquidityToken), 'LIQUIDITY')\n    invariant(liquidity.quotient <= totalSupply.quotient, 'LIQUIDITY')\n\n    let totalSupplyAdjusted: CurrencyAmount<ERC20Token>\n    if (!feeOn) {\n      totalSupplyAdjusted = totalSupply\n    } else {\n      invariant(!!kLast, 'K_LAST')\n      const kLastParsed = BigInt(kLast)\n      if (!(kLastParsed === ZERO)) {\n        const rootK = sqrt(this.reserve0.quotient * this.reserve1.quotient)\n        const rootKLast = sqrt(kLastParsed)\n        if (rootK > rootKLast) {\n          const numerator = totalSupply.quotient * (rootK - rootKLast)\n          const denominator = rootK * FIVE + rootKLast\n          const feeLiquidity = numerator / denominator\n          totalSupplyAdjusted = totalSupply.add(CurrencyAmount.fromRawAmount(this.liquidityToken, feeLiquidity))\n        } else {\n          totalSupplyAdjusted = totalSupply\n        }\n      } else {\n        totalSupplyAdjusted = totalSupply\n      }\n    }\n\n    if (totalSupply.equalTo(0)) {\n      return CurrencyAmount.fromRawAmount(token, 0)\n    }\n\n    return CurrencyAmount.fromRawAmount(\n      token,\n      (liquidity.quotient * this.reserveOf(token).quotient) / totalSupplyAdjusted.quotient,\n    )\n  }\n}\n","import invariant from 'tiny-invariant'\nimport { Token, Currency, Price } from '@pancakeswap/swap-sdk-core'\n\nimport { Pair } from './pair'\n\nexport class Route<TInput extends Currency, TOutput extends Currency> {\n  public readonly pairs: Pair[]\n\n  public readonly path: Token[]\n\n  public readonly input: TInput\n\n  public readonly output: TOutput\n\n  public constructor(pairs: Pair[], input: TInput, output: TOutput) {\n    invariant(pairs.length > 0, 'PAIRS')\n    const { chainId } = pairs[0]\n    invariant(\n      pairs.every((pair) => pair.chainId === chainId),\n      'CHAIN_IDS',\n    )\n\n    const wrappedInput = input.wrapped\n    invariant(pairs[0].involvesToken(wrappedInput), 'INPUT')\n    invariant(typeof output === 'undefined' || pairs[pairs.length - 1].involvesToken(output.wrapped), 'OUTPUT')\n\n    const path: Token[] = [wrappedInput]\n    for (const [i, pair] of pairs.entries()) {\n      const currentInput = path[i]\n      invariant(currentInput.equals(pair.token0) || currentInput.equals(pair.token1), 'PATH')\n      // eslint-disable-next-line @typescript-eslint/no-shadow\n      const output = currentInput.equals(pair.token0) ? pair.token1 : pair.token0\n      path.push(output)\n    }\n\n    this.pairs = pairs\n    this.path = path\n    this.input = input\n    this.output = output\n  }\n\n  private _midPrice: Price<TInput, TOutput> | null = null\n\n  public get midPrice(): Price<TInput, TOutput> {\n    if (this._midPrice !== null) return this._midPrice\n    const prices: Price<Currency, Currency>[] = []\n    for (const [i, pair] of this.pairs.entries()) {\n      prices.push(\n        this.path[i].equals(pair.token0)\n          ? new Price(pair.reserve0.currency, pair.reserve1.currency, pair.reserve0.quotient, pair.reserve1.quotient)\n          : new Price(pair.reserve1.currency, pair.reserve0.currency, pair.reserve1.quotient, pair.reserve0.quotient),\n      )\n    }\n    const reduced = prices.slice(1).reduce((accumulator, currentValue) => accumulator.multiply(currentValue), prices[0])\n    // eslint-disable-next-line no-return-assign\n    return (this._midPrice = new Price(this.input, this.output, reduced.denominator, reduced.numerator))\n  }\n\n  public get chainId(): number {\n    return this.pairs[0].chainId\n  }\n}\n","import invariant from 'tiny-invariant'\nimport {\n  InsufficientInputAmountError,\n  InsufficientReservesError,\n  ONE,\n  TradeType,\n  ZERO,\n  CurrencyAmount,\n  Currency,\n  Fraction,\n  Percent,\n  Price,\n  Token,\n  sortedInsert,\n  computePriceImpact,\n} from '@pancakeswap/swap-sdk-core'\n\nimport { Pair } from './pair'\nimport { Route } from './route'\n\n// minimal interface so the input output comparator may be shared across types\ninterface InputOutput<TInput extends Currency, TOutput extends Currency> {\n  readonly inputAmount: CurrencyAmount<TInput>\n  readonly outputAmount: CurrencyAmount<TOutput>\n}\n\n// comparator function that allows sorting trades by their output amounts, in decreasing order, and then input amounts\n// in increasing order. i.e. the best trades have the most outputs for the least inputs and are sorted first\nexport function inputOutputComparator<TInput extends Currency, TOutput extends Currency>(\n  a: InputOutput<TInput, TOutput>,\n  b: InputOutput<TInput, TOutput>,\n): number {\n  // must have same input and output token 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      return 0\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    }\n    return 1\n  }\n  // tradeA has less output than trade B, so should come second\n  if (a.outputAmount.lessThan(b.outputAmount)) {\n    return 1\n  }\n  return -1\n}\n\n// extension of the input output comparator that also considers other dimensions of the trade in ranking them\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  const ioComp = inputOutputComparator(a, b)\n  if (ioComp !== 0) {\n    return ioComp\n  }\n\n  // consider lowest slippage next, since these are less likely to fail\n  if (a.priceImpact.lessThan(b.priceImpact)) {\n    return -1\n  }\n  if (a.priceImpact.greaterThan(b.priceImpact)) {\n    return 1\n  }\n\n  // finally consider the number of hops since each hop costs gas\n  return a.route.path.length - b.route.path.length\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 list of pairs.\n * Does not account for slippage, i.e. trades that front run this trade and move the price.\n */\nexport class Trade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType> {\n  /**\n   * The route of the trade, i.e. which pairs the trade goes through and the input/output currencies.\n   */\n  public readonly route: Route<TInput, TOutput>\n\n  /**\n   * The type of the trade, either exact in or exact out.\n   */\n  public readonly tradeType: TTradeType\n\n  /**\n   * The input amount for the trade assuming no slippage.\n   */\n  public readonly inputAmount: CurrencyAmount<TInput>\n\n  /**\n   * The output amount for the trade assuming no slippage.\n   */\n  public readonly outputAmount: CurrencyAmount<TOutput>\n\n  /**\n   * The price expressed in terms of output amount/input amount.\n   */\n  public readonly executionPrice: Price<TInput, TOutput>\n\n  /**\n   * The percent difference between the mid price before the trade and the trade execution price.\n   */\n  public readonly priceImpact: Percent\n\n  /**\n   * Constructs an exact in trade with the given amount in and route\n   * @param route route of the exact in trade\n   * @param amountIn the amount being passed in\n   */\n  public static exactIn<TInput extends Currency, TOutput extends Currency>(\n    route: Route<TInput, TOutput>,\n    amountIn: CurrencyAmount<TInput>,\n  ): Trade<TInput, TOutput, TradeType.EXACT_INPUT> {\n    return new Trade(route, amountIn, TradeType.EXACT_INPUT)\n  }\n\n  /**\n   * Constructs an exact out trade with the given amount out and route\n   * @param route route of the exact out trade\n   * @param amountOut the amount returned by the trade\n   */\n  public static exactOut<TInput extends Currency, TOutput extends Currency>(\n    route: Route<TInput, TOutput>,\n    amountOut: CurrencyAmount<TOutput>,\n  ): Trade<TInput, TOutput, TradeType.EXACT_OUTPUT> {\n    return new Trade(route, amountOut, TradeType.EXACT_OUTPUT)\n  }\n\n  public constructor(\n    route: Route<TInput, TOutput>,\n    amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>,\n    tradeType: TTradeType,\n  ) {\n    this.route = route\n    this.tradeType = tradeType\n\n    const tokenAmounts: CurrencyAmount<Token>[] = new Array(route.path.length)\n    if (tradeType === TradeType.EXACT_INPUT) {\n      invariant(amount.currency.equals(route.input), 'INPUT')\n      tokenAmounts[0] = amount.wrapped\n      for (let i = 0; i < route.path.length - 1; i++) {\n        const pair = route.pairs[i]\n        const [outputAmount] = pair.getOutputAmount(tokenAmounts[i])\n        tokenAmounts[i + 1] = outputAmount\n      }\n      this.inputAmount = CurrencyAmount.fromFractionalAmount(route.input, amount.numerator, amount.denominator)\n      this.outputAmount = CurrencyAmount.fromFractionalAmount(\n        route.output,\n        tokenAmounts[tokenAmounts.length - 1].numerator,\n        tokenAmounts[tokenAmounts.length - 1].denominator,\n      )\n    } else {\n      invariant(amount.currency.equals(route.output), 'OUTPUT')\n      tokenAmounts[tokenAmounts.length - 1] = amount.wrapped\n      for (let i = route.path.length - 1; i > 0; i--) {\n        const pair = route.pairs[i - 1]\n        const [inputAmount] = pair.getInputAmount(tokenAmounts[i])\n        tokenAmounts[i - 1] = inputAmount\n      }\n      this.inputAmount = CurrencyAmount.fromFractionalAmount(\n        route.input,\n        tokenAmounts[0].numerator,\n        tokenAmounts[0].denominator,\n      )\n      this.outputAmount = CurrencyAmount.fromFractionalAmount(route.output, amount.numerator, amount.denominator)\n    }\n    this.executionPrice = new Price(\n      this.inputAmount.currency,\n      this.outputAmount.currency,\n      this.inputAmount.quotient,\n      this.outputAmount.quotient,\n    )\n    this.priceImpact = computePriceImpact(route.midPrice, this.inputAmount, this.outputAmount)\n  }\n\n  /**\n   * Get the minimum amount that must be received from this trade for the given slippage tolerance\n   * @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade\n   */\n  public minimumAmountOut(slippageTolerance: Percent): CurrencyAmount<TOutput> {\n    invariant(!slippageTolerance.lessThan(ZERO), 'SLIPPAGE_TOLERANCE')\n    if (this.tradeType === TradeType.EXACT_OUTPUT) {\n      return this.outputAmount\n    }\n    const slippageAdjustedAmountOut = new Fraction(ONE)\n      .add(slippageTolerance)\n      .invert()\n      .multiply(this.outputAmount.quotient).quotient\n    return CurrencyAmount.fromRawAmount(this.outputAmount.currency, slippageAdjustedAmountOut)\n  }\n\n  /**\n   * Get the maximum amount in that can be spent via this trade for the given slippage tolerance\n   * @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade\n   */\n  public maximumAmountIn(slippageTolerance: Percent): CurrencyAmount<TInput> {\n    invariant(!slippageTolerance.lessThan(ZERO), 'SLIPPAGE_TOLERANCE')\n    if (this.tradeType === TradeType.EXACT_INPUT) {\n      return this.inputAmount\n    }\n    const slippageAdjustedAmountIn = new Fraction(ONE)\n      .add(slippageTolerance)\n      .multiply(this.inputAmount.quotient).quotient\n    return CurrencyAmount.fromRawAmount(this.inputAmount.currency, slippageAdjustedAmountIn)\n  }\n\n  /**\n   * Given a list of pairs, and a fixed amount in, returns the top `maxNumResults` trades that go from an input token\n   * amount to an output token, 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 pairs the pairs 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 pair\n   * @param currentPairs used in recursion; the current list of pairs\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   */\n  public static bestTradeExactIn<TInput extends Currency, TOutput extends Currency>(\n    pairs: Pair[],\n    currencyAmountIn: CurrencyAmount<TInput>,\n    currencyOut: TOutput,\n    { maxNumResults = 3, maxHops = 3 }: BestTradeOptions = {},\n    // used in recursion.\n    currentPairs: Pair[] = [],\n    nextAmountIn: CurrencyAmount<Currency> = currencyAmountIn,\n    bestTrades: Trade<TInput, TOutput, TradeType.EXACT_INPUT>[] = [],\n  ): Trade<TInput, TOutput, TradeType.EXACT_INPUT>[] {\n    invariant(pairs.length > 0, 'PAIRS')\n    invariant(maxHops > 0, 'MAX_HOPS')\n    invariant(currencyAmountIn === nextAmountIn || currentPairs.length > 0, 'INVALID_RECURSION')\n\n    const amountIn = nextAmountIn.wrapped\n    const tokenOut = currencyOut.wrapped\n    for (let i = 0; i < pairs.length; i++) {\n      const pair = pairs[i]\n      // pair irrelevant\n      // eslint-disable-next-line no-continue\n      if (!pair.token0.equals(amountIn.currency) && !pair.token1.equals(amountIn.currency)) continue\n      // eslint-disable-next-line no-continue\n      if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO)) continue\n\n      let amountOut: CurrencyAmount<Token>\n      try {\n        // eslint-disable-next-line @typescript-eslint/no-extra-semi\n        ;[amountOut] = pair.getOutputAmount(amountIn)\n      } catch (error) {\n        // input too low\n        if ((error as InsufficientInputAmountError).isInsufficientInputAmountError) {\n          // eslint-disable-next-line no-continue\n          continue\n        }\n        throw error\n      }\n      // we have arrived at the output token, so this is the final trade of one of the paths\n      if (amountOut.currency.equals(tokenOut)) {\n        sortedInsert(\n          bestTrades,\n          new Trade(\n            new Route([...currentPairs, pair], currencyAmountIn.currency, currencyOut),\n            currencyAmountIn,\n            TradeType.EXACT_INPUT,\n          ),\n          maxNumResults,\n          tradeComparator,\n        )\n      } else if (maxHops > 1 && pairs.length > 1) {\n        const pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length))\n\n        // otherwise, consider all the other paths that lead from this token as long as we have not exceeded maxHops\n        Trade.bestTradeExactIn(\n          pairsExcludingThisPair,\n          currencyAmountIn,\n          currencyOut,\n          {\n            maxNumResults,\n            maxHops: maxHops - 1,\n          },\n          [...currentPairs, pair],\n          amountOut,\n          bestTrades,\n        )\n      }\n    }\n\n    return bestTrades\n  }\n\n  /**\n   * Return the execution price after accounting for slippage tolerance\n   * @param slippageTolerance the allowed tolerated slippage\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   * similar to the above method but instead targets a fixed output amount\n   * given a list of pairs, and a fixed amount out, returns the top `maxNumResults` trades that go from an input token\n   * to an output token 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 pairs the pairs to consider in finding the best trade\n   * @param currencyIn the currency to spend\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 pair\n   * @param currentPairs used in recursion; the current list of pairs\n   * @param currencyAmountOut used in recursion; the original value of the currencyAmountOut parameter\n   * @param bestTrades used in recursion; the current list of best trades\n   */\n  public static bestTradeExactOut<TInput extends Currency, TOutput extends Currency>(\n    pairs: Pair[],\n    currencyIn: TInput,\n    currencyAmountOut: CurrencyAmount<TOutput>,\n    { maxNumResults = 3, maxHops = 3 }: BestTradeOptions = {},\n    // used in recursion.\n    currentPairs: Pair[] = [],\n    nextAmountOut: CurrencyAmount<Currency> = currencyAmountOut,\n    bestTrades: Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>[] = [],\n  ): Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>[] {\n    invariant(pairs.length > 0, 'PAIRS')\n    invariant(maxHops > 0, 'MAX_HOPS')\n    invariant(currencyAmountOut === nextAmountOut || currentPairs.length > 0, 'INVALID_RECURSION')\n\n    const amountOut = nextAmountOut.wrapped\n    const tokenIn = currencyIn.wrapped\n    for (let i = 0; i < pairs.length; i++) {\n      const pair = pairs[i]\n      // pair irrelevant\n      // eslint-disable-next-line no-continue\n      if (!pair.token0.equals(amountOut.currency) && !pair.token1.equals(amountOut.currency)) continue\n      // eslint-disable-next-line no-continue\n      if (pair.reserve0.equalTo(ZERO) || pair.reserve1.equalTo(ZERO)) continue\n\n      let amountIn: CurrencyAmount<Token>\n      try {\n        // eslint-disable-next-line @typescript-eslint/no-extra-semi\n        ;[amountIn] = pair.getInputAmount(amountOut)\n      } catch (error) {\n        // not enough liquidity in this pair\n        if ((error as InsufficientReservesError).isInsufficientReservesError) {\n          // eslint-disable-next-line no-continue\n          continue\n        }\n        throw error\n      }\n      // we have arrived at the input token, so this is the first trade of one of the paths\n      if (amountIn.currency.equals(tokenIn)) {\n        sortedInsert(\n          bestTrades,\n          new Trade(\n            new Route([pair, ...currentPairs], currencyIn, currencyAmountOut.currency),\n            currencyAmountOut,\n            TradeType.EXACT_OUTPUT,\n          ),\n          maxNumResults,\n          tradeComparator,\n        )\n      } else if (maxHops > 1 && pairs.length > 1) {\n        const pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length))\n\n        // otherwise, consider all the other paths that arrive at this token as long as we have not exceeded maxHops\n        Trade.bestTradeExactOut(\n          pairsExcludingThisPair,\n          currencyIn,\n          currencyAmountOut,\n          {\n            maxNumResults,\n            maxHops: maxHops - 1,\n          },\n          [pair, ...currentPairs],\n          amountIn,\n          bestTrades,\n        )\n      }\n    }\n\n    return bestTrades\n  }\n}\n","export const pancakePairV2ABI = [\n  {\n    anonymous: false,\n    inputs: [\n      {\n        indexed: true,\n        internalType: 'address',\n        name: 'owner',\n        type: 'address',\n      },\n      {\n        indexed: true,\n        internalType: 'address',\n        name: 'spender',\n        type: 'address',\n      },\n      {\n        indexed: false,\n        internalType: 'uint256',\n        name: 'value',\n        type: 'uint256',\n      },\n    ],\n    name: 'Approval',\n    type: 'event',\n  },\n  {\n    anonymous: false,\n    inputs: [\n      {\n        indexed: true,\n        internalType: 'address',\n        name: 'sender',\n        type: 'address',\n      },\n      {\n        indexed: false,\n        internalType: 'uint256',\n        name: 'amount0',\n        type: 'uint256',\n      },\n      {\n        indexed: false,\n        internalType: 'uint256',\n        name: 'amount1',\n        type: 'uint256',\n      },\n      {\n        indexed: true,\n        internalType: 'address',\n        name: 'to',\n        type: 'address',\n      },\n    ],\n    name: 'Burn',\n    type: 'event',\n  },\n  {\n    anonymous: false,\n    inputs: [\n      {\n        indexed: true,\n        internalType: 'address',\n        name: 'sender',\n        type: 'address',\n      },\n      {\n        indexed: false,\n        internalType: 'uint256',\n        name: 'amount0',\n        type: 'uint256',\n      },\n      {\n        indexed: false,\n        internalType: 'uint256',\n        name: 'amount1',\n        type: 'uint256',\n      },\n    ],\n    name: 'Mint',\n    type: 'event',\n  },\n  {\n    anonymous: false,\n    inputs: [\n      {\n        indexed: true,\n        internalType: 'address',\n        name: 'sender',\n        type: 'address',\n      },\n      {\n        indexed: false,\n        internalType: 'uint256',\n        name: 'amount0In',\n        type: 'uint256',\n      },\n      {\n        indexed: false,\n        internalType: 'uint256',\n        name: 'amount1In',\n        type: 'uint256',\n      },\n      {\n        indexed: false,\n        internalType: 'uint256',\n        name: 'amount0Out',\n        type: 'uint256',\n      },\n      {\n        indexed: false,\n        internalType: 'uint256',\n        name: 'amount1Out',\n        type: 'uint256',\n      },\n      {\n        indexed: true,\n        internalType: 'address',\n        name: 'to',\n        type: 'address',\n      },\n    ],\n    name: 'Swap',\n    type: 'event',\n  },\n  {\n    anonymous: false,\n    inputs: [\n      {\n        indexed: false,\n        internalType: 'uint112',\n        name: 'reserve0',\n        type: 'uint112',\n      },\n      {\n        indexed: false,\n        internalType: 'uint112',\n        name: 'reserve1',\n        type: 'uint112',\n      },\n    ],\n    name: 'Sync',\n    type: 'event',\n  },\n  {\n    anonymous: false,\n    inputs: [\n      {\n        indexed: true,\n        internalType: 'address',\n        name: 'from',\n        type: 'address',\n      },\n      {\n        indexed: true,\n        internalType: 'address',\n        name: 'to',\n        type: 'address',\n      },\n      {\n        indexed: false,\n        internalType: 'uint256',\n        name: 'value',\n        type: 'uint256',\n      },\n    ],\n    name: 'Transfer',\n    type: 'event',\n  },\n  {\n    constant: true,\n    inputs: [],\n    name: 'DOMAIN_SEPARATOR',\n    outputs: [\n      {\n        internalType: 'bytes32',\n        name: '',\n        type: 'bytes32',\n      },\n    ],\n    payable: false,\n    stateMutability: 'view',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [],\n    name: 'MINIMUM_LIQUIDITY',\n    outputs: [\n      {\n        internalType: 'uint256',\n        name: '',\n        type: 'uint256',\n      },\n    ],\n    payable: false,\n    stateMutability: 'pure',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [],\n    name: 'PERMIT_TYPEHASH',\n    outputs: [\n      {\n        internalType: 'bytes32',\n        name: '',\n        type: 'bytes32',\n      },\n    ],\n    payable: false,\n    stateMutability: 'pure',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [\n      {\n        internalType: 'address',\n        name: 'owner',\n        type: 'address',\n      },\n      {\n        internalType: 'address',\n        name: 'spender',\n        type: 'address',\n      },\n    ],\n    name: 'allowance',\n    outputs: [\n      {\n        internalType: 'uint256',\n        name: '',\n        type: 'uint256',\n      },\n    ],\n    payable: false,\n    stateMutability: 'view',\n    type: 'function',\n  },\n  {\n    constant: false,\n    inputs: [\n      {\n        internalType: 'address',\n        name: 'spender',\n        type: 'address',\n      },\n      {\n        internalType: 'uint256',\n        name: 'value',\n        type: 'uint256',\n      },\n    ],\n    name: 'approve',\n    outputs: [\n      {\n        internalType: 'bool',\n        name: '',\n        type: 'bool',\n      },\n    ],\n    payable: false,\n    stateMutability: 'nonpayable',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [\n      {\n        internalType: 'address',\n        name: 'owner',\n        type: 'address',\n      },\n    ],\n    name: 'balanceOf',\n    outputs: [\n      {\n        internalType: 'uint256',\n        name: '',\n        type: 'uint256',\n      },\n    ],\n    payable: false,\n    stateMutability: 'view',\n    type: 'function',\n  },\n  {\n    constant: false,\n    inputs: [\n      {\n        internalType: 'address',\n        name: 'to',\n        type: 'address',\n      },\n    ],\n    name: 'burn',\n    outputs: [\n      {\n        internalType: 'uint256',\n        name: 'amount0',\n        type: 'uint256',\n      },\n      {\n        internalType: 'uint256',\n        name: 'amount1',\n        type: 'uint256',\n      },\n    ],\n    payable: false,\n    stateMutability: 'nonpayable',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [],\n    name: 'decimals',\n    outputs: [\n      {\n        internalType: 'uint8',\n        name: '',\n        type: 'uint8',\n      },\n    ],\n    payable: false,\n    stateMutability: 'pure',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [],\n    name: 'factory',\n    outputs: [\n      {\n        internalType: 'address',\n        name: '',\n        type: 'address',\n      },\n    ],\n    payable: false,\n    stateMutability: 'view',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [],\n    name: 'getReserves',\n    outputs: [\n      {\n        internalType: 'uint112',\n        name: 'reserve0',\n        type: 'uint112',\n      },\n      {\n        internalType: 'uint112',\n        name: 'reserve1',\n        type: 'uint112',\n      },\n      {\n        internalType: 'uint32',\n        name: 'blockTimestampLast',\n        type: 'uint32',\n      },\n    ],\n    payable: false,\n    stateMutability: 'view',\n    type: 'function',\n  },\n  {\n    constant: false,\n    inputs: [\n      {\n        internalType: 'address',\n        name: '',\n        type: 'address',\n      },\n      {\n        internalType: 'address',\n        name: '',\n        type: 'address',\n      },\n    ],\n    name: 'initialize',\n    outputs: [],\n    payable: false,\n    stateMutability: 'nonpayable',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [],\n    name: 'kLast',\n    outputs: [\n      {\n        internalType: 'uint256',\n        name: '',\n        type: 'uint256',\n      },\n    ],\n    payable: false,\n    stateMutability: 'view',\n    type: 'function',\n  },\n  {\n    constant: false,\n    inputs: [\n      {\n        internalType: 'address',\n        name: 'to',\n        type: 'address',\n      },\n    ],\n    name: 'mint',\n    outputs: [\n      {\n        internalType: 'uint256',\n        name: 'liquidity',\n        type: 'uint256',\n      },\n    ],\n    payable: false,\n    stateMutability: 'nonpayable',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [],\n    name: 'name',\n    outputs: [\n      {\n        internalType: 'string',\n        name: '',\n        type: 'string',\n      },\n    ],\n    payable: false,\n    stateMutability: 'pure',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [\n      {\n        internalType: 'address',\n        name: 'owner',\n        type: 'address',\n      },\n    ],\n    name: 'nonces',\n    outputs: [\n      {\n        internalType: 'uint256',\n        name: '',\n        type: 'uint256',\n      },\n    ],\n    payable: false,\n    stateMutability: 'view',\n    type: 'function',\n  },\n  {\n    constant: false,\n    inputs: [\n      {\n        internalType: 'address',\n        name: 'owner',\n        type: 'address',\n      },\n      {\n        internalType: 'address',\n        name: 'spender',\n        type: 'address',\n      },\n      {\n        internalType: 'uint256',\n        name: 'value',\n        type: 'uint256',\n      },\n      {\n        internalType: 'uint256',\n        name: 'deadline',\n        type: 'uint256',\n      },\n      {\n        internalType: 'uint8',\n        name: 'v',\n        type: 'uint8',\n      },\n      {\n        internalType: 'bytes32',\n        name: 'r',\n        type: 'bytes32',\n      },\n      {\n        internalType: 'bytes32',\n        name: 's',\n        type: 'bytes32',\n      },\n    ],\n    name: 'permit',\n    outputs: [],\n    payable: false,\n    stateMutability: 'nonpayable',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [],\n    name: 'price0CumulativeLast',\n    outputs: [\n      {\n        internalType: 'uint256',\n        name: '',\n        type: 'uint256',\n      },\n    ],\n    payable: false,\n    stateMutability: 'view',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [],\n    name: 'price1CumulativeLast',\n    outputs: [\n      {\n        internalType: 'uint256',\n        name: '',\n        type: 'uint256',\n      },\n    ],\n    payable: false,\n    stateMutability: 'view',\n    type: 'function',\n  },\n  {\n    constant: false,\n    inputs: [\n      {\n        internalType: 'address',\n        name: 'to',\n        type: 'address',\n      },\n    ],\n    name: 'skim',\n    outputs: [],\n    payable: false,\n    stateMutability: 'nonpayable',\n    type: 'function',\n  },\n  {\n    constant: false,\n    inputs: [\n      {\n        internalType: 'uint256',\n        name: 'amount0Out',\n        type: 'uint256',\n      },\n      {\n        internalType: 'uint256',\n        name: 'amount1Out',\n        type: 'uint256',\n      },\n      {\n        internalType: 'address',\n        name: 'to',\n        type: 'address',\n      },\n      {\n        internalType: 'bytes',\n        name: 'data',\n        type: 'bytes',\n      },\n    ],\n    name: 'swap',\n    outputs: [],\n    payable: false,\n    stateMutability: 'nonpayable',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [],\n    name: 'symbol',\n    outputs: [\n      {\n        internalType: 'string',\n        name: '',\n        type: 'string',\n      },\n    ],\n    payable: false,\n    stateMutability: 'pure',\n    type: 'function',\n  },\n  {\n    constant: false,\n    inputs: [],\n    name: 'sync',\n    outputs: [],\n    payable: false,\n    stateMutability: 'nonpayable',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [],\n    name: 'token0',\n    outputs: [\n      {\n        internalType: 'address',\n        name: '',\n        type: 'address',\n      },\n    ],\n    payable: false,\n    stateMutability: 'view',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [],\n    name: 'token1',\n    outputs: [\n      {\n        internalType: 'address',\n        name: '',\n        type: 'address',\n      },\n    ],\n    payable: false,\n    stateMutability: 'view',\n    type: 'function',\n  },\n  {\n    constant: true,\n    inputs: [],\n    name: 'totalSupply',\n    outputs: [\n      {\n        internalType: 'uint256',\n        name: '',\n        type: 'uint256',\n      },\n    ],\n    payable: false,\n    stateMutability: 'view',\n    type: 'function',\n  },\n  {\n    constant: false,\n    inputs: [\n      {\n        internalType: 'address',\n        name: 'to',\n        type: 'address',\n      },\n      {\n        internalType: 'uint256',\n        name: 'value',\n        type: 'uint256',\n      },\n    ],\n    name: 'transfer',\n    outputs: [\n      {\n        internalType: 'bool',\n        name: '',\n        type: 'bool',\n      },\n    ],\n    payable: false,\n    stateMutability: 'nonpayable',\n    type: 'function',\n  },\n  {\n    constant: false,\n    inputs: [\n      {\n        internalType: 'address',\n        name: 'from',\n        type: 'address',\n      },\n      {\n        internalType: 'address',\n        name: 'to',\n        type: 'address',\n      },\n      {\n        internalType: 'uint256',\n        name: 'value',\n        type: 'uint256',\n      },\n    ],\n    name: 'transferFrom',\n    outputs: [\n      {\n        internalType: 'bool',\n        name: '',\n        type: 'bool',\n      },\n    ],\n    payable: false,\n    stateMutability: 'nonpayable',\n    type: 'function',\n  },\n] as const\n","import { Currency, CurrencyAmount, Percent, Token, TradeType } from '@pancakeswap/swap-sdk-core'\nimport { validateAndParseAddress } from '@pancakeswap/swap-sdk-evm'\nimport invariant from 'tiny-invariant'\nimport { Address, Hex } from 'viem'\n\nimport { Trade } from './entities'\n\n/**\n * Options for producing the arguments to send call to the router.\n */\nexport interface TradeOptions {\n  /**\n   * How much the execution price is allowed to move unfavorably from the trade execution price.\n   */\n  allowedSlippage: Percent\n  /**\n   * How long the swap is valid until it expires, in seconds.\n   * This will be used to produce a `deadline` parameter which is computed from when the swap call parameters\n   * are generated.\n   */\n  ttl: number\n  /**\n   * The account that should receive the output of the swap.\n   */\n  recipient: string\n\n  /**\n   * Whether any of the tokens in the path are fee on transfer tokens, which should be handled with special methods\n   */\n  feeOnTransfer?: boolean\n}\n\nexport interface TradeOptionsDeadline extends Omit<TradeOptions, 'ttl'> {\n  /**\n   * When the transaction expires.\n   * This is an atlernate to specifying the ttl, for when you do not want to use local time.\n   */\n  deadline: number\n}\n\n/**\n * The parameters to use in the call to the Pancake Router to execute a trade.\n */\nexport interface SwapParameters {\n  /**\n   * The method to call on the Pancake Router.\n   */\n  methodName: string\n  /**\n   * The arguments to pass to the method, all hex encoded.\n   */\n  args: Array<Hex | Hex[] | unknown>\n  /**\n   * The amount of wei to send in hex.\n   */\n  value: Hex\n}\n\nfunction toHex(currencyAmount: CurrencyAmount<Currency>): Hex {\n  return `0x${currencyAmount.quotient.toString(16)}`\n}\n\nconst ZERO_HEX = '0x0'\n\n/**\n * Represents the Pancake Router, and has static methods for helping execute trades.\n */\nexport abstract class Router {\n  /**\n   * Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade.\n   * @param trade to produce call parameters for\n   * @param options options for the call parameters\n   */\n  public static swapCallParameters(\n    trade: Trade<Currency, Currency, TradeType>,\n    options: TradeOptions | TradeOptionsDeadline,\n  ): SwapParameters {\n    const etherIn = trade.inputAmount.currency.isNative\n    const etherOut = trade.outputAmount.currency.isNative\n    // the router does not support both ether in and out\n    invariant(!(etherIn && etherOut), 'ETHER_IN_OUT')\n    invariant(!('ttl' in options) || options.ttl > 0, 'TTL')\n\n    const to = validateAndParseAddress(options.recipient)\n    const amountIn = toHex(trade.maximumAmountIn(options.allowedSlippage))\n    const amountOut = toHex(trade.minimumAmountOut(options.allowedSlippage))\n    const path: Address[] = trade.route.path.map((token: Token) => token.address)\n    const deadline: Hex =\n      'ttl' in options\n        ? `0x${(Math.floor(new Date().getTime() / 1000) + options.ttl).toString(16)}`\n        : `0x${options.deadline.toString(16)}`\n\n    const useFeeOnTransfer = Boolean(options.feeOnTransfer)\n\n    let methodName: string\n    let args: (Hex | Hex[])[]\n    let value: Hex\n\n    // eslint-disable-next-line default-case\n    switch (trade.tradeType) {\n      case TradeType.EXACT_INPUT:\n        if (etherIn) {\n          methodName = useFeeOnTransfer ? 'swapExactETHForTokensSupportingFeeOnTransferTokens' : 'swapExactETHForTokens'\n          // (uint amountOutMin, address[] calldata path, address to, uint deadline)\n          args = [amountOut, path, to, deadline]\n          value = amountIn\n        } else if (etherOut) {\n          methodName = useFeeOnTransfer ? 'swapExactTokensForETHSupportingFeeOnTransferTokens' : 'swapExactTokensForETH'\n          // (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\n          args = [amountIn, amountOut, path, to, deadline]\n          value = ZERO_HEX\n        } else {\n          methodName = useFeeOnTransfer\n            ? 'swapExactTokensForTokensSupportingFeeOnTransferTokens'\n            : 'swapExactTokensForTokens'\n          // (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\n          args = [amountIn, amountOut, path, to, deadline]\n          value = ZERO_HEX\n        }\n        break\n      case TradeType.EXACT_OUTPUT:\n        invariant(!useFeeOnTransfer, 'EXACT_OUT_FOT')\n        if (etherIn) {\n          methodName = 'swapETHForExactTokens'\n          // (uint amountOut, address[] calldata path, address to, uint deadline)\n          args = [amountOut, path, to, deadline]\n          value = amountIn\n        } else if (etherOut) {\n          methodName = 'swapTokensForExactETH'\n          // (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\n          args = [amountOut, amountIn, path, to, deadline]\n          value = ZERO_HEX\n        } else {\n          methodName = 'swapTokensForExactTokens'\n          // (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\n          args = [amountOut, amountIn, path, to, deadline]\n          value = ZERO_HEX\n        }\n        break\n    }\n\n    return {\n      methodName,\n      args,\n      value,\n    }\n  }\n}\n","import { ChainId } from '@pancakeswap/chains'\nimport { CurrencyAmount, Token } from '@pancakeswap/swap-sdk-core'\nimport { erc20Abi } from '@pancakeswap/swap-sdk-evm'\nimport invariant from 'tiny-invariant'\nimport { Address, PublicClient, createPublicClient, getContract, http } from 'viem'\nimport { bsc, bscTestnet, goerli, mainnet } from 'viem/chains'\n\nimport { pancakePairV2ABI } from './abis/IPancakePair'\nimport { Pair } from './entities/pair'\n\nlet TOKEN_DECIMALS_CACHE: { [chainId: number]: { [address: string]: number } } = {\n  [ChainId.BSC]: {},\n}\n\nconst ethClient = createPublicClient({ chain: mainnet, transport: http() })\nconst bscClient = createPublicClient({ chain: bsc, transport: http() })\nconst bscTestnetClient = createPublicClient({ chain: bscTestnet, transport: http() })\nconst goerliClient = createPublicClient({ chain: goerli, transport: http() })\n\nconst getDefaultClient = (chainId: ChainId): PublicClient => {\n  switch (chainId) {\n    case ChainId.ETHEREUM:\n      return ethClient\n    case ChainId.BSC:\n      return bscClient\n    case ChainId.BSC_TESTNET:\n      return bscTestnetClient\n    case ChainId.GOERLI:\n      return goerliClient\n    default:\n      return bscClient\n  }\n}\n\n/**\n * Contains methods for constructing instances of pairs and tokens from on-chain data.\n */\nexport abstract class Fetcher {\n  /**\n   * Cannot be constructed.\n   */\n  // eslint-disable-next-line no-useless-constructor,@typescript-eslint/no-empty-function\n  private constructor() {}\n\n  /**\n   * Fetch information for a given token on the given chain, using the given viem provider.\n   * @param chainId chain of the token\n   * @param address address of the token on the chain\n   * @param provider provider used to fetch the token\n   * @param symbol symbol of the token\n   * @param name optional name of the token\n   */\n  public static async fetchTokenData(\n    chainId: ChainId,\n    address: Address,\n    publicClient: any = getDefaultClient(chainId),\n    symbol: string,\n    name?: string,\n  ): Promise<Token> {\n    const erc20 = getContract({\n      abi: erc20Abi,\n      address,\n      client: publicClient as PublicClient,\n    })\n    const parsedDecimals =\n      typeof TOKEN_DECIMALS_CACHE?.[chainId]?.[address] === 'number'\n        ? TOKEN_DECIMALS_CACHE[chainId][address]\n        : await erc20.read.decimals().then((decimals): number => {\n            TOKEN_DECIMALS_CACHE = {\n              ...TOKEN_DECIMALS_CACHE,\n              [chainId]: {\n                ...TOKEN_DECIMALS_CACHE?.[chainId],\n                [address]: decimals,\n              },\n            }\n            return decimals\n          })\n    return new Token(chainId, address, parsedDecimals, symbol, name)\n  }\n\n  /**\n   * Fetches information about a pair and constructs a pair from the given two tokens.\n   * @param tokenA first token\n   * @param tokenB second token\n   * @param provider the provider to use to fetch the data\n   */\n  public static async fetchPairData(\n    tokenA: Token,\n    tokenB: Token,\n    publicClient: any = getDefaultClient(tokenA.chainId),\n  ): Promise<Pair> {\n    invariant(tokenA.chainId === tokenB.chainId, 'CHAIN_ID')\n    const address = Pair.getAddress(tokenA, tokenB)\n    const pairContract: any = getContract({\n      abi: pancakePairV2ABI,\n      address,\n      client: publicClient,\n    })\n    const [reserves0, reserves1] = await pairContract.read.getReserves()\n    const balances = tokenA.sortsBefore(tokenB) ? [reserves0, reserves1] : [reserves1, reserves0]\n    return new Pair(\n      CurrencyAmount.fromRawAmount(tokenA, balances[0]),\n      CurrencyAmount.fromRawAmount(tokenB, balances[1]),\n    )\n  }\n}\n"]}