@uniswap/router-sdk 1.22.2 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entities/trade.d.ts +7 -0
- package/dist/router-sdk.cjs.development.js +48 -5
- package/dist/router-sdk.cjs.development.js.map +1 -1
- package/dist/router-sdk.cjs.production.min.js +1 -1
- package/dist/router-sdk.cjs.production.min.js.map +1 -1
- package/dist/router-sdk.esm.js +49 -6
- package/dist/router-sdk.esm.js.map +1 -1
- package/package.json +5 -5
package/dist/router-sdk.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Percent, validateAndParseAddress, CurrencyAmount, Price, Fraction, TradeType, sortedInsert, WETH9 } from '@uniswap/sdk-core';
|
|
1
|
+
import { Percent, validateAndParseAddress, CurrencyAmount, Price, Fraction, TradeType, sortedInsert, Ether, WETH9 } from '@uniswap/sdk-core';
|
|
2
2
|
import JSBI from 'jsbi';
|
|
3
3
|
import { Interface } from '@ethersproject/abi';
|
|
4
4
|
import invariant from 'tiny-invariant';
|
|
@@ -1471,6 +1471,15 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1471
1471
|
!(numPools === poolIdentifierSet.size) ? process.env.NODE_ENV !== "production" ? invariant(false, 'POOLS_DUPLICATED') : invariant(false) : void 0;
|
|
1472
1472
|
}
|
|
1473
1473
|
var _proto = Trade.prototype;
|
|
1474
|
+
_proto.isWrappedNative = function isWrappedNative(currency) {
|
|
1475
|
+
var chainId = currency.chainId;
|
|
1476
|
+
return currency.equals(Ether.onChain(chainId).wrapped);
|
|
1477
|
+
}
|
|
1478
|
+
/**
|
|
1479
|
+
* Returns the percent difference between the route's mid price and the expected execution price
|
|
1480
|
+
* In order to exclude token taxes from the price impact calculation, the spot price is calculated
|
|
1481
|
+
* using a ratio of values that go into the pools, which are the post-tax input amount and pre-tax output amount.
|
|
1482
|
+
*/;
|
|
1474
1483
|
/**
|
|
1475
1484
|
* Get the minimum amount that must be received from this trade for the given slippage tolerance
|
|
1476
1485
|
* @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
|
|
@@ -1785,6 +1794,45 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1785
1794
|
}, CurrencyAmount.fromRawAmount(outputNativeCurrency, 0)) : undefined
|
|
1786
1795
|
};
|
|
1787
1796
|
}
|
|
1797
|
+
}, {
|
|
1798
|
+
key: "numberOfInputWraps",
|
|
1799
|
+
get: function get() {
|
|
1800
|
+
// if the trade's input is eth it may require a wrap
|
|
1801
|
+
if (this.inputAmount.currency.isNative) {
|
|
1802
|
+
return this.wethInputRoutes.length;
|
|
1803
|
+
} else return 0;
|
|
1804
|
+
}
|
|
1805
|
+
}, {
|
|
1806
|
+
key: "numberOfInputUnwraps",
|
|
1807
|
+
get: function get() {
|
|
1808
|
+
// if the trade's input is weth, it may require an unwrap
|
|
1809
|
+
if (this.isWrappedNative(this.inputAmount.currency)) {
|
|
1810
|
+
return this.nativeInputRoutes.length;
|
|
1811
|
+
} else return 0;
|
|
1812
|
+
}
|
|
1813
|
+
}, {
|
|
1814
|
+
key: "nativeInputRoutes",
|
|
1815
|
+
get: function get() {
|
|
1816
|
+
if (this._nativeInputRoutes) {
|
|
1817
|
+
return this._nativeInputRoutes;
|
|
1818
|
+
}
|
|
1819
|
+
this._nativeInputRoutes = this.routes.filter(function (route) {
|
|
1820
|
+
return route.pathInput.isNative;
|
|
1821
|
+
});
|
|
1822
|
+
return this._nativeInputRoutes;
|
|
1823
|
+
}
|
|
1824
|
+
}, {
|
|
1825
|
+
key: "wethInputRoutes",
|
|
1826
|
+
get: function get() {
|
|
1827
|
+
var _this = this;
|
|
1828
|
+
if (this._wethInputRoutes) {
|
|
1829
|
+
return this._wethInputRoutes;
|
|
1830
|
+
}
|
|
1831
|
+
this._wethInputRoutes = this.routes.filter(function (route) {
|
|
1832
|
+
return _this.isWrappedNative(route.pathInput);
|
|
1833
|
+
});
|
|
1834
|
+
return this._wethInputRoutes;
|
|
1835
|
+
}
|
|
1788
1836
|
/**
|
|
1789
1837
|
* The price expressed in terms of output amount/input amount.
|
|
1790
1838
|
*/
|
|
@@ -1814,11 +1862,6 @@ var Trade = /*#__PURE__*/function () {
|
|
|
1814
1862
|
if (outputCurrency.isNative || !outputCurrency.wrapped.buyFeeBps) return ZERO_PERCENT;
|
|
1815
1863
|
return new Percent(outputCurrency.wrapped.buyFeeBps.toNumber(), 10000);
|
|
1816
1864
|
}
|
|
1817
|
-
/**
|
|
1818
|
-
* Returns the percent difference between the route's mid price and the expected execution price
|
|
1819
|
-
* In order to exclude token taxes from the price impact calculation, the spot price is calculated
|
|
1820
|
-
* using a ratio of values that go into the pools, which are the post-tax input amount and pre-tax output amount.
|
|
1821
|
-
*/
|
|
1822
1865
|
}, {
|
|
1823
1866
|
key: "priceImpact",
|
|
1824
1867
|
get: function get() {
|