@uniswap/router-sdk 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
+ import { Percent, validateAndParseAddress, Price, Fraction, CurrencyAmount, TradeType, sortedInsert, WETH9 } from '@uniswap/sdk-core';
1
2
  import JSBI from 'jsbi';
2
3
  import { Interface } from '@ethersproject/abi';
3
4
  import invariant from 'tiny-invariant';
4
5
  import { abi } from '@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IApproveAndCall.sol/IApproveAndCall.json';
5
6
  import { NonfungiblePositionManager, toHex, Multicall, Payments, Pool, Route as Route$1, Trade as Trade$1, encodeRouteToPath, SelfPermit, Position } from '@uniswap/v3-sdk';
6
7
  import { abi as abi$1 } from '@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IMulticallExtended.sol/IMulticallExtended.json';
7
- import { validateAndParseAddress, Price, Fraction, CurrencyAmount, TradeType, Percent, sortedInsert, WETH9 } from '@uniswap/sdk-core';
8
8
  import { abi as abi$2 } from '@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IPeripheryPaymentsWithFeeExtended.sol/IPeripheryPaymentsWithFeeExtended.json';
9
9
  import { abi as abi$3 } from '@uniswap/swap-router-contracts/artifacts/contracts/interfaces/ISwapRouter02.sol/ISwapRouter02.json';
10
10
  import { Pair, Route, Trade as Trade$2 } from '@uniswap/v2-sdk';
@@ -16,6 +16,7 @@ var ZERO = /*#__PURE__*/JSBI.BigInt(0);
16
16
  var ONE = /*#__PURE__*/JSBI.BigInt(1); // = 1 << 23 or 100000000000000000000000
17
17
 
18
18
  var V2_FEE_PATH_PLACEHOLDER = 8388608;
19
+ var ZERO_PERCENT = /*#__PURE__*/new Percent(ZERO);
19
20
 
20
21
  var ApprovalTypes;
21
22
 
@@ -2237,7 +2238,31 @@ var Trade = /*#__PURE__*/function () {
2237
2238
  return (_this$_executionPrice = this._executionPrice) != null ? _this$_executionPrice : this._executionPrice = new Price(this.inputAmount.currency, this.outputAmount.currency, this.inputAmount.quotient, this.outputAmount.quotient);
2238
2239
  }
2239
2240
  /**
2240
- * Returns the percent difference between the route's mid price and the price impact
2241
+ * Returns the sell tax of the input token
2242
+ */
2243
+
2244
+ }, {
2245
+ key: "inputTax",
2246
+ get: function get() {
2247
+ var inputCurrency = this.inputAmount.currency;
2248
+ if (inputCurrency.isNative || !inputCurrency.wrapped.sellFeeBps) return ZERO_PERCENT;
2249
+ return new Percent(inputCurrency.wrapped.sellFeeBps.toNumber(), 10000);
2250
+ }
2251
+ /**
2252
+ * Returns the buy tax of the output token
2253
+ */
2254
+
2255
+ }, {
2256
+ key: "outputTax",
2257
+ get: function get() {
2258
+ var outputCurrency = this.outputAmount.currency;
2259
+ if (outputCurrency.isNative || !outputCurrency.wrapped.buyFeeBps) return ZERO_PERCENT;
2260
+ return new Percent(outputCurrency.wrapped.buyFeeBps.toNumber(), 10000);
2261
+ }
2262
+ /**
2263
+ * Returns the percent difference between the route's mid price and the expected execution price
2264
+ * In order to exclude token taxes from the price impact calculation, the spot price is calculated
2265
+ * using a ratio of values that go into the pools, which are the post-tax input amount and pre-tax output amount.
2241
2266
  */
2242
2267
 
2243
2268
  }, {
@@ -2254,10 +2279,12 @@ var Trade = /*#__PURE__*/function () {
2254
2279
  route = _step9$value.route,
2255
2280
  inputAmount = _step9$value.inputAmount;
2256
2281
  var midPrice = route.midPrice;
2257
- spotOutputAmount = spotOutputAmount.add(midPrice.quote(inputAmount));
2282
+ var postTaxInputAmount = inputAmount.multiply(new Fraction(ONE).subtract(this.inputTax));
2283
+ spotOutputAmount = spotOutputAmount.add(midPrice.quote(postTaxInputAmount));
2258
2284
  }
2259
2285
 
2260
- var priceImpact = spotOutputAmount.subtract(this.outputAmount).divide(spotOutputAmount);
2286
+ var preTaxOutputAmount = this.outputAmount.divide(new Fraction(ONE).subtract(this.outputTax));
2287
+ var priceImpact = spotOutputAmount.subtract(preTaxOutputAmount).divide(spotOutputAmount);
2261
2288
  this._priceImpact = new Percent(priceImpact.numerator, priceImpact.denominator);
2262
2289
  return this._priceImpact;
2263
2290
  }
@@ -2837,5 +2864,5 @@ var SwapRouter = /*#__PURE__*/function () {
2837
2864
  }();
2838
2865
  SwapRouter.INTERFACE = /*#__PURE__*/new Interface(abi$3);
2839
2866
 
2840
- export { ADDRESS_THIS, ApprovalTypes, ApproveAndCall, MSG_SENDER, MixedRoute, MixedRouteSDK, MixedRouteTrade, MulticallExtended, ONE, PaymentsExtended, Protocol, RouteV2, RouteV3, SwapRouter, Trade, V2_FEE_PATH_PLACEHOLDER, ZERO, encodeMixedRouteToPath, getOutputOfPools, isMint, partitionMixedRouteByProtocol, tradeComparator };
2867
+ export { ADDRESS_THIS, ApprovalTypes, ApproveAndCall, MSG_SENDER, MixedRoute, MixedRouteSDK, MixedRouteTrade, MulticallExtended, ONE, PaymentsExtended, Protocol, RouteV2, RouteV3, SwapRouter, Trade, V2_FEE_PATH_PLACEHOLDER, ZERO, ZERO_PERCENT, encodeMixedRouteToPath, getOutputOfPools, isMint, partitionMixedRouteByProtocol, tradeComparator };
2841
2868
  //# sourceMappingURL=router-sdk.esm.js.map