@uniswap/router-sdk 1.2.0 → 1.3.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 +29 -0
- package/dist/entities/mixedRoute/trade.d.ts +183 -0
- package/dist/entities/protocol.d.ts +2 -1
- package/dist/entities/route.d.ts +5 -0
- package/dist/entities/trade.d.ts +12 -3
- package/dist/index.d.ts +3 -0
- package/dist/router-sdk.cjs.development.js +1120 -85
- 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 +1118 -89
- package/dist/router-sdk.esm.js.map +1 -1
- package/dist/swapRouter.d.ts +31 -4
- package/dist/utils/encodeMixedRouteToPath.d.ts +9 -0
- package/dist/utils/index.d.ts +17 -0
- package/package.json +1 -1
package/dist/swapRouter.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { FeeOptions, MethodParameters, PermitOptions, Position, Trade as V3Trade
|
|
|
5
5
|
import { ApprovalTypes, CondensedAddLiquidityOptions } from './approveAndCall';
|
|
6
6
|
import { Trade } from './entities/trade';
|
|
7
7
|
import { Validation } from './multicallExtended';
|
|
8
|
+
import { MixedRouteTrade } from './entities/mixedRoute/trade';
|
|
8
9
|
/**
|
|
9
10
|
* Options for producing the arguments to send calls to the router.
|
|
10
11
|
*/
|
|
@@ -36,7 +37,7 @@ export interface SwapAndAddOptions extends SwapOptions {
|
|
|
36
37
|
*/
|
|
37
38
|
outputTokenPermit?: PermitOptions;
|
|
38
39
|
}
|
|
39
|
-
declare type AnyTradeType = Trade<Currency, Currency, TradeType> | V2Trade<Currency, Currency, TradeType> | V3Trade<Currency, Currency, TradeType> | (V2Trade<Currency, Currency, TradeType> | V3Trade<Currency, Currency, TradeType>)[];
|
|
40
|
+
declare type AnyTradeType = Trade<Currency, Currency, TradeType> | V2Trade<Currency, Currency, TradeType> | V3Trade<Currency, Currency, TradeType> | MixedRouteTrade<Currency, Currency, TradeType> | (V2Trade<Currency, Currency, TradeType> | V3Trade<Currency, Currency, TradeType> | MixedRouteTrade<Currency, Currency, TradeType>)[];
|
|
40
41
|
/**
|
|
41
42
|
* Represents the Uniswap V2 + V3 SwapRouter02, and has static methods for helping execute trades.
|
|
42
43
|
*/
|
|
@@ -46,18 +47,44 @@ export declare abstract class SwapRouter {
|
|
|
46
47
|
* Cannot be constructed.
|
|
47
48
|
*/
|
|
48
49
|
private constructor();
|
|
50
|
+
/**
|
|
51
|
+
* @notice Generates the calldata for a Swap with a V2 Route.
|
|
52
|
+
* @param trade The V2Trade to encode.
|
|
53
|
+
* @param options SwapOptions to use for the trade.
|
|
54
|
+
* @param routerMustCustody Flag for whether funds should be sent to the router
|
|
55
|
+
* @param performAggregatedSlippageCheck Flag for whether we want to perform an aggregated slippage check
|
|
56
|
+
* @returns A string array of calldatas for the trade.
|
|
57
|
+
*/
|
|
49
58
|
private static encodeV2Swap;
|
|
59
|
+
/**
|
|
60
|
+
* @notice Generates the calldata for a Swap with a V3 Route.
|
|
61
|
+
* @param trade The V3Trade to encode.
|
|
62
|
+
* @param options SwapOptions to use for the trade.
|
|
63
|
+
* @param routerMustCustody Flag for whether funds should be sent to the router
|
|
64
|
+
* @param performAggregatedSlippageCheck Flag for whether we want to perform an aggregated slippage check
|
|
65
|
+
* @returns A string array of calldatas for the trade.
|
|
66
|
+
*/
|
|
50
67
|
private static encodeV3Swap;
|
|
68
|
+
/**
|
|
69
|
+
* @notice Generates the calldata for a MixedRouteSwap. Since single hop routes are not MixedRoutes, we will instead generate
|
|
70
|
+
* them via the existing encodeV3Swap and encodeV2Swap methods.
|
|
71
|
+
* @param trade The MixedRouteTrade to encode.
|
|
72
|
+
* @param options SwapOptions to use for the trade.
|
|
73
|
+
* @param routerMustCustody Flag for whether funds should be sent to the router
|
|
74
|
+
* @param performAggregatedSlippageCheck Flag for whether we want to perform an aggregated slippage check
|
|
75
|
+
* @returns A string array of calldatas for the trade.
|
|
76
|
+
*/
|
|
77
|
+
private static encodeMixedRouteSwap;
|
|
51
78
|
private static encodeSwaps;
|
|
52
79
|
/**
|
|
53
80
|
* Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade.
|
|
54
|
-
* @param
|
|
81
|
+
* @param trades to produce call parameters for
|
|
55
82
|
* @param options options for the call parameters
|
|
56
83
|
*/
|
|
57
|
-
static swapCallParameters(trades: Trade<Currency, Currency, TradeType> | V2Trade<Currency, Currency, TradeType> | V3Trade<Currency, Currency, TradeType> | (V2Trade<Currency, Currency, TradeType> | V3Trade<Currency, Currency, TradeType>)[], options: SwapOptions): MethodParameters;
|
|
84
|
+
static swapCallParameters(trades: Trade<Currency, Currency, TradeType> | V2Trade<Currency, Currency, TradeType> | V3Trade<Currency, Currency, TradeType> | MixedRouteTrade<Currency, Currency, TradeType> | (V2Trade<Currency, Currency, TradeType> | V3Trade<Currency, Currency, TradeType> | MixedRouteTrade<Currency, Currency, TradeType>)[], options: SwapOptions): MethodParameters;
|
|
58
85
|
/**
|
|
59
86
|
* Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade.
|
|
60
|
-
* @param
|
|
87
|
+
* @param trades to produce call parameters for
|
|
61
88
|
* @param options options for the call parameters
|
|
62
89
|
*/
|
|
63
90
|
static swapAndAddCallParameters(trades: AnyTradeType, options: SwapAndAddOptions, position: Position, addLiquidityOptions: CondensedAddLiquidityOptions, tokenInApprovalType: ApprovalTypes, tokenOutApprovalType: ApprovalTypes): MethodParameters;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Currency } from '@uniswap/sdk-core';
|
|
2
|
+
import { MixedRouteSDK } from '../entities/mixedRoute/route';
|
|
3
|
+
/**
|
|
4
|
+
* Converts a route to a hex encoded path
|
|
5
|
+
* @notice only supports exactIn route encodings
|
|
6
|
+
* @param route the mixed path to convert to an encoded path
|
|
7
|
+
* @returns the exactIn encoded path
|
|
8
|
+
*/
|
|
9
|
+
export declare function encodeMixedRouteToPath(route: MixedRouteSDK<Currency, Currency>): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Currency, Token } from '@uniswap/sdk-core';
|
|
2
|
+
import { Pair } from '@uniswap/v2-sdk';
|
|
3
|
+
import { Pool } from '@uniswap/v3-sdk';
|
|
4
|
+
import { MixedRouteSDK } from '../entities/mixedRoute/route';
|
|
5
|
+
/**
|
|
6
|
+
* Utility function to return each consecutive section of Pools or Pairs in a MixedRoute
|
|
7
|
+
* @param route
|
|
8
|
+
* @returns a nested array of Pools or Pairs in the order of the route
|
|
9
|
+
*/
|
|
10
|
+
export declare const partitionMixedRouteByProtocol: (route: MixedRouteSDK<Currency, Currency>) => (Pool | Pair)[][];
|
|
11
|
+
/**
|
|
12
|
+
* Simple utility function to get the output of an array of Pools or Pairs
|
|
13
|
+
* @param pools
|
|
14
|
+
* @param firstInputToken
|
|
15
|
+
* @returns the output token of the last pool in the array
|
|
16
|
+
*/
|
|
17
|
+
export declare const getOutputOfPools: (pools: (Pool | Pair)[], firstInputToken: Token) => Token;
|