@uniswap/router-sdk 1.9.3 → 1.11.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 +1 -0
- package/dist/entities/mixedRoute/route.d.ts +6 -4
- package/dist/entities/mixedRoute/trade.d.ts +5 -2
- package/dist/entities/protocol.d.ts +1 -0
- package/dist/entities/route.d.ts +11 -5
- package/dist/entities/trade.d.ts +17 -8
- package/dist/router-sdk.cjs.development.js +343 -184
- 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 +353 -196
- package/dist/router-sdk.esm.js.map +1 -1
- package/dist/utils/getOutputAmount.d.ts +7 -0
- package/dist/utils/index.d.ts +7 -4
- package/package.json +5 -3
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Percent } from '@uniswap/sdk-core';
|
|
2
2
|
import JSBI from 'jsbi';
|
|
3
|
+
export declare const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000";
|
|
3
4
|
export declare const MSG_SENDER = "0x0000000000000000000000000000000000000001";
|
|
4
5
|
export declare const ADDRESS_THIS = "0x0000000000000000000000000000000000000002";
|
|
5
6
|
export declare const ZERO: JSBI;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Currency, Price
|
|
2
|
-
import { Pool } from '@uniswap/v3-sdk';
|
|
1
|
+
import { Currency, Price } from '@uniswap/sdk-core';
|
|
3
2
|
import { Pair } from '@uniswap/v2-sdk';
|
|
4
|
-
|
|
3
|
+
import { Pool as V3Pool } from '@uniswap/v3-sdk';
|
|
4
|
+
import { Pool as V4Pool } from '@uniswap/v4-sdk';
|
|
5
|
+
declare type TPool = Pair | V3Pool | V4Pool;
|
|
5
6
|
/**
|
|
6
7
|
* Represents a list of pools or pairs through which a swap can occur
|
|
7
8
|
* @template TInput The input token
|
|
@@ -9,9 +10,10 @@ declare type TPool = Pair | Pool;
|
|
|
9
10
|
*/
|
|
10
11
|
export declare class MixedRouteSDK<TInput extends Currency, TOutput extends Currency> {
|
|
11
12
|
readonly pools: TPool[];
|
|
12
|
-
readonly path:
|
|
13
|
+
readonly path: Currency[];
|
|
13
14
|
readonly input: TInput;
|
|
14
15
|
readonly output: TOutput;
|
|
16
|
+
readonly adjustedInput: Currency;
|
|
15
17
|
private _midPrice;
|
|
16
18
|
/**
|
|
17
19
|
* Creates an instance of route.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Currency, Percent, Price, CurrencyAmount, TradeType } from '@uniswap/sdk-core';
|
|
2
2
|
import { Pair } from '@uniswap/v2-sdk';
|
|
3
|
-
import { BestTradeOptions, Pool } from '@uniswap/v3-sdk';
|
|
3
|
+
import { BestTradeOptions, Pool as V3Pool } from '@uniswap/v3-sdk';
|
|
4
|
+
import { Pool as V4Pool } from '@uniswap/v4-sdk';
|
|
4
5
|
import { MixedRouteSDK } from './route';
|
|
6
|
+
declare type TPool = Pair | V3Pool | V4Pool;
|
|
5
7
|
/**
|
|
6
8
|
* Trades comparator, an extension of the input output comparator that also considers other dimensions of the trade in ranking them
|
|
7
9
|
* @template TInput The input token, either Ether or an ERC-20
|
|
@@ -179,5 +181,6 @@ export declare class MixedRouteTrade<TInput extends Currency, TOutput extends Cu
|
|
|
179
181
|
* @param bestTrades used in recursion; the current list of best trades
|
|
180
182
|
* @returns The exact in trade
|
|
181
183
|
*/
|
|
182
|
-
static bestTradeExactIn<TInput extends Currency, TOutput extends Currency>(pools:
|
|
184
|
+
static bestTradeExactIn<TInput extends Currency, TOutput extends Currency>(pools: TPool[], currencyAmountIn: CurrencyAmount<TInput>, currencyOut: TOutput, { maxNumResults, maxHops }?: BestTradeOptions, currentPools?: TPool[], nextAmountIn?: CurrencyAmount<Currency>, bestTrades?: MixedRouteTrade<TInput, TOutput, TradeType.EXACT_INPUT>[]): Promise<MixedRouteTrade<TInput, TOutput, TradeType.EXACT_INPUT>[]>;
|
|
183
185
|
}
|
|
186
|
+
export {};
|
package/dist/entities/route.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Route as V2RouteSDK, Pair } from '@uniswap/v2-sdk';
|
|
2
|
-
import { Route as V3RouteSDK, Pool } from '@uniswap/v3-sdk';
|
|
2
|
+
import { Route as V3RouteSDK, Pool as V3Pool } from '@uniswap/v3-sdk';
|
|
3
|
+
import { Route as V4RouteSDK, Pool as V4Pool } from '@uniswap/v4-sdk';
|
|
3
4
|
import { Protocol } from './protocol';
|
|
4
5
|
import { Currency, Price, Token } from '@uniswap/sdk-core';
|
|
5
6
|
import { MixedRouteSDK } from './mixedRoute/route';
|
|
6
|
-
export interface IRoute<TInput extends Currency, TOutput extends Currency, TPool extends
|
|
7
|
+
export interface IRoute<TInput extends Currency, TOutput extends Currency, TPool extends Pair | V3Pool | V4Pool> {
|
|
7
8
|
protocol: Protocol;
|
|
8
9
|
pools: TPool[];
|
|
9
|
-
path:
|
|
10
|
+
path: Currency[];
|
|
10
11
|
midPrice: Price<TInput, TOutput>;
|
|
11
12
|
input: TInput;
|
|
12
13
|
output: TOutput;
|
|
@@ -16,12 +17,17 @@ export declare class RouteV2<TInput extends Currency, TOutput extends Currency>
|
|
|
16
17
|
readonly pools: Pair[];
|
|
17
18
|
constructor(v2Route: V2RouteSDK<TInput, TOutput>);
|
|
18
19
|
}
|
|
19
|
-
export declare class RouteV3<TInput extends Currency, TOutput extends Currency> extends V3RouteSDK<TInput, TOutput> implements IRoute<TInput, TOutput,
|
|
20
|
+
export declare class RouteV3<TInput extends Currency, TOutput extends Currency> extends V3RouteSDK<TInput, TOutput> implements IRoute<TInput, TOutput, V3Pool> {
|
|
20
21
|
readonly protocol: Protocol;
|
|
21
22
|
readonly path: Token[];
|
|
22
23
|
constructor(v3Route: V3RouteSDK<TInput, TOutput>);
|
|
23
24
|
}
|
|
24
|
-
export declare class
|
|
25
|
+
export declare class RouteV4<TInput extends Currency, TOutput extends Currency> extends V4RouteSDK<TInput, TOutput> implements IRoute<TInput, TOutput, V4Pool> {
|
|
26
|
+
readonly protocol: Protocol;
|
|
27
|
+
readonly path: Currency[];
|
|
28
|
+
constructor(v4Route: V4RouteSDK<TInput, TOutput>);
|
|
29
|
+
}
|
|
30
|
+
export declare class MixedRoute<TInput extends Currency, TOutput extends Currency> extends MixedRouteSDK<TInput, TOutput> implements IRoute<TInput, TOutput, Pair | V3Pool | V4Pool> {
|
|
25
31
|
readonly protocol: Protocol;
|
|
26
32
|
constructor(mixedRoute: MixedRouteSDK<TInput, TOutput>);
|
|
27
33
|
}
|
package/dist/entities/trade.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Currency, CurrencyAmount, Percent, Price, TradeType } from '@uniswap/sdk-core';
|
|
2
2
|
import { Pair, Route as V2RouteSDK } from '@uniswap/v2-sdk';
|
|
3
|
-
import { Pool, Route as V3RouteSDK } from '@uniswap/v3-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';
|
|
4
5
|
import { MixedRouteSDK } from './mixedRoute/route';
|
|
5
6
|
import { IRoute } from './route';
|
|
6
7
|
export declare class Trade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType> {
|
|
7
|
-
readonly routes: IRoute<TInput, TOutput, Pair |
|
|
8
|
+
readonly routes: IRoute<TInput, TOutput, Pair | V3Pool | V4Pool>[];
|
|
8
9
|
readonly tradeType: TTradeType;
|
|
9
10
|
private _outputAmount;
|
|
10
11
|
private _inputAmount;
|
|
@@ -13,27 +14,32 @@ export declare class Trade<TInput extends Currency, TOutput extends Currency, TT
|
|
|
13
14
|
* make up the trade. May consist of swaps in v2 or v3.
|
|
14
15
|
*/
|
|
15
16
|
readonly swaps: {
|
|
16
|
-
route: IRoute<TInput, TOutput, Pair |
|
|
17
|
+
route: IRoute<TInput, TOutput, Pair | V3Pool | V4Pool>;
|
|
17
18
|
inputAmount: CurrencyAmount<TInput>;
|
|
18
19
|
outputAmount: CurrencyAmount<TOutput>;
|
|
19
20
|
}[];
|
|
20
|
-
constructor({ v2Routes, v3Routes,
|
|
21
|
-
v2Routes
|
|
21
|
+
constructor({ v2Routes, v3Routes, v4Routes, mixedRoutes, tradeType, }: {
|
|
22
|
+
v2Routes?: {
|
|
22
23
|
routev2: V2RouteSDK<TInput, TOutput>;
|
|
23
24
|
inputAmount: CurrencyAmount<TInput>;
|
|
24
25
|
outputAmount: CurrencyAmount<TOutput>;
|
|
25
26
|
}[];
|
|
26
|
-
v3Routes
|
|
27
|
+
v3Routes?: {
|
|
27
28
|
routev3: V3RouteSDK<TInput, TOutput>;
|
|
28
29
|
inputAmount: CurrencyAmount<TInput>;
|
|
29
30
|
outputAmount: CurrencyAmount<TOutput>;
|
|
30
31
|
}[];
|
|
31
|
-
|
|
32
|
+
v4Routes?: {
|
|
33
|
+
routev4: V4RouteSDK<TInput, TOutput>;
|
|
34
|
+
inputAmount: CurrencyAmount<TInput>;
|
|
35
|
+
outputAmount: CurrencyAmount<TOutput>;
|
|
36
|
+
}[];
|
|
32
37
|
mixedRoutes?: {
|
|
33
38
|
mixedRoute: MixedRouteSDK<TInput, TOutput>;
|
|
34
39
|
inputAmount: CurrencyAmount<TInput>;
|
|
35
40
|
outputAmount: CurrencyAmount<TOutput>;
|
|
36
41
|
}[];
|
|
42
|
+
tradeType: TTradeType;
|
|
37
43
|
});
|
|
38
44
|
get inputAmount(): CurrencyAmount<TInput>;
|
|
39
45
|
get outputAmount(): CurrencyAmount<TOutput>;
|
|
@@ -88,6 +94,9 @@ export declare class Trade<TInput extends Currency, TOutput extends Currency, TT
|
|
|
88
94
|
}[], tradeType: TTradeType, mixedRoutes?: {
|
|
89
95
|
mixedRoute: MixedRouteSDK<TInput, TOutput>;
|
|
90
96
|
amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>;
|
|
97
|
+
}[], v4Routes?: {
|
|
98
|
+
routev4: V4RouteSDK<TInput, TOutput>;
|
|
99
|
+
amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>;
|
|
91
100
|
}[]): Promise<Trade<TInput, TOutput, TTradeType>>;
|
|
92
|
-
static fromRoute<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(route: V2RouteSDK<TInput, TOutput> | V3RouteSDK<TInput, TOutput> | MixedRouteSDK<TInput, TOutput>, amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>, tradeType: TTradeType): Promise<Trade<TInput, TOutput, TTradeType>>;
|
|
101
|
+
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>>;
|
|
93
102
|
}
|