@uniswap/router-sdk 2.0.0 → 2.0.2

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.
Files changed (176) hide show
  1. package/dist/{cjs/src/approveAndCall.d.ts → approveAndCall.d.ts} +33 -33
  2. package/dist/{types/src/constants.d.ts → constants.d.ts} +13 -13
  3. package/dist/{types/src/entities → entities}/mixedRoute/route.d.ts +29 -29
  4. package/dist/{esm/src/entities → entities}/mixedRoute/trade.d.ts +183 -183
  5. package/dist/{cjs/src/entities → entities}/protocol.d.ts +6 -6
  6. package/dist/{esm/src/entities → entities}/route.d.ts +40 -40
  7. package/dist/{esm/src/entities → entities}/trade.d.ts +127 -127
  8. package/dist/{cjs/src/index.d.ts → index.d.ts} +14 -14
  9. package/dist/index.js +8 -0
  10. package/dist/{cjs/src/multicallExtended.d.ts → multicallExtended.d.ts} +11 -11
  11. package/dist/{types/src/paymentsExtended.d.ts → paymentsExtended.d.ts} +15 -15
  12. package/dist/router-sdk.cjs.development.js +2460 -0
  13. package/dist/router-sdk.cjs.development.js.map +1 -0
  14. package/dist/router-sdk.cjs.production.min.js +2 -0
  15. package/dist/router-sdk.cjs.production.min.js.map +1 -0
  16. package/dist/router-sdk.esm.js +2427 -0
  17. package/dist/router-sdk.esm.js.map +1 -0
  18. package/dist/{cjs/src/swapRouter.d.ts → swapRouter.d.ts} +95 -95
  19. package/dist/{cjs/src/utils → utils}/TPool.d.ts +4 -4
  20. package/dist/{cjs/src/utils → utils}/encodeMixedRouteToPath.d.ts +9 -9
  21. package/dist/{types/src/utils → utils}/index.d.ts +16 -16
  22. package/dist/{cjs/src/utils → utils}/pathCurrency.d.ts +4 -4
  23. package/package.json +18 -33
  24. package/dist/cjs/src/approveAndCall.js +0 -111
  25. package/dist/cjs/src/approveAndCall.js.map +0 -1
  26. package/dist/cjs/src/constants.d.ts +0 -13
  27. package/dist/cjs/src/constants.js +0 -22
  28. package/dist/cjs/src/constants.js.map +0 -1
  29. package/dist/cjs/src/entities/mixedRoute/route.d.ts +0 -29
  30. package/dist/cjs/src/entities/mixedRoute/route.js +0 -119
  31. package/dist/cjs/src/entities/mixedRoute/route.js.map +0 -1
  32. package/dist/cjs/src/entities/mixedRoute/route.test.d.ts +0 -1
  33. package/dist/cjs/src/entities/mixedRoute/route.test.js +0 -469
  34. package/dist/cjs/src/entities/mixedRoute/route.test.js.map +0 -1
  35. package/dist/cjs/src/entities/mixedRoute/trade.d.ts +0 -183
  36. package/dist/cjs/src/entities/mixedRoute/trade.js +0 -357
  37. package/dist/cjs/src/entities/mixedRoute/trade.js.map +0 -1
  38. package/dist/cjs/src/entities/mixedRoute/trade.test.d.ts +0 -1
  39. package/dist/cjs/src/entities/mixedRoute/trade.test.js +0 -1010
  40. package/dist/cjs/src/entities/mixedRoute/trade.test.js.map +0 -1
  41. package/dist/cjs/src/entities/protocol.js +0 -11
  42. package/dist/cjs/src/entities/protocol.js.map +0 -1
  43. package/dist/cjs/src/entities/route.d.ts +0 -40
  44. package/dist/cjs/src/entities/route.js +0 -63
  45. package/dist/cjs/src/entities/route.js.map +0 -1
  46. package/dist/cjs/src/entities/route.test.d.ts +0 -1
  47. package/dist/cjs/src/entities/route.test.js +0 -192
  48. package/dist/cjs/src/entities/route.test.js.map +0 -1
  49. package/dist/cjs/src/entities/trade.d.ts +0 -127
  50. package/dist/cjs/src/entities/trade.js +0 -366
  51. package/dist/cjs/src/entities/trade.js.map +0 -1
  52. package/dist/cjs/src/entities/trade.test.d.ts +0 -1
  53. package/dist/cjs/src/entities/trade.test.js +0 -1267
  54. package/dist/cjs/src/entities/trade.test.js.map +0 -1
  55. package/dist/cjs/src/index.js +0 -18
  56. package/dist/cjs/src/index.js.map +0 -1
  57. package/dist/cjs/src/multicallExtended.js +0 -43
  58. package/dist/cjs/src/multicallExtended.js.map +0 -1
  59. package/dist/cjs/src/multicallExtended.test.d.ts +0 -1
  60. package/dist/cjs/src/multicallExtended.test.js +0 -22
  61. package/dist/cjs/src/multicallExtended.test.js.map +0 -1
  62. package/dist/cjs/src/paymentsExtended.d.ts +0 -15
  63. package/dist/cjs/src/paymentsExtended.js +0 -65
  64. package/dist/cjs/src/paymentsExtended.js.map +0 -1
  65. package/dist/cjs/src/paymentsExtended.test.d.ts +0 -1
  66. package/dist/cjs/src/paymentsExtended.test.js +0 -60
  67. package/dist/cjs/src/paymentsExtended.test.js.map +0 -1
  68. package/dist/cjs/src/swapRouter.js +0 -439
  69. package/dist/cjs/src/swapRouter.js.map +0 -1
  70. package/dist/cjs/src/swapRouter.test.d.ts +0 -1
  71. package/dist/cjs/src/swapRouter.test.js +0 -1161
  72. package/dist/cjs/src/swapRouter.test.js.map +0 -1
  73. package/dist/cjs/src/utils/TPool.js +0 -3
  74. package/dist/cjs/src/utils/TPool.js.map +0 -1
  75. package/dist/cjs/src/utils/encodeMixedRouteToPath.js +0 -90
  76. package/dist/cjs/src/utils/encodeMixedRouteToPath.js.map +0 -1
  77. package/dist/cjs/src/utils/encodeMixedRouteToPath.test.d.ts +0 -1
  78. package/dist/cjs/src/utils/encodeMixedRouteToPath.test.js +0 -136
  79. package/dist/cjs/src/utils/encodeMixedRouteToPath.test.js.map +0 -1
  80. package/dist/cjs/src/utils/index.d.ts +0 -16
  81. package/dist/cjs/src/utils/index.js +0 -51
  82. package/dist/cjs/src/utils/index.js.map +0 -1
  83. package/dist/cjs/src/utils/pathCurrency.js +0 -35
  84. package/dist/cjs/src/utils/pathCurrency.js.map +0 -1
  85. package/dist/cjs/src/utils/pathCurrency.test.d.ts +0 -1
  86. package/dist/cjs/src/utils/pathCurrency.test.js +0 -17
  87. package/dist/cjs/src/utils/pathCurrency.test.js.map +0 -1
  88. package/dist/esm/src/approveAndCall.d.ts +0 -33
  89. package/dist/esm/src/approveAndCall.js +0 -105
  90. package/dist/esm/src/approveAndCall.js.map +0 -1
  91. package/dist/esm/src/constants.d.ts +0 -13
  92. package/dist/esm/src/constants.js +0 -18
  93. package/dist/esm/src/constants.js.map +0 -1
  94. package/dist/esm/src/entities/mixedRoute/route.d.ts +0 -29
  95. package/dist/esm/src/entities/mixedRoute/route.js +0 -114
  96. package/dist/esm/src/entities/mixedRoute/route.js.map +0 -1
  97. package/dist/esm/src/entities/mixedRoute/route.test.d.ts +0 -1
  98. package/dist/esm/src/entities/mixedRoute/route.test.js +0 -467
  99. package/dist/esm/src/entities/mixedRoute/route.test.js.map +0 -1
  100. package/dist/esm/src/entities/mixedRoute/trade.js +0 -352
  101. package/dist/esm/src/entities/mixedRoute/trade.js.map +0 -1
  102. package/dist/esm/src/entities/mixedRoute/trade.test.d.ts +0 -1
  103. package/dist/esm/src/entities/mixedRoute/trade.test.js +0 -1008
  104. package/dist/esm/src/entities/mixedRoute/trade.test.js.map +0 -1
  105. package/dist/esm/src/entities/protocol.d.ts +0 -6
  106. package/dist/esm/src/entities/protocol.js +0 -8
  107. package/dist/esm/src/entities/protocol.js.map +0 -1
  108. package/dist/esm/src/entities/route.js +0 -55
  109. package/dist/esm/src/entities/route.js.map +0 -1
  110. package/dist/esm/src/entities/route.test.d.ts +0 -1
  111. package/dist/esm/src/entities/route.test.js +0 -190
  112. package/dist/esm/src/entities/route.test.js.map +0 -1
  113. package/dist/esm/src/entities/trade.js +0 -362
  114. package/dist/esm/src/entities/trade.js.map +0 -1
  115. package/dist/esm/src/entities/trade.test.d.ts +0 -1
  116. package/dist/esm/src/entities/trade.test.js +0 -1265
  117. package/dist/esm/src/entities/trade.test.js.map +0 -1
  118. package/dist/esm/src/index.d.ts +0 -14
  119. package/dist/esm/src/index.js +0 -15
  120. package/dist/esm/src/index.js.map +0 -1
  121. package/dist/esm/src/multicallExtended.d.ts +0 -11
  122. package/dist/esm/src/multicallExtended.js +0 -39
  123. package/dist/esm/src/multicallExtended.js.map +0 -1
  124. package/dist/esm/src/multicallExtended.test.d.ts +0 -1
  125. package/dist/esm/src/multicallExtended.test.js +0 -20
  126. package/dist/esm/src/multicallExtended.test.js.map +0 -1
  127. package/dist/esm/src/paymentsExtended.d.ts +0 -15
  128. package/dist/esm/src/paymentsExtended.js +0 -61
  129. package/dist/esm/src/paymentsExtended.js.map +0 -1
  130. package/dist/esm/src/paymentsExtended.test.d.ts +0 -1
  131. package/dist/esm/src/paymentsExtended.test.js +0 -57
  132. package/dist/esm/src/paymentsExtended.test.js.map +0 -1
  133. package/dist/esm/src/swapRouter.d.ts +0 -95
  134. package/dist/esm/src/swapRouter.js +0 -434
  135. package/dist/esm/src/swapRouter.js.map +0 -1
  136. package/dist/esm/src/swapRouter.test.d.ts +0 -1
  137. package/dist/esm/src/swapRouter.test.js +0 -1159
  138. package/dist/esm/src/swapRouter.test.js.map +0 -1
  139. package/dist/esm/src/utils/TPool.d.ts +0 -4
  140. package/dist/esm/src/utils/TPool.js +0 -2
  141. package/dist/esm/src/utils/TPool.js.map +0 -1
  142. package/dist/esm/src/utils/encodeMixedRouteToPath.d.ts +0 -9
  143. package/dist/esm/src/utils/encodeMixedRouteToPath.js +0 -86
  144. package/dist/esm/src/utils/encodeMixedRouteToPath.js.map +0 -1
  145. package/dist/esm/src/utils/encodeMixedRouteToPath.test.d.ts +0 -1
  146. package/dist/esm/src/utils/encodeMixedRouteToPath.test.js +0 -134
  147. package/dist/esm/src/utils/encodeMixedRouteToPath.test.js.map +0 -1
  148. package/dist/esm/src/utils/index.d.ts +0 -16
  149. package/dist/esm/src/utils/index.js +0 -46
  150. package/dist/esm/src/utils/index.js.map +0 -1
  151. package/dist/esm/src/utils/pathCurrency.d.ts +0 -4
  152. package/dist/esm/src/utils/pathCurrency.js +0 -30
  153. package/dist/esm/src/utils/pathCurrency.js.map +0 -1
  154. package/dist/esm/src/utils/pathCurrency.test.d.ts +0 -1
  155. package/dist/esm/src/utils/pathCurrency.test.js +0 -15
  156. package/dist/esm/src/utils/pathCurrency.test.js.map +0 -1
  157. package/dist/types/src/approveAndCall.d.ts +0 -33
  158. package/dist/types/src/entities/mixedRoute/route.test.d.ts +0 -1
  159. package/dist/types/src/entities/mixedRoute/trade.d.ts +0 -183
  160. package/dist/types/src/entities/mixedRoute/trade.test.d.ts +0 -1
  161. package/dist/types/src/entities/protocol.d.ts +0 -6
  162. package/dist/types/src/entities/route.d.ts +0 -40
  163. package/dist/types/src/entities/route.test.d.ts +0 -1
  164. package/dist/types/src/entities/trade.d.ts +0 -127
  165. package/dist/types/src/entities/trade.test.d.ts +0 -1
  166. package/dist/types/src/index.d.ts +0 -14
  167. package/dist/types/src/multicallExtended.d.ts +0 -11
  168. package/dist/types/src/multicallExtended.test.d.ts +0 -1
  169. package/dist/types/src/paymentsExtended.test.d.ts +0 -1
  170. package/dist/types/src/swapRouter.d.ts +0 -95
  171. package/dist/types/src/swapRouter.test.d.ts +0 -1
  172. package/dist/types/src/utils/TPool.d.ts +0 -4
  173. package/dist/types/src/utils/encodeMixedRouteToPath.d.ts +0 -9
  174. package/dist/types/src/utils/encodeMixedRouteToPath.test.d.ts +0 -1
  175. package/dist/types/src/utils/pathCurrency.d.ts +0 -4
  176. package/dist/types/src/utils/pathCurrency.test.d.ts +0 -1
