@uniswap/universal-router-sdk 4.19.3 → 4.19.5

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 (118) hide show
  1. package/dist/{cjs/src/entities → entities}/Command.d.ts +12 -12
  2. package/dist/{types/src/entities → entities}/actions/index.d.ts +2 -2
  3. package/dist/{cjs/src/entities → entities}/actions/uniswap.d.ts +30 -30
  4. package/dist/{esm/src/entities → entities}/actions/unwrapWETH.d.ts +12 -12
  5. package/dist/{cjs/src/entities → entities}/index.d.ts +2 -2
  6. package/dist/{esm/src/index.d.ts → index.d.ts} +10 -10
  7. package/dist/index.js +8 -0
  8. package/dist/{esm/src/swapRouter.d.ts → swapRouter.d.ts} +37 -37
  9. package/dist/test/forge/writeInterop.d.ts +2 -0
  10. package/dist/test/utils/addresses.d.ts +5 -0
  11. package/dist/test/utils/hexToDecimalString.d.ts +2 -0
  12. package/dist/test/utils/permit2.d.ts +7 -0
  13. package/dist/test/utils/uniswapData.d.ts +24 -0
  14. package/dist/universal-router-sdk.cjs.development.js +1424 -0
  15. package/dist/universal-router-sdk.cjs.development.js.map +1 -0
  16. package/dist/universal-router-sdk.cjs.production.min.js +2 -0
  17. package/dist/universal-router-sdk.cjs.production.min.js.map +1 -0
  18. package/dist/universal-router-sdk.esm.js +1417 -0
  19. package/dist/universal-router-sdk.esm.js.map +1 -0
  20. package/dist/{esm/src/utils → utils}/commandParser.d.ts +34 -34
  21. package/dist/{types/src/utils → utils}/constants.d.ts +30 -30
  22. package/dist/{cjs/src/utils → utils}/getCurrencyAddress.d.ts +2 -2
  23. package/dist/{types/src/utils → utils}/inputTokens.d.ts +23 -23
  24. package/dist/{cjs/src/utils → utils}/numbers.d.ts +6 -6
  25. package/dist/{types/src/utils → utils}/pathCurrency.d.ts +3 -3
  26. package/dist/{cjs/src/utils → utils}/routerCommands.d.ts +64 -64
  27. package/dist/{types/src/utils → utils}/routerTradeAdapter.d.ts +73 -73
  28. package/package.json +10 -21
  29. package/dist/cjs/src/entities/Command.js +0 -9
  30. package/dist/cjs/src/entities/Command.js.map +0 -1
  31. package/dist/cjs/src/entities/actions/index.d.ts +0 -2
  32. package/dist/cjs/src/entities/actions/index.js +0 -6
  33. package/dist/cjs/src/entities/actions/index.js.map +0 -1
  34. package/dist/cjs/src/entities/actions/uniswap.js +0 -365
  35. package/dist/cjs/src/entities/actions/uniswap.js.map +0 -1
  36. package/dist/cjs/src/entities/actions/unwrapWETH.d.ts +0 -12
  37. package/dist/cjs/src/entities/actions/unwrapWETH.js +0 -33
  38. package/dist/cjs/src/entities/actions/unwrapWETH.js.map +0 -1
  39. package/dist/cjs/src/entities/index.js +0 -6
  40. package/dist/cjs/src/entities/index.js.map +0 -1
  41. package/dist/cjs/src/index.d.ts +0 -10
  42. package/dist/cjs/src/index.js +0 -24
  43. package/dist/cjs/src/index.js.map +0 -1
  44. package/dist/cjs/src/swapRouter.d.ts +0 -37
  45. package/dist/cjs/src/swapRouter.js +0 -120
  46. package/dist/cjs/src/swapRouter.js.map +0 -1
  47. package/dist/cjs/src/utils/commandParser.d.ts +0 -34
  48. package/dist/cjs/src/utils/commandParser.js +0 -144
  49. package/dist/cjs/src/utils/commandParser.js.map +0 -1
  50. package/dist/cjs/src/utils/constants.d.ts +0 -30
  51. package/dist/cjs/src/utils/constants.js +0 -373
  52. package/dist/cjs/src/utils/constants.js.map +0 -1
  53. package/dist/cjs/src/utils/getCurrencyAddress.js +0 -9
  54. package/dist/cjs/src/utils/getCurrencyAddress.js.map +0 -1
  55. package/dist/cjs/src/utils/inputTokens.d.ts +0 -23
  56. package/dist/cjs/src/utils/inputTokens.js +0 -58
  57. package/dist/cjs/src/utils/inputTokens.js.map +0 -1
  58. package/dist/cjs/src/utils/numbers.js +0 -22
  59. package/dist/cjs/src/utils/numbers.js.map +0 -1
  60. package/dist/cjs/src/utils/pathCurrency.d.ts +0 -3
  61. package/dist/cjs/src/utils/pathCurrency.js +0 -27
  62. package/dist/cjs/src/utils/pathCurrency.js.map +0 -1
  63. package/dist/cjs/src/utils/routerCommands.js +0 -231
  64. package/dist/cjs/src/utils/routerCommands.js.map +0 -1
  65. package/dist/cjs/src/utils/routerTradeAdapter.d.ts +0 -73
  66. package/dist/cjs/src/utils/routerTradeAdapter.js +0 -139
  67. package/dist/cjs/src/utils/routerTradeAdapter.js.map +0 -1
  68. package/dist/esm/src/entities/Command.d.ts +0 -12
  69. package/dist/esm/src/entities/Command.js +0 -6
  70. package/dist/esm/src/entities/Command.js.map +0 -1
  71. package/dist/esm/src/entities/actions/index.d.ts +0 -2
  72. package/dist/esm/src/entities/actions/index.js +0 -3
  73. package/dist/esm/src/entities/actions/index.js.map +0 -1
  74. package/dist/esm/src/entities/actions/uniswap.d.ts +0 -30
  75. package/dist/esm/src/entities/actions/uniswap.js +0 -361
  76. package/dist/esm/src/entities/actions/uniswap.js.map +0 -1
  77. package/dist/esm/src/entities/actions/unwrapWETH.js +0 -28
  78. package/dist/esm/src/entities/actions/unwrapWETH.js.map +0 -1
  79. package/dist/esm/src/entities/index.d.ts +0 -2
  80. package/dist/esm/src/entities/index.js +0 -3
  81. package/dist/esm/src/entities/index.js.map +0 -1
  82. package/dist/esm/src/index.js +0 -7
  83. package/dist/esm/src/index.js.map +0 -1
  84. package/dist/esm/src/swapRouter.js +0 -115
  85. package/dist/esm/src/swapRouter.js.map +0 -1
  86. package/dist/esm/src/utils/commandParser.js +0 -137
  87. package/dist/esm/src/utils/commandParser.js.map +0 -1
  88. package/dist/esm/src/utils/constants.d.ts +0 -30
  89. package/dist/esm/src/utils/constants.js +0 -367
  90. package/dist/esm/src/utils/constants.js.map +0 -1
  91. package/dist/esm/src/utils/getCurrencyAddress.d.ts +0 -2
  92. package/dist/esm/src/utils/getCurrencyAddress.js +0 -5
  93. package/dist/esm/src/utils/getCurrencyAddress.js.map +0 -1
  94. package/dist/esm/src/utils/inputTokens.d.ts +0 -23
  95. package/dist/esm/src/utils/inputTokens.js +0 -51
  96. package/dist/esm/src/utils/inputTokens.js.map +0 -1
  97. package/dist/esm/src/utils/numbers.d.ts +0 -6
  98. package/dist/esm/src/utils/numbers.js +0 -15
  99. package/dist/esm/src/utils/numbers.js.map +0 -1
  100. package/dist/esm/src/utils/pathCurrency.d.ts +0 -3
  101. package/dist/esm/src/utils/pathCurrency.js +0 -23
  102. package/dist/esm/src/utils/pathCurrency.js.map +0 -1
  103. package/dist/esm/src/utils/routerCommands.d.ts +0 -64
  104. package/dist/esm/src/utils/routerCommands.js +0 -226
  105. package/dist/esm/src/utils/routerCommands.js.map +0 -1
  106. package/dist/esm/src/utils/routerTradeAdapter.d.ts +0 -73
  107. package/dist/esm/src/utils/routerTradeAdapter.js +0 -134
  108. package/dist/esm/src/utils/routerTradeAdapter.js.map +0 -1
  109. package/dist/types/src/entities/Command.d.ts +0 -12
  110. package/dist/types/src/entities/actions/uniswap.d.ts +0 -30
  111. package/dist/types/src/entities/actions/unwrapWETH.d.ts +0 -12
  112. package/dist/types/src/entities/index.d.ts +0 -2
  113. package/dist/types/src/index.d.ts +0 -10
  114. package/dist/types/src/swapRouter.d.ts +0 -37
  115. package/dist/types/src/utils/commandParser.d.ts +0 -34
  116. package/dist/types/src/utils/getCurrencyAddress.d.ts +0 -2
  117. package/dist/types/src/utils/numbers.d.ts +0 -6
  118. package/dist/types/src/utils/routerCommands.d.ts +0 -64
