@uniswap/router-sdk 1.5.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.
- package/dist/constants.d.ts +2 -0
- package/dist/entities/trade.d.ts +11 -1
- package/dist/router-sdk.cjs.development.js +32 -4
- 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 +32 -5
- package/dist/router-sdk.esm.js.map +1 -1
- package/package.json +5 -5
package/dist/constants.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { Percent } from '@uniswap/sdk-core';
|
|
1
2
|
import JSBI from 'jsbi';
|
|
2
3
|
export declare const MSG_SENDER = "0x0000000000000000000000000000000000000001";
|
|
3
4
|
export declare const ADDRESS_THIS = "0x0000000000000000000000000000000000000002";
|
|
4
5
|
export declare const ZERO: JSBI;
|
|
5
6
|
export declare const ONE: JSBI;
|
|
6
7
|
export declare const V2_FEE_PATH_PLACEHOLDER = 8388608;
|
|
8
|
+
export declare const ZERO_PERCENT: Percent;
|
package/dist/entities/trade.d.ts
CHANGED
|
@@ -42,13 +42,23 @@ export declare class Trade<TInput extends Currency, TOutput extends Currency, TT
|
|
|
42
42
|
* The price expressed in terms of output amount/input amount.
|
|
43
43
|
*/
|
|
44
44
|
get executionPrice(): Price<TInput, TOutput>;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the sell tax of the input token
|
|
47
|
+
*/
|
|
48
|
+
get inputTax(): Percent;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the buy tax of the output token
|
|
51
|
+
*/
|
|
52
|
+
get outputTax(): Percent;
|
|
45
53
|
/**
|
|
46
54
|
* The cached result of the price impact computation
|
|
47
55
|
* @private
|
|
48
56
|
*/
|
|
49
57
|
private _priceImpact;
|
|
50
58
|
/**
|
|
51
|
-
* Returns the percent difference between the route's mid price and the price
|
|
59
|
+
* Returns the percent difference between the route's mid price and the expected execution price
|
|
60
|
+
* In order to exclude token taxes from the price impact calculation, the spot price is calculated
|
|
61
|
+
* using a ratio of values that go into the pools, which are the post-tax input amount and pre-tax output amount.
|
|
52
62
|
*/
|
|
53
63
|
get priceImpact(): Percent;
|
|
54
64
|
/**
|
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
|
+
var sdkCore = require('@uniswap/sdk-core');
|
|
7
8
|
var JSBI = _interopDefault(require('jsbi'));
|
|
8
9
|
var abi = require('@ethersproject/abi');
|
|
9
10
|
var invariant = _interopDefault(require('tiny-invariant'));
|
|
10
11
|
var IApproveAndCall_json = require('@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IApproveAndCall.sol/IApproveAndCall.json');
|
|
11
12
|
var v3Sdk = require('@uniswap/v3-sdk');
|
|
12
13
|
var IMulticallExtended_json = require('@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IMulticallExtended.sol/IMulticallExtended.json');
|
|
13
|
-
var sdkCore = require('@uniswap/sdk-core');
|
|
14
14
|
var IPeripheryPaymentsWithFeeExtended_json = require('@uniswap/swap-router-contracts/artifacts/contracts/interfaces/IPeripheryPaymentsWithFeeExtended.sol/IPeripheryPaymentsWithFeeExtended.json');
|
|
15
15
|
var ISwapRouter02_json = require('@uniswap/swap-router-contracts/artifacts/contracts/interfaces/ISwapRouter02.sol/ISwapRouter02.json');
|
|
16
16
|
var v2Sdk = require('@uniswap/v2-sdk');
|
|
@@ -22,6 +22,7 @@ var ZERO = /*#__PURE__*/JSBI.BigInt(0);
|
|
|
22
22
|
var ONE = /*#__PURE__*/JSBI.BigInt(1); // = 1 << 23 or 100000000000000000000000
|
|
23
23
|
|
|
24
24
|
var V2_FEE_PATH_PLACEHOLDER = 8388608;
|
|
25
|
+
var ZERO_PERCENT = /*#__PURE__*/new sdkCore.Percent(ZERO);
|
|
25
26
|
|
|
26
27
|
(function (ApprovalTypes) {
|
|
27
28
|
ApprovalTypes[ApprovalTypes["NOT_REQUIRED"] = 0] = "NOT_REQUIRED";
|
|
@@ -2239,7 +2240,31 @@ var Trade = /*#__PURE__*/function () {
|
|
|
2239
2240
|
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);
|
|
2240
2241
|
}
|
|
2241
2242
|
/**
|
|
2242
|
-
* Returns the
|
|
2243
|
+
* Returns the sell tax of the input token
|
|
2244
|
+
*/
|
|
2245
|
+
|
|
2246
|
+
}, {
|
|
2247
|
+
key: "inputTax",
|
|
2248
|
+
get: function get() {
|
|
2249
|
+
var inputCurrency = this.inputAmount.currency;
|
|
2250
|
+
if (inputCurrency.isNative || !inputCurrency.wrapped.sellFeeBps) return ZERO_PERCENT;
|
|
2251
|
+
return new sdkCore.Percent(inputCurrency.wrapped.sellFeeBps.toNumber(), 10000);
|
|
2252
|
+
}
|
|
2253
|
+
/**
|
|
2254
|
+
* Returns the buy tax of the output token
|
|
2255
|
+
*/
|
|
2256
|
+
|
|
2257
|
+
}, {
|
|
2258
|
+
key: "outputTax",
|
|
2259
|
+
get: function get() {
|
|
2260
|
+
var outputCurrency = this.outputAmount.currency;
|
|
2261
|
+
if (outputCurrency.isNative || !outputCurrency.wrapped.buyFeeBps) return ZERO_PERCENT;
|
|
2262
|
+
return new sdkCore.Percent(outputCurrency.wrapped.buyFeeBps.toNumber(), 10000);
|
|
2263
|
+
}
|
|
2264
|
+
/**
|
|
2265
|
+
* Returns the percent difference between the route's mid price and the expected execution price
|
|
2266
|
+
* In order to exclude token taxes from the price impact calculation, the spot price is calculated
|
|
2267
|
+
* using a ratio of values that go into the pools, which are the post-tax input amount and pre-tax output amount.
|
|
2243
2268
|
*/
|
|
2244
2269
|
|
|
2245
2270
|
}, {
|
|
@@ -2256,10 +2281,12 @@ var Trade = /*#__PURE__*/function () {
|
|
|
2256
2281
|
route = _step9$value.route,
|
|
2257
2282
|
inputAmount = _step9$value.inputAmount;
|
|
2258
2283
|
var midPrice = route.midPrice;
|
|
2259
|
-
|
|
2284
|
+
var postTaxInputAmount = inputAmount.multiply(new sdkCore.Fraction(ONE).subtract(this.inputTax));
|
|
2285
|
+
spotOutputAmount = spotOutputAmount.add(midPrice.quote(postTaxInputAmount));
|
|
2260
2286
|
}
|
|
2261
2287
|
|
|
2262
|
-
var
|
|
2288
|
+
var preTaxOutputAmount = this.outputAmount.divide(new sdkCore.Fraction(ONE).subtract(this.outputTax));
|
|
2289
|
+
var priceImpact = spotOutputAmount.subtract(preTaxOutputAmount).divide(spotOutputAmount);
|
|
2263
2290
|
this._priceImpact = new sdkCore.Percent(priceImpact.numerator, priceImpact.denominator);
|
|
2264
2291
|
return this._priceImpact;
|
|
2265
2292
|
}
|
|
@@ -2854,6 +2881,7 @@ exports.SwapRouter = SwapRouter;
|
|
|
2854
2881
|
exports.Trade = Trade;
|
|
2855
2882
|
exports.V2_FEE_PATH_PLACEHOLDER = V2_FEE_PATH_PLACEHOLDER;
|
|
2856
2883
|
exports.ZERO = ZERO;
|
|
2884
|
+
exports.ZERO_PERCENT = ZERO_PERCENT;
|
|
2857
2885
|
exports.encodeMixedRouteToPath = encodeMixedRouteToPath;
|
|
2858
2886
|
exports.getOutputOfPools = getOutputOfPools;
|
|
2859
2887
|
exports.isMint = isMint;
|