@kayenfinance/v3-sdk 1.3.1 → 1.3.3

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.
@@ -229,6 +229,7 @@ var _FACTORY_ADDRESS_BY_C, _POOL_INIT_CODE_HASH_, _TICK_SPACINGS;
229
229
  var FACTORY_ADDRESS = '0x4bC8BDF50843Cc503E196Be4A9560134d358bb3C';
230
230
  var FACTORY_ADDRESS_BY_CHAIN_ID = (_FACTORY_ADDRESS_BY_C = {}, _FACTORY_ADDRESS_BY_C[sdkCore.ChainId.CHILIZ] = '0x4bC8BDF50843Cc503E196Be4A9560134d358bb3C', _FACTORY_ADDRESS_BY_C[sdkCore.ChainId.SPICY] = '0x9Fc08909577539c635F04ef924f65c56560c8BD3', _FACTORY_ADDRESS_BY_C);
231
231
  var ADDRESS_ZERO = '0x0000000000000000000000000000000000000000';
232
+
232
233
  // @deprecated please use poolInitCodeHash(chainId: ChainId)
233
234
  var POOL_INIT_CODE_HASH = '0xcb96d536c98123b475b91f2f81bd6d5877fb48561b42d7892f4725df4c8cce7e';
234
235
  var POOL_INIT_CODE_HASH_BY_CHAIN_ID = (_POOL_INIT_CODE_HASH_ = {}, _POOL_INIT_CODE_HASH_[sdkCore.ChainId.CHILIZ] = '0xcb96d536c98123b475b91f2f81bd6d5877fb48561b42d7892f4725df4c8cce7e', _POOL_INIT_CODE_HASH_[sdkCore.ChainId.SPICY] = '0xcb96d536c98123b475b91f2f81bd6d5877fb48561b42d7892f4725df4c8cce7e', _POOL_INIT_CODE_HASH_);
@@ -241,7 +242,11 @@ function poolInitCodeHash(chainId) {
241
242
  return (_POOL_INIT_CODE_HASH_2 = POOL_INIT_CODE_HASH_BY_CHAIN_ID[chainId]) != null ? _POOL_INIT_CODE_HASH_2 : POOL_INIT_CODE_HASH;
242
243
  }
243
244
  }