@@ -1,64 +1,64 @@
1
- /**
2
- * CommandTypes
3
- * @description Flags that modify a command's execution
4
- * @enum {number}
5
- */
6
- export declare enum CommandType {
7
- V3_SWAP_EXACT_IN = 0,
8
- V3_SWAP_EXACT_OUT = 1,
9
- PERMIT2_TRANSFER_FROM = 2,
10
- PERMIT2_PERMIT_BATCH = 3,
11
- SWEEP = 4,
12
- TRANSFER = 5,
13
- PAY_PORTION = 6,
14
- V2_SWAP_EXACT_IN = 8,
15
- V2_SWAP_EXACT_OUT = 9,
16
- PERMIT2_PERMIT = 10,
17
- WRAP_ETH = 11,
18
- UNWRAP_WETH = 12,
19
- PERMIT2_TRANSFER_FROM_BATCH = 13,
20
- BALANCE_CHECK_ERC20 = 14,
21
- V4_SWAP = 16,
22
- V3_POSITION_MANAGER_PERMIT = 17,
23
- V3_POSITION_MANAGER_CALL = 18,
24
- V4_INITIALIZE_POOL = 19,
25
- V4_POSITION_MANAGER_CALL = 20,
26
- EXECUTE_SUB_PLAN = 33
27
- }
28
- export declare enum Subparser {
29
- V3PathExactIn = 0,
30
- V3PathExactOut = 1
31
- }
32
- export declare enum Parser {
33
- Abi = 0,
34
- V4Actions = 1,
35
- V3Actions = 2
36
- }
37
- export type ParamType = {
38
- readonly name: string;
39
- readonly type: string;
40
- readonly subparser?: Subparser;
41
- };
42
- export type CommandDefinition = {
43
- parser: Parser.Abi;
44
- params: ParamType[];
45
- } | {
46
- parser: Parser.V4Actions;
47
- } | {
48
- parser: Parser.V3Actions;
49
- };
50
- export declare const COMMAND_DEFINITION: {
51
- [key in CommandType]: CommandDefinition;
52
- };
53
- export declare class RoutePlanner {
54
- commands: string;
55
- inputs: string[];
56
- constructor();
57
- addSubPlan(subplan: RoutePlanner): RoutePlanner;
58
- addCommand(type: CommandType, parameters: any[], allowRevert?: boolean): RoutePlanner;
59
- }
60
- export type RouterCommand = {
61
- type: CommandType;
62
- encodedInput: string;
63
- };
64
- export declare function createCommand(type: CommandType, parameters: any[]): RouterCommand;
1
+ /**
2
+ * CommandTypes
3
+ * @description Flags that modify a command's execution
4
+ * @enum {number}
5
+ */
6
+ export declare enum CommandType {
7
+ V3_SWAP_EXACT_IN = 0,
8
+ V3_SWAP_EXACT_OUT = 1,
9
+ PERMIT2_TRANSFER_FROM = 2,
10
+ PERMIT2_PERMIT_BATCH = 3,
11
+ SWEEP = 4,
12
+ TRANSFER = 5,
13
+ PAY_PORTION = 6,
14
+ V2_SWAP_EXACT_IN = 8,
15
+ V2_SWAP_EXACT_OUT = 9,
16
+ PERMIT2_PERMIT = 10,
17
+ WRAP_ETH = 11,
18
+ UNWRAP_WETH = 12,
19
+ PERMIT2_TRANSFER_FROM_BATCH = 13,
20
+ BALANCE_CHECK_ERC20 = 14,
21
+ V4_SWAP = 16,
22
+ V3_POSITION_MANAGER_PERMIT = 17,
23
+ V3_POSITION_MANAGER_CALL = 18,
24
+ V4_INITIALIZE_POOL = 19,
25
+ V4_POSITION_MANAGER_CALL = 20,
26
+ EXECUTE_SUB_PLAN = 33
27
+ }
28
+ export declare enum Subparser {
29
+ V3PathExactIn = 0,
30
+ V3PathExactOut = 1
31
+ }
32
+ export declare enum Parser {
33
+ Abi = 0,
34
+ V4Actions = 1,
35
+ V3Actions = 2
36
+ }
37
+ export declare type ParamType = {
38
+ readonly name: string;
39
+ readonly type: string;
40
+ readonly subparser?: Subparser;
41
+ };
42
+ export declare type CommandDefinition = {
43
+ parser: Parser.Abi;
44
+ params: ParamType[];
45
+ } | {
46
+ parser: Parser.V4Actions;
47
+ } | {
48
+ parser: Parser.V3Actions;
49
+ };
50
+ export declare const COMMAND_DEFINITION: {
51
+ [key in CommandType]: CommandDefinition;
52
+ };
53
+ export declare class RoutePlanner {
54
+ commands: string;
55
+ inputs: string[];
56
+ constructor();
57
+ addSubPlan(subplan: RoutePlanner): RoutePlanner;
58
+ addCommand(type: CommandType, parameters: any[], allowRevert?: boolean): RoutePlanner;
59
+ }
60
+ export declare type RouterCommand = {
61
+ type: CommandType;
62
+ encodedInput: string;
63
+ };
64
+ export declare function createCommand(type: CommandType, parameters: any[]): RouterCommand;
@@ -1,73 +1,73 @@
1
- import { Trade as RouterTrade } from '@uniswap/router-sdk';
2
- import { Currency, TradeType } from '@uniswap/sdk-core';
3
- export type TokenInRoute = {
4
- address: string;
5
- chainId: number;
6
- symbol: string;
7
- decimals: string;
8
- name?: string;
9
- buyFeeBps?: string;
10
- sellFeeBps?: string;
11
- };
12
- export declare enum PoolType {
13
- V2Pool = "v2-pool",
14
- V3Pool = "v3-pool",
15
- V4Pool = "v4-pool"
16
- }
17
- export type V2Reserve = {
18
- token: TokenInRoute;
19
- quotient: string;
20
- };
21
- export type V2PoolInRoute = {
22
- type: PoolType.V2Pool;
23
- address?: string;
24
- tokenIn: TokenInRoute;
25
- tokenOut: TokenInRoute;
26
- reserve0: V2Reserve;
27
- reserve1: V2Reserve;
28
- amountIn?: string;
29
- amountOut?: string;
30
- };
31
- export type V3PoolInRoute = {
32
- type: PoolType.V3Pool;
33
- address?: string;
34
- tokenIn: TokenInRoute;
35
- tokenOut: TokenInRoute;
36
- sqrtRatioX96: string;
37
- liquidity: string;
38
- tickCurrent: string;
39
- fee: string;
40
- amountIn?: string;
41
- amountOut?: string;
42
- };
43
- export type V4PoolInRoute = {
44
- type: PoolType.V4Pool;
45
- address?: string;
46
- tokenIn: TokenInRoute;
47
- tokenOut: TokenInRoute;
48
- fee: string;
49
- tickSpacing: string;
50
- hooks: string;
51
- liquidity: string;
52
- sqrtRatioX96: string;
53
- tickCurrent: string;
54
- amountIn?: string;
55
- amountOut?: string;
56
- };
57
- export type PartialClassicQuote = {
58
- tokenIn: string;
59
- tokenOut: string;
60
- tradeType: TradeType;
61
- route: Array<(V4PoolInRoute | V3PoolInRoute | V2PoolInRoute)[]>;
62
- };
63
- export declare const isNativeCurrency: (address: string) => boolean;
64
- export declare class RouterTradeAdapter {
65
- static fromClassicQuote(quote: PartialClassicQuote): RouterTrade<Currency, Currency, TradeType>;
66
- private static toCurrency;
67
- private static toPoolOrPair;
68
- private static toToken;
69
- private static toV3Pool;
70
- private static toV4Pool;
71
- private static toPair;
72
- private static isVersionedRoute;
73
- }
1
+ import { Trade as RouterTrade } from '@uniswap/router-sdk';
2
+ import { Currency, TradeType } from '@uniswap/sdk-core';
3
+ export declare type TokenInRoute = {
4
+ address: string;
5
+ chainId: number;
6
+ symbol: string;
7
+ decimals: string;
8
+ name?: string;
9
+ buyFeeBps?: string;
10
+ sellFeeBps?: string;
11
+ };
12
+ export declare enum PoolType {
13
+ V2Pool = "v2-pool",
14
+ V3Pool = "v3-pool",
15
+ V4Pool = "v4-pool"
16
+ }
17
+ export declare type V2Reserve = {
18
+ token: TokenInRoute;
19
+ quotient: string;
20
+ };
21
+ export declare type V2PoolInRoute = {
22
+ type: PoolType.V2Pool;
23
+ address?: string;
24
+ tokenIn: TokenInRoute;
25
+ tokenOut: TokenInRoute;
26
+ reserve0: V2Reserve;
27
+ reserve1: V2Reserve;
28
+ amountIn?: string;
29
+ amountOut?: string;
30
+ };
31
+ export declare type V3PoolInRoute = {
32
+ type: PoolType.V3Pool;
33
+ address?: string;
34
+ tokenIn: TokenInRoute;
35
+ tokenOut: TokenInRoute;
36
+ sqrtRatioX96: string;
37
+ liquidity: string;
38
+ tickCurrent: string;
39
+ fee: string;
40
+ amountIn?: string;
41
+ amountOut?: string;
42
+ };
43
+ export declare type V4PoolInRoute = {
44
+ type: PoolType.V4Pool;
45
+ address?: string;
46
+ tokenIn: TokenInRoute;
47
+ tokenOut: TokenInRoute;
48
+ fee: string;
49
+ tickSpacing: string;
50
+ hooks: string;
51
+ liquidity: string;
52
+ sqrtRatioX96: string;
53
+ tickCurrent: string;
54
+ amountIn?: string;
55
+ amountOut?: string;
56
+ };
57
+ export declare type PartialClassicQuote = {
58
+ tokenIn: string;
59
+ tokenOut: string;
60
+ tradeType: TradeType;
61
+ route: Array<(V4PoolInRoute | V3PoolInRoute | V2PoolInRoute)[]>;
62
+ };
63
+ export declare const isNativeCurrency: (address: string) => boolean;
64
+ export declare class RouterTradeAdapter {
65
+ static fromClassicQuote(quote: PartialClassicQuote): RouterTrade<Currency, Currency, TradeType>;
66
+ private static toCurrency;
67
+ private static toPoolOrPair;
68
+ private static toToken;
69
+ private static toV3Pool;
70
+ private static toV4Pool;
71
+ private static toPair;
72
+ private static isVersionedRoute;
73
+ }
package/package.json CHANGED
@@ -7,9 +7,8 @@
7
7
  "ethereum"
