@uniswap/router-sdk 2.7.3 → 2.8.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/{approveAndCall.d.ts → cjs/src/approveAndCall.d.ts} +33 -33
- package/dist/cjs/src/approveAndCall.js +111 -0
- package/dist/cjs/src/approveAndCall.js.map +1 -0
- package/dist/{constants.d.ts → cjs/src/constants.d.ts} +13 -13
- package/dist/cjs/src/constants.js +22 -0
- package/dist/cjs/src/constants.js.map +1 -0
- package/dist/{entities → cjs/src/entities}/mixedRoute/route.d.ts +29 -29
- package/dist/cjs/src/entities/mixedRoute/route.js +119 -0
- package/dist/cjs/src/entities/mixedRoute/route.js.map +1 -0
- package/dist/{entities → cjs/src/entities}/mixedRoute/trade.d.ts +183 -183
- package/dist/cjs/src/entities/mixedRoute/trade.js +354 -0
- package/dist/cjs/src/entities/mixedRoute/trade.js.map +1 -0
- package/dist/{entities → cjs/src/entities}/protocol.d.ts +6 -6
- package/dist/cjs/src/entities/protocol.js +11 -0
- package/dist/cjs/src/entities/protocol.js.map +1 -0
- package/dist/{entities → cjs/src/entities}/route.d.ts +40 -40
- package/dist/cjs/src/entities/route.js +63 -0
- package/dist/cjs/src/entities/route.js.map +1 -0
- package/dist/{entities → cjs/src/entities}/trade.d.ts +136 -127
- package/dist/cjs/src/entities/trade.js +370 -0
- package/dist/cjs/src/entities/trade.js.map +1 -0
- package/dist/{index.d.ts → cjs/src/index.d.ts} +14 -14
- package/dist/cjs/src/index.js +18 -0
- package/dist/cjs/src/index.js.map +1 -0
- package/dist/{multicallExtended.d.ts → cjs/src/multicallExtended.d.ts} +11 -11
- package/dist/cjs/src/multicallExtended.js +44 -0
- package/dist/cjs/src/multicallExtended.js.map +1 -0
- package/dist/{paymentsExtended.d.ts → cjs/src/paymentsExtended.d.ts} +15 -15
- package/dist/cjs/src/paymentsExtended.js +66 -0
- package/dist/cjs/src/paymentsExtended.js.map +1 -0
- package/dist/{swapRouter.d.ts → cjs/src/swapRouter.d.ts} +95 -95
- package/dist/cjs/src/swapRouter.js +439 -0
- package/dist/cjs/src/swapRouter.js.map +1 -0
- package/dist/{utils → cjs/src/utils}/TPool.d.ts +4 -4
- package/dist/cjs/src/utils/TPool.js +3 -0
- package/dist/cjs/src/utils/TPool.js.map +1 -0
- package/dist/{utils → cjs/src/utils}/encodeMixedRouteToPath.d.ts +10 -10
- package/dist/cjs/src/utils/encodeMixedRouteToPath.js +91 -0
- package/dist/cjs/src/utils/encodeMixedRouteToPath.js.map +1 -0
- package/dist/{utils → cjs/src/utils}/index.d.ts +16 -16
- package/dist/cjs/src/utils/index.js +51 -0
- package/dist/cjs/src/utils/index.js.map +1 -0
- package/dist/{utils → cjs/src/utils}/pathCurrency.d.ts +4 -4
- package/dist/cjs/src/utils/pathCurrency.js +35 -0
- package/dist/cjs/src/utils/pathCurrency.js.map +1 -0
- package/dist/esm/src/approveAndCall.d.ts +33 -0
- package/dist/esm/src/approveAndCall.js +105 -0
- package/dist/esm/src/approveAndCall.js.map +1 -0
- package/dist/esm/src/constants.d.ts +13 -0
- package/dist/esm/src/constants.js +18 -0
- package/dist/esm/src/constants.js.map +1 -0
- package/dist/esm/src/entities/mixedRoute/route.d.ts +29 -0
- package/dist/esm/src/entities/mixedRoute/route.js +114 -0
- package/dist/esm/src/entities/mixedRoute/route.js.map +1 -0
- package/dist/esm/src/entities/mixedRoute/trade.d.ts +183 -0
- package/dist/esm/src/entities/mixedRoute/trade.js +348 -0
- package/dist/esm/src/entities/mixedRoute/trade.js.map +1 -0
- package/dist/esm/src/entities/protocol.d.ts +6 -0
- package/dist/esm/src/entities/protocol.js +8 -0
- package/dist/esm/src/entities/protocol.js.map +1 -0
- package/dist/esm/src/entities/route.d.ts +40 -0
- package/dist/esm/src/entities/route.js +55 -0
- package/dist/esm/src/entities/route.js.map +1 -0
- package/dist/esm/src/entities/trade.d.ts +136 -0
- package/dist/esm/src/entities/trade.js +365 -0
- package/dist/esm/src/entities/trade.js.map +1 -0
- package/dist/esm/src/index.d.ts +14 -0
- package/dist/esm/src/index.js +15 -0
- package/dist/esm/src/index.js.map +1 -0
- package/dist/esm/src/multicallExtended.d.ts +11 -0
- package/dist/esm/src/multicallExtended.js +39 -0
- package/dist/esm/src/multicallExtended.js.map +1 -0
- package/dist/esm/src/paymentsExtended.d.ts +15 -0
- package/dist/esm/src/paymentsExtended.js +61 -0
- package/dist/esm/src/paymentsExtended.js.map +1 -0
- package/dist/esm/src/swapRouter.d.ts +95 -0
- package/dist/esm/src/swapRouter.js +434 -0
- package/dist/esm/src/swapRouter.js.map +1 -0
- package/dist/esm/src/utils/TPool.d.ts +4 -0
- package/dist/esm/src/utils/TPool.js +2 -0
- package/dist/esm/src/utils/TPool.js.map +1 -0
- package/dist/esm/src/utils/encodeMixedRouteToPath.d.ts +10 -0
- package/dist/esm/src/utils/encodeMixedRouteToPath.js +87 -0
- package/dist/esm/src/utils/encodeMixedRouteToPath.js.map +1 -0
- package/dist/esm/src/utils/index.d.ts +16 -0
- package/dist/esm/src/utils/index.js +46 -0
- package/dist/esm/src/utils/index.js.map +1 -0
- package/dist/esm/src/utils/pathCurrency.d.ts +4 -0
- package/dist/esm/src/utils/pathCurrency.js +30 -0
- package/dist/esm/src/utils/pathCurrency.js.map +1 -0
- package/dist/types/src/approveAndCall.d.ts +33 -0
- package/dist/types/src/constants.d.ts +13 -0
- package/dist/types/src/entities/mixedRoute/route.d.ts +29 -0
- package/dist/types/src/entities/mixedRoute/trade.d.ts +183 -0
- package/dist/types/src/entities/protocol.d.ts +6 -0
- package/dist/types/src/entities/route.d.ts +40 -0
- package/dist/types/src/entities/trade.d.ts +136 -0
- package/dist/types/src/index.d.ts +14 -0
- package/dist/types/src/multicallExtended.d.ts +11 -0
- package/dist/types/src/paymentsExtended.d.ts +15 -0
- package/dist/types/src/swapRouter.d.ts +95 -0
- package/dist/types/src/utils/TPool.d.ts +4 -0
- package/dist/types/src/utils/encodeMixedRouteToPath.d.ts +10 -0
- package/dist/types/src/utils/index.d.ts +16 -0
- package/dist/types/src/utils/pathCurrency.d.ts +4 -0
- package/package.json +31 -12
- package/dist/index.js +0 -8
- package/dist/router-sdk.cjs.development.js +0 -2250
- package/dist/router-sdk.cjs.development.js.map +0 -1
- package/dist/router-sdk.cjs.production.min.js +0 -2
- package/dist/router-sdk.cjs.production.min.js.map +0 -1
- package/dist/router-sdk.esm.js +0 -2217
- package/dist/router-sdk.esm.js.map +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// entities/route.ts
|
|
2
|
+
import { Route as V2RouteSDK } from '@uniswap/v2-sdk';
|
|
3
|
+
import { Route as V3RouteSDK } from '@uniswap/v3-sdk';
|
|
4
|
+
import { Route as V4RouteSDK } from '@uniswap/v4-sdk';
|
|
5
|
+
import { Protocol } from './protocol';
|
|
6
|
+
import { MixedRouteSDK } from './mixedRoute/route';
|
|
7
|
+
// Helper function to get the pathInput and pathOutput for a V2 / V3 route
|
|
8
|
+
// currency could be native so we check against the wrapped version as they don't support native ETH in path
|
|
9
|
+
export function getPathToken(currency, pool) {
|
|
10
|
+
if (pool.token0.wrapped.equals(currency.wrapped)) {
|
|
11
|
+
return pool.token0;
|
|
12
|
+
}
|
|
13
|
+
else if (pool.token1.wrapped.equals(currency.wrapped)) {
|
|
14
|
+
return pool.token1;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
throw new Error(`Expected token ${currency.symbol} to be either ${pool.token0.symbol} or ${pool.token1.symbol}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// V2 route wrapper
|
|
21
|
+
export class RouteV2 extends V2RouteSDK {
|
|
22
|
+
constructor(v2Route) {
|
|
23
|
+
super(v2Route.pairs, v2Route.input, v2Route.output);
|
|
24
|
+
this.protocol = Protocol.V2;
|
|
25
|
+
this.pools = this.pairs;
|
|
26
|
+
this.pathInput = getPathToken(v2Route.input, this.pairs[0]);
|
|
27
|
+
this.pathOutput = getPathToken(v2Route.output, this.pairs[this.pairs.length - 1]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// V3 route wrapper
|
|
31
|
+
export class RouteV3 extends V3RouteSDK {
|
|
32
|
+
constructor(v3Route) {
|
|
33
|
+
super(v3Route.pools, v3Route.input, v3Route.output);
|
|
34
|
+
this.protocol = Protocol.V3;
|
|
35
|
+
this.path = v3Route.tokenPath;
|
|
36
|
+
this.pathInput = getPathToken(v3Route.input, this.pools[0]);
|
|
37
|
+
this.pathOutput = getPathToken(v3Route.output, this.pools[this.pools.length - 1]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// V4 route wrapper
|
|
41
|
+
export class RouteV4 extends V4RouteSDK {
|
|
42
|
+
constructor(v4Route) {
|
|
43
|
+
super(v4Route.pools, v4Route.input, v4Route.output);
|
|
44
|
+
this.protocol = Protocol.V4;
|
|
45
|
+
this.path = v4Route.currencyPath;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Mixed route wrapper
|
|
49
|
+
export class MixedRoute extends MixedRouteSDK {
|
|
50
|
+
constructor(mixedRoute) {
|
|
51
|
+
super(mixedRoute.pools, mixedRoute.input, mixedRoute.output);
|
|
52
|
+
this.protocol = Protocol.MIXED;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../src/entities/route.ts"],"names":[],"mappings":"AAAA,oBAAoB;AAEpB,OAAO,EAAE,KAAK,IAAI,UAAU,EAAQ,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAE,KAAK,IAAI,UAAU,EAAkB,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,KAAK,IAAI,UAAU,EAAkB,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,0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A;QANrC,aAAQ,GAAa,QAAQ,CAAC,EAAE,CAAA;QAO9C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,SAAS,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QAC3D,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAA;IACnF,CAAC;CACF;AAED,mBAAmB;AACnB,MAAM,OAAO,OACX,SAAQ,UAA2B;IAMnC,YAAY,OAAoC;QAC9C,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;QAJrC,aAAQ,GAAa,QAAQ,CAAC,EAAE,CAAA;QAK9C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,YAAY,CAAA;IAClC,CAAC;CACF;AAED,sBAAsB;AACtB,MAAM,OAAO,UACX,SAAQ,aAA8B;IAKtC,YAAY,UAA0C;QACpD,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;QAH9C,aAAQ,GAAa,QAAQ,CAAC,KAAK,CAAA;IAInD,CAAC;CACF"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { Currency, CurrencyAmount, Percent, Price, TradeType } from '@uniswap/sdk-core';
|
|
2
|
+
import { Pair, Route as V2RouteSDK } from '@uniswap/v2-sdk';
|
|
3
|
+
import { Pool as V3Pool, Route as V3RouteSDK } from '@uniswap/v3-sdk';
|
|
4
|
+
import { Pool as V4Pool, Route as V4RouteSDK } from '@uniswap/v4-sdk';
|
|
5
|
+
import { MixedRouteSDK } from './mixedRoute/route';
|
|
6
|
+
import { IRoute } from './route';
|
|
7
|
+
export declare class Trade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType> {
|
|
8
|
+
readonly routes: IRoute<TInput, TOutput, Pair | V3Pool | V4Pool>[];
|
|
9
|
+
readonly tradeType: TTradeType;
|
|
10
|
+
private _outputAmount;
|
|
11
|
+
private _inputAmount;
|
|
12
|
+
private _nativeInputRoutes;
|
|
13
|
+
private _wethInputRoutes;
|
|
14
|
+
/**
|
|
15
|
+
* The swaps of the trade, i.e. which routes and how much is swapped in each that
|
|
16
|
+
* make up the trade. May consist of swaps in v2 or v3.
|
|
17
|
+
*/
|
|
18
|
+
readonly swaps: {
|
|
19
|
+
route: IRoute<TInput, TOutput, Pair | V3Pool | V4Pool>;
|
|
20
|
+
inputAmount: CurrencyAmount<TInput>;
|
|
21
|
+
outputAmount: CurrencyAmount<TOutput>;
|
|
22
|
+
maxHopSlippage?: bigint[];
|
|
23
|
+
}[];
|
|
24
|
+
constructor({ v2Routes, v3Routes, v4Routes, mixedRoutes, tradeType, }: {
|
|
25
|
+
v2Routes?: {
|
|
26
|
+
routev2: V2RouteSDK<TInput, TOutput>;
|
|
27
|
+
inputAmount: CurrencyAmount<TInput>;
|
|
28
|
+
outputAmount: CurrencyAmount<TOutput>;
|
|
29
|
+
maxHopSlippage?: bigint[];
|
|
30
|
+
}[];
|
|
31
|
+
v3Routes?: {
|
|
32
|
+
routev3: V3RouteSDK<TInput, TOutput>;
|
|
33
|
+
inputAmount: CurrencyAmount<TInput>;
|
|
34
|
+
outputAmount: CurrencyAmount<TOutput>;
|
|
35
|
+
maxHopSlippage?: bigint[];
|
|
36
|
+
}[];
|
|
37
|
+
v4Routes?: {
|
|
38
|
+
routev4: V4RouteSDK<TInput, TOutput>;
|
|
39
|
+
inputAmount: CurrencyAmount<TInput>;
|
|
40
|
+
outputAmount: CurrencyAmount<TOutput>;
|
|
41
|
+
maxHopSlippage?: bigint[];
|
|
42
|
+
}[];
|
|
43
|
+
mixedRoutes?: {
|
|
44
|
+
mixedRoute: MixedRouteSDK<TInput, TOutput>;
|
|
45
|
+
inputAmount: CurrencyAmount<TInput>;
|
|
46
|
+
outputAmount: CurrencyAmount<TOutput>;
|
|
47
|
+
maxHopSlippage?: bigint[];
|
|
48
|
+
}[];
|
|
49
|
+
tradeType: TTradeType;
|
|
50
|
+
});
|
|
51
|
+
get inputAmount(): CurrencyAmount<TInput>;
|
|
52
|
+
get outputAmount(): CurrencyAmount<TOutput>;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the sum of all swaps within the trade
|
|
55
|
+
* @returns
|
|
56
|
+
* inputAmount: total input amount
|
|
57
|
+
* inputAmountNative: total amount of native currency required for ETH input paths
|
|
58
|
+
* - 0 if inputAmount is native but no native input paths
|
|
59
|
+
* - undefined if inputAmount is not native
|
|
60
|
+
* outputAmount: total output amount
|
|
61
|
+
* outputAmountNative: total amount of native currency returned from ETH output paths
|
|
62
|
+
* - 0 if outputAmount is native but no native output paths
|
|
63
|
+
* - undefined if outputAmount is not native
|
|
64
|
+
*/
|
|
65
|
+
get amounts(): {
|
|
66
|
+
inputAmount: CurrencyAmount<TInput>;
|
|
67
|
+
inputAmountNative: CurrencyAmount<TInput> | undefined;
|
|
68
|
+
outputAmount: CurrencyAmount<TOutput>;
|
|
69
|
+
outputAmountNative: CurrencyAmount<TOutput> | undefined;
|
|
70
|
+
};
|
|
71
|
+
get numberOfInputWraps(): number;
|
|
72
|
+
get numberOfInputUnwraps(): number;
|
|
73
|
+
get nativeInputRoutes(): IRoute<TInput, TOutput, Pair | V3Pool | V4Pool>[];
|
|
74
|
+
get wethInputRoutes(): IRoute<TInput, TOutput, Pair | V3Pool | V4Pool>[];
|
|
75
|
+
private _executionPrice;
|
|
76
|
+
/**
|
|
77
|
+
* The price expressed in terms of output amount/input amount.
|
|
78
|
+
*/
|
|
79
|
+
get executionPrice(): Price<TInput, TOutput>;
|
|
80
|
+
/**
|
|
81
|
+
* Returns the sell tax of the input token
|
|
82
|
+
*/
|
|
83
|
+
get inputTax(): Percent;
|
|
84
|
+
/**
|
|
85
|
+
* Returns the buy tax of the output token
|
|
86
|
+
*/
|
|
87
|
+
get outputTax(): Percent;
|
|
88
|
+
private isWrappedNative;
|
|
89
|
+
/**
|
|
90
|
+
* The cached result of the price impact computation
|
|
91
|
+
* @private
|
|
92
|
+
*/
|
|
93
|
+
private _priceImpact;
|
|
94
|
+
/**
|
|
95
|
+
* Returns the percent difference between the route's mid price and the expected execution price
|
|
96
|
+
* In order to exclude token taxes from the price impact calculation, the spot price is calculated
|
|
97
|
+
* using a ratio of values that go into the pools, which are the post-tax input amount and pre-tax output amount.
|
|
98
|
+
*/
|
|
99
|
+
get priceImpact(): Percent;
|
|
100
|
+
/**
|
|
101
|
+
* Get the minimum amount that must be received from this trade for the given slippage tolerance
|
|
102
|
+
* @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
|
|
103
|
+
* @returns The amount out
|
|
104
|
+
*/
|
|
105
|
+
minimumAmountOut(slippageTolerance: Percent, amountOut?: CurrencyAmount<TOutput>): CurrencyAmount<TOutput>;
|
|
106
|
+
/**
|
|
107
|
+
* Get the maximum amount in that can be spent via this trade for the given slippage tolerance
|
|
108
|
+
* @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
|
|
109
|
+
* @returns The amount in
|
|
110
|
+
*/
|
|
111
|
+
maximumAmountIn(slippageTolerance: Percent, amountIn?: CurrencyAmount<TInput>): CurrencyAmount<TInput>;
|
|
112
|
+
/**
|
|
113
|
+
* Return the execution price after accounting for slippage tolerance
|
|
114
|
+
* @param slippageTolerance the allowed tolerated slippage
|
|
115
|
+
* @returns The execution price
|
|
116
|
+
*/
|
|
117
|
+
worstExecutionPrice(slippageTolerance: Percent): Price<TInput, TOutput>;
|
|
118
|
+
static fromRoutes<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(v2Routes: {
|
|
119
|
+
routev2: V2RouteSDK<TInput, TOutput>;
|
|
120
|
+
amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>;
|
|
121
|
+
maxHopSlippage?: bigint[];
|
|
122
|
+
}[], v3Routes: {
|
|
123
|
+
routev3: V3RouteSDK<TInput, TOutput>;
|
|
124
|
+
amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>;
|
|
125
|
+
maxHopSlippage?: bigint[];
|
|
126
|
+
}[], tradeType: TTradeType, mixedRoutes?: {
|
|
127
|
+
mixedRoute: MixedRouteSDK<TInput, TOutput>;
|
|
128
|
+
amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>;
|
|
129
|
+
maxHopSlippage?: bigint[];
|
|
130
|
+
}[], v4Routes?: {
|
|
131
|
+
routev4: V4RouteSDK<TInput, TOutput>;
|
|
132
|
+
amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>;
|
|
133
|
+
maxHopSlippage?: bigint[];
|
|
134
|
+
}[]): Promise<Trade<TInput, TOutput, TTradeType>>;
|
|
135
|
+
static fromRoute<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(route: V2RouteSDK<TInput, TOutput> | V3RouteSDK<TInput, TOutput> | V4RouteSDK<TInput, TOutput> | MixedRouteSDK<TInput, TOutput>, amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>, tradeType: TTradeType): Promise<Trade<TInput, TOutput, TTradeType>>;
|
|
136
|
+
}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { CurrencyAmount, Fraction, Percent, Price, TradeType, Ether } from '@uniswap/sdk-core';
|
|
2
|
+
import { Pair, Route as V2RouteSDK, Trade as V2TradeSDK } from '@uniswap/v2-sdk';
|
|
3
|
+
import { Pool as V3Pool, Route as V3RouteSDK, Trade as V3TradeSDK } from '@uniswap/v3-sdk';
|
|
4
|
+
import { Pool as V4Pool, Route as V4RouteSDK, Trade as V4TradeSDK } from '@uniswap/v4-sdk';
|
|
5
|
+
import invariant from 'tiny-invariant';
|
|
6
|
+
import { ONE, ONE_HUNDRED_PERCENT, ZERO, ZERO_PERCENT } from '../constants';
|
|
7
|
+
import { MixedRouteSDK } from './mixedRoute/route';
|
|
8
|
+
import { MixedRouteTrade as MixedRouteTradeSDK } from './mixedRoute/trade';
|
|
9
|
+
import { MixedRoute, RouteV2, RouteV3, RouteV4 } from './route';
|
|
10
|
+
export class Trade {
|
|
11
|
+
// construct a trade across v2 and v3 routes from pre-computed amounts
|
|
12
|
+
constructor({ v2Routes = [], v3Routes = [], v4Routes = [], mixedRoutes = [], tradeType, }) {
|
|
13
|
+
this.swaps = [];
|
|
14
|
+
this.routes = [];
|
|
15
|
+
// wrap v2 routes
|
|
16
|
+
for (const { routev2, inputAmount, outputAmount, maxHopSlippage } of v2Routes) {
|
|
17
|
+
const route = new RouteV2(routev2);
|
|
18
|
+
this.routes.push(route);
|
|
19
|
+
this.swaps.push({
|
|
20
|
+
route,
|
|
21
|
+
inputAmount,
|
|
22
|
+
outputAmount,
|
|
23
|
+
maxHopSlippage,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
// wrap v3 routes
|
|
27
|
+
for (const { routev3, inputAmount, outputAmount, maxHopSlippage } of v3Routes) {
|
|
28
|
+
const route = new RouteV3(routev3);
|
|
29
|
+
this.routes.push(route);
|
|
30
|
+
this.swaps.push({
|
|
31
|
+
route,
|
|
32
|
+
inputAmount,
|
|
33
|
+
outputAmount,
|
|
34
|
+
maxHopSlippage,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
// wrap v4 routes
|
|
38
|
+
for (const { routev4, inputAmount, outputAmount, maxHopSlippage } of v4Routes) {
|
|
39
|
+
const route = new RouteV4(routev4);
|
|
40
|
+
this.routes.push(route);
|
|
41
|
+
this.swaps.push({
|
|
42
|
+
route,
|
|
43
|
+
inputAmount,
|
|
44
|
+
outputAmount,
|
|
45
|
+
maxHopSlippage,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
for (const { mixedRoute, inputAmount, outputAmount, maxHopSlippage } of mixedRoutes) {
|
|
49
|
+
const route = new MixedRoute(mixedRoute);
|
|
50
|
+
this.routes.push(route);
|
|
51
|
+
this.swaps.push({
|
|
52
|
+
route,
|
|
53
|
+
inputAmount,
|
|
54
|
+
outputAmount,
|
|
55
|
+
maxHopSlippage,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (this.swaps.length === 0) {
|
|
59
|
+
throw new Error('No routes provided when calling Trade constructor');
|
|
60
|
+
}
|
|
61
|
+
this.tradeType = tradeType;
|
|
62
|
+
// each route must have the same input and output currency
|
|
63
|
+
const inputCurrency = this.swaps[0].inputAmount.currency;
|
|
64
|
+
const outputCurrency = this.swaps[0].outputAmount.currency;
|
|
65
|
+
invariant(this.swaps.every(({ route }) => inputCurrency.wrapped.equals(route.input.wrapped)), 'INPUT_CURRENCY_MATCH');
|
|
66
|
+
invariant(this.swaps.every(({ route }) => outputCurrency.wrapped.equals(route.output.wrapped)), 'OUTPUT_CURRENCY_MATCH');
|
|
67
|
+
// pools must be unique inter protocols
|
|
68
|
+
const numPools = this.swaps.map(({ route }) => route.pools.length).reduce((total, cur) => total + cur, 0);
|
|
69
|
+
const poolIdentifierSet = new Set();
|
|
70
|
+
for (const { route } of this.swaps) {
|
|
71
|
+
for (const pool of route.pools) {
|
|
72
|
+
if (pool instanceof V4Pool) {
|
|
73
|
+
poolIdentifierSet.add(pool.poolId);
|
|
74
|
+
}
|
|
75
|
+
else if (pool instanceof V3Pool) {
|
|
76
|
+
poolIdentifierSet.add(V3Pool.getAddress(pool.token0, pool.token1, pool.fee));
|
|
77
|
+
}
|
|
78
|
+
else if (pool instanceof Pair) {
|
|
79
|
+
const pair = pool;
|
|
80
|
+
poolIdentifierSet.add(Pair.getAddress(pair.token0, pair.token1));
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
throw new Error('Unexpected pool type in route when constructing trade object');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
invariant(numPools === poolIdentifierSet.size, 'POOLS_DUPLICATED');
|
|
88
|
+
}
|
|
89
|
+
get inputAmount() {
|
|
90
|
+
if (this._inputAmount) {
|
|
91
|
+
return this._inputAmount;
|
|
92
|
+
}
|
|
93
|
+
const inputAmountCurrency = this.swaps[0].inputAmount.currency;
|
|
94
|
+
const totalInputFromRoutes = this.swaps
|
|
95
|
+
.map(({ inputAmount: routeInputAmount }) => routeInputAmount)
|
|
96
|
+
.reduce((total, cur) => total.add(cur), CurrencyAmount.fromRawAmount(inputAmountCurrency, 0));
|
|
97
|
+
this._inputAmount = totalInputFromRoutes;
|
|
98
|
+
return this._inputAmount;
|
|
99
|
+
}
|
|
100
|
+
get outputAmount() {
|
|
101
|
+
if (this._outputAmount) {
|
|
102
|
+
return this._outputAmount;
|
|
103
|
+
}
|
|
104
|
+
const outputCurrency = this.swaps[0].outputAmount.currency;
|
|
105
|
+
const totalOutputFromRoutes = this.swaps
|
|
106
|
+
.map(({ outputAmount: routeOutputAmount }) => routeOutputAmount)
|
|
107
|
+
.reduce((total, cur) => total.add(cur), CurrencyAmount.fromRawAmount(outputCurrency, 0));
|
|
108
|
+
this._outputAmount = totalOutputFromRoutes;
|
|
109
|
+
return this._outputAmount;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Returns the sum of all swaps within the trade
|
|
113
|
+
* @returns
|
|
114
|
+
* inputAmount: total input amount
|
|
115
|
+
* inputAmountNative: total amount of native currency required for ETH input paths
|
|
116
|
+
* - 0 if inputAmount is native but no native input paths
|
|
117
|
+
* - undefined if inputAmount is not native
|
|
118
|
+
* outputAmount: total output amount
|
|
119
|
+
* outputAmountNative: total amount of native currency returned from ETH output paths
|
|
120
|
+
* - 0 if outputAmount is native but no native output paths
|
|
121
|
+
* - undefined if outputAmount is not native
|
|
122
|
+
*/
|
|
123
|
+
get amounts() {
|
|
124
|
+
var _a, _b;
|
|
125
|
+
// Find native currencies for reduce below
|
|
126
|
+
const inputNativeCurrency = (_a = this.swaps.find(({ inputAmount }) => inputAmount.currency.isNative)) === null || _a === void 0 ? void 0 : _a.inputAmount.currency;
|
|
127
|
+
const outputNativeCurrency = (_b = this.swaps.find(({ outputAmount }) => outputAmount.currency.isNative)) === null || _b === void 0 ? void 0 : _b.outputAmount.currency;
|
|
128
|
+
return {
|
|
129
|
+
inputAmount: this.inputAmount,
|
|
130
|
+
inputAmountNative: inputNativeCurrency
|
|
131
|
+
? this.swaps.reduce((total, swap) => {
|
|
132
|
+
return swap.route.pathInput.isNative ? total.add(swap.inputAmount) : total;
|
|
133
|
+
}, CurrencyAmount.fromRawAmount(inputNativeCurrency, 0))
|
|
134
|
+
: undefined,
|
|
135
|
+
outputAmount: this.outputAmount,
|
|
136
|
+
outputAmountNative: outputNativeCurrency
|
|
137
|
+
? this.swaps.reduce((total, swap) => {
|
|
138
|
+
return swap.route.pathOutput.isNative ? total.add(swap.outputAmount) : total;
|
|
139
|
+
}, CurrencyAmount.fromRawAmount(outputNativeCurrency, 0))
|
|
140
|
+
: undefined,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
get numberOfInputWraps() {
|
|
144
|
+
// if the trade's input is eth it may require a wrap
|
|
145
|
+
if (this.inputAmount.currency.isNative) {
|
|
146
|
+
return this.wethInputRoutes.length;
|
|
147
|
+
}
|
|
148
|
+
else
|
|
149
|
+
return 0;
|
|
150
|
+
}
|
|
151
|
+
get numberOfInputUnwraps() {
|
|
152
|
+
// if the trade's input is weth, it may require an unwrap
|
|
153
|
+
if (this.isWrappedNative(this.inputAmount.currency)) {
|
|
154
|
+
return this.nativeInputRoutes.length;
|
|
155
|
+
}
|
|
156
|
+
else
|
|
157
|
+
return 0;
|
|
158
|
+
}
|
|
159
|
+
get nativeInputRoutes() {
|
|
160
|
+
if (this._nativeInputRoutes) {
|
|
161
|
+
return this._nativeInputRoutes;
|
|
162
|
+
}
|
|
163
|
+
this._nativeInputRoutes = this.routes.filter((route) => route.pathInput.isNative);
|
|
164
|
+
return this._nativeInputRoutes;
|
|
165
|
+
}
|
|
166
|
+
get wethInputRoutes() {
|
|
167
|
+
if (this._wethInputRoutes) {
|
|
168
|
+
return this._wethInputRoutes;
|
|
169
|
+
}
|
|
170
|
+
this._wethInputRoutes = this.routes.filter((route) => this.isWrappedNative(route.pathInput));
|
|
171
|
+
return this._wethInputRoutes;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* The price expressed in terms of output amount/input amount.
|
|
175
|
+
*/
|
|
176
|
+
get executionPrice() {
|
|
177
|
+
var _a;
|
|
178
|
+
return ((_a = this._executionPrice) !== null && _a !== void 0 ? _a : (this._executionPrice = new Price(this.inputAmount.currency, this.outputAmount.currency, this.inputAmount.quotient, this.outputAmount.quotient)));
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Returns the sell tax of the input token
|
|
182
|
+
*/
|
|
183
|
+
get inputTax() {
|
|
184
|
+
const inputCurrency = this.inputAmount.currency;
|
|
185
|
+
if (inputCurrency.isNative || !inputCurrency.wrapped.sellFeeBps)
|
|
186
|
+
return ZERO_PERCENT;
|
|
187
|
+
return new Percent(inputCurrency.wrapped.sellFeeBps.toNumber(), 10000);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Returns the buy tax of the output token
|
|
191
|
+
*/
|
|
192
|
+
get outputTax() {
|
|
193
|
+
const outputCurrency = this.outputAmount.currency;
|
|
194
|
+
if (outputCurrency.isNative || !outputCurrency.wrapped.buyFeeBps)
|
|
195
|
+
return ZERO_PERCENT;
|
|
196
|
+
return new Percent(outputCurrency.wrapped.buyFeeBps.toNumber(), 10000);
|
|
197
|
+
}
|
|
198
|
+
isWrappedNative(currency) {
|
|
199
|
+
const chainId = currency.chainId;
|
|
200
|
+
return currency.equals(Ether.onChain(chainId).wrapped);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Returns the percent difference between the route's mid price and the expected execution price
|
|
204
|
+
* In order to exclude token taxes from the price impact calculation, the spot price is calculated
|
|
205
|
+
* using a ratio of values that go into the pools, which are the post-tax input amount and pre-tax output amount.
|
|
206
|
+
*/
|
|
207
|
+
get priceImpact() {
|
|
208
|
+
if (this._priceImpact) {
|
|
209
|
+
return this._priceImpact;
|
|
210
|
+
}
|
|
211
|
+
// returns 0% price impact even though this may be inaccurate as a swap may have occured.
|
|
212
|
+
// because we're unable to derive the pre-buy-tax amount, use 0% as a placeholder.
|
|
213
|
+
if (this.outputTax.equalTo(ONE_HUNDRED_PERCENT))
|
|
214
|
+
return ZERO_PERCENT;
|
|
215
|
+
let spotOutputAmount = CurrencyAmount.fromRawAmount(this.outputAmount.currency, 0);
|
|
216
|
+
for (const { route, inputAmount } of this.swaps) {
|
|
217
|
+
const midPrice = route.midPrice;
|
|
218
|
+
const postTaxInputAmount = inputAmount.multiply(new Fraction(ONE).subtract(this.inputTax));
|
|
219
|
+
spotOutputAmount = spotOutputAmount.add(midPrice.quote(postTaxInputAmount));
|
|
220
|
+
}
|
|
221
|
+
// if the total output of this trade is 0, then most likely the post-tax input was also 0, and therefore this swap
|
|
222
|
+
// does not move the pools' market price
|
|
223
|
+
if (spotOutputAmount.equalTo(ZERO))
|
|
224
|
+
return ZERO_PERCENT;
|
|
225
|
+
const preTaxOutputAmount = this.outputAmount.divide(new Fraction(ONE).subtract(this.outputTax));
|
|
226
|
+
const priceImpact = spotOutputAmount.subtract(preTaxOutputAmount).divide(spotOutputAmount);
|
|
227
|
+
this._priceImpact = new Percent(priceImpact.numerator, priceImpact.denominator);
|
|
228
|
+
return this._priceImpact;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Get the minimum amount that must be received from this trade for the given slippage tolerance
|
|
232
|
+
* @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
|
|
233
|
+
* @returns The amount out
|
|
234
|
+
*/
|
|
235
|
+
minimumAmountOut(slippageTolerance, amountOut = this.outputAmount) {
|
|
236
|
+
invariant(!slippageTolerance.lessThan(ZERO), 'SLIPPAGE_TOLERANCE');
|
|
237
|
+
if (this.tradeType === TradeType.EXACT_OUTPUT) {
|
|
238
|
+
return amountOut;
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
const slippageAdjustedAmountOut = new Fraction(ONE)
|
|
242
|
+
.add(slippageTolerance)
|
|
243
|
+
.invert()
|
|
244
|
+
.multiply(amountOut.quotient).quotient;
|
|
245
|
+
return CurrencyAmount.fromRawAmount(amountOut.currency, slippageAdjustedAmountOut);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Get the maximum amount in that can be spent via this trade for the given slippage tolerance
|
|
250
|
+
* @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
|
|
251
|
+
* @returns The amount in
|
|
252
|
+
*/
|
|
253
|
+
maximumAmountIn(slippageTolerance, amountIn = this.inputAmount) {
|
|
254
|
+
invariant(!slippageTolerance.lessThan(ZERO), 'SLIPPAGE_TOLERANCE');
|
|
255
|
+
if (this.tradeType === TradeType.EXACT_INPUT) {
|
|
256
|
+
return amountIn;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
const slippageAdjustedAmountIn = new Fraction(ONE).add(slippageTolerance).multiply(amountIn.quotient).quotient;
|
|
260
|
+
return CurrencyAmount.fromRawAmount(amountIn.currency, slippageAdjustedAmountIn);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Return the execution price after accounting for slippage tolerance
|
|
265
|
+
* @param slippageTolerance the allowed tolerated slippage
|
|
266
|
+
* @returns The execution price
|
|
267
|
+
*/
|
|
268
|
+
worstExecutionPrice(slippageTolerance) {
|
|
269
|
+
return new Price(this.inputAmount.currency, this.outputAmount.currency, this.maximumAmountIn(slippageTolerance).quotient, this.minimumAmountOut(slippageTolerance).quotient);
|
|
270
|
+
}
|
|
271
|
+
static async fromRoutes(v2Routes, v3Routes, tradeType, mixedRoutes, v4Routes) {
|
|
272
|
+
const populatedV2Routes = [];
|
|
273
|
+
const populatedV3Routes = [];
|
|
274
|
+
const populatedV4Routes = [];
|
|
275
|
+
const populatedMixedRoutes = [];
|
|
276
|
+
for (const { routev2, amount, maxHopSlippage } of v2Routes) {
|
|
277
|
+
const v2Trade = new V2TradeSDK(routev2, amount, tradeType);
|
|
278
|
+
const { inputAmount, outputAmount } = v2Trade;
|
|
279
|
+
populatedV2Routes.push({
|
|
280
|
+
routev2,
|
|
281
|
+
inputAmount,
|
|
282
|
+
outputAmount,
|
|
283
|
+
maxHopSlippage,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
for (const { routev3, amount, maxHopSlippage } of v3Routes) {
|
|
287
|
+
const v3Trade = await V3TradeSDK.fromRoute(routev3, amount, tradeType);
|
|
288
|
+
const { inputAmount, outputAmount } = v3Trade;
|
|
289
|
+
populatedV3Routes.push({
|
|
290
|
+
routev3,
|
|
291
|
+
inputAmount,
|
|
292
|
+
outputAmount,
|
|
293
|
+
maxHopSlippage,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
if (v4Routes) {
|
|
297
|
+
for (const { routev4, amount, maxHopSlippage } of v4Routes) {
|
|
298
|
+
const v4Trade = await V4TradeSDK.fromRoute(routev4, amount, tradeType);
|
|
299
|
+
const { inputAmount, outputAmount } = v4Trade;
|
|
300
|
+
populatedV4Routes.push({
|
|
301
|
+
routev4,
|
|
302
|
+
inputAmount,
|
|
303
|
+
outputAmount,
|
|
304
|
+
maxHopSlippage,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (mixedRoutes) {
|
|
309
|
+
for (const { mixedRoute, amount, maxHopSlippage } of mixedRoutes) {
|
|
310
|
+
const mixedRouteTrade = await MixedRouteTradeSDK.fromRoute(mixedRoute, amount, tradeType);
|
|
311
|
+
const { inputAmount, outputAmount } = mixedRouteTrade;
|
|
312
|
+
populatedMixedRoutes.push({
|
|
313
|
+
mixedRoute,
|
|
314
|
+
inputAmount,
|
|
315
|
+
outputAmount,
|
|
316
|
+
maxHopSlippage,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return new Trade({
|
|
321
|
+
v2Routes: populatedV2Routes,
|
|
322
|
+
v3Routes: populatedV3Routes,
|
|
323
|
+
v4Routes: populatedV4Routes,
|
|
324
|
+
mixedRoutes: populatedMixedRoutes,
|
|
325
|
+
tradeType,
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
static async fromRoute(route, amount, tradeType) {
|
|
329
|
+
let v2Routes = [];
|
|
330
|
+
let v3Routes = [];
|
|
331
|
+
let v4Routes = [];
|
|
332
|
+
let mixedRoutes = [];
|
|
333
|
+
if (route instanceof V2RouteSDK) {
|
|
334
|
+
const v2Trade = new V2TradeSDK(route, amount, tradeType);
|
|
335
|
+
const { inputAmount, outputAmount } = v2Trade;
|
|
336
|
+
v2Routes = [{ routev2: route, inputAmount, outputAmount }];
|
|
337
|
+
}
|
|
338
|
+
else if (route instanceof V3RouteSDK) {
|
|
339
|
+
const v3Trade = await V3TradeSDK.fromRoute(route, amount, tradeType);
|
|
340
|
+
const { inputAmount, outputAmount } = v3Trade;
|
|
341
|
+
v3Routes = [{ routev3: route, inputAmount, outputAmount }];
|
|
342
|
+
}
|
|
343
|
+
else if (route instanceof V4RouteSDK) {
|
|
344
|
+
const v4Trade = await V4TradeSDK.fromRoute(route, amount, tradeType);
|
|
345
|
+
const { inputAmount, outputAmount } = v4Trade;
|
|
346
|
+
v4Routes = [{ routev4: route, inputAmount, outputAmount }];
|
|
347
|
+
}
|
|
348
|
+
else if (route instanceof MixedRouteSDK) {
|
|
349
|
+
const mixedRouteTrade = await MixedRouteTradeSDK.fromRoute(route, amount, tradeType);
|
|
350
|
+
const { inputAmount, outputAmount } = mixedRouteTrade;
|
|
351
|
+
mixedRoutes = [{ mixedRoute: route, inputAmount, outputAmount }];
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
throw new Error('Invalid route type');
|
|
355
|
+
}
|
|
356
|
+
return new Trade({
|
|
357
|
+
v2Routes,
|
|
358
|
+
v3Routes,
|
|
359
|
+
v4Routes,
|
|
360
|
+
mixedRoutes,
|
|
361
|
+
tradeType,
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
//# sourceMappingURL=trade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trade.js","sourceRoot":"","sources":["../../../../src/entities/trade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACxG,OAAO,EAAE,IAAI,EAAE,KAAK,IAAI,UAAU,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAChF,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,KAAK,IAAI,UAAU,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC1F,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,KAAK,IAAI,UAAU,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC1F,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,GAAG,EAAE,mBAAmB,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,eAAe,IAAI,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAC1E,OAAO,EAAU,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEvE,MAAM,OAAO,KAAK;IAmBhB,uEAAuE;IACvE,YAAmB,EACjB,QAAQ,GAAG,EAAE,EACb,QAAQ,GAAG,EAAE,EACb,QAAQ,GAAG,EAAE,EACb,W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CAAA;YACrD,WAAW,GAAG,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,CAAA;SACjE;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;SACtC;QAED,OAAO,IAAI,KAAK,CAAC;YACf,QAAQ;YACR,QAAQ;YACR,QAAQ;YACR,WAAW;YACX,SAAS;SACV,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './approveAndCall';
|
|
3
|
+
export * from './multicallExtended';
|
|
4
|
+
export * from './paymentsExtended';
|
|
5
|
+
export * from './swapRouter';
|
|
6
|
+
export * from './entities/trade';
|
|
7
|
+
export * from './entities/protocol';
|
|
8
|
+
export * from './entities/route';
|
|
9
|
+
export * from './entities/mixedRoute/route';
|
|
10
|
+
export * from './entities/mixedRoute/trade';
|
|
11
|
+
export * from './utils/encodeMixedRouteToPath';
|
|
12
|
+
export * from './utils/TPool';
|
|
13
|
+
export * from './utils/pathCurrency';
|
|
14
|
+
export * from './utils';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './approveAndCall';
|
|
3
|
+
export * from './multicallExtended';
|
|
4
|
+
export * from './paymentsExtended';
|
|
5
|
+
export * from './swapRouter';
|
|
6
|
+
export * from './entities/trade';
|
|
7
|
+
export * from './entities/protocol';
|
|
8
|
+
export * from './entities/route';
|
|
9
|
+
export * from './entities/mixedRoute/route';
|
|
10
|
+
export * from './entities/mixedRoute/trade';
|
|
11
|
+
export * from './utils/encodeMixedRouteToPath';
|
|
12
|
+
export * from './utils/TPool';
|
|
13
|
+
export * from './utils/pathCurrency';
|
|
14
|
+
export * from './utils';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { BigintIsh } from '@uniswap/sdk-core';
|
|
3
|
+
export type Validation = BigintIsh | string;
|
|
4
|
+
export declare abstract class MulticallExtended {
|
|
5
|
+
static INTERFACE: Interface;
|
|
6
|
+
/**
|
|
7
|
+
* Cannot be constructed.
|
|
8
|
+
*/
|
|
9
|
+
private constructor();
|
|
10
|
+
static encodeMulticall(calldatas: string | string[], validation?: Validation): string;
|
|
11
|
+
}
|