@@ -1,33 +1,33 @@
1
- import { Interface } from '@ethersproject/abi';
2
- import { Currency, Percent, Token } from '@uniswap/sdk-core';
3
- import { MintSpecificOptions, IncreaseSpecificOptions, Position } from '@uniswap/v3-sdk';
4
- export type CondensedAddLiquidityOptions = Omit<MintSpecificOptions, 'createPool'> | IncreaseSpecificOptions;
5
- export declare enum ApprovalTypes {
6
- NOT_REQUIRED = 0,
7
- MAX = 1,
8
- MAX_MINUS_ONE = 2,
9
- ZERO_THEN_MAX = 3,
10
- ZERO_THEN_MAX_MINUS_ONE = 4
11
- }
12
- export declare function isMint(options: CondensedAddLiquidityOptions): options is Omit<MintSpecificOptions, 'createPool'>;
13
- export declare abstract class ApproveAndCall {
14
- static INTERFACE: Interface;
15
- /**
16
- * Cannot be constructed.
17
- */
18
- private constructor();
19
- static encodeApproveMax(token: Token): string;
20
- static encodeApproveMaxMinusOne(token: Token): string;
21
- static encodeApproveZeroThenMax(token: Token): string;
22
- static encodeApproveZeroThenMaxMinusOne(token: Token): string;
23
- static encodeCallPositionManager(calldatas: string[]): string;
24
- /**
25
- * Encode adding liquidity to a position in the nft manager contract
26
- * @param position Forcasted position with expected amount out from swap
27
- * @param minimalPosition Forcasted position with custom minimal token amounts
28
- * @param addLiquidityOptions Options for adding liquidity
29
- * @param slippageTolerance Defines maximum slippage
30
- */
31
- static encodeAddLiquidity(position: Position, minimalPosition: Position, addLiquidityOptions: CondensedAddLiquidityOptions, slippageTolerance: Percent): string;
32
- static encodeApprove(token: Currency, approvalType: ApprovalTypes): string;
33
- }
1
+ import { Interface } from '@ethersproject/abi';
2
+ import { Currency, Percent, Token } from '@uniswap/sdk-core';
3
+ import { MintSpecificOptions, IncreaseSpecificOptions, Position } from '@uniswap/v3-sdk';
4
+ export declare type CondensedAddLiquidityOptions = Omit<MintSpecificOptions, 'createPool'> | IncreaseSpecificOptions;
5
+ export declare enum ApprovalTypes {
6
+ NOT_REQUIRED = 0,
7
+ MAX = 1,
8
+ MAX_MINUS_ONE = 2,
9
+ ZERO_THEN_MAX = 3,
10
+ ZERO_THEN_MAX_MINUS_ONE = 4
11
+ }
12
+ export declare function isMint(options: CondensedAddLiquidityOptions): options is Omit<MintSpecificOptions, 'createPool'>;
13
+ export declare abstract class ApproveAndCall {
14
+ static INTERFACE: Interface;
15
+ /**
16
+ * Cannot be constructed.
17
+ */
18
+ private constructor();
19
+ static encodeApproveMax(token: Token): string;
20
+ static encodeApproveMaxMinusOne(token: Token): string;
21
+ static encodeApproveZeroThenMax(token: Token): string;
22
+ static encodeApproveZeroThenMaxMinusOne(token: Token): string;
23
+ static encodeCallPositionManager(calldatas: string[]): string;
24
+ /**
25
+ * Encode adding liquidity to a position in the nft manager contract
26
+ * @param position Forcasted position with expected amount out from swap
27
+ * @param minimalPosition Forcasted position with custom minimal token amounts
28
+ * @param addLiquidityOptions Options for adding liquidity
29
+ * @param slippageTolerance Defines maximum slippage
30
+ */
31
+ static encodeAddLiquidity(position: Position, minimalPosition: Position, addLiquidityOptions: CondensedAddLiquidityOptions, slippageTolerance: Percent): string;
32
+ static encodeApprove(token: Currency, approvalType: ApprovalTypes): string;
33
+ }
@@ -1,13 +1,13 @@
1
- import { Percent } from '@uniswap/sdk-core';
2
- import JSBI from 'jsbi';
3
- export declare const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000";
4
- export declare const MSG_SENDER = "0x0000000000000000000000000000000000000001";
5
- export declare const ADDRESS_THIS = "0x0000000000000000000000000000000000000002";
6
- export declare const ZERO: JSBI;
7
- export declare const ONE: JSBI;
8
- export declare const MIXED_QUOTER_V1_V2_FEE_PATH_PLACEHOLDER: number;
9
- export declare const MIXED_QUOTER_V2_V2_FEE_PATH_PLACEHOLDER: number;
10
- export declare const MIXED_QUOTER_V2_V3_FEE_PATH_PLACEHOLDER: number;
11
- export declare const MIXED_QUOTER_V2_V4_FEE_PATH_PLACEHOLDER: number;
12
- export declare const ZERO_PERCENT: Percent;
13
- export declare const ONE_HUNDRED_PERCENT: Percent;
1
+ import { Percent } from '@uniswap/sdk-core';
2
+ import JSBI from 'jsbi';
3
+ export declare const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000";
4
+ export declare const MSG_SENDER = "0x0000000000000000000000000000000000000001";
5
+ export declare const ADDRESS_THIS = "0x0000000000000000000000000000000000000002";
6
+ export declare const ZERO: JSBI;
7
+ export declare const ONE: JSBI;
8
+ export declare const MIXED_QUOTER_V1_V2_FEE_PATH_PLACEHOLDER: number;
9
+ export declare const MIXED_QUOTER_V2_V2_FEE_PATH_PLACEHOLDER: number;
10
+ export declare const MIXED_QUOTER_V2_V3_FEE_PATH_PLACEHOLDER: number;
11
+ export declare const MIXED_QUOTER_V2_V4_FEE_PATH_PLACEHOLDER: number;
12
+ export declare const ZERO_PERCENT: Percent;
13
+ export declare const ONE_HUNDRED_PERCENT: Percent;
@@ -1,29 +1,29 @@
1
- import { Currency, Price } from '@uniswap/sdk-core';
2
- import { TPool } from '../../utils/TPool';
3
- /**
4
- * Represents a list of pools or pairs through which a swap can occur
5
- * @template TInput The input token
6
- * @template TOutput The output token
7
- */
8
- export declare class MixedRouteSDK<TInput extends Currency, TOutput extends Currency> {
9
- readonly pools: TPool[];
10
- readonly path: Currency[];
11
- readonly input: TInput;
12
- readonly output: TOutput;
13
- readonly pathInput: Currency;
14
- readonly pathOutput: Currency;
15
- private _midPrice;
16
- /**
17
- * Creates an instance of route.
18
- * @param pools An array of `TPool` objects (pools or pairs), ordered by the route the swap will take
19
- * @param input The input token
20
- * @param output The output token
21
- * @param retainsFakePool Set to true to filter out a pool that has a fake eth-weth pool
22
- */
23
- constructor(pools: TPool[], input: TInput, output: TOutput, retainFakePools?: boolean);
24
- get chainId(): number;
25
- /**
26
- * Returns the mid price of the route
27
- */
28
- get midPrice(): Price<TInput, TOutput>;
29
- }
1
+ import { Currency, Price } from '@uniswap/sdk-core';
2
+ import { TPool } from '../../utils/TPool';
3
+ /**
4
+ * Represents a list of pools or pairs through which a swap can occur
5
+ * @template TInput The input token
6
+ * @template TOutput The output token
7
+ */
8
+ export declare class MixedRouteSDK<TInput extends Currency, TOutput extends Currency> {
9
+ readonly pools: TPool[];
10
+ readonly path: Currency[];
11
+ readonly input: TInput;
12
+ readonly output: TOutput;
13
+ readonly pathInput: Currency;
14
+ readonly pathOutput: Currency;
15
+ private _midPrice;
16
+ /**
17
+ * Creates an instance of route.
18
+ * @param pools An array of `TPool` objects (pools or pairs), ordered by the route the swap will take
19
+ * @param input The input token
20
+ * @param output The output token
21
+ * @param retainsFakePool Set to true to filter out a pool that has a fake eth-weth pool
22
+ */
23
+ constructor(pools: TPool[], input: TInput, output: TOutput, retainFakePools?: boolean);
24
+ get chainId(): number;
25
+ /**
26
+ * Returns the mid price of the route
27
+ */
28
+ get midPrice(): Price<TInput, TOutput>;
29
+ }
@@ -1,183 +1,183 @@
1
- import { Currency, Percent, Price, CurrencyAmount, TradeType } from '@uniswap/sdk-core';
2
- import { BestTradeOptions } from '@uniswap/v3-sdk';
3
- import { MixedRouteSDK } from './route';
4
- import { TPool } from '../../utils/TPool';
5
- /**
6
- * Trades comparator, an extension of the input output comparator that also considers other dimensions of the trade in ranking them
7
- * @template TInput The input token, either Ether or an ERC-20
8
- * @template TOutput The output token, either Ether or an ERC-20
9
- * @template TTradeType The trade type, either exact input or exact output
10
- * @param a The first trade to compare
11
- * @param b The second trade to compare
12
- * @returns A sorted ordering for two neighboring elements in a trade array
13
- */
14
- export declare function tradeComparator<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(a: MixedRouteTrade<TInput, TOutput, TTradeType>, b: MixedRouteTrade<TInput, TOutput, TTradeType>): number;
15
- /**
16
- * Represents a trade executed against a set of routes where some percentage of the input is
17
- * split across each route.
18
- *
19
- * Each route has its own set of pools. Pools can not be re-used across routes.
20
- *
21
- * Does not account for slippage, i.e., changes in price environment that can occur between
22
- * the time the trade is submitted and when it is executed.
23
- * @notice This class is functionally the same as the `Trade` class in the `@uniswap/v3-sdk` package, aside from typing and some input validation.
24
- * @template TInput The input token, either Ether or an ERC-20
25
- * @template TOutput The output token, either Ether or an ERC-20
26
- * @template TTradeType The trade type, either exact input or exact output
27
- */
28
- export declare class MixedRouteTrade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType> {
29
- /**
30
- * @deprecated Deprecated in favor of 'swaps' property. If the trade consists of multiple routes
31
- * this will return an error.
32
- *
33
- * When the trade consists of just a single route, this returns the route of the trade,
34
- * i.e. which pools the trade goes through.
35
- */
36
- get route(): MixedRouteSDK<TInput, TOutput>;
37
- /**
38
- * The swaps of the trade, i.e. which routes and how much is swapped in each that
39
- * make up the trade.
40
- */
41
- readonly swaps: {
42
- route: MixedRouteSDK<TInput, TOutput>;
43
- inputAmount: CurrencyAmount<TInput>;
44
- outputAmount: CurrencyAmount<TOutput>;
45
- }[];
46
- /**
47
- * The type of the trade, either exact in or exact out.
48
- */
49
- readonly tradeType: TTradeType;
50
- /**
51
- * The cached result of the input amount computation
52
- * @private
53
- */
54
- private _inputAmount;
55
- /**
56
- * The input amount for the trade assuming no slippage.
57
- */
58
- get inputAmount(): CurrencyAmount<TInput>;
59
- /**
60
- * The cached result of the output amount computation
61
- * @private
62
- */
63
- private _outputAmount;
64
- /**
65
- * The output amount for the trade assuming no slippage.
66
- */
67
- get outputAmount(): CurrencyAmount<TOutput>;
68
- /**
69
- * The cached result of the computed execution price
70
- * @private
71
- */
72
- private _executionPrice;
73
- /**
74
- * The price expressed in terms of output amount/input amount.
75
- */
76
- get executionPrice(): Price<TInput, TOutput>;
77
- /**
78
- * The cached result of the price impact computation
79
- * @private
80
- */
81
- private _priceImpact;
82
- /**
83
- * Returns the percent difference between the route's mid price and the price impact
84
- */
85
- get priceImpact(): Percent;
86
- /**
87
- * Constructs a trade by simulating swaps through the given route
88
- * @template TInput The input token, either Ether or an ERC-20.
89
- * @template TOutput The output token, either Ether or an ERC-20.
90
- * @template TTradeType The type of the trade, either exact in or exact out.
91
- * @param route route to swap through
92
- * @param amount the amount specified, either input or output, depending on tradeType
93
- * @param tradeType whether the trade is an exact input or exact output swap
94
- * @returns The route
95
- */
96
- static fromRoute<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(route: MixedRouteSDK<TInput, TOutput>, amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>, tradeType: TTradeType): Promise<MixedRouteTrade<TInput, TOutput, TTradeType>>;
97
- /**
98
- * Constructs a trade from routes by simulating swaps
99
- *
100
- * @template TInput The input token, either Ether or an ERC-20.
101
- * @template TOutput The output token, either Ether or an ERC-20.
102
- * @template TTradeType The type of the trade, either exact in or exact out.
103
- * @param routes the routes to swap through and how much of the amount should be routed through each
104
- * @param tradeType whether the trade is an exact input or exact output swap
105
- * @returns The trade
106
- */
107
- static fromRoutes<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(routes: {
108
- amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>;
109
- route: MixedRouteSDK<TInput, TOutput>;
110
- }[], tradeType: TTradeType): Promise<MixedRouteTrade<TInput, TOutput, TTradeType>>;
111
- /**
112
- * Creates a trade without computing the result of swapping through the route. Useful when you have simulated the trade
113
- * elsewhere and do not have any tick data
114
- * @template TInput The input token, either Ether or an ERC-20
115
- * @template TOutput The output token, either Ether or an ERC-20
116
- * @template TTradeType The type of the trade, either exact in or exact out
117
- * @param constructorArguments The arguments passed to the trade constructor
118
- * @returns The unchecked trade
119
- */
120
- static createUncheckedTrade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(constructorArguments: {
121
- route: MixedRouteSDK<TInput, TOutput>;
122
- inputAmount: CurrencyAmount<TInput>;
123
- outputAmount: CurrencyAmount<TOutput>;
124
- tradeType: TTradeType;
125
- }): MixedRouteTrade<TInput, TOutput, TTradeType>;
126
- /**
127
- * Creates a trade without computing the result of swapping through the routes. Useful when you have simulated the trade
128
- * elsewhere and do not have any tick data
129
- * @template TInput The input token, either Ether or an ERC-20
130
- * @template TOutput The output token, either Ether or an ERC-20
131
- * @template TTradeType The type of the trade, either exact in or exact out
132
- * @param constructorArguments The arguments passed to the trade constructor
133
- * @returns The unchecked trade
134
- */
135
- static createUncheckedTradeWithMultipleRoutes<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(constructorArguments: {
136
- routes: {
137
- route: MixedRouteSDK<TInput, TOutput>;
138
- inputAmount: CurrencyAmount<TInput>;
139
- outputAmount: CurrencyAmount<TOutput>;
140
- }[];
141
- tradeType: TTradeType;
142
- }): MixedRouteTrade<TInput, TOutput, TTradeType>;
143
- /**
144
- * Construct a trade by passing in the pre-computed property values
145
- * @param routes The routes through which the trade occurs
146
- * @param tradeType The type of trade, exact input or exact output
147
- */
148
- private constructor();
149
- /**
150
- * Get the minimum amount that must be received from this trade for the given slippage tolerance
151
- * @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
152
- * @returns The amount out
153
- */
154
- minimumAmountOut(slippageTolerance: Percent, amountOut?: CurrencyAmount<TOutput>): CurrencyAmount<TOutput>;
155
- /**
156
- * Get the maximum amount in that can be spent via this trade for the given slippage tolerance
157
- * @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
158
- * @returns The amount in
159
- */
160
- maximumAmountIn(slippageTolerance: Percent, amountIn?: CurrencyAmount<TInput>): CurrencyAmount<TInput>;
161
- /**
162
- * Return the execution price after accounting for slippage tolerance
163
- * @param slippageTolerance the allowed tolerated slippage
164
- * @returns The execution price
165
- */
166
- worstExecutionPrice(slippageTolerance: Percent): Price<TInput, TOutput>;
167
- /**
168
- * Given a list of pools, and a fixed amount in, returns the top `maxNumResults` trades that go from an input token
169
- * amount to an output token, making at most `maxHops` hops.
170
- * Note this does not consider aggregation, as routes are linear. It's possible a better route exists by splitting
171
- * the amount in among multiple routes.
172
- * @param pools the pools to consider in finding the best trade
173
- * @param nextAmountIn exact amount of input currency to spend
174
- * @param currencyOut the desired currency out
175
- * @param maxNumResults maximum number of results to return
176
- * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pool
177
- * @param currentPools used in recursion; the current list of pools
178
- * @param currencyAmountIn used in recursion; the original value of the currencyAmountIn parameter
179
- * @param bestTrades used in recursion; the current list of best trades
180
- * @returns The exact in trade
181
- */
182
- 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
- }
1
+ import { Currency, Percent, Price, CurrencyAmount, TradeType } from '@uniswap/sdk-core';
2
+ import { BestTradeOptions } from '@uniswap/v3-sdk';
3
+ import { MixedRouteSDK } from './route';
4
+ import { TPool } from '../../utils/TPool';
5
+ /**
6
+ * Trades comparator, an extension of the input output comparator that also considers other dimensions of the trade in ranking them
7
+ * @template TInput The input token, either Ether or an ERC-20
8
+ * @template TOutput The output token, either Ether or an ERC-20
9
+ * @template TTradeType The trade type, either exact input or exact output
10
+ * @param a The first trade to compare
11
+ * @param b The second trade to compare
12
+ * @returns A sorted ordering for two neighboring elements in a trade array
13
+ */
14
+ export declare function tradeComparator<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(a: MixedRouteTrade<TInput, TOutput, TTradeType>, b: MixedRouteTrade<TInput, TOutput, TTradeType>): number;
15
+ /**
16
+ * Represents a trade executed against a set of routes where some percentage of the input is
17
+ * split across each route.
18
+ *
19
+ * Each route has its own set of pools. Pools can not be re-used across routes.
20
+ *
21
+ * Does not account for slippage, i.e., changes in price environment that can occur between
22
+ * the time the trade is submitted and when it is executed.
23
+ * @notice This class is functionally the same as the `Trade` class in the `@uniswap/v3-sdk` package, aside from typing and some input validation.
24
+ * @template TInput The input token, either Ether or an ERC-20
25
+ * @template TOutput The output token, either Ether or an ERC-20
26
+ * @template TTradeType The trade type, either exact input or exact output
27
+ */
28
+ export declare class MixedRouteTrade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType> {
29
+ /**
30
+ * @deprecated Deprecated in favor of 'swaps' property. If the trade consists of multiple routes
31
+ * this will return an error.
32
+ *
33
+ * When the trade consists of just a single route, this returns the route of the trade,
34
+ * i.e. which pools the trade goes through.
35
+ */
36
+ get route(): MixedRouteSDK<TInput, TOutput>;
37
+ /**
38
+ * The swaps of the trade, i.e. which routes and how much is swapped in each that
39
+ * make up the trade.
40
+ */
41
+ readonly swaps: {
42
+ route: MixedRouteSDK<TInput, TOutput>;
43
+ inputAmount: CurrencyAmount<TInput>;
44
+ outputAmount: CurrencyAmount<TOutput>;
45
+ }[];
46
+ /**
47
+ * The type of the trade, either exact in or exact out.
48
+ */
49
+ readonly tradeType: TTradeType;
50
+ /**
51
+ * The cached result of the input amount computation
52
+ * @private
53
+ */
54
+ private _inputAmount;
55
+ /**
56
+ * The input amount for the trade assuming no slippage.
57
+ */
58
+ get inputAmount(): CurrencyAmount<TInput>;
59
+ /**
60
+ * The cached result of the output amount computation
61
+ * @private
62
+ */
63
+ private _outputAmount;
64
+ /**
65
+ * The output amount for the trade assuming no slippage.
66
+ */
67
+ get outputAmount(): CurrencyAmount<TOutput>;
68
+ /**
69
+ * The cached result of the computed execution price
70
+ * @private
71
+ */
72
+ private _executionPrice;
73
+ /**
74
+ * The price expressed in terms of output amount/input amount.
75
+ */
76
+ get executionPrice(): Price<TInput, TOutput>;
77
+ /**
78
+ * The cached result of the price impact computation
79
+ * @private
80
+ */
81
+ private _priceImpact;
82
+ /**
83
+ * Returns the percent difference between the route's mid price and the price impact
84
+ */
85
+ get priceImpact(): Percent;
86
+ /**
87
+ * Constructs a trade by simulating swaps through the given route
88
+ * @template TInput The input token, either Ether or an ERC-20.
89
+ * @template TOutput The output token, either Ether or an ERC-20.
90
+ * @template TTradeType The type of the trade, either exact in or exact out.
91
+ * @param route route to swap through
92
+ * @param amount the amount specified, either input or output, depending on tradeType
93
+ * @param tradeType whether the trade is an exact input or exact output swap
94
+ * @returns The route
95
+ */
96
+ static fromRoute<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(route: MixedRouteSDK<TInput, TOutput>, amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>, tradeType: TTradeType): Promise<MixedRouteTrade<TInput, TOutput, TTradeType>>;
97
+ /**
98
+ * Constructs a trade from routes by simulating swaps
99
+ *
100
+ * @template TInput The input token, either Ether or an ERC-20.
101
+ * @template TOutput The output token, either Ether or an ERC-20.
102
+ * @template TTradeType The type of the trade, either exact in or exact out.
103
+ * @param routes the routes to swap through and how much of the amount should be routed through each
104
+ * @param tradeType whether the trade is an exact input or exact output swap
105
+ * @returns The trade
106
+ */
107
+ static fromRoutes<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(routes: {
108
+ amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>;
109
+ route: MixedRouteSDK<TInput, TOutput>;
110
+ }[], tradeType: TTradeType): Promise<MixedRouteTrade<TInput, TOutput, TTradeType>>;
111
+ /**
112
+ * Creates a trade without computing the result of swapping through the route. Useful when you have simulated the trade
113
+ * elsewhere and do not have any tick data
114
+ * @template TInput The input token, either Ether or an ERC-20
115
+ * @template TOutput The output token, either Ether or an ERC-20
116
+ * @template TTradeType The type of the trade, either exact in or exact out
117
+ * @param constructorArguments The arguments passed to the trade constructor
118
+ * @returns The unchecked trade
119
+ */
120
+ static createUncheckedTrade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(constructorArguments: {
121
+ route: MixedRouteSDK<TInput, TOutput>;
122
+ inputAmount: CurrencyAmount<TInput>;
123
+ outputAmount: CurrencyAmount<TOutput>;
124
+ tradeType: TTradeType;
125
+ }): MixedRouteTrade<TInput, TOutput, TTradeType>;
126
+ /**
127
+ * Creates a trade without computing the result of swapping through the routes. Useful when you have simulated the trade
128
+ * elsewhere and do not have any tick data
129
+ * @template TInput The input token, either Ether or an ERC-20
130
+ * @template TOutput The output token, either Ether or an ERC-20
131
+ * @template TTradeType The type of the trade, either exact in or exact out
132
+ * @param constructorArguments The arguments passed to the trade constructor
133
+ * @returns The unchecked trade
134
+ */
135
+ static createUncheckedTradeWithMultipleRoutes<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(constructorArguments: {
136
+ routes: {
137
+ route: MixedRouteSDK<TInput, TOutput>;
138
+ inputAmount: CurrencyAmount<TInput>;
139
+ outputAmount: CurrencyAmount<TOutput>;
140
+ }[];
141
+ tradeType: TTradeType;
142
+ }): MixedRouteTrade<TInput, TOutput, TTradeType>;
143
+ /**
144
+ * Construct a trade by passing in the pre-computed property values
145
+ * @param routes The routes through which the trade occurs
146
+ * @param tradeType The type of trade, exact input or exact output
147
+ */
148
+ private constructor();
149
+ /**
150
+ * Get the minimum amount that must be received from this trade for the given slippage tolerance
151
+ * @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
152
+ * @returns The amount out
153
+ */
154
+ minimumAmountOut(slippageTolerance: Percent, amountOut?: CurrencyAmount<TOutput>): CurrencyAmount<TOutput>;
155
+ /**
156
+ * Get the maximum amount in that can be spent via this trade for the given slippage tolerance
157
+ * @param slippageTolerance The tolerance of unfavorable slippage from the execution price of this trade
158
+ * @returns The amount in
159
+ */
160
+ maximumAmountIn(slippageTolerance: Percent, amountIn?: CurrencyAmount<TInput>): CurrencyAmount<TInput>;
161
+ /**
162
+ * Return the execution price after accounting for slippage tolerance
163
+ * @param slippageTolerance the allowed tolerated slippage
164
+ * @returns The execution price
165
+ */
166
+ worstExecutionPrice(slippageTolerance: Percent): Price<TInput, TOutput>;
167
+ /**
168
+ * Given a list of pools, and a fixed amount in, returns the top `maxNumResults` trades that go from an input token
169
+ * amount to an output token, making at most `maxHops` hops.
170
+ * Note this does not consider aggregation, as routes are linear. It's possible a better route exists by splitting
171
+ * the amount in among multiple routes.
172
+ * @param pools the pools to consider in finding the best trade
173
+ * @param nextAmountIn exact amount of input currency to spend
174
+ * @param currencyOut the desired currency out
175
+ * @param maxNumResults maximum number of results to return
176
+ * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pool
177
+ * @param currentPools used in recursion; the current list of pools
178
+ * @param currencyAmountIn used in recursion; the original value of the currencyAmountIn parameter
179
+ * @param bestTrades used in recursion; the current list of best trades
180
+ * @returns The exact in trade
181
+ */
182
+ 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
+ }
@@ -1,6 +1,6 @@
1
- export declare enum Protocol {
2
- V2 = "V2",
3
- V3 = "V3",
4
- V4 = "V4",
5
- MIXED = "MIXED"
6
- }
1
+ export declare enum Protocol {
2
+ V2 = "V2",
3
+ V3 = "V3",
4
+ V4 = "V4",
5
+ MIXED = "MIXED"
6
+ }
@@ -1,40 +1,40 @@
1
- import { Route as V2RouteSDK, Pair } from '@uniswap/v2-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';
4
- import { Protocol } from './protocol';
5
- import { Currency, Price, Token } from '@uniswap/sdk-core';
6
- import { MixedRouteSDK } from './mixedRoute/route';
7
- export declare function getPathToken(currency: Currency, pool: Pair | V3Pool): Token;
8
- export interface IRoute<TInput extends Currency, TOutput extends Currency, TPool extends Pair | V3Pool | V4Pool> {
9
- protocol: Protocol;
10
- pools: TPool[];
11
- path: Currency[];
12
- midPrice: Price<TInput, TOutput>;
13
- input: TInput;
14
- output: TOutput;
15
- pathInput: Currency;
16
- pathOutput: Currency;
17
- }
18
- export declare class RouteV2<TInput extends Currency, TOutput extends Currency> extends V2RouteSDK<TInput, TOutput> implements IRoute<TInput, TOutput, Pair> {
19
- readonly protocol: Protocol;
20
- readonly pools: Pair[];
21
- pathInput: Currency;
22
- pathOutput: Currency;
23
- constructor(v2Route: V2RouteSDK<TInput, TOutput>);
24
- }
25
- export declare class RouteV3<TInput extends Currency, TOutput extends Currency> extends V3RouteSDK<TInput, TOutput> implements IRoute<TInput, TOutput, V3Pool> {
26
- readonly protocol: Protocol;
27
- readonly path: Token[];
28
- pathInput: Currency;
29
- pathOutput: Currency;
30
- constructor(v3Route: V3RouteSDK<TInput, TOutput>);
31
- }
32
- export declare class RouteV4<TInput extends Currency, TOutput extends Currency> extends V4RouteSDK<TInput, TOutput> implements IRoute<TInput, TOutput, V4Pool> {
33
- readonly protocol: Protocol;
34
- readonly path: Currency[];
35
- constructor(v4Route: V4RouteSDK<TInput, TOutput>);
36
- }
37
- export declare class MixedRoute<TInput extends Currency, TOutput extends Currency> extends MixedRouteSDK<TInput, TOutput> implements IRoute<TInput, TOutput, Pair | V3Pool | V4Pool> {
38
- readonly protocol: Protocol;
39
- constructor(mixedRoute: MixedRouteSDK<TInput, TOutput>);
40
- }
1
+ import { Route as V2RouteSDK, Pair } from '@uniswap/v2-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';
4
+ import { Protocol } from './protocol';
5
+ import { Currency, Price, Token } from '@uniswap/sdk-core';
6
+ import { MixedRouteSDK } from './mixedRoute/route';
7
+ export declare function getPathToken(currency: Currency, pool: Pair | V3Pool): Token;
8
+ export interface IRoute<TInput extends Currency, TOutput extends Currency, TPool extends Pair | V3Pool | V4Pool> {
9
+ protocol: Protocol;
10
+ pools: TPool[];
11
+ path: Currency[];
12
+ midPrice: Price<TInput, TOutput>;
13
+ input: TInput;
14
+ output: TOutput;
15
+ pathInput: Currency;
16
+ pathOutput: Currency;
17
+ }
18
+ export declare class RouteV2<TInput extends Currency, TOutput extends Currency> extends V2RouteSDK<TInput, TOutput> implements IRoute<TInput, TOutput, Pair> {
19
+ readonly protocol: Protocol;
20
+ readonly pools: Pair[];
21
+ pathInput: Currency;
22
+ pathOutput: Currency;
23
+ constructor(v2Route: V2RouteSDK<TInput, TOutput>);
24
+ }
25
+ export declare class RouteV3<TInput extends Currency, TOutput extends Currency> extends V3RouteSDK<TInput, TOutput> implements IRoute<TInput, TOutput, V3Pool> {
26
+ readonly protocol: Protocol;
27
+ readonly path: Token[];
28
+ pathInput: Currency;
29
+ pathOutput: Currency;
30
+ constructor(v3Route: V3RouteSDK<TInput, TOutput>);
31
+ }
32
+ export declare class RouteV4<TInput extends Currency, TOutput extends Currency> extends V4RouteSDK<TInput, TOutput> implements IRoute<TInput, TOutput, V4Pool> {
33
+ readonly protocol: Protocol;
34
+ readonly path: Currency[];
35
+ constructor(v4Route: V4RouteSDK<TInput, TOutput>);
36
+ }
37
+ export declare class MixedRoute<TInput extends Currency, TOutput extends Currency> extends MixedRouteSDK<TInput, TOutput> implements IRoute<TInput, TOutput, Pair | V3Pool | V4Pool> {
38
+ readonly protocol: Protocol;
39
+ constructor(mixedRoute: MixedRouteSDK<TInput, TOutput>);
40
+ }