@uniswap/router-sdk 1.22.1 → 1.22.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.
@@ -9,6 +9,8 @@ export declare class Trade<TInput extends Currency, TOutput extends Currency, TT
9
9
  readonly tradeType: TTradeType;
10
10
  private _outputAmount;
11
11
  private _inputAmount;
12
+ private _nativeInputRoutes;
13
+ private _wethInputRoutes;
12
14
  /**
13
15
  * The swaps of the trade, i.e. which routes and how much is swapped in each that
14
16
  * make up the trade. May consist of swaps in v2 or v3.
@@ -61,6 +63,10 @@ export declare class Trade<TInput extends Currency, TOutput extends Currency, TT
61
63
  outputAmount: CurrencyAmount<TOutput>;
62
64
  outputAmountNative: CurrencyAmount<TOutput> | undefined;
63
65
  };
66
+ get numberOfInputWraps(): number;
67
+ get numberOfInputUnwraps(): number;
68
+ get nativeInputRoutes(): IRoute<TInput, TOutput, Pair | V3Pool | V4Pool>[];
69
+ get wethInputRoutes(): IRoute<TInput, TOutput, Pair | V3Pool | V4Pool>[];
64
70
  private _executionPrice;
65
71
  /**
66
72
  * The price expressed in terms of output amount/input amount.
@@ -74,6 +80,7 @@ export declare class Trade<TInput extends Currency, TOutput extends Currency, TT
74
80
  * Returns the buy tax of the output token
75
81
  */
76
82
  get outputTax(): Percent;
83
+ private isWrappedNative;
77
84
  /**
78
85
  * The cached result of the price impact computation
79
86
  * @private
@@ -1475,6 +1475,15 @@ var Trade = /*#__PURE__*/function () {
1475
1475
  !(numPools === poolIdentifierSet.size) ? invariant(false, 'POOLS_DUPLICATED') : void 0;
1476
1476
  }
1477
1477
  var _proto = Trade.prototype;
1478
+ _proto.isWrappedNative = function isWrappedNative(currency) {
1479
+ var chainId = currency.chainId;
1480
+ return currency.equals(sdkCore.Ether.onChain(chainId).wrapped);
1481
+ }
1482
+ /**
1483
+ * Returns the percent difference between the route's mid price and the expected execution price
1484
+ * In order to exclude token taxes from the price impact calculation, the spot price is calculated
1485
+ * using a ratio of values that go into the pools, which are the post-tax input amount and pre-tax output amount.
1486
+ */;
1478
1487
  /**
1479
1488
  * Get the minimum amount that must be received from this trade for the given slippage tolerance
1480
1489
  * @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
@@ -1789,6 +1798,45 @@ var Trade = /*#__PURE__*/function () {
1789
1798
  }, sdkCore.CurrencyAmount.fromRawAmount(outputNativeCurrency, 0)) : undefined
1790
1799
  };
1791
1800
  }
1801
+ }, {
1802
+ key: "numberOfInputWraps",
1803
+ get: function get() {
1804
+ // if the trade's input is eth it may require a wrap
1805
+ if (this.inputAmount.currency.isNative) {
1806
+ return this.wethInputRoutes.length;
1807
+ } else return 0;
1808
+ }
1809
+ }, {
1810
+ key: "numberOfInputUnwraps",
1811
+ get: function get() {
1812
+ // if the trade's input is weth, it may require an unwrap
1813
+ if (this.isWrappedNative(this.inputAmount.currency)) {
1814
+ return this.nativeInputRoutes.length;
1815
+ } else return 0;
1816
+ }
1817
+ }, {
1818
+ key: "nativeInputRoutes",
1819
+ get: function get() {
1820
+ if (this._nativeInputRoutes) {
1821
+ return this._nativeInputRoutes;
1822
+ }
1823
+ this._nativeInputRoutes = this.routes.filter(function (route) {
1824
+ return route.pathInput.isNative;
1825
+ });
1826
+ return this._nativeInputRoutes;
1827
+ }
1828
+ }, {
1829
+ key: "wethInputRoutes",
1830
+ get: function get() {
1831
+ var _this = this;
1832
+ if (this._wethInputRoutes) {
1833
+ return this._wethInputRoutes;
1834
+ }
1835
+ this._wethInputRoutes = this.routes.filter(function (route) {
1836
+ return _this.isWrappedNative(route.pathInput);
1837
+ });
1838
+ return this._wethInputRoutes;
1839
+ }
1792
1840
  /**
1793
1841
  * The price expressed in terms of output amount/input amount.
1794
1842
  */
@@ -1818,11 +1866,6 @@ var Trade = /*#__PURE__*/function () {
1818
1866
  if (outputCurrency.isNative || !outputCurrency.wrapped.buyFeeBps) return ZERO_PERCENT;
1819
1867
  return new sdkCore.Percent(outputCurrency.wrapped.buyFeeBps.toNumber(), 10000);
1820
1868
  }
1821
- /**
1822
- * Returns the percent difference between the route's mid price and the expected execution price
1823
- * In order to exclude token taxes from the price impact calculation, the spot price is calculated
1824
- * using a ratio of values that go into the pools, which are the post-tax input amount and pre-tax output amount.
1825
- */
1826
1869
  }, {
1827
1870
  key: "priceImpact",
1828
1871
  get: function get() {