@uniswap/universal-router-sdk 4.34.2 → 5.0.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.
Files changed (133) hide show
  1. package/README.md +104 -96
  2. package/dist/{entities → cjs/src/entities}/Command.d.ts +12 -12
  3. package/dist/cjs/src/entities/Command.js +9 -0
  4. package/dist/cjs/src/entities/Command.js.map +1 -0
  5. package/dist/{entities → cjs/src/entities}/actions/across.d.ts +21 -21
  6. package/dist/cjs/src/entities/actions/across.js +7 -0
  7. package/dist/cjs/src/entities/actions/across.js.map +1 -0
  8. package/dist/{entities → cjs/src/entities}/actions/index.d.ts +3 -3
  9. package/dist/cjs/src/entities/actions/index.js +7 -0
  10. package/dist/cjs/src/entities/actions/index.js.map +1 -0
  11. package/dist/{entities → cjs/src/entities}/actions/uniswap.d.ts +38 -39
  12. package/dist/cjs/src/entities/actions/uniswap.js +532 -0
  13. package/dist/cjs/src/entities/actions/uniswap.js.map +1 -0
  14. package/dist/{entities → cjs/src/entities}/actions/unwrapWETH.d.ts +12 -12
  15. package/dist/cjs/src/entities/actions/unwrapWETH.js +33 -0
  16. package/dist/cjs/src/entities/actions/unwrapWETH.js.map +1 -0
  17. package/dist/{entities → cjs/src/entities}/index.d.ts +2 -2
  18. package/dist/cjs/src/entities/index.js +6 -0
  19. package/dist/cjs/src/entities/index.js.map +1 -0
  20. package/dist/{index.d.ts → cjs/src/index.d.ts} +12 -12
  21. package/dist/cjs/src/index.js +33 -0
  22. package/dist/cjs/src/index.js.map +1 -0
  23. package/dist/{swapRouter.d.ts → cjs/src/swapRouter.d.ts} +87 -87
  24. package/dist/cjs/src/swapRouter.js +276 -0
  25. package/dist/cjs/src/swapRouter.js.map +1 -0
  26. package/dist/{utils → cjs/src/utils}/commandParser.d.ts +34 -34
  27. package/dist/cjs/src/utils/commandParser.js +145 -0
  28. package/dist/cjs/src/utils/commandParser.js.map +1 -0
  29. package/dist/{utils → cjs/src/utils}/constants.d.ts +33 -33
  30. package/dist/cjs/src/utils/constants.js +541 -0
  31. package/dist/cjs/src/utils/constants.js.map +1 -0
  32. package/dist/{utils → cjs/src/utils}/eip712.d.ts +17 -17
  33. package/dist/cjs/src/utils/eip712.js +43 -0
  34. package/dist/cjs/src/utils/eip712.js.map +1 -0
  35. package/dist/{utils → cjs/src/utils}/getCurrencyAddress.d.ts +2 -2
  36. package/dist/cjs/src/utils/getCurrencyAddress.js +9 -0
  37. package/dist/cjs/src/utils/getCurrencyAddress.js.map +1 -0
  38. package/dist/{utils → cjs/src/utils}/inputTokens.d.ts +23 -23
  39. package/dist/cjs/src/utils/inputTokens.js +58 -0
  40. package/dist/cjs/src/utils/inputTokens.js.map +1 -0
  41. package/dist/{utils → cjs/src/utils}/numbers.d.ts +7 -6
  42. package/dist/cjs/src/utils/numbers.js +27 -0
  43. package/dist/cjs/src/utils/numbers.js.map +1 -0
  44. package/dist/{utils → cjs/src/utils}/pathCurrency.d.ts +3 -3
  45. package/dist/cjs/src/utils/pathCurrency.js +27 -0
  46. package/dist/cjs/src/utils/pathCurrency.js.map +1 -0
  47. package/dist/{utils → cjs/src/utils}/routerCommands.d.ts +77 -72
  48. package/dist/cjs/src/utils/routerCommands.js +334 -0
  49. package/dist/cjs/src/utils/routerCommands.js.map +1 -0
  50. package/dist/{utils → cjs/src/utils}/routerTradeAdapter.d.ts +73 -73
  51. package/dist/cjs/src/utils/routerTradeAdapter.js +139 -0
  52. package/dist/cjs/src/utils/routerTradeAdapter.js.map +1 -0
  53. package/dist/esm/src/entities/Command.d.ts +12 -0
  54. package/dist/esm/src/entities/Command.js +6 -0
  55. package/dist/esm/src/entities/Command.js.map +1 -0
  56. package/dist/esm/src/entities/actions/across.d.ts +21 -0
  57. package/dist/esm/src/entities/actions/across.js +3 -0
  58. package/dist/esm/src/entities/actions/across.js.map +1 -0
  59. package/dist/esm/src/entities/actions/index.d.ts +3 -0
  60. package/dist/esm/src/entities/actions/index.js +4 -0
  61. package/dist/esm/src/entities/actions/index.js.map +1 -0
  62. package/dist/esm/src/entities/actions/uniswap.d.ts +38 -0
  63. package/dist/esm/src/entities/actions/uniswap.js +528 -0
  64. package/dist/esm/src/entities/actions/uniswap.js.map +1 -0
  65. package/dist/esm/src/entities/actions/unwrapWETH.d.ts +12 -0
  66. package/dist/esm/src/entities/actions/unwrapWETH.js +28 -0
  67. package/dist/esm/src/entities/actions/unwrapWETH.js.map +1 -0
  68. package/dist/esm/src/entities/index.d.ts +2 -0
  69. package/dist/esm/src/entities/index.js +3 -0
  70. package/dist/esm/src/entities/index.js.map +1 -0
  71. package/dist/esm/src/index.d.ts +12 -0
  72. package/dist/esm/src/index.js +9 -0
  73. package/dist/esm/src/index.js.map +1 -0
  74. package/dist/esm/src/swapRouter.d.ts +87 -0
  75. package/dist/esm/src/swapRouter.js +271 -0
  76. package/dist/esm/src/swapRouter.js.map +1 -0
  77. package/dist/esm/src/utils/commandParser.d.ts +34 -0
  78. package/dist/esm/src/utils/commandParser.js +137 -0
  79. package/dist/esm/src/utils/commandParser.js.map +1 -0
  80. package/dist/esm/src/utils/constants.d.ts +33 -0
  81. package/dist/esm/src/utils/constants.js +534 -0
  82. package/dist/esm/src/utils/constants.js.map +1 -0
  83. package/dist/esm/src/utils/eip712.d.ts +17 -0
  84. package/dist/esm/src/utils/eip712.js +38 -0
  85. package/dist/esm/src/utils/eip712.js.map +1 -0
  86. package/dist/esm/src/utils/getCurrencyAddress.d.ts +2 -0
  87. package/dist/esm/src/utils/getCurrencyAddress.js +5 -0
  88. package/dist/esm/src/utils/getCurrencyAddress.js.map +1 -0
  89. package/dist/esm/src/utils/inputTokens.d.ts +23 -0
  90. package/dist/esm/src/utils/inputTokens.js +51 -0
  91. package/dist/esm/src/utils/inputTokens.js.map +1 -0
  92. package/dist/esm/src/utils/numbers.d.ts +7 -0
  93. package/dist/esm/src/utils/numbers.js +19 -0
  94. package/dist/esm/src/utils/numbers.js.map +1 -0
  95. package/dist/esm/src/utils/pathCurrency.d.ts +3 -0
  96. package/dist/esm/src/utils/pathCurrency.js +23 -0
  97. package/dist/esm/src/utils/pathCurrency.js.map +1 -0
  98. package/dist/esm/src/utils/routerCommands.d.ts +77 -0
  99. package/dist/esm/src/utils/routerCommands.js +329 -0
  100. package/dist/esm/src/utils/routerCommands.js.map +1 -0
  101. package/dist/esm/src/utils/routerTradeAdapter.d.ts +73 -0
  102. package/dist/esm/src/utils/routerTradeAdapter.js +134 -0
  103. package/dist/esm/src/utils/routerTradeAdapter.js.map +1 -0
  104. package/dist/types/src/entities/Command.d.ts +12 -0
  105. package/dist/types/src/entities/actions/across.d.ts +21 -0
  106. package/dist/types/src/entities/actions/index.d.ts +3 -0
  107. package/dist/types/src/entities/actions/uniswap.d.ts +38 -0
  108. package/dist/types/src/entities/actions/unwrapWETH.d.ts +12 -0
  109. package/dist/types/src/entities/index.d.ts +2 -0
  110. package/dist/types/src/index.d.ts +12 -0
  111. package/dist/types/src/swapRouter.d.ts +87 -0
  112. package/dist/types/src/utils/commandParser.d.ts +34 -0
  113. package/dist/types/src/utils/constants.d.ts +33 -0
  114. package/dist/types/src/utils/eip712.d.ts +17 -0
  115. package/dist/types/src/utils/getCurrencyAddress.d.ts +2 -0
  116. package/dist/types/src/utils/inputTokens.d.ts +23 -0
  117. package/dist/types/src/utils/numbers.d.ts +7 -0
  118. package/dist/types/src/utils/pathCurrency.d.ts +3 -0
  119. package/dist/types/src/utils/routerCommands.d.ts +77 -0
  120. package/dist/types/src/utils/routerTradeAdapter.d.ts +73 -0
  121. package/package.json +31 -22
  122. package/dist/index.js +0 -8
  123. package/dist/test/forge/writeInterop.d.ts +0 -2
  124. package/dist/test/utils/addresses.d.ts +0 -5
  125. package/dist/test/utils/hexToDecimalString.d.ts +0 -2
  126. package/dist/test/utils/permit2.d.ts +0 -7
  127. package/dist/test/utils/uniswapData.d.ts +0 -24
  128. package/dist/universal-router-sdk.cjs.development.js +0 -1925
  129. package/dist/universal-router-sdk.cjs.development.js.map +0 -1
  130. package/dist/universal-router-sdk.cjs.production.min.js +0 -2
  131. package/dist/universal-router-sdk.cjs.production.min.js.map +0 -1
  132. package/dist/universal-router-sdk.esm.js +0 -1912
  133. package/dist/universal-router-sdk.esm.js.map +0 -1