244
- (function (FeeAmount) {
245
+
246
+ /**
247
+ * The default factory enabled fee amounts, denominated in hundredths of bips.
248
+ */
249
+ var FeeAmount = /*#__PURE__*/function (FeeAmount) {
245
250
  FeeAmount[FeeAmount["LOWEST"] = 100] = "LOWEST";
246
251
  FeeAmount[FeeAmount["LOW_200"] = 200] = "LOW_200";
247
252
  FeeAmount[FeeAmount["LOW_300"] = 300] = "LOW_300";
@@ -249,29 +254,32 @@ function poolInitCodeHash(chainId) {
249
254
  FeeAmount[FeeAmount["LOW"] = 500] = "LOW";
250
255
  FeeAmount[FeeAmount["MEDIUM"] = 3000] = "MEDIUM";
251
256
  FeeAmount[FeeAmount["HIGH"] = 10000] = "HIGH";
252
- })(exports.FeeAmount || (exports.FeeAmount = {}));
253
- /**
254
- * The default factory tick spacings by fee amount.
257
+ return FeeAmount;
258
+ }({});
259
+
260
+ /**
261
+ * The default factory tick spacings by fee amount.
255
262
  */
256
- var TICK_SPACINGS = (_TICK_SPACINGS = {}, _TICK_SPACINGS[exports.FeeAmount.LOWEST] = 1, _TICK_SPACINGS[exports.FeeAmount.LOW_200] = 4, _TICK_SPACINGS[exports.FeeAmount.LOW_300] = 6, _TICK_SPACINGS[exports.FeeAmount.LOW_400] = 8, _TICK_SPACINGS[exports.FeeAmount.LOW] = 10, _TICK_SPACINGS[exports.FeeAmount.MEDIUM] = 60, _TICK_SPACINGS[exports.FeeAmount.HIGH] = 200, _TICK_SPACINGS);
263
+ var TICK_SPACINGS = (_TICK_SPACINGS = {}, _TICK_SPACINGS[FeeAmount.LOWEST] = 1, _TICK_SPACINGS[FeeAmount.LOW_200] = 4, _TICK_SPACINGS[FeeAmount.LOW_300] = 6, _TICK_SPACINGS[FeeAmount.LOW_400] = 8, _TICK_SPACINGS[FeeAmount.LOW] = 10, _TICK_SPACINGS[FeeAmount.MEDIUM] = 60, _TICK_SPACINGS[FeeAmount.HIGH] = 200, _TICK_SPACINGS);
257
264
 
258
265
  // constants used internally but not expected to be used externally
259
266
  var NEGATIVE_ONE = /*#__PURE__*/JSBI.BigInt(-1);
260
267
  var ZERO = /*#__PURE__*/JSBI.BigInt(0);
261
268
  var ONE = /*#__PURE__*/JSBI.BigInt(1);
269
+
262
270
  // used in liquidity amount math
263
271
  var Q96 = /*#__PURE__*/JSBI.exponentiate(/*#__PURE__*/JSBI.BigInt(2), /*#__PURE__*/JSBI.BigInt(96));
264
272
  var Q192 = /*#__PURE__*/JSBI.exponentiate(Q96, /*#__PURE__*/JSBI.BigInt(2));
265
273
 
266
- /**
267
- * Computes a pool address
268
- * @param factoryAddress The Uniswap V3 factory address
269
- * @param tokenA The first token of the pair, irrespective of sort order
270
- * @param tokenB The second token of the pair, irrespective of sort order
271
- * @param fee The fee tier of the pool
272
- * @param initCodeHashManualOverride Override the init code hash used to compute the pool address if necessary
273
- * @param chainId
274
- * @returns The pool address
274
+ /**
275
+ * Computes a pool address
276
+ * @param factoryAddress The Uniswap V3 factory address
277
+ * @param tokenA The first token of the pair, irrespective of sort order
278
+ * @param tokenB The second token of the pair, irrespective of sort order
279
+ * @param fee The fee tier of the pool
280
+ * @param initCodeHashManualOverride Override the init code hash used to compute the pool address if necessary
281
+ * @param chainId
282
+ * @returns The pool address
275
283
  */
276
284
  function computePoolAddress(_ref) {
277
285
  var factoryAddress = _ref.factoryAddress,
@@ -285,6 +293,7 @@ function computePoolAddress(_ref) {
285
293
  token1 = _ref2[1]; // does safety checks
286
294
  var salt = solidity.keccak256(['bytes'], [abi.defaultAbiCoder.encode(['address', 'address', 'uint24'], [token0.address, token1.address, fee])]);
287
295
  var initCodeHash = initCodeHashManualOverride != null ? initCodeHashManualOverride : poolInitCodeHash(chainId);
296
+
288
297
  // ZKSync uses a different create2 address computation
289
298
  // Most likely all ZKEVM chains will use the different computation from standard create2
290
299
  switch (chainId) {
@@ -296,8 +305,8 @@ function computePoolAddress(_ref) {
296
305
  }
297
306
 
298
307
  var FullMath = /*#__PURE__*/function () {
299
- /**
300
- * Cannot be constructed.
308
+ /**
309
+ * Cannot be constructed.
301
310
  */
302
311
  function FullMath() {}
303
312
  FullMath.mulDivRoundingUp = function mulDivRoundingUp(a, b, denominator) {
@@ -319,8 +328,8 @@ function addIn256(x, y) {
319
328
  return JSBI.bitwiseAnd(sum, sdkCore.MaxUint256);
320
329
  }
321
330
  var SqrtPriceMath = /*#__PURE__*/function () {
322
- /**
323
- * Cannot be constructed.
331
+ /**
332
+ * Cannot be constructed.
324
333
  */
325
334
  function SqrtPriceMath() {}
326
335
  SqrtPriceMath.getAmount0Delta = function getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, liquidity, roundUp) {
@@ -386,8 +395,8 @@ var SqrtPriceMath = /*#__PURE__*/function () {
386
395
 
387
396
  var MAX_FEE = /*#__PURE__*/JSBI.exponentiate(/*#__PURE__*/JSBI.BigInt(10), /*#__PURE__*/JSBI.BigInt(6));
388
397
  var SwapMath = /*#__PURE__*/function () {
389
- /**
390
- * Cannot be constructed.
398
+ /**
399
+ * Cannot be constructed.
391
400
  */
392
401
  function SwapMath() {}
393
402
  SwapMath.computeSwapStep = function computeSwapStep(sqrtRatioCurrentX96, sqrtRatioTargetX96, liquidity, amountRemaining, feePips) {
@@ -434,8 +443,8 @@ var SwapMath = /*#__PURE__*/function () {
434
443
  }();
435
444
 
436
445
  var LiquidityMath = /*#__PURE__*/function () {
437
- /**
438
- * Cannot be constructed.
446
+ /**
447
+ * Cannot be constructed.
439
448
  */
440
449
  function LiquidityMath() {}
441
450
  LiquidityMath.addDelta = function addDelta(x, y) {
@@ -468,18 +477,23 @@ function mostSignificantBit(x) {
468
477
  return msb;
469
478
  }
470
479
 
480
+ var _TickMath;
471
481
  function mulShift(val, mulBy) {
472
482
  return JSBI.signedRightShift(JSBI.multiply(val, JSBI.BigInt(mulBy)), JSBI.BigInt(128));
473
483
  }
474
484
  var Q32 = /*#__PURE__*/JSBI.exponentiate(/*#__PURE__*/JSBI.BigInt(2), /*#__PURE__*/JSBI.BigInt(32));
475
485
  var TickMath = /*#__PURE__*/function () {
476
- /**
477
- * Cannot be constructed.
486
+ /**
487
+ * Cannot be constructed.
478
488
  */
479
489
  function TickMath() {}
480
- /**
481
- * Returns the sqrt ratio as a Q64.96 for the given tick. The sqrt ratio is computed as sqrt(1.0001)^tick
482
- * @param tick the tick for which to compute the sqrt ratio
490
+
491
+ /**
492
+ * The minimum tick that can be used on any pool.
493
+ */
494
+ /**
495
+ * Returns the sqrt ratio as a Q64.96 for the given tick. The sqrt ratio is computed as sqrt(1.0001)^tick
496
+ * @param tick the tick for which to compute the sqrt ratio
483
497
  */
484
498
  TickMath.getSqrtRatioAtTick = function getSqrtRatioAtTick(tick) {
485
499
  !(tick >= TickMath.MIN_TICK && tick <= TickMath.MAX_TICK && Number.isInteger(tick)) ? invariant(false, 'TICK') : void 0;
@@ -505,13 +519,15 @@ var TickMath = /*#__PURE__*/function () {
505
519
  if ((absTick & 0x40000) !== 0) ratio = mulShift(ratio, '0x2216e584f5fa1ea926041bedfe98');
506
520
  if ((absTick & 0x80000) !== 0) ratio = mulShift(ratio, '0x48a170391f7dc42444e8fa2');
507
521
  if (tick > 0) ratio = JSBI.divide(sdkCore.MaxUint256, ratio);
522
+
508
523
  // back to Q96
509
524
  return JSBI.greaterThan(JSBI.remainder(ratio, Q32), ZERO) ? JSBI.add(JSBI.divide(ratio, Q32), ONE) : JSBI.divide(ratio, Q32);
510
525
  }
511
- /**
512
- * Returns the tick corresponding to a given sqrt ratio, s.t. #getSqrtRatioAtTick(tick) <= sqrtRatioX96
513
- * and #getSqrtRatioAtTick(tick + 1) > sqrtRatioX96
514
- * @param sqrtRatioX96 the sqrt ratio as a Q64.96 for which to compute the tick
526
+
527
+ /**
528
+ * Returns the tick corresponding to a given sqrt ratio, s.t. #getSqrtRatioAtTick(tick) <= sqrtRatioX96
529
+ * and #getSqrtRatioAtTick(tick + 1) > sqrtRatioX96
530
+ * @param sqrtRatioX96 the sqrt ratio as a Q64.96 for which to compute the tick
515
531
  */;
516
532
  TickMath.getTickAtSqrtRatio = function getTickAtSqrtRatio(sqrtRatioX96) {
517
533
  !(JSBI.greaterThanOrEqual(sqrtRatioX96, TickMath.MIN_SQRT_RATIO) && JSBI.lessThan(sqrtRatioX96, TickMath.MAX_SQRT_RATIO)) ? invariant(false, 'SQRT_RATIO') : void 0;
@@ -537,20 +553,18 @@ var TickMath = /*#__PURE__*/function () {
537
553
  };
538
554
  return TickMath;
539
555
  }();
540
- /**
541
- * The minimum tick that can be used on any pool.
542
- */
556
+ _TickMath = TickMath;
543
557
  TickMath.MIN_TICK = -887272;
544
- /**
545
- * The maximum tick that can be used on any pool.
558
+ /**
559
+ * The maximum tick that can be used on any pool.
546
560
  */
547
- TickMath.MAX_TICK = -TickMath.MIN_TICK;
548
- /**
549
- * The sqrt ratio corresponding to the minimum tick that could be used on any pool.
561
+ TickMath.MAX_TICK = -_TickMath.MIN_TICK;
562
+ /**
563
+ * The sqrt ratio corresponding to the minimum tick that could be used on any pool.
550
564
  */
551
565
  TickMath.MIN_SQRT_RATIO = /*#__PURE__*/JSBI.BigInt('4295128739');
552
- /**
553
- * The sqrt ratio corresponding to the maximum tick that could be used on any pool.
566
+ /**
567
+ * The sqrt ratio corresponding to the maximum tick that could be used on any pool.
554
568
  */
555
569
  TickMath.MAX_SQRT_RATIO = /*#__PURE__*/JSBI.BigInt('1461446703485210103287273052203988822378723970342');
556
570
 
@@ -585,7 +599,12 @@ function _v3Swap() {
585
599
  break;
586
600
  }
587
601
  step = {};
588
- step.sqrtPriceStartX96 = state.sqrtPriceX96;
602
+ step.sqrtPriceStartX96 = state.sqrtPriceX96
603
+
604
+ // because each iteration of the while loop rounds, we can't optimize this code (relative to the smart contract)
605
+ // by simply traversing to the next available tick, we instead need to exactly replicate
606
+ // tickBitmap.nextInitializedTickWithinOneWord
607
+ ;
589
608
  _context.n = 2;
590
609
  return tickDataProvider.nextInitializedTickWithinOneWord(state.tick, zeroForOne, tickSpacing);
591
610
  case 2:
@@ -610,6 +629,7 @@ function _v3Swap() {
610
629
  state.amountSpecifiedRemaining = JSBI.add(state.amountSpecifiedRemaining, step.amountOut);
611
630
  state.amountCalculated = JSBI.add(state.amountCalculated, JSBI.add(step.amountIn, step.feeAmount));
612
631
  }
632
+
613
633
  // TODO
614
634
  if (!JSBI.equal(state.sqrtPriceX96, step.sqrtPriceNextX96)) {
615
635
  _context.n = 5;
@@ -654,9 +674,13 @@ function _v3Swap() {
654
674
  return _v3Swap.apply(this, arguments);
655
675
  }
656
676
 
657
- /**
658
- * This tick data provider does not know how to fetch any tick data. It throws whenever it is required. Useful if you
659
- * do not need to load tick data for your use case.
677
+ /**
678
+ * Provides information about ticks
679
+ */
680
+
681
+ /**
682
+ * This tick data provider does not know how to fetch any tick data. It throws whenever it is required. Useful if you
683
+ * do not need to load tick data for your use case.
660
684
  */
661
685
  var NoTickDataProvider = /*#__PURE__*/function () {
662
686
  function NoTickDataProvider() {}
@@ -697,11 +721,11 @@ var NoTickDataProvider = /*#__PURE__*/function () {
697
721
  }();
698
722
  NoTickDataProvider.ERROR_MESSAGE = 'No tick data provider was given';
699
723
 
700
- /**
701
- * Determines if a tick list is sorted
702
- * @param list The tick list
703
- * @param comparator The comparator
704
- * @returns true if sorted
724
+ /**
725
+ * Determines if a tick list is sorted
726
+ * @param list The tick list
727
+ * @param comparator The comparator
728
+ * @returns true if sorted
705
729
  */
706
730
  function isSorted(list, comparator) {
707
731
  for (var i = 0; i < list.length - 1; i++) {
@@ -715,12 +739,13 @@ function isSorted(list, comparator) {
715
739
  function tickComparator(a, b) {
716
740
  return a.index - b.index;
717
741
  }
718
- /**
719
- * Utility methods for interacting with sorted lists of ticks
742
+
743
+ /**
744
+ * Utility methods for interacting with sorted lists of ticks
720
745
  */
721
746
  var TickList = /*#__PURE__*/function () {
722
- /**
723
- * Cannot be constructed
747
+ /**
748
+ * Cannot be constructed
724
749
  */
725
750
  function TickList() {}
726
751
  TickList.validateList = function validateList(ticks, tickSpacing) {
@@ -730,6 +755,7 @@ var TickList = /*#__PURE__*/function () {
730
755
  var index = _ref.index;
731
756
  return index % tickSpacing === 0;
732
757
  }) ? invariant(false, 'TICK_SPACING') : void 0;
758
+
733
759
  // ensure tick liquidity deltas sum to 0
734
760
  !JSBI.equal(ticks.reduce(function (accumulator, _ref2) {
735
761
  var liquidityNet = _ref2.liquidityNet;
@@ -750,11 +776,12 @@ var TickList = /*#__PURE__*/function () {
750
776
  !(tick.index === index) ? invariant(false, 'NOT_CONTAINED') : void 0;
751
777
  return tick;
752
778
  }
753
- /**
754
- * Finds the largest tick in the list of ticks that is less than or equal to tick
755
- * @param ticks list of ticks
756
- * @param tick tick to find the largest tick that is less than or equal to tick
757
- * @private
779
+
780
+ /**
781
+ * Finds the largest tick in the list of ticks that is less than or equal to tick
782
+ * @param ticks list of ticks
783
+ * @param tick tick to find the largest tick that is less than or equal to tick
784
+ * @private
758
785
  */;
759
786
  TickList.binarySearch = function binarySearch(ticks, tick) {
760
787
  !!this.isBelowSmallest(ticks, tick) ? invariant(false, 'BELOW_SMALLEST') : void 0;
@@ -792,6 +819,7 @@ var TickList = /*#__PURE__*/function () {
792
819
  };
793
820
  TickList.nextInitializedTickWithinOneWord = function nextInitializedTickWithinOneWord(ticks, tick, lte, tickSpacing) {
794
821
  var compressed = Math.floor(tick / tickSpacing); // matches rounding in the code
822
+
795
823
  if (lte) {
796
824
  var wordPos = compressed >> 8;
797
825
  var minimum = (wordPos << 8) * tickSpacing;
@@ -815,10 +843,14 @@ var TickList = /*#__PURE__*/function () {
815
843
  return TickList;
816
844
  }();
817
845
 
818
- /**
819
- * Converts a big int to a hex string
820
- * @param bigintIsh
821
- * @returns The hex encoded calldata
846
+ /**
847
+ * Generated method parameters for executing a call.
848
+ */
849
+
850
+ /**
851
+ * Converts a big int to a hex string
852
+ * @param bigintIsh
853
+ * @returns The hex encoded calldata
822
854
  */
823
855
  function toHex(bigintIsh) {
824
856
  var bigInt = JSBI.BigInt(bigintIsh);
@@ -829,10 +861,10 @@ function toHex(bigintIsh) {
829
861
  return "0x" + hex;
830
862
  }
831
863
 
832
- /**
833
- * Converts a route to a hex encoded path
834
- * @param route the v3 path to convert to an encoded path
835
- * @param exactOutput whether the route should be encoded in reverse, for making exact output swaps
864
+ /**
865
+ * Converts a route to a hex encoded path
866
+ * @param route the v3 path to convert to an encoded path
867
+ * @param exactOutput whether the route should be encoded in reverse, for making exact output swaps
836
868
  */
837
869
  function encodeRouteToPath(route, exactOutput) {
838
870
  var firstInputToken = route.input.wrapped;
@@ -864,12 +896,13 @@ function encodeRouteToPath(route, exactOutput) {
864
896
  return exactOutput ? solidity.pack(types.reverse(), path.reverse()) : solidity.pack(types, path);
865
897
  }
866
898
 
867
- /**
868
- * Returns the sqrt ratio as a Q64.96 corresponding to a given ratio of amount1 and amount0
869
- * @param amount1 The numerator amount i.e., the amount of token1
870
- * @param amount0 The denominator amount i.e., the amount of token0
871
- * @returns The sqrt ratio
899
+ /**
900
+ * Returns the sqrt ratio as a Q64.96 corresponding to a given ratio of amount1 and amount0
901
+ * @param amount1 The numerator amount i.e., the amount of token1
902
+ * @param amount0 The denominator amount i.e., the amount of token0
903
+ * @returns The sqrt ratio
872
904
  */
905
+
873
906
  function encodeSqrtRatioX96(amount1, amount0) {
874
907
  var numerator = JSBI.leftShift(JSBI.BigInt(amount1), JSBI.BigInt(192));
875
908
  var denominator = JSBI.BigInt(amount0);
@@ -877,16 +910,16 @@ function encodeSqrtRatioX96(amount1, amount0) {
877
910
  return sdkCore.sqrt(ratioX192);
878
911
  }
879
912
 
880
- /**
881
- * Returns an imprecise maximum amount of liquidity received for a given amount of token 0.
882
- * This function is available to accommodate LiquidityAmounts#getLiquidityForAmount0 in the v3 periphery,
883
- * which could be more precise by at least 32 bits by dividing by Q64 instead of Q96 in the intermediate step,
884
- * and shifting the subtracted ratio left by 32 bits. This imprecise calculation will likely be replaced in a future
885
- * v3 router contract.
886
- * @param sqrtRatioAX96 The price at the lower boundary
887
- * @param sqrtRatioBX96 The price at the upper boundary
888
- * @param amount0 The token0 amount
889
- * @returns liquidity for amount0, imprecise
913
+ /**
914
+ * Returns an imprecise maximum amount of liquidity received for a given amount of token 0.
915
+ * This function is available to accommodate LiquidityAmounts#getLiquidityForAmount0 in the v3 periphery,
916
+ * which could be more precise by at least 32 bits by dividing by Q64 instead of Q96 in the intermediate step,
917
+ * and shifting the subtracted ratio left by 32 bits. This imprecise calculation will likely be replaced in a future
918
+ * v3 router contract.
919
+ * @param sqrtRatioAX96 The price at the lower boundary
920
+ * @param sqrtRatioBX96 The price at the upper boundary
921
+ * @param amount0 The token0 amount
922
+ * @returns liquidity for amount0, imprecise
890
923
  */
891
924
  function maxLiquidityForAmount0Imprecise(sqrtRatioAX96, sqrtRatioBX96, amount0) {
892
925
  if (JSBI.greaterThan(sqrtRatioAX96, sqrtRatioBX96)) {
@@ -897,13 +930,14 @@ function maxLiquidityForAmount0Imprecise(sqrtRatioAX96, sqrtRatioBX96, amount0)
897
930
  var intermediate = JSBI.divide(JSBI.multiply(sqrtRatioAX96, sqrtRatioBX96), Q96);
898
931
  return JSBI.divide(JSBI.multiply(JSBI.BigInt(amount0), intermediate), JSBI.subtract(sqrtRatioBX96, sqrtRatioAX96));
899
932
  }
900
- /**
901
- * Returns a precise maximum amount of liquidity received for a given amount of token 0 by dividing by Q64 instead of Q96 in the intermediate step,
902
- * and shifting the subtracted ratio left by 32 bits.
903
- * @param sqrtRatioAX96 The price at the lower boundary
904
- * @param sqrtRatioBX96 The price at the upper boundary
905
- * @param amount0 The token0 amount
906
- * @returns liquidity for amount0, precise
933
+
934
+ /**
935
+ * Returns a precise maximum amount of liquidity received for a given amount of token 0 by dividing by Q64 instead of Q96 in the intermediate step,
936
+ * and shifting the subtracted ratio left by 32 bits.
937
+ * @param sqrtRatioAX96 The price at the lower boundary
938
+ * @param sqrtRatioBX96 The price at the upper boundary
939
+ * @param amount0 The token0 amount
940
+ * @returns liquidity for amount0, precise
907
941
  */
908
942
  function maxLiquidityForAmount0Precise(sqrtRatioAX96, sqrtRatioBX96, amount0) {
909
943
  if (JSBI.greaterThan(sqrtRatioAX96, sqrtRatioBX96)) {
@@ -915,12 +949,13 @@ function maxLiquidityForAmount0Precise(sqrtRatioAX96, sqrtRatioBX96, amount0) {
915
949
  var denominator = JSBI.multiply(Q96, JSBI.subtract(sqrtRatioBX96, sqrtRatioAX96));
916
950
  return JSBI.divide(numerator, denominator);
917
951
  }
918
- /**
919
- * Computes the maximum amount of liquidity received for a given amount of token1
920
- * @param sqrtRatioAX96 The price at the lower tick boundary
921
- * @param sqrtRatioBX96 The price at the upper tick boundary
922
- * @param amount1 The token1 amount
923
- * @returns liquidity for amount1
952
+
953
+ /**
954
+ * Computes the maximum amount of liquidity received for a given amount of token1
955
+ * @param sqrtRatioAX96 The price at the lower tick boundary
956
+ * @param sqrtRatioBX96 The price at the upper tick boundary
957
+ * @param amount1 The token1 amount
958
+ * @returns liquidity for amount1
924
959
  */
925
960
  function maxLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1) {
926
961
  if (JSBI.greaterThan(sqrtRatioAX96, sqrtRatioBX96)) {
@@ -930,16 +965,17 @@ function maxLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1) {
930
965
  }
931
966
  return JSBI.divide(JSBI.multiply(JSBI.BigInt(amount1), Q96), JSBI.subtract(sqrtRatioBX96, sqrtRatioAX96));
932
967
  }
933
- /**
934
- * Computes the maximum amount of liquidity received for a given amount of token0, token1,
935
- * and the prices at the tick boundaries.
936
- * @param sqrtRatioCurrentX96 the current price
937
- * @param sqrtRatioAX96 price at lower boundary
938
- * @param sqrtRatioBX96 price at upper boundary
939
- * @param amount0 token0 amount
940
- * @param amount1 token1 amount
941
- * @param useFullPrecision if false, liquidity will be maximized according to what the router can calculate,
942
- * not what core can theoretically support
968
+
969
+ /**
970
+ * Computes the maximum amount of liquidity received for a given amount of token0, token1,
971
+ * and the prices at the tick boundaries.
972
+ * @param sqrtRatioCurrentX96 the current price
973
+ * @param sqrtRatioAX96 price at lower boundary
974
+ * @param sqrtRatioBX96 price at upper boundary
975
+ * @param amount0 token0 amount
976
+ * @param amount1 token1 amount
977
+ * @param useFullPrecision if false, liquidity will be maximized according to what the router can calculate,
978
+ * not what core can theoretically support
943
979
  */
944
980
  function maxLiquidityForAmounts(sqrtRatioCurrentX96, sqrtRatioAX96, sqrtRatioBX96, amount0, amount1, useFullPrecision) {
945
981
  if (JSBI.greaterThan(sqrtRatioAX96, sqrtRatioBX96)) {
@@ -959,10 +995,10 @@ function maxLiquidityForAmounts(sqrtRatioCurrentX96, sqrtRatioAX96, sqrtRatioBX9
959
995
  }
960
996
  }
961
997
 
962
- /**
963
- * Returns the closest tick that is nearest a given tick and usable for the given tick spacing
964
- * @param tick the target tick
965
- * @param tickSpacing the spacing of the pool
998
+ /**
999
+ * Returns the closest tick that is nearest a given tick and usable for the given tick spacing
1000
+ * @param tick the target tick
1001
+ * @param tickSpacing the spacing of the pool
966
1002
  */
967
1003
  function nearestUsableTick(tick, tickSpacing) {
968
1004
  !(Number.isInteger(tick) && Number.isInteger(tickSpacing)) ? invariant(false, 'INTEGERS') : void 0;
@@ -974,10 +1010,11 @@ function nearestUsableTick(tick, tickSpacing) {
974
1010
 
975
1011
  var Q128 = /*#__PURE__*/JSBI.exponentiate(/*#__PURE__*/JSBI.BigInt(2), /*#__PURE__*/JSBI.BigInt(128));
976
1012
  var PositionLibrary = /*#__PURE__*/function () {
977
- /**
978
- * Cannot be constructed.
1013
+ /**
1014
+ * Cannot be constructed.
979
1015
  */
980
1016
  function PositionLibrary() {}
1017
+
981
1018
  // replicates the portions of Position#update required to compute unaccounted fees
982
1019
  PositionLibrary.getTokensOwed = function getTokensOwed(feeGrowthInside0LastX128, feeGrowthInside1LastX128, liquidity, feeGrowthInside0X128, feeGrowthInside1X128) {
983
1020
  var tokensOwed0 = JSBI.divide(JSBI.multiply(subIn256(feeGrowthInside0X128, feeGrowthInside0LastX128), liquidity), Q128);
@@ -987,22 +1024,23 @@ var PositionLibrary = /*#__PURE__*/function () {
987
1024
  return PositionLibrary;
988
1025
  }();
989
1026
 
990
- /**
991
- * Returns a price object corresponding to the input tick and the base/quote token
992
- * Inputs must be tokens because the address order is used to interpret the price represented by the tick
993
- * @param baseToken the base token of the price
994
- * @param quoteToken the quote token of the price
995
- * @param tick the tick for which to return the price
1027
+ /**
1028
+ * Returns a price object corresponding to the input tick and the base/quote token
1029
+ * Inputs must be tokens because the address order is used to interpret the price represented by the tick
1030
+ * @param baseToken the base token of the price
1031
+ * @param quoteToken the quote token of the price
1032
+ * @param tick the tick for which to return the price
996
1033
  */
997
1034
  function tickToPrice(baseToken, quoteToken, tick) {
998
1035
  var sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick);
999
1036
  var ratioX192 = JSBI.multiply(sqrtRatioX96, sqrtRatioX96);
1000
1037
  return baseToken.sortsBefore(quoteToken) ? new sdkCore.Price(baseToken, quoteToken, Q192, ratioX192) : new sdkCore.Price(baseToken, quoteToken, ratioX192, Q192);
1001
1038
  }
1002
- /**
1003
- * Returns the first tick for which the given price is greater than or equal to the tick price
1004
- * @param price for which to return the closest tick that represents a price less than or equal to the input price,
1005
- * i.e. the price of the returned tick is less than or equal to the input price
1039
+
1040
+ /**
1041
+ * Returns the first tick for which the given price is greater than or equal to the tick price
1042
+ * @param price for which to return the closest tick that represents a price less than or equal to the input price,
1043
+ * i.e. the price of the returned tick is less than or equal to the input price
1006
1044
  */
1007
1045
  function priceToClosestTick(price) {
1008
1046
  var sorted = price.baseCurrency.sortsBefore(price.quoteCurrency);
@@ -1031,8 +1069,8 @@ function subIn256(x, y) {
1031
1069
  }
1032
1070
  }
1033
1071
  var TickLibrary = /*#__PURE__*/function () {
1034
- /**
1035
- * Cannot be constructed.
1072
+ /**
1073
+ * Cannot be constructed.
1036
1074
  */
1037
1075
  function TickLibrary() {}
1038
1076
  TickLibrary.getFeeGrowthInside = function getFeeGrowthInside(feeGrowthOutsideLower, feeGrowthOutsideUpper, tickLower, tickUpper, tickCurrent, feeGrowthGlobal0X128, feeGrowthGlobal1X128) {
@@ -1063,17 +1101,21 @@ var Tick = function Tick(_ref) {
1063
1101
  var index = _ref.index,
1064
1102
  liquidityGross = _ref.liquidityGross,
1065
1103
  liquidityNet = _ref.liquidityNet;
1104
+ this.index = void 0;
1105
+ this.liquidityGross = void 0;
1106
+ this.liquidityNet = void 0;
1066
1107
  !(index >= TickMath.MIN_TICK && index <= TickMath.MAX_TICK) ? invariant(false, 'TICK') : void 0;
1067
1108
  this.index = index;
1068
1109
  this.liquidityGross = JSBI.BigInt(liquidityGross);
1069
1110
  this.liquidityNet = JSBI.BigInt(liquidityNet);
1070
1111
  };
1071
1112
 
1072
- /**
1073
- * A data provider for ticks that is backed by an in-memory array of ticks.
1113
+ /**
1114
+ * A data provider for ticks that is backed by an in-memory array of ticks.
1074
1115
  */
1075
1116
  var TickListDataProvider = /*#__PURE__*/function () {
1076
1117
  function TickListDataProvider(ticks, tickSpacing) {
1118
+ this.ticks = void 0;
1077
1119
  var ticksMapped = ticks.map(function (t) {
1078
1120
  return t instanceof Tick ? t : new Tick(t);
1079
1121
  });
@@ -1112,32 +1154,43 @@ var TickListDataProvider = /*#__PURE__*/function () {
1112
1154
  return TickListDataProvider;
1113
1155
  }();
1114
1156
 
1115
- /**
1116
- * By default, pools will not allow operations that require ticks.
1157
+ /**
1158
+ * By default, pools will not allow operations that require ticks.
1117
1159
  */
1118
1160
  var NO_TICK_DATA_PROVIDER_DEFAULT = /*#__PURE__*/new NoTickDataProvider();
1119
- /**
1120
- * Represents a V3 pool
1161
+
1162
+ /**
1163
+ * Represents a V3 pool
1121
1164
  */
1122
1165
  var Pool = /*#__PURE__*/function () {
1123
- /**
1124
- * Construct a pool
1125
- * @param tokenA One of the tokens in the pool
1126
- * @param tokenB The other token in the pool
1127
- * @param fee The fee in hundredths of a bips of the input amount of every swap that is collected by the pool
1128
- * @param sqrtRatioX96 The sqrt of the current ratio of amounts of token1 to token0
1129
- * @param liquidity The current value of in range liquidity
1130
- * @param tickCurrent The current tick of the pool
1131
- * @param ticks The current state of the pool ticks or a data provider that can return tick data
1166
+ /**
1167
+ * Construct a pool
1168
+ * @param tokenA One of the tokens in the pool
1169
+ * @param tokenB The other token in the pool
1170
+ * @param fee The fee in hundredths of a bips of the input amount of every swap that is collected by the pool
1171
+ * @param sqrtRatioX96 The sqrt of the current ratio of amounts of token1 to token0
1172
+ * @param liquidity The current value of in range liquidity
1173
+ * @param tickCurrent The current tick of the pool
1174
+ * @param ticks The current state of the pool ticks or a data provider that can return tick data
1132
1175
  */
1133
1176
  function Pool(tokenA, tokenB, fee, sqrtRatioX96, liquidity, tickCurrent, ticks) {
1134
1177
  if (ticks === void 0) {
1135
1178
  ticks = NO_TICK_DATA_PROVIDER_DEFAULT;
1136
1179
  }
1180
+ this.token0 = void 0;
1181
+ this.token1 = void 0;
1182
+ this.fee = void 0;
1183
+ this.sqrtRatioX96 = void 0;
1184
+ this.liquidity = void 0;
1185
+ this.tickCurrent = void 0;
1186
+ this.tickDataProvider = void 0;
1187
+ this._token0Price = void 0;
1188
+ this._token1Price = void 0;
1137
1189
  !(Number.isInteger(fee) && fee < 1000000) ? invariant(false, 'FEE') : void 0;
1138
1190
  var tickCurrentSqrtRatioX96 = TickMath.getSqrtRatioAtTick(tickCurrent);
1139
1191
  var nextTickSqrtRatioX96 = TickMath.getSqrtRatioAtTick(tickCurrent + 1);
1140
- !(JSBI.greaterThanOrEqual(JSBI.BigInt(sqrtRatioX96), tickCurrentSqrtRatioX96) && JSBI.lessThanOrEqual(JSBI.BigInt(sqrtRatioX96), nextTickSqrtRatioX96)) ? invariant(false, 'PRICE_BOUNDS') : void 0;
1192
+ !(JSBI.greaterThanOrEqual(JSBI.BigInt(sqrtRatioX96), tickCurrentSqrtRatioX96) && JSBI.lessThanOrEqual(JSBI.BigInt(sqrtRatioX96), nextTickSqrtRatioX96)) ? invariant(false, 'PRICE_BOUNDS') : void 0 // always create a copy of the list since we want the pool's tick list to be immutable
1193
+ ;
1141
1194
  var _ref = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA];
1142
1195
  this.token0 = _ref[0];
1143
1196
  this.token1 = _ref[1];
@@ -1147,6 +1200,12 @@ var Pool = /*#__PURE__*/function () {
1147
1200
  this.tickCurrent = tickCurrent;
1148
1201
  this.tickDataProvider = Array.isArray(ticks) ? new TickListDataProvider(ticks, TICK_SPACINGS[fee]) : ticks;
1149
1202
  }
1203
+
1204
+ /**
1205
+ * Returns true if the token is either token0 or token1
1206
+ * @param token The token to check
1207
+ * @returns True if token is either token0 or token
1208
+ */
1150
1209
  Pool.getAddress = function getAddress(tokenA, tokenB, fee, initCodeHashManualOverride, factoryAddressOverride) {
1151
1210
  return computePoolAddress({
1152
1211
  factoryAddress: factoryAddressOverride != null ? factoryAddressOverride : FACTORY_ADDRESS,
@@ -1155,36 +1214,33 @@ var Pool = /*#__PURE__*/function () {
1155
1214
  tokenB: tokenB,
1156
1215
  initCodeHashManualOverride: initCodeHashManualOverride
1157
1216
  });
1158
- }
1159
- /**
1160
- * Returns true if the token is either token0 or token1
1161
- * @param token The token to check
1162
- * @returns True if token is either token0 or token
1163
- */;
1217
+ };
1164
1218
  var _proto = Pool.prototype;
1165
1219
  _proto.involvesToken = function involvesToken(token) {
1166
1220
  return token.equals(this.token0) || token.equals(this.token1);
1167
1221
  }
1168
- /**
1169
- * Returns the current mid price of the pool in terms of token0, i.e. the ratio of token1 over token0
1222
+
1223
+ /**
1224
+ * Returns the current mid price of the pool in terms of token0, i.e. the ratio of token1 over token0
1170
1225
  */;
1171
- /**
1172
- * Return the price of the given token in terms of the other token in the pool.
1173
- * @param token The token to return price of
1174
- * @returns The price of the given token, in terms of the other.
1226
+ /**
1227
+ * Return the price of the given token in terms of the other token in the pool.
1228
+ * @param token The token to return price of
1229
+ * @returns The price of the given token, in terms of the other.
1175
1230
  */
1176
1231
  _proto.priceOf = function priceOf(token) {
1177
1232
  !this.involvesToken(token) ? invariant(false, 'TOKEN') : void 0;
1178
1233
  return token.equals(this.token0) ? this.token0Price : this.token1Price;
1179
1234
  }
1180
- /**
1181
- * Returns the chain ID of the tokens in the pool.
1235
+
1236
+ /**
1237
+ * Returns the chain ID of the tokens in the pool.
1182
1238
  */;
1183
- /**
1184
- * Given an input amount of a token, return the computed output amount, and a pool with state updated after the trade
1185
- * @param inputAmount The input amount for which to quote the output amount
1186
- * @param sqrtPriceLimitX96 The Q64.96 sqrt price limit
1187
- * @returns The output amount and the pool with updated state
1239
+ /**
1240
+ * Given an input amount of a token, return the computed output amount, and a pool with state updated after the trade
1241
+ * @param inputAmount The input amount for which to quote the output amount
1242
+ * @param sqrtPriceLimitX96 The Q64.96 sqrt price limit
1243
+ * @returns The output amount and the pool with updated state
1188
1244
  */
1189
1245
  _proto.getOutputAmount =
1190
1246
  /*#__PURE__*/
@@ -1214,11 +1270,11 @@ var Pool = /*#__PURE__*/function () {
1214
1270
  }
1215
1271
  return getOutputAmount;
1216
1272
  }()
1217
- /**
1218
- * Given a desired output amount of a token, return the computed input amount and a pool with state updated after the trade
1219
- * @param outputAmount the output amount for which to quote the input amount
1220
- * @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
1221
- * @returns The input amount and the pool with updated state
1273
+ /**
1274
+ * Given a desired output amount of a token, return the computed input amount and a pool with state updated after the trade
1275
+ * @param outputAmount the output amount for which to quote the input amount
1276
+ * @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
1277
+ * @returns The input amount and the pool with updated state
1222
1278
  */
1223
1279
  ;
1224
1280
  _proto.getInputAmount =
@@ -1249,15 +1305,15 @@ var Pool = /*#__PURE__*/function () {
1249
1305
  }
1250
1306
  return getInputAmount;
1251
1307
  }()
1252
- /**
1253
- * Executes a swap
1254
- * @param zeroForOne Whether the amount in is token0 or token1
1255
- * @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
1256
- * @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
1257
- * @returns amountCalculated
1258
- * @returns sqrtRatioX96
1259
- * @returns liquidity
1260
- * @returns tickCurrent
1308
+ /**
1309
+ * Executes a swap
1310
+ * @param zeroForOne Whether the amount in is token0 or token1
1311
+ * @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
1312
+ * @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
1313
+ * @returns amountCalculated
1314
+ * @returns sqrtRatioX96
1315
+ * @returns liquidity
1316
+ * @returns tickCurrent
1261
1317
  */
1262
1318
  ;
1263
1319
  _proto.swap =
@@ -1282,8 +1338,9 @@ var Pool = /*#__PURE__*/function () {
1282
1338
  var _this$_token0Price;
1283
1339
  return (_this$_token0Price = this._token0Price) != null ? _this$_token0Price : this._token0Price = new sdkCore.Price(this.token0, this.token1, Q192, JSBI.multiply(this.sqrtRatioX96, this.sqrtRatioX96));
1284
1340
  }
1285
- /**
1286
- * Returns the current mid price of the pool in terms of token1, i.e. the ratio of token0 over token1
1341
+
1342
+ /**
1343
+ * Returns the current mid price of the pool in terms of token1, i.e. the ratio of token0 over token1
1287
1344
  */
1288
1345
  }, {
1289
1346
  key: "token1Price",
@@ -1304,22 +1361,26 @@ var Pool = /*#__PURE__*/function () {
1304
1361
  }]);
1305
1362
  }();
1306
1363
 
1307
- /**
1308
- * Represents a position on a Uniswap V3 Pool
1364
+ /**
1365
+ * Represents a position on a Uniswap V3 Pool
1309
1366
  */
1310
1367
  var Position = /*#__PURE__*/function () {
1311
- /**
1312
- * Constructs a position for a given pool with the given liquidity
1313
- * @param pool For which pool the liquidity is assigned
1314
- * @param liquidity The amount of liquidity that is in the position
1315
- * @param tickLower The lower tick of the position
1316
- * @param tickUpper The upper tick of the position
1368
+ /**
1369
+ * Constructs a position for a given pool with the given liquidity
1370
+ * @param pool For which pool the liquidity is assigned
1371
+ * @param liquidity The amount of liquidity that is in the position
1372
+ * @param tickLower The lower tick of the position
1373
+ * @param tickUpper The upper tick of the position
1317
1374
  */
1318
1375
  function Position(_ref) {
1319
1376
  var pool = _ref.pool,
1320
1377
  liquidity = _ref.liquidity,
1321
1378
  tickLower = _ref.tickLower,
1322
1379
  tickUpper = _ref.tickUpper;
1380
+ this.pool = void 0;
1381
+ this.tickLower = void 0;
1382
+ this.tickUpper = void 0;
1383
+ this.liquidity = void 0;
1323
1384
  // cached resuts for the getters
1324
1385
  this._token0Amount = null;
1325
1386
  this._token1Amount = null;
@@ -1332,14 +1393,15 @@ var Position = /*#__PURE__*/function () {
1332
1393
  this.tickUpper = tickUpper;
1333
1394
  this.liquidity = JSBI.BigInt(liquidity);
1334
1395
  }
1335
- /**
1336
- * Returns the price of token0 at the lower tick
1396
+
1397
+ /**
1398
+ * Returns the price of token0 at the lower tick
1337
1399
  */
1338
1400
  var _proto = Position.prototype;
1339
- /**
1340
- * Returns the lower and upper sqrt ratios if the price 'slips' up to slippage tolerance percentage
1341
- * @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert
1342
- * @returns The sqrt ratios after slippage
1401
+ /**
1402
+ * Returns the lower and upper sqrt ratios if the price 'slips' up to slippage tolerance percentage
1403
+ * @param slippageTolerance The amount by which the price can 'slip' before the transaction will revert
1404
+ * @returns The sqrt ratios after slippage
1343
1405
  */
1344
1406
  _proto.ratiosAfterSlippage = function ratiosAfterSlippage(slippageTolerance) {
1345
1407
  var priceLower = this.pool.token0Price.asFraction.multiply(new sdkCore.Percent(1).subtract(slippageTolerance));
@@ -1357,28 +1419,33 @@ var Position = /*#__PURE__*/function () {
1357
1419
  sqrtRatioX96Upper: sqrtRatioX96Upper
1358
1420
  };
1359
1421
  }
1360
- /**
1361
- * Returns the minimum amounts that must be sent in order to safely mint the amount of liquidity held by the position
1362
- * with the given slippage tolerance
1363
- * @param slippageTolerance Tolerance of unfavorable slippage from the current price
1364
- * @returns The amounts, with slippage
1422
+
1423
+ /**
1424
+ * Returns the minimum amounts that must be sent in order to safely mint the amount of liquidity held by the position
1425
+ * with the given slippage tolerance
1426
+ * @param slippageTolerance Tolerance of unfavorable slippage from the current price
1427
+ * @returns The amounts, with slippage
1365
1428
  */;
1366
1429
  _proto.mintAmountsWithSlippage = function mintAmountsWithSlippage(slippageTolerance) {
1367
1430
  // get lower/upper prices
1368
1431
  var _this$ratiosAfterSlip = this.ratiosAfterSlippage(slippageTolerance),
1369
1432
  sqrtRatioX96Upper = _this$ratiosAfterSlip.sqrtRatioX96Upper,
1370
1433
  sqrtRatioX96Lower = _this$ratiosAfterSlip.sqrtRatioX96Lower;
1434
+
1371
1435
  // construct counterfactual pools
1372
1436
  var poolLower = new Pool(this.pool.token0, this.pool.token1, this.pool.fee, sqrtRatioX96Lower, 0 /* liquidity doesn't matter */, TickMath.getTickAtSqrtRatio(sqrtRatioX96Lower));
1373
1437
  var poolUpper = new Pool(this.pool.token0, this.pool.token1, this.pool.fee, sqrtRatioX96Upper, 0 /* liquidity doesn't matter */, TickMath.getTickAtSqrtRatio(sqrtRatioX96Upper));
1438
+
1374
1439
  // because the router is imprecise, we need to calculate the position that will be created (assuming no slippage)
1375
1440
  var positionThatWillBeCreated = Position.fromAmounts(_extends({
1376
1441
  pool: this.pool,
1377
1442
  tickLower: this.tickLower,
1378
1443
  tickUpper: this.tickUpper
1379
1444
  }, this.mintAmounts, {
1445
+ // the mint amounts are what will be passed as calldata
1380
1446
  useFullPrecision: false
1381
1447
  }));
1448
+
1382
1449
  // we want the smaller amounts...
1383
1450
  // ...which occurs at the upper price for amount0...
1384
1451
  var amount0 = new Position({
@@ -1399,20 +1466,23 @@ var Position = /*#__PURE__*/function () {
1399
1466
  amount1: amount1
1400
1467
  };
1401
1468
  }
1402
- /**
1403
- * Returns the minimum amounts that should be requested in order to safely burn the amount of liquidity held by the
1404
- * position with the given slippage tolerance
1405
- * @param slippageTolerance tolerance of unfavorable slippage from the current price
1406
- * @returns The amounts, with slippage
1469
+
1470
+ /**
1471
+ * Returns the minimum amounts that should be requested in order to safely burn the amount of liquidity held by the
1472
+ * position with the given slippage tolerance
1473
+ * @param slippageTolerance tolerance of unfavorable slippage from the current price
1474
+ * @returns The amounts, with slippage
1407
1475
  */;
1408
1476
  _proto.burnAmountsWithSlippage = function burnAmountsWithSlippage(slippageTolerance) {
1409
1477
  // get lower/upper prices
1410
1478
  var _this$ratiosAfterSlip2 = this.ratiosAfterSlippage(slippageTolerance),
1411
1479
  sqrtRatioX96Upper = _this$ratiosAfterSlip2.sqrtRatioX96Upper,
1412
1480
  sqrtRatioX96Lower = _this$ratiosAfterSlip2.sqrtRatioX96Lower;
1481
+
1413
1482
  // construct counterfactual pools
1414
1483
  var poolLower = new Pool(this.pool.token0, this.pool.token1, this.pool.fee, sqrtRatioX96Lower, 0 /* liquidity doesn't matter */, TickMath.getTickAtSqrtRatio(sqrtRatioX96Lower));
1415
1484
  var poolUpper = new Pool(this.pool.token0, this.pool.token1, this.pool.fee, sqrtRatioX96Upper, 0 /* liquidity doesn't matter */, TickMath.getTickAtSqrtRatio(sqrtRatioX96Upper));
1485
+
1416
1486
  // we want the smaller amounts...
1417
1487
  // ...which occurs at the upper price for amount0...
1418
1488
  var amount0 = new Position({
@@ -1433,21 +1503,22 @@ var Position = /*#__PURE__*/function () {
1433
1503
  amount1: amount1.quotient
1434
1504
  };
1435
1505
  }
1436
- /**
1437
- * Returns the minimum amounts that must be sent in order to mint the amount of liquidity held by the position at
1438
- * the current price for the pool
1506
+
1507
+ /**
1508
+ * Returns the minimum amounts that must be sent in order to mint the amount of liquidity held by the position at
1509
+ * the current price for the pool
1439
1510
  */;
1440
- /**
1441
- * Computes the maximum amount of liquidity received for a given amount of token0, token1,
1442
- * and the prices at the tick boundaries.
1443
- * @param pool The pool for which the position should be created
1444
- * @param tickLower The lower tick of the position
1445
- * @param tickUpper The upper tick of the position
1446
- * @param amount0 token0 amount
1447
- * @param amount1 token1 amount
1448
- * @param useFullPrecision If false, liquidity will be maximized according to what the router can calculate,
1449
- * not what core can theoretically support
1450
- * @returns The amount of liquidity for the position
1511
+ /**
1512
+ * Computes the maximum amount of liquidity received for a given amount of token0, token1,
1513
+ * and the prices at the tick boundaries.
1514
+ * @param pool The pool for which the position should be created
1515
+ * @param tickLower The lower tick of the position
1516
+ * @param tickUpper The upper tick of the position
1517
+ * @param amount0 token0 amount
1518
+ * @param amount1 token1 amount
1519
+ * @param useFullPrecision If false, liquidity will be maximized according to what the router can calculate,
1520
+ * not what core can theoretically support
1521
+ * @returns The amount of liquidity for the position
1451
1522
  */
1452
1523
  Position.fromAmounts = function fromAmounts(_ref2) {
1453
1524
  var pool = _ref2.pool,
@@ -1465,15 +1536,16 @@ var Position = /*#__PURE__*/function () {
1465
1536
  liquidity: maxLiquidityForAmounts(pool.sqrtRatioX96, sqrtRatioAX96, sqrtRatioBX96, amount0, amount1, useFullPrecision)
1466
1537
  });
1467
1538
  }
1468
- /**
1469
- * Computes a position with the maximum amount of liquidity received for a given amount of token0, assuming an unlimited amount of token1
1470
- * @param pool The pool for which the position is created
1471
- * @param tickLower The lower tick
1472
- * @param tickUpper The upper tick
1473
- * @param amount0 The desired amount of token0
1474
- * @param useFullPrecision If true, liquidity will be maximized according to what the router can calculate,
1475
- * not what core can theoretically support
1476
- * @returns The position
1539
+
1540
+ /**
1541
+ * Computes a position with the maximum amount of liquidity received for a given amount of token0, assuming an unlimited amount of token1
1542
+ * @param pool The pool for which the position is created
1543
+ * @param tickLower The lower tick
1544
+ * @param tickUpper The upper tick
1545
+ * @param amount0 The desired amount of token0
1546
+ * @param useFullPrecision If true, liquidity will be maximized according to what the router can calculate,
1547
+ * not what core can theoretically support
1548
+ * @returns The position
1477
1549
  */;
1478
1550
  Position.fromAmount0 = function fromAmount0(_ref3) {
1479
1551
  var pool = _ref3.pool,
@@ -1490,13 +1562,14 @@ var Position = /*#__PURE__*/function () {
1490
1562
  useFullPrecision: useFullPrecision
1491
1563
  });
1492
1564
  }
1493
- /**
1494
- * Computes a position with the maximum amount of liquidity received for a given amount of token1, assuming an unlimited amount of token0
1495
- * @param pool The pool for which the position is created
1496
- * @param tickLower The lower tick
1497
- * @param tickUpper The upper tick
1498
- * @param amount1 The desired amount of token1
1499
- * @returns The position
1565
+
1566
+ /**
1567
+ * Computes a position with the maximum amount of liquidity received for a given amount of token1, assuming an unlimited amount of token0
1568
+ * @param pool The pool for which the position is created
1569
+ * @param tickLower The lower tick
1570
+ * @param tickUpper The upper tick
1571
+ * @param amount1 The desired amount of token1
1572
+ * @returns The position
1500
1573
  */;
1501
1574
  Position.fromAmount1 = function fromAmount1(_ref4) {
1502
1575
  var pool = _ref4.pool,
@@ -1518,16 +1591,18 @@ var Position = /*#__PURE__*/function () {
1518
1591
  get: function get() {
1519
1592
  return tickToPrice(this.pool.token0, this.pool.token1, this.tickLower);
1520
1593
  }
1521
- /**
1522
- * Returns the price of token0 at the upper tick
1594
+
1595
+ /**
1596
+ * Returns the price of token0 at the upper tick
1523
1597
  */
1524
1598
  }, {
1525
1599
  key: "token0PriceUpper",
1526
1600
  get: function get() {
1527
1601
  return tickToPrice(this.pool.token0, this.pool.token1, this.tickUpper);
1528
1602
  }
1529
- /**
1530
- * Returns the amount of token0 that this position's liquidity could be burned for at the current pool price
1603
+
1604
+ /**
1605
+ * Returns the amount of token0 that this position's liquidity could be burned for at the current pool price
1531
1606
  */
1532
1607
  }, {
1533
1608
  key: "amount0",
@@ -1543,8 +1618,9 @@ var Position = /*#__PURE__*/function () {
1543
1618
  }
1544
1619
  return this._token0Amount;
1545
1620
  }
1546
- /**
1547
- * Returns the amount of token1 that this position's liquidity could be burned for at the current pool price
1621
+
1622
+ /**
1623
+ * Returns the amount of token1 that this position's liquidity could be burned for at the current pool price
1548
1624
  */
1549
1625
  }, {
1550
1626
  key: "amount1",
@@ -1586,19 +1662,23 @@ var Position = /*#__PURE__*/function () {
1586
1662
  }]);
1587
1663
  }();
1588
1664
 
1589
- /**
1590
- * Represents a list of pools through which a swap can occur
1591
- * @template TInput The input token
1592
- * @template TOutput The output token
1665
+ /**
1666
+ * Represents a list of pools through which a swap can occur
1667
+ * @template TInput The input token
1668
+ * @template TOutput The output token
1593
1669
  */
1594
1670
  var Route = /*#__PURE__*/function () {
1595
- /**
1596
- * Creates an instance of route.
1597
- * @param pools An array of `Pool` objects, ordered by the route the swap will take
1598
- * @param input The input token
1599
- * @param output The output token
1671
+ /**
1672
+ * Creates an instance of route.
1673
+ * @param pools An array of `Pool` objects, ordered by the route the swap will take
1674
+ * @param input The input token
1675
+ * @param output The output token
1600
1676
  */
1601
1677
  function Route(pools, input, output) {
1678
+ this.pools = void 0;
1679
+ this.tokenPath = void 0;
1680
+ this.input = void 0;
1681
+ this.output = void 0;
1602
1682
  this._midPrice = null;
1603
1683
  !(pools.length > 0) ? invariant(false, 'POOLS') : void 0;
1604
1684
  var chainId = pools[0].chainId;
@@ -1609,8 +1689,9 @@ var Route = /*#__PURE__*/function () {
1609
1689
  var wrappedInput = input.wrapped;
1610
1690
  !pools[0].involvesToken(wrappedInput) ? invariant(false, 'INPUT') : void 0;
1611
1691
  !pools[pools.length - 1].involvesToken(output.wrapped) ? invariant(false, 'OUTPUT') : void 0;
1612
- /**
1613
- * Normalizes token0-token1 order and selects the next token/fee step to add to the path
1692
+
1693
+ /**
1694
+ * Normalizes token0-token1 order and selects the next token/fee step to add to the path
1614
1695
  * */
1615
1696
  var tokenPath = [wrappedInput];
1616
1697
  for (var _iterator = _createForOfIteratorHelperLoose(pools.entries()), _step; !(_step = _iterator()).done;) {
@@ -1632,8 +1713,9 @@ var Route = /*#__PURE__*/function () {
1632
1713
  get: function get() {
1633
1714
  return this.pools[0].chainId;
1634
1715
  }
1635
- /**
1636
- * Returns the mid price of the route
1716
+
1717
+ /**
1718
+ * Returns the mid price of the route
1637
1719
  */
1638
1720
  }, {
1639
1721
  key: "midPrice",
@@ -1661,14 +1743,14 @@ var Route = /*#__PURE__*/function () {
1661
1743
  }]);
1662
1744
  }();
1663
1745
 
1664
- /**
1665
- * Trades comparator, an extension of the input output comparator that also considers other dimensions of the trade in ranking them
1666
- * @template TInput The input token, either Ether or an ERC-20
1667
- * @template TOutput The output token, either Ether or an ERC-20
1668
- * @template TTradeType The trade type, either exact input or exact output
1669
- * @param a The first trade to compare
1670
- * @param b The second trade to compare
1671
- * @returns A sorted ordering for two neighboring elements in a trade array
1746
+ /**
1747
+ * Trades comparator, an extension of the input output comparator that also considers other dimensions of the trade in ranking them
1748
+ * @template TInput The input token, either Ether or an ERC-20
1749
+ * @template TOutput The output token, either Ether or an ERC-20
1750
+ * @template TTradeType The trade type, either exact input or exact output
1751
+ * @param a The first trade to compare
1752
+ * @param b The second trade to compare
1753
+ * @returns A sorted ordering for two neighboring elements in a trade array
1672
1754
  */
1673
1755
  function tradeComparator(a, b) {
1674
1756
  // must have same input and output token for comparison
@@ -1700,27 +1782,56 @@ function tradeComparator(a, b) {
1700
1782
  }
1701
1783
  }
1702
1784
  }
1703
- /**
1704
- * Represents a trade executed against a set of routes where some percentage of the input is
1705
- * split across each route.
1706
- *
1707
- * Each route has its own set of pools. Pools can not be re-used across routes.
1708
- *
1709
- * Does not account for slippage, i.e., changes in price environment that can occur between
1710
- * the time the trade is submitted and when it is executed.
1711
- * @template TInput The input token, either Ether or an ERC-20
1712
- * @template TOutput The output token, either Ether or an ERC-20
1713
- * @template TTradeType The trade type, either exact input or exact output
1785
+ /**
1786
+ * Represents a trade executed against a set of routes where some percentage of the input is
1787
+ * split across each route.
1788
+ *
1789
+ * Each route has its own set of pools. Pools can not be re-used across routes.
1790
+ *
1791
+ * Does not account for slippage, i.e., changes in price environment that can occur between
1792
+ * the time the trade is submitted and when it is executed.
1793
+ * @template TInput The input token, either Ether or an ERC-20
1794
+ * @template TOutput The output token, either Ether or an ERC-20
1795
+ * @template TTradeType The trade type, either exact input or exact output
1714
1796
  */
1715
1797
  var Trade = /*#__PURE__*/function () {
1716
- /**
1717
- * Construct a trade by passing in the pre-computed property values
1718
- * @param routes The routes through which the trade occurs
1719
- * @param tradeType The type of trade, exact input or exact output
1798
+ /**
1799
+ * Construct a trade by passing in the pre-computed property values
1800
+ * @param routes The routes through which the trade occurs
1801
+ * @param tradeType The type of trade, exact input or exact output
1720
1802
  */
1721
1803
  function Trade(_ref) {
1722
1804
  var routes = _ref.routes,
1723
1805
  tradeType = _ref.tradeType;
1806
+ /**
1807
+ * The swaps of the trade, i.e. which routes and how much is swapped in each that
1808
+ * make up the trade.
1809
+ */
1810
+ this.swaps = void 0;
1811
+ /**
1812
+ * The type of the trade, either exact in or exact out.
1813
+ */
1814
+ this.tradeType = void 0;
1815
+ /**
1816
+ * The cached result of the input amount computation
1817
+ * @private
1818
+ */
1819
+ this._inputAmount = void 0;
1820
+ /**
1821
+ * The cached result of the output amount computation
1822
+ * @private
1823
+ */
1824
+ this._outputAmount = void 0;
1825
+ /**
1826
+ * The cached result of the computed execution price
1827
+ * @private
1828
+ */
1829
+ this._executionPrice = void 0;
1830
+ /**
1831
+ * The cached result of the price impact computation
1832
+ * @private
1833
+ */
1834
+ this._priceImpact = void 0;
1724
1835
  var inputCurrency = routes[0].inputAmount.currency;
1725
1836
  var outputCurrency = routes[0].outputAmount.currency;
1726
1837
  !routes.every(function (_ref2) {
@@ -1749,20 +1860,19 @@ var Trade = /*#__PURE__*/function () {
1749
1860
  this.swaps = routes;
1750
1861
  this.tradeType = tradeType;
1751
1862
  }
1752
- /**
1753
- * @deprecated Deprecated in favor of 'swaps' property. If the trade consists of multiple routes
1754
- * this will return an error.
1755
- *
1756
- * When the trade consists of just a single route, this returns the route of the trade,
1757
- * i.e. which pools the trade goes through.
1863
+
1864
+ /**
1865
+ * Get the minimum amount that must be received from this trade for the given slippage tolerance
1866
+ * @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
1867
+ * @returns The amount out
1758
1868
  */
1759
- /**
1760
- * Constructs an exact in trade with the given amount in and route
1761
- * @template TInput The input token, either Ether or an ERC-20
1762
- * @template TOutput The output token, either Ether or an ERC-20
1763
- * @param route The route of the exact in trade
1764
- * @param amountIn The amount being passed in
1765
- * @returns The exact in trade
1869
+ /**
1870
+ * Constructs an exact in trade with the given amount in and route
1871
+ * @template TInput The input token, either Ether or an ERC-20
1872
+ * @template TOutput The output token, either Ether or an ERC-20
1873
+ * @param route The route of the exact in trade
1874
+ * @param amountIn The amount being passed in
1875
+ * @returns The exact in trade
1766
1876
  */
1767
1877
  Trade.exactIn =
1768
1878
  /*#__PURE__*/
@@ -1780,13 +1890,13 @@ var Trade = /*#__PURE__*/function () {
1780
1890
  }
1781
1891
  return exactIn;
1782
1892
  }()
1783
- /**
1784
- * Constructs an exact out trade with the given amount out and route
1785
- * @template TInput The input token, either Ether or an ERC-20
1786
- * @template TOutput The output token, either Ether or an ERC-20
1787
- * @param route The route of the exact out trade
1788
- * @param amountOut The amount returned by the trade
1789
- * @returns The exact out trade
1893
+ /**
1894
+ * Constructs an exact out trade with the given amount out and route
1895
+ * @template TInput The input token, either Ether or an ERC-20
1896
+ * @template TOutput The output token, either Ether or an ERC-20
1897
+ * @param route The route of the exact out trade
1898
+ * @param amountOut The amount returned by the trade
1899
+ * @returns The exact out trade
1790
1900
  */
1791
1901
  ;
1792
1902
  Trade.exactOut =
@@ -1805,15 +1915,15 @@ var Trade = /*#__PURE__*/function () {
1805
1915
  }
1806
1916
  return exactOut;
1807
1917
  }()
1808
- /**
1809
- * Constructs a trade by simulating swaps through the given route
1810
- * @template TInput The input token, either Ether or an ERC-20.
1811
- * @template TOutput The output token, either Ether or an ERC-20.
1812
- * @template TTradeType The type of the trade, either exact in or exact out.
1813
- * @param route route to swap through
1814
- * @param amount the amount specified, either input or output, depending on tradeType
1815
- * @param tradeType whether the trade is an exact input or exact output swap
1816
- * @returns The route
1918
+ /**
1919
+ * Constructs a trade by simulating swaps through the given route
1920
+ * @template TInput The input token, either Ether or an ERC-20.
1921
+ * @template TOutput The output token, either Ether or an ERC-20.
1922
+ * @template TTradeType The type of the trade, either exact in or exact out.
1923
+ * @param route route to swap through
1924
+ * @param amount the amount specified, either input or output, depending on tradeType
1925
+ * @param tradeType whether the trade is an exact input or exact output swap
1926
+ * @returns The route
1817
1927
  */
1818
1928
  ;
1819
1929
  Trade.fromRoute =
@@ -1893,15 +2003,15 @@ var Trade = /*#__PURE__*/function () {
1893
2003
  }
1894
2004
  return fromRoute;
1895
2005
  }()
1896
- /**
1897
- * Constructs a trade from routes by simulating swaps
1898
- *
1899
- * @template TInput The input token, either Ether or an ERC-20.
1900
- * @template TOutput The output token, either Ether or an ERC-20.
1901
- * @template TTradeType The type of the trade, either exact in or exact out.
1902
- * @param routes the routes to swap through and how much of the amount should be routed through each
1903
- * @param tradeType whether the trade is an exact input or exact output swap
1904
- * @returns The trade
2006
+ /**
2007
+ * Constructs a trade from routes by simulating swaps
2008
+ *
2009
+ * @template TInput The input token, either Ether or an ERC-20.
2010
+ * @template TOutput The output token, either Ether or an ERC-20.
2011
+ * @template TTradeType The type of the trade, either exact in or exact out.
2012
+ * @param routes the routes to swap through and how much of the amount should be routed through each
2013
+ * @param tradeType whether the trade is an exact input or exact output swap
2014
+ * @returns The trade
1905
2015
  */
1906
2016
  ;
1907
2017
  Trade.fromRoutes =
@@ -1996,14 +2106,14 @@ var Trade = /*#__PURE__*/function () {
1996
2106
  }
1997
2107
  return fromRoutes;
1998
2108
  }()
1999
- /**
2000
- * Creates a trade without computing the result of swapping through the route. Useful when you have simulated the trade
2001
- * elsewhere and do not have any tick data
2002
- * @template TInput The input token, either Ether or an ERC-20
2003
- * @template TOutput The output token, either Ether or an ERC-20
2004
- * @template TTradeType The type of the trade, either exact in or exact out
2005
- * @param constructorArguments The arguments passed to the trade constructor
2006
- * @returns The unchecked trade
2109
+ /**
2110
+ * Creates a trade without computing the result of swapping through the route. Useful when you have simulated the trade
2111
+ * elsewhere and do not have any tick data
2112
+ * @template TInput The input token, either Ether or an ERC-20
2113
+ * @template TOutput The output token, either Ether or an ERC-20
2114
+ * @template TTradeType The type of the trade, either exact in or exact out
2115
+ * @param constructorArguments The arguments passed to the trade constructor
2116
+ * @returns The unchecked trade
2007
2117
  */
2008
2118
  ;
2009
2119
  Trade.createUncheckedTrade = function createUncheckedTrade(constructorArguments) {
@@ -2015,23 +2125,19 @@ var Trade = /*#__PURE__*/function () {
2015
2125
  }]
2016
2126
  }));
2017
2127
  }
2018
- /**
2019
- * Creates a trade without computing the result of swapping through the routes. Useful when you have simulated the trade
2020
- * elsewhere and do not have any tick data
2021
- * @template TInput The input token, either Ether or an ERC-20
2022
- * @template TOutput The output token, either Ether or an ERC-20
2023
- * @template TTradeType The type of the trade, either exact in or exact out
2024
- * @param constructorArguments The arguments passed to the trade constructor
2025
- * @returns The unchecked trade
2128
+
2129
+ /**
2130
+ * Creates a trade without computing the result of swapping through the routes. Useful when you have simulated the trade
2131
+ * elsewhere and do not have any tick data
2132
+ * @template TInput The input token, either Ether or an ERC-20
2133
+ * @template TOutput The output token, either Ether or an ERC-20
2134
+ * @template TTradeType The type of the trade, either exact in or exact out
2135
+ * @param constructorArguments The arguments passed to the trade constructor
2136
+ * @returns The unchecked trade
2026
2137
  */;
2027
2138
  Trade.createUncheckedTradeWithMultipleRoutes = function createUncheckedTradeWithMultipleRoutes(constructorArguments) {
2028
2139
  return new Trade(constructorArguments);
2029
- }
2030
- /**
2031
- * Get the minimum amount that must be received from this trade for the given slippage tolerance
2032
- * @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
2033
- * @returns The amount out
2034
- */;
2140
+ };
2035
2141
  var _proto = Trade.prototype;
2036
2142
  _proto.minimumAmountOut = function minimumAmountOut(slippageTolerance, amountOut) {
2037
2143
  if (amountOut === void 0) {
@@ -2045,10 +2151,11 @@ var Trade = /*#__PURE__*/function () {
2045
2151
  return sdkCore.CurrencyAmount.fromRawAmount(amountOut.currency, slippageAdjustedAmountOut);
2046
2152
  }
2047
2153
  }
2048
- /**
2049
- * Get the maximum amount in that can be spent via this trade for the given slippage tolerance
2050
- * @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
2051
- * @returns The amount in
2154
+
2155
+ /**
2156
+ * Get the maximum amount in that can be spent via this trade for the given slippage tolerance
2157
+ * @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
2158
+ * @returns The amount in
2052
2159
  */;
2053
2160
  _proto.maximumAmountIn = function maximumAmountIn(slippageTolerance, amountIn) {
2054
2161
  if (amountIn === void 0) {
@@ -2062,28 +2169,30 @@ var Trade = /*#__PURE__*/function () {
2062
2169
  return sdkCore.CurrencyAmount.fromRawAmount(amountIn.currency, slippageAdjustedAmountIn);
2063
2170
  }
2064
2171
  }
2065
- /**
2066
- * Return the execution price after accounting for slippage tolerance
2067
- * @param slippageTolerance the allowed tolerated slippage
2068
- * @returns The execution price
2172
+
2173
+ /**
2174
+ * Return the execution price after accounting for slippage tolerance
2175
+ * @param slippageTolerance the allowed tolerated slippage
2176
+ * @returns The execution price
2069
2177
  */;
2070
2178
  _proto.worstExecutionPrice = function worstExecutionPrice(slippageTolerance) {
2071
2179
  return new sdkCore.Price(this.inputAmount.currency, this.outputAmount.currency, this.maximumAmountIn(slippageTolerance).quotient, this.minimumAmountOut(slippageTolerance).quotient);
2072
2180
  }
2073
- /**
2074
- * Given a list of pools, and a fixed amount in, returns the top `maxNumResults` trades that go from an input token
2075
- * amount to an output token, making at most `maxHops` hops.
2076
- * Note this does not consider aggregation, as routes are linear. It's possible a better route exists by splitting
2077
- * the amount in among multiple routes.
2078
- * @param pools the pools to consider in finding the best trade
2079
- * @param nextAmountIn exact amount of input currency to spend
2080
- * @param currencyOut the desired currency out
2081
- * @param maxNumResults maximum number of results to return
2082
- * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pool
2083
- * @param currentPools used in recursion; the current list of pools
2084
- * @param currencyAmountIn used in recursion; the original value of the currencyAmountIn parameter
2085
- * @param bestTrades used in recursion; the current list of best trades
2086
- * @returns The exact in trade
2181
+
2182
+ /**
2183
+ * Given a list of pools, and a fixed amount in, returns the top `maxNumResults` trades that go from an input token
2184
+ * amount to an output token, making at most `maxHops` hops.
2185
+ * Note this does not consider aggregation, as routes are linear. It's possible a better route exists by splitting
2186
+ * the amount in among multiple routes.
2187
+ * @param pools the pools to consider in finding the best trade
2188
+ * @param nextAmountIn exact amount of input currency to spend
2189
+ * @param currencyOut the desired currency out
2190
+ * @param maxNumResults maximum number of results to return
2191
+ * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pool
2192
+ * @param currentPools used in recursion; the current list of pools
2193
+ * @param currencyAmountIn used in recursion; the original value of the currencyAmountIn parameter
2194
+ * @param bestTrades used in recursion; the current list of best trades
2195
+ * @returns The exact in trade
2087
2196
  */;
2088
2197
  Trade.bestTradeExactIn =
2089
2198
  /*#__PURE__*/
@@ -2180,21 +2289,21 @@ var Trade = /*#__PURE__*/function () {
2180
2289
  }
2181
2290
  return bestTradeExactIn;
2182
2291
  }()
2183
- /**
2184
- * similar to the above method but instead targets a fixed output amount
2185
- * given a list of pools, and a fixed amount out, returns the top `maxNumResults` trades that go from an input token
2186
- * to an output token amount, making at most `maxHops` hops
2187
- * note this does not consider aggregation, as routes are linear. it's possible a better route exists by splitting
2188
- * the amount in among multiple routes.
2189
- * @param pools the pools to consider in finding the best trade
2190
- * @param currencyIn the currency to spend
2191
- * @param currencyAmountOut the desired currency amount out
2192
- * @param nextAmountOut the exact amount of currency out
2193
- * @param maxNumResults maximum number of results to return
2194
- * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pool
2195
- * @param currentPools used in recursion; the current list of pools
2196
- * @param bestTrades used in recursion; the current list of best trades
2197
- * @returns The exact out trade
2292
+ /**
2293
+ * similar to the above method but instead targets a fixed output amount
2294
+ * given a list of pools, and a fixed amount out, returns the top `maxNumResults` trades that go from an input token
2295
+ * to an output token amount, making at most `maxHops` hops
2296
+ * note this does not consider aggregation, as routes are linear. it's possible a better route exists by splitting
2297
+ * the amount in among multiple routes.
2298
+ * @param pools the pools to consider in finding the best trade
2299
+ * @param currencyIn the currency to spend
2300
+ * @param currencyAmountOut the desired currency amount out
2301
+ * @param nextAmountOut the exact amount of currency out
2302
+ * @param maxNumResults maximum number of results to return
2303
+ * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pool
2304
+ * @param currentPools used in recursion; the current list of pools
2305
+ * @param bestTrades used in recursion; the current list of best trades
2306
+ * @returns The exact out trade
2198
2307
  */
2199
2308
  ;
2200
2309
  Trade.bestTradeExactOut =
@@ -2294,16 +2403,25 @@ var Trade = /*#__PURE__*/function () {
2294
2403
  }();
2295
2404
  return _createClass(Trade, [{
2296
2405
  key: "route",
2297
- get: function get() {
2406
+ get:
2407
+ /**
2408
+ * @deprecated Deprecated in favor of 'swaps' property. If the trade consists of multiple routes
2409
+ * this will return an error.
2410
+ *
2411
+ * When the trade consists of just a single route, this returns the route of the trade,
2412
+ * i.e. which pools the trade goes through.
2413
+ */
2414
+ function get() {
2298
2415
  !(this.swaps.length === 1) ? invariant(false, 'MULTIPLE_ROUTES') : void 0;
2299
2416
  return this.swaps[0].route;
2300
2417
  }
2301
- /**
2302
- * The input amount for the trade assuming no slippage.
2303
- */
2304
2418
  }, {
2305
2419
  key: "inputAmount",
2306
- get: function get() {
2420
+ get:
2421
+ /**
2422
+ * The input amount for the trade assuming no slippage.
2423
+ */
2424
+ function get() {
2307
2425
  if (this._inputAmount) {
2308
2426
  return this._inputAmount;
2309
2427
  }
@@ -2317,12 +2435,13 @@ var Trade = /*#__PURE__*/function () {
2317
2435
  this._inputAmount = totalInputFromRoutes;
2318
2436
  return this._inputAmount;
2319
2437
  }
2320
- /**
2321
- * The output amount for the trade assuming no slippage.
2322
- */
2323
2438
  }, {
2324
2439
  key: "outputAmount",
2325
- get: function get() {
2440
+ get:
2441
+ /**
2442
+ * The output amount for the trade assuming no slippage.
2443
+ */
2444
+ function get() {
2326
2445
  if (this._outputAmount) {
2327
2446
  return this._outputAmount;
2328
2447
  }
@@ -2336,21 +2455,23 @@ var Trade = /*#__PURE__*/function () {
2336
2455
  this._outputAmount = totalOutputFromRoutes;
2337
2456
  return this._outputAmount;
2338
2457
  }
2339
- /**
2340
- * The price expressed in terms of output amount/input amount.
2341
- */
2342
2458
  }, {
2343
2459
  key: "executionPrice",
2344
- get: function get() {
2460
+ get:
2461
+ /**
2462
+ * The price expressed in terms of output amount/input amount.
2463
+ */
2464
+ function get() {
2345
2465
  var _this$_executionPrice;
2346
2466
  return (_this$_executionPrice = this._executionPrice) != null ? _this$_executionPrice : this._executionPrice = new sdkCore.Price(this.inputAmount.currency, this.outputAmount.currency, this.inputAmount.quotient, this.outputAmount.quotient);
2347
2467
  }
2348
- /**
2349
- * Returns the percent difference between the route's mid price and the price impact
2350
- */
2351
2468
  }, {
2352
2469
  key: "priceImpact",
2353
- get: function get() {
2470
+ get:
2471
+ /**
2472
+ * Returns the percent difference between the route's mid price and the price impact
2473
+ */
2474
+ function get() {
2354
2475
  if (this._priceImpact) {
2355
2476
  return this._priceImpact;
2356
2477
  }
@@ -2370,8 +2491,8 @@ var Trade = /*#__PURE__*/function () {
2370
2491
  }();
2371
2492
 
2372
2493
  var Multicall = /*#__PURE__*/function () {
2373
- /**
2374
- * Cannot be constructed.
2494
+ /**
2495
+ * Cannot be constructed.
2375
2496
  */
2376
2497
  function Multicall() {}
2377
2498
  Multicall.encodeMulticall = function encodeMulticall(calldatas) {
@@ -2388,8 +2509,8 @@ function isAllowedPermit(permitOptions) {
2388
2509
  return 'nonce' in permitOptions;
2389
2510
  }
2390
2511
  var SelfPermit = /*#__PURE__*/function () {
2391
- /**
2392
- * Cannot be constructed.
2512
+ /**
2513
+ * Cannot be constructed.
2393
2514
  */
2394
2515
  function SelfPermit() {}
2395
2516
  SelfPermit.encodePermit = function encodePermit(token, options) {
@@ -2400,8 +2521,8 @@ var SelfPermit = /*#__PURE__*/function () {
2400
2521
  SelfPermit.INTERFACE = /*#__PURE__*/new abi.Interface(ISelfPermit.abi);
2401
2522
 
2402
2523
  var Payments = /*#__PURE__*/function () {
2403
- /**
2404
- * Cannot be constructed.
2524
+ /**
2525
+ * Cannot be constructed.
2405
2526
  */
2406
2527
  function Payments() {}
2407
2528
  Payments.encodeFeeBips = function encodeFeeBips(fee) {
@@ -2436,15 +2557,25 @@ Payments.INTERFACE = /*#__PURE__*/new abi.Interface(IPeripheryPaymentsWithFee.ab
2436
2557
 
2437
2558
  var _excluded = ["expectedCurrencyOwed0", "expectedCurrencyOwed1"];
2438
2559
  var MaxUint128 = /*#__PURE__*/toHex(/*#__PURE__*/JSBI.subtract(/*#__PURE__*/JSBI.exponentiate(/*#__PURE__*/JSBI.BigInt(2), /*#__PURE__*/JSBI.BigInt(128)), /*#__PURE__*/JSBI.BigInt(1)));
2560
+
2561
+ /**
2562
+ * Options for producing the calldata to add liquidity.
2563
+ */
2564
+
2439
2565
  // type guard
2440
2566
  function isMint(options) {
2441
2567
  return Object.keys(options).some(function (k) {
2442
2568
  return k === 'recipient';
2443
2569
  });
2444
2570
  }
2571
+
2572
+ /**
2573
+ * Options for producing the calldata to exit a position.
2574
+ */
2575
+
2445
2576
  var NonfungiblePositionManager = /*#__PURE__*/function () {
2446
- /**
2447
- * Cannot be constructed.
2577
+ /**
2578
+ * Cannot be constructed.
2448
2579
  */
2449
2580
  function NonfungiblePositionManager() {}
2450
2581
  NonfungiblePositionManager.encodeCreate = function encodeCreate(pool) {
@@ -2459,19 +2590,23 @@ var NonfungiblePositionManager = /*#__PURE__*/function () {
2459
2590
  NonfungiblePositionManager.addCallParameters = function addCallParameters(position, options) {
2460
2591
  !JSBI.greaterThan(position.liquidity, ZERO) ? invariant(false, 'ZERO_LIQUIDITY') : void 0;
2461
2592
  var calldatas = [];
2593
+
2462
2594
  // get amounts
2463
2595
  var _position$mintAmounts = position.mintAmounts,
2464
2596
  amount0Desired = _position$mintAmounts.amount0,
2465
2597
  amount1Desired = _position$mintAmounts.amount1;
2598
+
2466
2599
  // adjust for slippage
2467
2600
  var minimumAmounts = position.mintAmountsWithSlippage(options.slippageTolerance);
2468
2601
  var amount0Min = toHex(minimumAmounts.amount0);
2469
2602
  var amount1Min = toHex(minimumAmounts.amount1);
2470
2603
  var deadline = toHex(options.deadline);
2604
+
2471
2605
  // create pool if needed
2472
2606
  if (isMint(options) && options.createPool) {
2473
2607
  calldatas.push(this.encodeCreate(position.pool));
2474
2608
  }
2609
+
2475
2610
  // permits if necessary
2476
2611
  if (options.token0Permit) {
2477
2612
  calldatas.push(SelfPermit.encodePermit(position.pool.token0, options.token0Permit));
@@ -2479,6 +2614,7 @@ var NonfungiblePositionManager = /*#__PURE__*/function () {
2479
2614
  if (options.token1Permit) {
2480
2615
  calldatas.push(SelfPermit.encodePermit(position.pool.token1, options.token1Permit));
2481
2616
  }
2617
+
2482
2618
  // mint
2483
2619
  if (isMint(options)) {
2484
2620
  var recipient = sdkCore.validateAndParseAddress(options.recipient);
@@ -2511,6 +2647,7 @@ var NonfungiblePositionManager = /*#__PURE__*/function () {
2511
2647
  var wrapped = options.useNative.wrapped;
2512
2648
  !(position.pool.token0.equals(wrapped) || position.pool.token1.equals(wrapped)) ? invariant(false, 'NO_WETH') : void 0;
2513
2649
  var wrappedValue = position.pool.token0.equals(wrapped) ? amount0Desired : amount1Desired;
2650
+
2514
2651
  // we only need to refund if we're actually sending ETH
2515
2652
  if (JSBI.greaterThan(wrappedValue, ZERO)) {
2516
2653
  calldatas.push(Payments.encodeRefundETH());
@@ -2527,6 +2664,7 @@ var NonfungiblePositionManager = /*#__PURE__*/function () {
2527
2664
  var tokenId = toHex(options.tokenId);
2528
2665
  var involvesETH = options.expectedCurrencyOwed0.currency.isNative || options.expectedCurrencyOwed1.currency.isNative;
2529
2666
  var recipient = sdkCore.validateAndParseAddress(options.recipient);
2667
+
2530
2668
  // collect
2531
2669
  calldatas.push(NonfungiblePositionManager.INTERFACE.encodeFunctionData('collect', [{
2532
2670
  tokenId: tokenId,
@@ -2550,16 +2688,18 @@ var NonfungiblePositionManager = /*#__PURE__*/function () {
2550
2688
  value: toHex(0)
2551
2689
  };
2552
2690
  }
2553
- /**
2554
- * Produces the calldata for completely or partially exiting a position
2555
- * @param position The position to exit
2556
- * @param options Additional information necessary for generating the calldata
2557
- * @returns The call parameters
2691
+
2692
+ /**
2693
+ * Produces the calldata for completely or partially exiting a position
2694
+ * @param position The position to exit
2695
+ * @param options Additional information necessary for generating the calldata
2696
+ * @returns The call parameters
2558
2697
  */;
2559
2698
  NonfungiblePositionManager.removeCallParameters = function removeCallParameters(position, options) {
2560
2699
  var calldatas = [];
2561
2700
  var deadline = toHex(options.deadline);
2562
2701
  var tokenId = toHex(options.tokenId);
2702
+
2563
2703
  // construct a partial position with a percentage of liquidity
2564
2704
  var partialPosition = new Position({
2565
2705
  pool: position.pool,
@@ -2568,6 +2708,7 @@ var NonfungiblePositionManager = /*#__PURE__*/function () {
2568
2708
  tickUpper: position.tickUpper
2569
2709
  });
2570
2710
  !JSBI.greaterThan(partialPosition.liquidity, ZERO) ? invariant(false, 'ZERO_LIQUIDITY') : void 0;
2711
+
2571
2712
  // slippage-adjusted underlying amounts
2572
2713
  var _partialPosition$burn = partialPosition.burnAmountsWithSlippage(options.slippageTolerance),
2573
2714
  amount0Min = _partialPosition$burn.amount0,
@@ -2575,6 +2716,7 @@ var NonfungiblePositionManager = /*#__PURE__*/function () {
2575
2716
  if (options.permit) {
2576
2717
  calldatas.push(NonfungiblePositionManager.INTERFACE.encodeFunctionData('permit', [sdkCore.validateAndParseAddress(options.permit.spender), tokenId, toHex(options.permit.deadline), options.permit.v, options.permit.r, options.permit.s]));
2577
2718
  }
2719
+
2578
2720
  // remove liquidity
2579
2721
  calldatas.push(NonfungiblePositionManager.INTERFACE.encodeFunctionData('decreaseLiquidity', [{
2580
2722
  tokenId: tokenId,
@@ -2623,22 +2765,26 @@ var NonfungiblePositionManager = /*#__PURE__*/function () {
2623
2765
  }();
2624
2766
  NonfungiblePositionManager.INTERFACE = /*#__PURE__*/new abi.Interface(INonfungiblePositionManager.abi);
2625
2767
 
2626
- /**
2627
- * Represents the Uniswap V3 QuoterV1 contract with a method for returning the formatted
2628
- * calldata needed to call the quoter contract.
2768
+ /**
2769
+ * Optional arguments to send to the quoter.
2770
+ */
2771
+
2772
+ /**
2773
+ * Represents the Uniswap V3 QuoterV1 contract with a method for returning the formatted
2774
+ * calldata needed to call the quoter contract.
2629
2775
  */
2630
2776
  var SwapQuoter = /*#__PURE__*/function () {
2631
2777
  function SwapQuoter() {}
2632
- /**
2633
- * Produces the on-chain method name of the appropriate function within QuoterV2,
2634
- * and the relevant hex encoded parameters.
2635
- * @template TInput The input token, either Ether or an ERC-20
2636
- * @template TOutput The output token, either Ether or an ERC-20
2637
- * @param route The swap route, a list of pools through which a swap can occur
2638
- * @param amount The amount of the quote, either an amount in, or an amount out
2639
- * @param tradeType The trade type, either exact input or exact output
2640
- * @param options The optional params including price limit and Quoter contract switch
2641
- * @returns The formatted calldata
2778
+ /**
2779
+ * Produces the on-chain method name of the appropriate function within QuoterV2,
2780
+ * and the relevant hex encoded parameters.
2781
+ * @template TInput The input token, either Ether or an ERC-20
2782
+ * @template TOutput The output token, either Ether or an ERC-20
2783
+ * @param route The swap route, a list of pools through which a swap can occur
2784
+ * @param amount The amount of the quote, either an amount in, or an amount out
2785
+ * @param tradeType The trade type, either exact input or exact output
2786
+ * @param options The optional params including price limit and Quoter contract switch
2787
+ * @returns The formatted calldata
2642
2788
  */
2643
2789
  SwapQuoter.quoteCallParameters = function quoteCallParameters(route, amount, tradeType, options) {
2644
2790
  if (options === void 0) {
@@ -2681,13 +2827,25 @@ var SwapQuoter = /*#__PURE__*/function () {
2681
2827
  SwapQuoter.V1INTERFACE = /*#__PURE__*/new abi.Interface(IQuoter.abi);
2682
2828
  SwapQuoter.V2INTERFACE = /*#__PURE__*/new abi.Interface(IQuoterV2.abi);
2683
2829
 
2830
+ /**
2831
+ * Represents a unique staking program.
2832
+ */
2833
+
2834
+ /**
2835
+ * Options to specify when claiming rewards.
2836
+ */
2837
+
2838
+ /**
2839
+ * Options to specify when withdrawing a position.
2840
+ */
2841
+
2684
2842
  var Staker = /*#__PURE__*/function () {
2685
2843
  function Staker() {}
2686
- /**
2687
- * To claim rewards, must unstake and then claim.
2688
- * @param incentiveKey The unique identifier of a staking program.
2689
- * @param options Options for producing the calldata to claim. Can't claim unless you unstake.
2690
- * @returns The calldatas for 'unstakeToken' and 'claimReward'.
2844
+ /**
2845
+ * To claim rewards, must unstake and then claim.
2846
+ * @param incentiveKey The unique identifier of a staking program.
2847
+ * @param options Options for producing the calldata to claim. Can't claim unless you unstake.
2848
+ * @returns The calldatas for 'unstakeToken' and 'claimReward'.
2691
2849
  */
2692
2850
  Staker.encodeClaim = function encodeClaim(incentiveKey, options) {
2693
2851
  var _options$amount;
@@ -2698,14 +2856,15 @@ var Staker = /*#__PURE__*/function () {
2698
2856
  calldatas.push(Staker.INTERFACE.encodeFunctionData('claimReward', [incentiveKey.rewardToken.address, recipient, toHex(amount)]));
2699
2857
  return calldatas;
2700
2858
  }
2701
- /**
2702
- *
2703
- * Note: A `tokenId` can be staked in many programs but to claim rewards and continue the program you must unstake, claim, and then restake.
2704
- * @param incentiveKeys An IncentiveKey or array of IncentiveKeys that `tokenId` is staked in.
2705
- * Input an array of IncentiveKeys to claim rewards for each program.
2706
- * @param options ClaimOptions to specify tokenId, recipient, and amount wanting to collect.
2707
- * Note that you can only specify one amount and one recipient across the various programs if you are collecting from multiple programs at once.
2708
- * @returns
2859
+
2860
+ /**
2861
+ *
2862
+ * Note: A `tokenId` can be staked in many programs but to claim rewards and continue the program you must unstake, claim, and then restake.
2863
+ * @param incentiveKeys An IncentiveKey or array of IncentiveKeys that `tokenId` is staked in.
2864
+ * Input an array of IncentiveKeys to claim rewards for each program.
2865
+ * @param options ClaimOptions to specify tokenId, recipient, and amount wanting to collect.
2866
+ * Note that you can only specify one amount and one recipient across the various programs if you are collecting from multiple programs at once.
2867
+ * @returns
2709
2868
  */;
2710
2869
  Staker.collectRewards = function collectRewards(incentiveKeys, options) {
2711
2870
  incentiveKeys = Array.isArray(incentiveKeys) ? incentiveKeys : [incentiveKeys];
@@ -2723,11 +2882,12 @@ var Staker = /*#__PURE__*/function () {
2723
2882
  value: toHex(0)
2724
2883
  };
2725
2884
  }
2726
- /**
2727
- *
2728
- * @param incentiveKeys A list of incentiveKeys to unstake from. Should include all incentiveKeys (unique staking programs) that `options.tokenId` is staked in.
2729
- * @param withdrawOptions Options for producing claim calldata and withdraw calldata. Can't withdraw without unstaking all programs for `tokenId`.
2730
- * @returns Calldata for unstaking, claiming, and withdrawing.
2885
+
2886
+ /**
2887
+ *
2888
+ * @param incentiveKeys A list of incentiveKeys to unstake from. Should include all incentiveKeys (unique staking programs) that `options.tokenId` is staked in.
2889
+ * @param withdrawOptions Options for producing claim calldata and withdraw calldata. Can't withdraw without unstaking all programs for `tokenId`.
2890
+ * @returns Calldata for unstaking, claiming, and withdrawing.
2731
2891
  */;
2732
2892
  Staker.withdrawToken = function withdrawToken(incentiveKeys, withdrawOptions) {
2733
2893
  var calldatas = [];
@@ -2748,10 +2908,11 @@ var Staker = /*#__PURE__*/function () {
2748
2908
  value: toHex(0)
2749
2909
  };
2750
2910
  }
2751
- /**
2752
- *
2753
- * @param incentiveKeys A single IncentiveKey or array of IncentiveKeys to be encoded and used in the data parameter in `safeTransferFrom`
2754
- * @returns An IncentiveKey as a string
2911
+
2912
+ /**
2913
+ *
2914
+ * @param incentiveKeys A single IncentiveKey or array of IncentiveKeys to be encoded and used in the data parameter in `safeTransferFrom`
2915
+ * @returns An IncentiveKey as a string
2755
2916
  */;
2756
2917
  Staker.encodeDeposit = function encodeDeposit(incentiveKeys) {
2757
2918
  incentiveKeys = Array.isArray(incentiveKeys) ? incentiveKeys : [incentiveKeys];
@@ -2768,10 +2929,10 @@ var Staker = /*#__PURE__*/function () {
2768
2929
  }
2769
2930
  return data;
2770
2931
  }
2771
- /**
2772
- *
2773
- * @param incentiveKey An `IncentiveKey` which represents a unique staking program.
2774
- * @returns An encoded IncentiveKey to be read by ethers
2932
+ /**
2933
+ *
2934
+ * @param incentiveKey An `IncentiveKey` which represents a unique staking program.
2935
+ * @returns An encoded IncentiveKey to be read by ethers
2775
2936
  */;
2776
2937
  Staker._encodeIncentiveKey = function _encodeIncentiveKey(incentiveKey) {
2777
2938
  var _incentiveKey$pool = incentiveKey.pool,
@@ -2792,18 +2953,23 @@ var Staker = /*#__PURE__*/function () {
2792
2953
  Staker.INTERFACE = /*#__PURE__*/new abi.Interface(IUniswapV3Staker.abi);
2793
2954
  Staker.INCENTIVE_KEY_ABI = 'tuple(address rewardToken, address pool, uint256 startTime, uint256 endTime, address refundee)';
2794
2955
 
2795
- /**
2796
- * Represents the Uniswap V3 SwapRouter, and has static methods for helping execute trades.
2956
+ /**
2957
+ * Options for producing the arguments to send calls to the router.
2958
+ */
2959
+
2960
+ /**
2961
+ * Represents the Uniswap V3 SwapRouter, and has static methods for helping execute trades.
2797
2962
  */
2798
2963
  var SwapRouter = /*#__PURE__*/function () {
2799
- /**
2800
- * Cannot be constructed.
2964
+ /**
2965
+ * Cannot be constructed.
2801
2966
  */
2802
2967
  function SwapRouter() {}
2803
- /**
2804
- * Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade.
2805
- * @param trade to produce call parameters for
2806
- * @param options options for the call parameters
2968
+
2969
+ /**
2970
+ * Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade.
2971
+ * @param trade to produce call parameters for
2972
+ * @param options options for the call parameters
2807
2973
  */
2808
2974
  SwapRouter.swapCallParameters = function swapCallParameters(trades, options) {
2809
2975
  if (!Array.isArray(trades)) {
@@ -2812,6 +2978,7 @@ var SwapRouter = /*#__PURE__*/function () {
2812
2978
  var sampleTrade = trades[0];
2813
2979
  var tokenIn = sampleTrade.inputAmount.currency.wrapped;
2814
2980
  var tokenOut = sampleTrade.outputAmount.currency.wrapped;
2981
+
2815
2982
  // All trades should have the same starting and ending token.
2816
2983
  !trades.every(function (trade) {
2817
2984
  return trade.inputAmount.currency.wrapped.equals(tokenIn);
@@ -2825,6 +2992,7 @@ var SwapRouter = /*#__PURE__*/function () {
2825
2992
  var totalAmountOut = trades.reduce(function (sum, trade) {
2826
2993
  return sum.add(trade.minimumAmountOut(options.slippageTolerance));
2827
2994
  }, ZERO_OUT);
2995
+
2828
2996
  // flag for whether a refund needs to happen
2829
2997
  var mustRefund = sampleTrade.inputAmount.currency.isNative && sampleTrade.tradeType === sdkCore.TradeType.EXACT_OUTPUT;
2830
2998
  var inputIsNative = sampleTrade.inputAmount.currency.isNative;
@@ -2834,6 +3002,7 @@ var SwapRouter = /*#__PURE__*/function () {
2834
3002
  var totalValue = inputIsNative ? trades.reduce(function (sum, trade) {
2835
3003
  return sum.add(trade.maximumAmountIn(options.slippageTolerance));
2836
3004
  }, ZERO_IN) : ZERO_IN;
3005
+
2837
3006
  // encode permit if necessary
2838
3007
  if (options.inputTokenPermit) {
2839
3008
  !sampleTrade.inputAmount.currency.isToken ? invariant(false, 'NON_TOKEN_PERMIT') : void 0;
@@ -2850,6 +3019,7 @@ var SwapRouter = /*#__PURE__*/function () {
2850
3019
  outputAmount = _step2$value.outputAmount;
2851
3020
  var amountIn = toHex(trade.maximumAmountIn(options.slippageTolerance, inputAmount).quotient);
2852
3021
  var amountOut = toHex(trade.minimumAmountOut(options.slippageTolerance, outputAmount).quotient);
3022
+
2853
3023
  // flag for whether the trade is single hop or not
2854
3024
  var singleHop = route.pools.length === 1;
2855
3025
  if (singleHop) {
@@ -2905,6 +3075,7 @@ var SwapRouter = /*#__PURE__*/function () {
2905
3075
  }
2906
3076
  }
2907
3077
  }
3078
+
2908
3079
  // unwrap
2909
3080
  if (routerMustCustody) {
2910
3081
  if (!!options.fee) {
@@ -2917,6 +3088,7 @@ var SwapRouter = /*#__PURE__*/function () {
2917
3088
  calldatas.push(Payments.encodeUnwrapWETH9(totalAmountOut.quotient, recipient));
2918
3089
  }
2919
3090
  }
3091
+
2920
3092
  // refund
2921
3093
  if (mustRefund) {
2922
3094
  calldatas.push(Payments.encodeRefundETH());
@@ -2933,6 +3105,7 @@ SwapRouter.INTERFACE = /*#__PURE__*/new abi.Interface(ISwapRouter.abi);
2933
3105
  exports.ADDRESS_ZERO = ADDRESS_ZERO;
2934
3106
  exports.FACTORY_ADDRESS = FACTORY_ADDRESS;
2935
3107
  exports.FACTORY_ADDRESS_BY_CHAIN_ID = FACTORY_ADDRESS_BY_CHAIN_ID;
3108
+ exports.FeeAmount = FeeAmount;
2936
3109
  exports.FullMath = FullMath;
2937
3110
  exports.LiquidityMath = LiquidityMath;
2938
3111
  exports.Multicall = Multicall;