8
8
  ],
9
9
  "license": "MIT",
10
- "main": "./dist/cjs/src/index.js",
11
- "module": "./dist/esm/src/index.js",
12
- "types": "./dist/types/src/index.d.ts",
10
+ "main": "dist/index.js",
11
+ "typings": "dist/index.d.ts",
13
12
  "files": [
14
13
  "dist"
15
14
  ],
@@ -17,11 +16,7 @@
17
16
  "node": ">=14"
18
17
  },
19
18
  "scripts": {
20
- "clean": "rm -rf dist",
21
- "build": "yarn clean && yarn build:cjs && yarn build:esm && yarn build:types",
22
- "build:cjs": "tsc -p tsconfig.cjs.json",
23
- "build:esm": "tsc -p tsconfig.esm.json",
24
- "build:types": "tsc -p tsconfig.types.json",
19
+ "build": "tsdx build",
25
20
  "docs": "typedoc",
26
21
  "forge:fix": "forge fmt",
27
22
  "lint": "yarn prettier",
@@ -36,14 +31,14 @@
36
31
  "dependencies": {
37
32
  "@openzeppelin/contracts": "4.7.0",
38
33
  "@uniswap/permit2-sdk": "^1.3.0",
39
- "@uniswap/router-sdk": "^2.0.0",
40
- "@uniswap/sdk-core": "^7.7.0",
34
+ "@uniswap/router-sdk": "^2.0.2",
35
+ "@uniswap/sdk-core": "^7.7.1",
41
36
  "@uniswap/universal-router": "2.0.0-beta.2",
42
37
  "@uniswap/v2-core": "^1.0.1",
43
- "@uniswap/v2-sdk": "^4.15.0",
38
+ "@uniswap/v2-sdk": "^4.15.2",
44
39
  "@uniswap/v3-core": "1.0.0",
45
- "@uniswap/v3-sdk": "^3.25.1",
46
- "@uniswap/v4-sdk": "^1.21.1",
40
+ "@uniswap/v3-sdk": "^3.25.2",
41
+ "@uniswap/v4-sdk": "^1.21.2",
47
42
  "bignumber.js": "^9.0.2",
48
43
  "ethers": "^5.7.0"
49
44
  },
@@ -58,6 +53,7 @@
58
53
  "hardhat": "^2.22.15",
59
54
  "prettier": "^2.4.1",
60
55
  "ts-node": "^10.9.1",
56
+ "tsdx": "^0.14.1",
61
57
  "tslib": "^2.3.0",
62
58
  "typedoc": "^0.21.2",
63
59
  "typescript": "^4.3.3"
@@ -104,13 +100,6 @@
104
100
  "installConfig": {
105
101
  "hoistingLimits": "workspaces"
106
102
  },
107
- "exports": {
108
- ".": {
109
- "types": "./dist/types/src/index.d.ts",
110
- "import": "./dist/esm/src/index.js",
111
- "require": "./dist/cjs/src/index.js"
112
- }
113
- },
114
103
  "sideEffects": false,
115
- "version": "4.19.3"
104
+ "version": "4.19.5"
116
105
  }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RouterActionType = void 0;
4
- var RouterActionType;
5
- (function (RouterActionType) {
6
- RouterActionType["UniswapTrade"] = "UniswapTrade";
7
- RouterActionType["UnwrapWETH"] = "UnwrapWETH";
8
- })(RouterActionType = exports.RouterActionType || (exports.RouterActionType = {}));
9
- //# sourceMappingURL=Command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Command.js","sourceRoot":"","sources":["../../../../src/entities/Command.ts"],"names":[],"mappings":";;;AAMA,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,iDAA6B,CAAA;IAC7B,6CAAyB,CAAA;AAC3B,CAAC,EAHW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAG3B"}
@@ -1,2 +0,0 @@
1
- export * from './uniswap';
2
- export * from './unwrapWETH';
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./uniswap"), exports);
5
- tslib_1.__exportStar(require("./unwrapWETH"), exports);
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/entities/actions/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,uDAA4B"}