@@ -0,0 +1,334 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCommand = exports.RoutePlanner = exports.V2V3_SWAP_COMMANDS_V2_1_1 = exports.COMMAND_DEFINITION = exports.Parser = exports.Subparser = exports.CommandType = void 0;
4
+ const utils_1 = require("ethers/lib/utils");
5
+ const v4_sdk_1 = require("@uniswap/v4-sdk");
6
+ /**
7
+ * CommandTypes
8
+ * @description Flags that modify a command's execution
9
+ * @enum {number}
10
+ */
11
+ var CommandType;
12
+ (function (CommandType) {
13
+ CommandType[CommandType["V3_SWAP_EXACT_IN"] = 0] = "V3_SWAP_EXACT_IN";
14
+ CommandType[CommandType["V3_SWAP_EXACT_OUT"] = 1] = "V3_SWAP_EXACT_OUT";
15
+ CommandType[CommandType["PERMIT2_TRANSFER_FROM"] = 2] = "PERMIT2_TRANSFER_FROM";
16
+ CommandType[CommandType["PERMIT2_PERMIT_BATCH"] = 3] = "PERMIT2_PERMIT_BATCH";
17
+ CommandType[CommandType["SWEEP"] = 4] = "SWEEP";
18
+ CommandType[CommandType["TRANSFER"] = 5] = "TRANSFER";
19
+ CommandType[CommandType["PAY_PORTION"] = 6] = "PAY_PORTION";
20
+ CommandType[CommandType["PAY_PORTION_FULL_PRECISION"] = 7] = "PAY_PORTION_FULL_PRECISION";
21
+ CommandType[CommandType["V2_SWAP_EXACT_IN"] = 8] = "V2_SWAP_EXACT_IN";
22
+ CommandType[CommandType["V2_SWAP_EXACT_OUT"] = 9] = "V2_SWAP_EXACT_OUT";
23
+ CommandType[CommandType["PERMIT2_PERMIT"] = 10] = "PERMIT2_PERMIT";
24
+ CommandType[CommandType["WRAP_ETH"] = 11] = "WRAP_ETH";
25
+ CommandType[CommandType["UNWRAP_WETH"] = 12] = "UNWRAP_WETH";
26
+ CommandType[CommandType["PERMIT2_TRANSFER_FROM_BATCH"] = 13] = "PERMIT2_TRANSFER_FROM_BATCH";
27
+ CommandType[CommandType["BALANCE_CHECK_ERC20"] = 14] = "BALANCE_CHECK_ERC20";
28
+ CommandType[CommandType["V4_SWAP"] = 16] = "V4_SWAP";
29
+ CommandType[CommandType["V3_POSITION_MANAGER_PERMIT"] = 17] = "V3_POSITION_MANAGER_PERMIT";
30
+ CommandType[CommandType["V3_POSITION_MANAGER_CALL"] = 18] = "V3_POSITION_MANAGER_CALL";
31
+ CommandType[CommandType["V4_INITIALIZE_POOL"] = 19] = "V4_INITIALIZE_POOL";
32
+ CommandType[CommandType["V4_POSITION_MANAGER_CALL"] = 20] = "V4_POSITION_MANAGER_CALL";
33
+ CommandType[CommandType["EXECUTE_SUB_PLAN"] = 33] = "EXECUTE_SUB_PLAN";
34
+ // 3rd party integrations (0x40-0x5f range)
35
+ CommandType[CommandType["ACROSS_V4_DEPOSIT_V3"] = 64] = "ACROSS_V4_DEPOSIT_V3";
36
+ })(CommandType = exports.CommandType || (exports.CommandType = {}));
37
+ var Subparser;
38
+ (function (Subparser) {
39
+ Subparser[Subparser["V3PathExactIn"] = 0] = "V3PathExactIn";
40
+ Subparser[Subparser["V3PathExactOut"] = 1] = "V3PathExactOut";
41
+ })(Subparser = exports.Subparser || (exports.Subparser = {}));
42
+ var Parser;
43
+ (function (Parser) {
44
+ Parser[Parser["Abi"] = 0] = "Abi";
45
+ Parser[Parser["V4Actions"] = 1] = "V4Actions";
46
+ Parser[Parser["V3Actions"] = 2] = "V3Actions";
47
+ })(Parser = exports.Parser || (exports.Parser = {}));
48
+ const ALLOW_REVERT_FLAG = 0x80;
49
+ const REVERTIBLE_COMMANDS = new Set([CommandType.EXECUTE_SUB_PLAN]);
50
+ const PERMIT_STRUCT = '((address token,uint160 amount,uint48 expiration,uint48 nonce) details,address spender,uint256 sigDeadline)';
51
+ const PERMIT_BATCH_STRUCT = '((address token,uint160 amount,uint48 expiration,uint48 nonce)[] details,address spender,uint256 sigDeadline)';
52
+ const POOL_KEY_STRUCT = '(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)';
53
+ const PERMIT2_TRANSFER_FROM_STRUCT = '(address from,address to,uint160 amount,address token)';
54
+ const PERMIT2_TRANSFER_FROM_BATCH_STRUCT = PERMIT2_TRANSFER_FROM_STRUCT + '[]';
55
+ exports.COMMAND_DEFINITION = {
56
+ // Batch Reverts
57
+ [CommandType.EXECUTE_SUB_PLAN]: {
58
+ parser: Parser.Abi,
59
+ params: [
60
+ { name: 'commands', type: 'bytes' },
61
+ { name: 'inputs', type: 'bytes[]' },
62
+ ],
63
+ },
64
+ // Permit2 Actions
65
+ [CommandType.PERMIT2_PERMIT]: {
66
+ parser: Parser.Abi,
67
+ params: [
68
+ { name: 'permit', type: PERMIT_STRUCT },
69
+ { name: 'signature', type: 'bytes' },
70
+ ],
71
+ },
72
+ [CommandType.PERMIT2_PERMIT_BATCH]: {
73
+ parser: Parser.Abi,
74
+ params: [
75
+ { name: 'permit', type: PERMIT_BATCH_STRUCT },
76
+ { name: 'signature', type: 'bytes' },
77
+ ],
78
+ },
79
+ [CommandType.PERMIT2_TRANSFER_FROM]: {
80
+ parser: Parser.Abi,
81
+ params: [
82
+ { name: 'token', type: 'address' },
83
+ { name: 'recipient', type: 'address' },
84
+ { name: 'amount', type: 'uint160' },
85
+ ],
86
+ },
87
+ [CommandType.PERMIT2_TRANSFER_FROM_BATCH]: {
88
+ parser: Parser.Abi,
89
+ params: [
90
+ {
91
+ name: 'transferFrom',
92
+ type: PERMIT2_TRANSFER_FROM_BATCH_STRUCT,
93
+ },
94
+ ],
95
+ },
96
+ // Uniswap Actions
97
+ [CommandType.V3_SWAP_EXACT_IN]: {
98
+ parser: Parser.Abi,
99
+ params: [
100
+ { name: 'recipient', type: 'address' },
101
+ { name: 'amountIn', type: 'uint256' },
102
+ { name: 'amountOutMin', type: 'uint256' },
103
+ { name: 'path', subparser: Subparser.V3PathExactIn, type: 'bytes' },
104
+ { name: 'payerIsUser', type: 'bool' },
105
+ ],
106
+ },
107
+ [CommandType.V3_SWAP_EXACT_OUT]: {
108
+ parser: Parser.Abi,
109
+ params: [
110
+ { name: 'recipient', type: 'address' },
111
+ { name: 'amountOut', type: 'uint256' },
112
+ { name: 'amountInMax', type: 'uint256' },
113
+ { name: 'path', subparser: Subparser.V3PathExactOut, type: 'bytes' },
114
+ { name: 'payerIsUser', type: 'bool' },
115
+ ],
116
+ },
117
+ [CommandType.V2_SWAP_EXACT_IN]: {
118
+ parser: Parser.Abi,
119
+ params: [
120
+ { name: 'recipient', type: 'address' },
121
+ { name: 'amountIn', type: 'uint256' },
122
+ { name: 'amountOutMin', type: 'uint256' },
123
+ { name: 'path', type: 'address[]' },
124
+ { name: 'payerIsUser', type: 'bool' },
125
+ ],
126
+ },
127
+ [CommandType.V2_SWAP_EXACT_OUT]: {
128
+ parser: Parser.Abi,
129
+ params: [
130
+ { name: 'recipient', type: 'address' },
131
+ { name: 'amountOut', type: 'uint256' },
132
+ { name: 'amountInMax', type: 'uint256' },
133
+ { name: 'path', type: 'address[]' },
134
+ { name: 'payerIsUser', type: 'bool' },
135
+ ],
136
+ },
137
+ [CommandType.V4_SWAP]: { parser: Parser.V4Actions },
138
+ // Token Actions and Checks
139
+ [CommandType.WRAP_ETH]: {
140
+ parser: Parser.Abi,
141
+ params: [
142
+ { name: 'recipient', type: 'address' },
143
+ { name: 'amount', type: 'uint256' },
144
+ ],
145
+ },
146
+ [CommandType.UNWRAP_WETH]: {
147
+ parser: Parser.Abi,
148
+ params: [
149
+ { name: 'recipient', type: 'address' },
150
+ { name: 'amountMin', type: 'uint256' },
151
+ ],
152
+ },
153
+ [CommandType.SWEEP]: {
154
+ parser: Parser.Abi,
155
+ params: [
156
+ { name: 'token', type: 'address' },
157
+ { name: 'recipient', type: 'address' },
158
+ { name: 'amountMin', type: 'uint256' },
159
+ ],
160
+ },
161
+ [CommandType.TRANSFER]: {
162
+ parser: Parser.Abi,
163
+ params: [
164
+ { name: 'token', type: 'address' },
165
+ { name: 'recipient', type: 'address' },
166
+ { name: 'value', type: 'uint256' },
167
+ ],
168
+ },
169
+ [CommandType.PAY_PORTION]: {
170
+ parser: Parser.Abi,
171
+ params: [
172
+ { name: 'token', type: 'address' },
173
+ { name: 'recipient', type: 'address' },
174
+ { name: 'bips', type: 'uint256' },
175
+ ],
176
+ },
177
+ [CommandType.PAY_PORTION_FULL_PRECISION]: {
178
+ parser: Parser.Abi,
179
+ params: [
180
+ { name: 'token', type: 'address' },
181
+ { name: 'recipient', type: 'address' },
182
+ { name: 'portion', type: 'uint256' },
183
+ ],
184
+ },
185
+ [CommandType.BALANCE_CHECK_ERC20]: {
186
+ parser: Parser.Abi,
187
+ params: [
188
+ { name: 'owner', type: 'address' },
189
+ { name: 'token', type: 'address' },
190
+ { name: 'minBalance', type: 'uint256' },
191
+ ],
192
+ },
193
+ [CommandType.V4_INITIALIZE_POOL]: {
194
+ parser: Parser.Abi,
195
+ params: [
196
+ { name: 'poolKey', type: POOL_KEY_STRUCT },
197
+ { name: 'sqrtPriceX96', type: 'uint160' },
198
+ ],
199
+ },
200
+ // Position Actions
201
+ [CommandType.V3_POSITION_MANAGER_PERMIT]: { parser: Parser.V3Actions },
202
+ [CommandType.V3_POSITION_MANAGER_CALL]: { parser: Parser.V3Actions },
203
+ [CommandType.V4_POSITION_MANAGER_CALL]: { parser: Parser.V4Actions },
204
+ // 3rd Party Integrations
205
+ [CommandType.ACROSS_V4_DEPOSIT_V3]: {
206
+ parser: Parser.Abi,
207
+ params: [
208
+ { name: 'depositor', type: 'address' },
209
+ { name: 'recipient', type: 'address' },
210
+ { name: 'inputToken', type: 'address' },
211
+ { name: 'outputToken', type: 'address' },
212
+ { name: 'inputAmount', type: 'uint256' },
213
+ { name: 'outputAmount', type: 'uint256' },
214
+ { name: 'destinationChainId', type: 'uint256' },
215
+ { name: 'exclusiveRelayer', type: 'address' },
216
+ { name: 'quoteTimestamp', type: 'uint32' },
217
+ { name: 'fillDeadline', type: 'uint32' },
218
+ { name: 'exclusivityDeadline', type: 'uint32' },
219
+ { name: 'message', type: 'bytes' },
220
+ { name: 'useNative', type: 'bool' },
221
+ ],
222
+ },
223
+ };
224
+ // V2.1.1 ABI definitions for V2/V3 swap commands (extended with maxHopSlippage)
225
+ exports.V2V3_SWAP_COMMANDS_V2_1_1 = {
226
+ [CommandType.V3_SWAP_EXACT_IN]: {
227
+ parser: Parser.Abi,
228
+ params: [
229
+ { name: 'recipient', type: 'address' },
230
+ { name: 'amountIn', type: 'uint256' },
231
+ { name: 'amountOutMin', type: 'uint256' },
232
+ { name: 'path', subparser: Subparser.V3PathExactIn, type: 'bytes' },
233
+ { name: 'payerIsUser', type: 'bool' },
234
+ { name: 'maxHopSlippage', type: 'uint256[]' },
235
+ ],
236
+ },
237
+ [CommandType.V3_SWAP_EXACT_OUT]: {
238
+ parser: Parser.Abi,
239
+ params: [
240
+ { name: 'recipient', type: 'address' },
241
+ { name: 'amountOut', type: 'uint256' },
242
+ { name: 'amountInMax', type: 'uint256' },
243
+ { name: 'path', subparser: Subparser.V3PathExactOut, type: 'bytes' },
244
+ { name: 'payerIsUser', type: 'bool' },
245
+ { name: 'maxHopSlippage', type: 'uint256[]' },
246
+ ],
247
+ },
248
+ [CommandType.V2_SWAP_EXACT_IN]: {
249
+ parser: Parser.Abi,
250
+ params: [
251
+ { name: 'recipient', type: 'address' },
252
+ { name: 'amountIn', type: 'uint256' },
253
+ { name: 'amountOutMin', type: 'uint256' },
254
+ { name: 'path', type: 'address[]' },
255
+ { name: 'payerIsUser', type: 'bool' },
256
+ { name: 'maxHopSlippage', type: 'uint256[]' },
257
+ ],
258
+ },
259
+ [CommandType.V2_SWAP_EXACT_OUT]: {
260
+ parser: Parser.Abi,
261
+ params: [
262
+ { name: 'recipient', type: 'address' },
263
+ { name: 'amountOut', type: 'uint256' },
264
+ { name: 'amountInMax', type: 'uint256' },
265
+ { name: 'path', type: 'address[]' },
266
+ { name: 'payerIsUser', type: 'bool' },
267
+ { name: 'maxHopSlippage', type: 'uint256[]' },
268
+ ],
269
+ },
270
+ };
271
+ class RoutePlanner {
272
+ constructor() {
273
+ this.commands = '0x';
274
+ this.inputs = [];
275
+ }
276
+ addSubPlan(subplan) {
277
+ this.addCommand(CommandType.EXECUTE_SUB_PLAN, [subplan.commands, subplan.inputs], true);
278
+ return this;
279
+ }
280
+ addCommand(type, parameters, allowRevert = false, urVersion) {
281
+ let command = createCommand(type, parameters, urVersion);
282
+ this.inputs.push(command.encodedInput);
283
+ if (allowRevert) {
284
+ if (!REVERTIBLE_COMMANDS.has(command.type)) {
285
+ throw new Error(`command type: ${command.type} cannot be allowed to revert`);
286
+ }
287
+ command.type = command.type | ALLOW_REVERT_FLAG;
288
+ }
289
+ this.commands = this.commands.concat(command.type.toString(16).padStart(2, '0'));
290
+ return this;
291
+ }
292
+ /**
293
+ * Add Across bridge deposit command for cross-chain bridging
294
+ * @param params AcrossV4DepositV3Params containing bridge parameters
295
+ * @returns RoutePlanner instance for chaining
296
+ */
297
+ addAcrossBridge(params) {
298
+ this.addCommand(CommandType.ACROSS_V4_DEPOSIT_V3, [
299
+ params.depositor,
300
+ params.recipient,
301
+ params.inputToken,
302
+ params.outputToken,
303
+ params.inputAmount,
304
+ params.outputAmount,
305
+ params.destinationChainId,
306
+ params.exclusiveRelayer,
307
+ params.quoteTimestamp,
308
+ params.fillDeadline,
309
+ params.exclusivityDeadline,
310
+ params.message,
311
+ params.useNative,
312
+ ]);
313
+ return this;
314
+ }
315
+ }
316
+ exports.RoutePlanner = RoutePlanner;
317
+ function createCommand(type, parameters, urVersion) {
318
+ const commandDef = (0, v4_sdk_1.isAtLeastV2_1_1)(urVersion) && type in exports.V2V3_SWAP_COMMANDS_V2_1_1
319
+ ? exports.V2V3_SWAP_COMMANDS_V2_1_1[type]
320
+ : exports.COMMAND_DEFINITION[type];
321
+ switch (commandDef.parser) {
322
+ case Parser.Abi:
323
+ const encodedInput = utils_1.defaultAbiCoder.encode(commandDef.params.map((abi) => abi.type), parameters);
324
+ return { type, encodedInput };
325
+ case Parser.V4Actions:
326
+ // v4 swap data comes pre-encoded at index 0
327
+ return { type, encodedInput: parameters[0] };
328
+ case Parser.V3Actions:
329
+ // v3 swap data comes pre-encoded at index 0
330
+ return { type, encodedInput: parameters[0] };
331
+ }
332
+ }
333
+ exports.createCommand = createCommand;
334
+ //# sourceMappingURL=routerCommands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routerCommands.js","sourceRoot":"","sources":["../../../../src/utils/routerCommands.ts"],"names":[],"mappings":";;;AAAA,4CAAkD;AAClD,4CAA4D;AAG5D;;;;GAIG;AACH,IAAY,WA4BX;AA5BD,WAAY,WAAW;IACrB,qEAAuB,CAAA;IACvB,uEAAwB,CAAA;IACxB,+EAA4B,CAAA;IAC5B,6EAA2B,CAAA;IAC3B,+CAAY,CAAA;IACZ,qDAAe,CAAA;IACf,2DAAkB,CAAA;IAClB,yFAAiC,CAAA;IAEjC,qEAAuB,CAAA;IACvB,uEAAwB,CAAA;IACxB,kEAAqB,CAAA;IACrB,sDAAe,CAAA;IACf,4DAAkB,CAAA;IAClB,4FAAkC,CAAA;IAClC,4EAA0B,CAAA;IAE1B,oDAAc,CAAA;IACd,0FAAiC,CAAA;IACjC,sFAA+B,CAAA;IAC/B,0EAAyB,CAAA;IACzB,sFAA+B,CAAA;IAE/B,sEAAuB,CAAA;IAEvB,2CAA2C;IAC3C,8EAA2B,CAAA;AAC7B,CAAC,EA5BW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QA4BtB;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,2DAAa,CAAA;IACb,6DAAc,CAAA;AAChB,CAAC,EAHW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAGpB;AAED,IAAY,MAIX;AAJD,WAAY,MAAM;IAChB,iCAAG,CAAA;IACH,6CAAS,CAAA;IACT,6CAAS,CAAA;AACX,CAAC,EA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rade } 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
- }
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
+ }
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RouterTradeAdapter = exports.isNativeCurrency = exports.PoolType = void 0;
4
+ const router_sdk_1 = require("@uniswap/router-sdk");
5
+ const sdk_core_1 = require("@uniswap/sdk-core");
6
+ const v2_sdk_1 = require("@uniswap/v2-sdk");
7
+ const v3_sdk_1 = require("@uniswap/v3-sdk");
8
+ const v4_sdk_1 = require("@uniswap/v4-sdk");
9
+ const ethers_1 = require("ethers");
10
+ const constants_1 = require("./constants");
11
+ var PoolType;
12
+ (function (PoolType) {
13
+ PoolType["V2Pool"] = "v2-pool";
14
+ PoolType["V3Pool"] = "v3-pool";
15
+ PoolType["V4Pool"] = "v4-pool";
16
+ })(PoolType = exports.PoolType || (exports.PoolType = {}));
17
+ const isNativeCurrency = (address) => address.toLowerCase() === constants_1.ETH_ADDRESS.toLowerCase() || address.toLowerCase() === constants_1.E_ETH_ADDRESS.toLowerCase();
18
+ exports.isNativeCurrency = isNativeCurrency;
19
+ // Helper class to convert routing-specific quote entities to RouterTrade entities
20
+ // the returned RouterTrade can then be used to build the UniswapTrade entity in this package
21
+ class RouterTradeAdapter {
22
+ // Generate a RouterTrade using fields from a classic quote response
23
+ static fromClassicQuote(quote) {
24
+ const { route, tokenIn, tokenOut } = quote;
25
+ if (!route)
26
+ throw new Error('Expected route to be present');
27
+ if (!route.length)
28
+ throw new Error('Expected there to be at least one route');
29
+ if (route.some((r) => !r.length))
30
+ throw new Error('Expected all routes to have at least one pool');
31
+ const firstRoute = route[0];
32
+ const tokenInData = firstRoute[0].tokenIn;
33
+ const tokenOutData = firstRoute[firstRoute.length - 1].tokenOut;
34
+ if (!tokenInData || !tokenOutData)
35
+ throw new Error('Expected both tokenIn and tokenOut to be present');
36
+ if (tokenInData.chainId !== tokenOutData.chainId)
37
+ throw new Error('Expected tokenIn and tokenOut to be have same chainId');
38
+ const parsedCurrencyIn = RouterTradeAdapter.toCurrency((0, exports.isNativeCurrency)(tokenIn), tokenInData);
39
+ const parsedCurrencyOut = RouterTradeAdapter.toCurrency((0, exports.isNativeCurrency)(tokenOut), tokenOutData);
40
+ const typedRoutes = route.map((subRoute) => {
41
+ const rawAmountIn = subRoute[0].amountIn;
42
+ const rawAmountOut = subRoute[subRoute.length - 1].amountOut;
43
+ if (!rawAmountIn || !rawAmountOut) {
44
+ throw new Error('Expected both raw amountIn and raw amountOut to be present');
45
+ }
46
+ const inputAmount = sdk_core_1.CurrencyAmount.fromRawAmount(parsedCurrencyIn, rawAmountIn);
47
+ const outputAmount = sdk_core_1.CurrencyAmount.fromRawAmount(parsedCurrencyOut, rawAmountOut);
48
+ const isOnlyV2 = RouterTradeAdapter.isVersionedRoute(PoolType.V2Pool, subRoute);
49
+ const isOnlyV3 = RouterTradeAdapter.isVersionedRoute(PoolType.V3Pool, subRoute);
50
+ const isOnlyV4 = RouterTradeAdapter.isVersionedRoute(PoolType.V4Pool, subRoute);
51
+ return {
52
+ routev4: isOnlyV4
53
+ ? new v4_sdk_1.Route(subRoute.map(RouterTradeAdapter.toV4Pool), parsedCurrencyIn, parsedCurrencyOut)
54
+ : null,
55
+ routev3: isOnlyV3
56
+ ? new v3_sdk_1.Route(subRoute.map(RouterTradeAdapter.toV3Pool), parsedCurrencyIn, parsedCurrencyOut)
57
+ : null,
58
+ routev2: isOnlyV2
59
+ ? new v2_sdk_1.Route(subRoute.map(RouterTradeAdapter.toPair), parsedCurrencyIn, parsedCurrencyOut)
60
+ : null,
61
+ mixedRoute: !isOnlyV4 && !isOnlyV3 && !isOnlyV2
62
+ ? new router_sdk_1.MixedRouteSDK(subRoute.map(RouterTradeAdapter.toPoolOrPair), parsedCurrencyIn, parsedCurrencyOut)
63
+ : null,
64
+ inputAmount,
65
+ outputAmount,
66
+ };
67
+ });
68
+ return new router_sdk_1.Trade({
69
+ v2Routes: typedRoutes
70
+ .filter((route) => route.routev2)
71
+ .map((route) => ({
72
+ routev2: route.routev2,
73
+ inputAmount: route.inputAmount,
74
+ outputAmount: route.outputAmount,
75
+ })),
76
+ v3Routes: typedRoutes
77
+ .filter((route) => route.routev3)
78
+ .map((route) => ({
79
+ routev3: route.routev3,
80
+ inputAmount: route.inputAmount,
81
+ outputAmount: route.outputAmount,
82
+ })),
83
+ v4Routes: typedRoutes
84
+ .filter((route) => route.routev4)
85
+ .map((route) => ({
86
+ routev4: route.routev4,
87
+ inputAmount: route.inputAmount,
88
+ outputAmount: route.outputAmount,
89
+ })),
90
+ mixedRoutes: typedRoutes
91
+ .filter((route) => route.mixedRoute)
92
+ .map((route) => ({
93
+ mixedRoute: route.mixedRoute,
94
+ inputAmount: route.inputAmount,
95
+ outputAmount: route.outputAmount,
96
+ })),
97
+ tradeType: quote.tradeType,
98
+ });
99
+ }
100
+ static toCurrency(isNative, token) {
101
+ if (isNative) {
102
+ return sdk_core_1.Ether.onChain(token.chainId);
103
+ }
104
+ return this.toToken(token);
105
+ }
106
+ static toToken(token) {
107
+ const { chainId, address, decimals, symbol, buyFeeBps, sellFeeBps } = token;
108
+ return new sdk_core_1.Token(chainId, address, parseInt(decimals.toString()), symbol,
109
+ /* name */ undefined, false, buyFeeBps ? ethers_1.BigNumber.from(buyFeeBps) : undefined, sellFeeBps ? ethers_1.BigNumber.from(sellFeeBps) : undefined);
110
+ }
111
+ static toV3Pool({ fee, sqrtRatioX96, liquidity, tickCurrent, tokenIn, tokenOut }) {
112
+ return new v3_sdk_1.Pool(RouterTradeAdapter.toToken(tokenIn), RouterTradeAdapter.toToken(tokenOut), parseInt(fee), sqrtRatioX96, liquidity, parseInt(tickCurrent));
113
+ }
114
+ static toV4Pool(pool) {
115
+ const parsedCurrencyIn = RouterTradeAdapter.toCurrency((0, exports.isNativeCurrency)(pool.tokenIn.address), pool.tokenIn);
116
+ const parsedCurrencyOut = RouterTradeAdapter.toCurrency((0, exports.isNativeCurrency)(pool.tokenOut.address), pool.tokenOut);
117
+ return new v4_sdk_1.Pool(parsedCurrencyIn, parsedCurrencyOut, parseInt(pool.fee), parseInt(pool.tickSpacing), pool.hooks, pool.sqrtRatioX96, pool.liquidity, parseInt(pool.tickCurrent));
118
+ }
119
+ static isVersionedRoute(type, route) {
120
+ return route.every((pool) => pool.type === type);
121
+ }
122
+ }
123
+ exports.RouterTradeAdapter = RouterTradeAdapter;
124
+ RouterTradeAdapter.toPoolOrPair = (pool) => {
125
+ switch (pool.type) {
126
+ case PoolType.V4Pool:
127
+ return RouterTradeAdapter.toV4Pool(pool);
128
+ case PoolType.V3Pool:
129
+ return RouterTradeAdapter.toV3Pool(pool);
130
+ case PoolType.V2Pool:
131
+ return RouterTradeAdapter.toPair(pool);
132
+ default:
133
+ throw new Error('Invalid pool type');
134
+ }
135
+ };
136
+ RouterTradeAdapter.toPair = ({ reserve0, reserve1 }) => {
137
+ return new v2_sdk_1.Pair(sdk_core_1.CurrencyAmount.fromRawAmount(RouterTradeAdapter.toToken(reserve0.token), reserve0.quotient), sdk_core_1.CurrencyAmount.fromRawAmount(RouterTradeAdapter.toToken(reserve1.token), reserve1.quotient));
138
+ };
139
+ //# sourceMappingURL=routerTradeAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routerTradeAdapter.js","sourceRoot":"","sources":["../../../../src/utils/routerTradeAdapter.ts"],"names":[],"mappings":";;;AAAA,oDAAyE;AACzE,gDAAqF;AACrF,4CAAwD;AACxD,4CAA6E;AAC7E,4CAAkE;AAClE,mCAAkC;AAClC,2CAAwD;AAYxD,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,8BAAkB,CAAA;IAClB,8BAAkB,CAAA;IAClB,8BAAkB,CAAA;AACpB,CAAC,EAJW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAInB;AA+DM,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAE,EAAE,CA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AC1C,KAAK,QAAQ,CAAC,MAAM;YAClB,OAAO,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAC1C,KAAK,QAAQ,CAAC,MAAM;YAClB,OAAO,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACxC;YACE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;KACvC;AACH,CAAC,CAAA;AA0Cc,yBAAM,GAAG,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAiB,EAAQ,EAAE;IACtE,OAAO,IAAI,aAAI,CACb,yBAAc,CAAC,aAAa,CAAC,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAC3F,yBAAc,CAAC,aAAa,CAAC,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAC5F,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ import { RoutePlanner } from '../utils/routerCommands';
2
+ export type TradeConfig = {
3
+ allowRevert: boolean;
4
+ };
5
+ export declare enum RouterActionType {
6
+ UniswapTrade = "UniswapTrade",
7
+ UnwrapWETH = "UnwrapWETH"
8
+ }
9
+ export interface Command {
10
+ tradeType: RouterActionType;
11
+ encode(planner: RoutePlanner, config: TradeConfig): void;
12
+ }