@uniswap/universal-router-sdk 4.34.1 → 4.35.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
package/README.md CHANGED
@@ -39,71 +39,87 @@ forge install
39
39
  yarn test:forge
40
40
  ```
41
41
 
42
- ## Per-Hop Slippage Protection (V4 Routes)
42
+ ## Per-Hop Slippage Protection
43
43
 
44
- Universal Router v2.1 adds granular slippage protection for multi-hop V4 swaps. Additionally to checking slippage at the end of a route, you can now verify that each individual hop doesn't exceed a maximum price limit.
44
+ Universal Router v2.1.1 adds granular slippage protection for multi-hop swaps across all protocol versions (V2, V3, V4, and mixed routes). In addition to the overall trade-level slippage check, the contract can verify that each individual pool hop doesn't exceed a maximum price limit.
45
45
 
46
46
  ### How It Works
47
47
 
48
- For V4 multi-hop swaps, you can provide a `maxHopSlippage` array in your swap options:
48
+ Per-hop slippage bounds live on each swap's route data (via `RouterTrade`). The `maxHopSlippage` array on each route maps 1:1 to the route's pools: `maxHopSlippage[i]` constrains `route.pools[i]`.
49
+
50
+ To enable the V2.1.1 ABI encoding (which includes the `maxHopSlippage` parameter), set `urVersion: URVersion.V2_1_1` on your swap options.
49
51
 
50
52
  ```typescript
51
53
  import { SwapRouter } from '@uniswap/universal-router-sdk'
52
- import { BigNumber } from 'ethers'
53
- import { Percent } from '@uniswap/sdk-core'
54
+ import { Trade as RouterTrade } from '@uniswap/router-sdk'
55
+ import { URVersion } from '@uniswap/v4-sdk'
56
+ import { Percent, TradeType } from '@uniswap/sdk-core'
54
57
 
55
- const swapOptions = {
58
+ // 1. Build a trade with per-hop slippage on each route
59
+ const trade = new RouterTrade({
60
+ v3Routes: [
61
+ {
62
+ routev3: myV3Route, // e.g. USDC → DAI → WETH
63
+ inputAmount,
64
+ outputAmount,
65
+ maxHopSlippage: [
66
+ // one entry per pool in the route
67
+ BigInt('1010000000000000000'), // Hop 0: USDC→DAI, max price 1.01
68
+ BigInt('2500000000000000000000'), // Hop 1: DAI→WETH, max price 2500
69
+ ],
70
+ },
71
+ ],
72
+ tradeType: TradeType.EXACT_INPUT,
73
+ })
74
+
75
+ // 2. Encode with V2.1.1 ABI
76
+ const { calldata, value } = SwapRouter.swapCallParameters(trade, {
56
77
  slippageTolerance: new Percent(50, 10000), // 0.5% overall slippage
57
78
  recipient: '0x...',
58
- deadline: Math.floor(Date.now() / 1000) + 60 * 20,
59
- // Optional: per-hop slippage protection for V4 routes
60
- maxHopSlippage: [
61
- BigNumber.from('1010000000000000000'), // Hop 0: max price 1.01 (1% slippage)
62
- BigNumber.from('2500000000000000000000'), // Hop 1: max price 2500
63
- ]
64
- }
65
-
66
- const { calldata, value } = SwapRouter.swapCallParameters(trade, swapOptions)
79
+ urVersion: URVersion.V2_1_1, // required for per-hop encoding
80
+ })
67
81
  ```
68
82
 
69
83
  ### Price Calculation
70
84
 
71
- The slippage is expressed as a **price** with 18 decimals of precision:
85
+ Slippage is expressed as a **price** with 18 decimals of precision:
72
86
 
73
- - **For Exact Input**: `price = amountIn * 1e18 / amountOut`
74
- - **For Exact Output**: `price = amountIn * 1e18 / amountOut`
87
+ - `price = amountIn * 1e18 / amountOut`
75
88
 
76
- If the calculated price exceeds `maxHopSlippage[i]`, the transaction will revert with:
89
+ If the calculated price for hop `i` exceeds `maxHopSlippage[i]`, the transaction reverts.
77
90
 
78
- - `V4TooLittleReceivedPerHop` for exact input swaps
79
- - `V4TooMuchRequestedPerHop` for exact output swaps
91
+ ### Mixed Routes
80
92
 
81
- ### Example: USDCDAIWETH
93
+ For mixed routes that span multiple protocol versions (e.g. V3 pool V4 pool V2 pool), the SDK automatically slices the flat `maxHopSlippage` array by section. Each protocol section receives the corresponding slice of hop bounds:
82
94
 
83
95
  ```typescript
84
- // 2-hop swap: USDC → DAI → WETH
85
- const swapOptions = {
86
- slippageTolerance: new Percent(100, 10000), // 1% overall
87
- recipient: userAddress,
88
- deadline,
89
- maxHopSlippage: [
90
- BigNumber.from('1010000000000000000'), // Hop 0: USDC→DAI, max 1% slippage
91
- BigNumber.from('2500000000000000000000'), // Hop 1: DAI→WETH, max price 2500 DAI/WETH
92
- ]
93
- }
96
+ const trade = new RouterTrade({
97
+ mixedRoutes: [
98
+ {
99
+ mixedRoute: myMixedRoute, // V3 pool, V3 pool, V2 pool
100
+ inputAmount,
101
+ outputAmount,
102
+ maxHopSlippage: [
103
+ BigInt('1010000000000000000'), // Hop 0 (V3 section)
104
+ BigInt('2500000000000000000000'), // Hop 1 (V3 section)
105
+ BigInt('1005000000000000000'), // Hop 2 (V2 section)
106
+ ],
107
+ },
108
+ ],
109
+ tradeType: TradeType.EXACT_INPUT,
110
+ })
94
111
  ```
95
112
 
96
113
  ### Benefits
97
114
 
98
- 1. **MEV Protection**: Prevents sandwich attacks on individual hops
99
- 2. **Route Quality**: Ensures each segment of a multi-hop route meets expectations
100
- 3. **Granular Control**: Different slippage tolerance for different pairs in a route
115
+ 1. **MEV Protection**: Prevents sandwich attacks on individual pool hops
116
+ 2. **Route Quality**: Ensures each segment of a multi-hop route meets price expectations
117
+ 3. **Granular Control**: Different slippage tolerances for different pairs (e.g. tighter bounds on stablecoin hops)
101
118
 
102
119
  ### Backward Compatibility
103
120
 
104
- - If `maxHopSlippage` is not provided or is an empty array, only overall slippage is checked (backward compatible)
105
- - The feature only applies to V4 routes; V2 and V3 routes ignore this parameter
106
- - Mixed routes with V4 sections will apply per-hop checks only to the V4 portions
121
+ - If `maxHopSlippage` is omitted or is an empty array, only the overall trade-level slippage is checked
122
+ - If `urVersion` is not set (defaults to V2.0), commands use the standard ABI without `maxHopSlippage`
107
123
 
108
124
  ## Signed Routes (Universal Router v2.1)
109
125
 
@@ -133,9 +149,9 @@ const { calldata, value } = SwapRouter.swapCallParameters(trade, {
133
149
  const payload = SwapRouter.getExecuteSignedPayload(
134
150
  calldata,
135
151
  {
136
- intent: '0x' + '0'.repeat(64), // Application-specific intent
137
- data: '0x' + '0'.repeat(64), // Application-specific data
138
- sender: wallet.address, // Or address(0) to skip sender verification
152
+ intent: '0x' + '0'.repeat(64), // Application-specific intent
153
+ data: '0x' + '0'.repeat(64), // Application-specific data
154
+ sender: wallet.address, // Or address(0) to skip sender verification
139
155
  },
140
156
  deadline,
141
157
  chainId,
@@ -153,7 +169,7 @@ const { calldata: signedCalldata, value: signedValue } = SwapRouter.encodeExecut
153
169
  intent: payload.value.intent,
154
170
  data: payload.value.data,
155
171
  sender: payload.value.sender,
156
- nonce: payload.value.nonce, // Must match what was signed
172
+ nonce: payload.value.nonce, // Must match what was signed
157
173
  },
158
174
  deadline,
159
175
  BigNumber.from(value)
@@ -182,8 +198,8 @@ const payload = SwapRouter.getExecuteSignedPayload(
182
198
  {
183
199
  intent: '0x...',
184
200
  data: '0x...',
185
- sender: '0x0000000000000000000000000000000000000000', // Skip sender verification too
186
- nonce: NONCE_SKIP_CHECK, // Allow signature reuse
201
+ sender: '0x0000000000000000000000000000000000000000', // Skip sender verification too
202
+ nonce: NONCE_SKIP_CHECK, // Allow signature reuse
187
203
  },
188
204
  deadline,
189
205
  chainId,
@@ -209,28 +225,24 @@ import { SwapRouter } from '@uniswap/universal-router-sdk'
209
225
  import { BigNumber } from 'ethers'
210
226
 
211
227
  // 1. Prepare your swap (e.g., USDC → WETH on mainnet)
212
- const { calldata, value } = SwapRouter.swapCallParameters(
213
- trade,
214
- swapOptions,
215
- [
216
- {
217
- // Bridge configuration
218
- depositor: userAddress,
219
- recipient: userAddress, // Recipient on destination chain
220
- inputToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH mainnet
221
- outputToken: '0x4200000000000000000000000000000000000006', // WETH optimism
222
- inputAmount: BigNumber.from('1000000000000000000'), // 1 WETH
223
- outputAmount: BigNumber.from('990000000000000000'), // 0.99 WETH (with fees)
224
- destinationChainId: 10, // Optimism
225
- exclusiveRelayer: '0x0000000000000000000000000000000000000000',
226
- quoteTimestamp: Math.floor(Date.now() / 1000),
227
- fillDeadline: Math.floor(Date.now() / 1000) + 3600,
228
- exclusivityDeadline: 0,
229
- message: '0x',
230
- useNative: false,
231
- }
232
- ]
233
- )
228
+ const { calldata, value } = SwapRouter.swapCallParameters(trade, swapOptions, [
229
+ {
230
+ // Bridge configuration
231
+ depositor: userAddress,
232
+ recipient: userAddress, // Recipient on destination chain
233
+ inputToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH mainnet
234
+ outputToken: '0x4200000000000000000000000000000000000006', // WETH optimism
235
+ inputAmount: BigNumber.from('1000000000000000000'), // 1 WETH
236
+ outputAmount: BigNumber.from('990000000000000000'), // 0.99 WETH (with fees)
237
+ destinationChainId: 10, // Optimism
238
+ exclusiveRelayer: '0x0000000000000000000000000000000000000000',
239
+ quoteTimestamp: Math.floor(Date.now() / 1000),
240
+ fillDeadline: Math.floor(Date.now() / 1000) + 3600,
241
+ exclusivityDeadline: 0,
242
+ message: '0x',
243
+ useNative: false,
244
+ },
245
+ ])
234
246
  ```
235
247
 
236
248
  ### Swap + Bridge Example
@@ -239,24 +251,24 @@ const { calldata, value } = SwapRouter.swapCallParameters(
239
251
  // Swap USDC to WETH, then bridge WETH to Optimism
240
252
  const bridgeParams = {
241
253
  depositor: userAddress,
242
- recipient: userAddress, // Can be different address on destination
254
+ recipient: userAddress, // Can be different address on destination
243
255
  inputToken: WETH_MAINNET,
244
256
  outputToken: WETH_OPTIMISM,
245
- inputAmount: CONTRACT_BALANCE, // Use entire swap output
257
+ inputAmount: CONTRACT_BALANCE, // Use entire swap output
246
258
  outputAmount: expectedOutputAmount,
247
259
  destinationChainId: 10,
248
260
  exclusiveRelayer: '0x0000000000000000000000000000000000000000',
249
261
  quoteTimestamp: Math.floor(Date.now() / 1000),
250
262
  fillDeadline: Math.floor(Date.now() / 1000) + 3600,
251
263
  exclusivityDeadline: 0,
252
- message: '0x', // Optional message to execute on destination
253
- useNative: false, // Set to true to bridge native ETH
264
+ message: '0x', // Optional message to execute on destination
265
+ useNative: false, // Set to true to bridge native ETH
254
266
  }
255
267
 
256
268
  const { calldata, value } = SwapRouter.swapCallParameters(
257
269
  trade,
258
270
  swapOptions,
259
- [bridgeParams] // Array of bridge operations
271
+ [bridgeParams] // Array of bridge operations
260
272
  )
261
273
  ```
262
274
 
@@ -269,7 +281,7 @@ import { CONTRACT_BALANCE } from '@uniswap/universal-router-sdk'
269
281
 
270
282
  const bridgeParams = {
271
283
  // ... other params
272
- inputAmount: CONTRACT_BALANCE, // Bridge entire balance after swap
284
+ inputAmount: CONTRACT_BALANCE, // Bridge entire balance after swap
273
285
  // ... other params
274
286
  }
275
287
  ```
@@ -279,28 +291,24 @@ const bridgeParams = {
279
291
  You can perform multiple bridge operations after a swap:
280
292
 
281
293
  ```typescript
282
- const { calldata, value } = SwapRouter.swapCallParameters(
283
- trade,
284
- swapOptions,
285
- [
286
- {
287
- // Bridge 50% to Optimism
288
- inputToken: WETH_MAINNET,
289
- outputToken: WETH_OPTIMISM,
290
- inputAmount: BigNumber.from('500000000000000000'),
291
- destinationChainId: 10,
292
- // ... other params
293
- },
294
- {
295
- // Bridge remaining USDC to Arbitrum
296
- inputToken: USDC_MAINNET,
297
- outputToken: USDC_ARBITRUM,
298
- inputAmount: CONTRACT_BALANCE,
299
- destinationChainId: 42161,
300
- // ... other params
301
- }
302
- ]
303
- )
294
+ const { calldata, value } = SwapRouter.swapCallParameters(trade, swapOptions, [
295
+ {
296
+ // Bridge 50% to Optimism
297
+ inputToken: WETH_MAINNET,
298
+ outputToken: WETH_OPTIMISM,
299
+ inputAmount: BigNumber.from('500000000000000000'),
300
+ destinationChainId: 10,
301
+ // ... other params
302
+ },
303
+ {
304
+ // Bridge remaining USDC to Arbitrum
305
+ inputToken: USDC_MAINNET,
306
+ outputToken: USDC_ARBITRUM,
307
+ inputAmount: CONTRACT_BALANCE,
308
+ destinationChainId: 42161,
309
+ // ... other params
310
+ },
311
+ ])
304
312
  ```
305
313
 
306
314
  ### Native ETH Bridging
@@ -309,9 +317,9 @@ To bridge native ETH instead of WETH:
309
317
 
310
318
  ```typescript
311
319
  const bridgeParams = {
312
- inputToken: WETH_ADDRESS, // Must be WETH address
320
+ inputToken: WETH_ADDRESS, // Must be WETH address
313
321
  outputToken: WETH_ON_DESTINATION,
314
- useNative: true, // Bridge as native ETH
322
+ useNative: true, // Bridge as native ETH
315
323
  // ... other params
316
324
  }
317
325
  ```
@@ -1,12 +1,12 @@
1
- import { RoutePlanner } from '../utils/routerCommands';
2
- export declare 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
- }
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
+ }
@@ -0,0 +1,9 @@
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
@@ -0,0 +1 @@
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,21 +1,21 @@
1
- import { BigNumberish } from 'ethers';
2
- /**
3
- * Parameters for Across V4 Deposit V3 command
4
- * Used for cross-chain bridging via Across Protocol V3 SpokePool
5
- */
6
- export declare type AcrossV4DepositV3Params = {
7
- depositor: string;
8
- recipient: string;
9
- inputToken: string;
10
- outputToken: string;
11
- inputAmount: BigNumberish;
12
- outputAmount: BigNumberish;
13
- destinationChainId: number;
14
- exclusiveRelayer: string;
15
- quoteTimestamp: number;
16
- fillDeadline: number;
17
- exclusivityDeadline: number;
18
- message: string;
19
- useNative: boolean;
20
- };
21
- export { CONTRACT_BALANCE } from '../../utils/constants';
1
+ import { BigNumberish } from 'ethers';
2
+ /**
3
+ * Parameters for Across V4 Deposit V3 command
4
+ * Used for cross-chain bridging via Across Protocol V3 SpokePool
5
+ */
6
+ export type AcrossV4DepositV3Params = {
7
+ depositor: string;
8
+ recipient: string;
9
+ inputToken: string;
10
+ outputToken: string;
11
+ inputAmount: BigNumberish;
12
+ outputAmount: BigNumberish;
13
+ destinationChainId: number;
14
+ exclusiveRelayer: string;
15
+ quoteTimestamp: number;
16
+ fillDeadline: number;
17
+ exclusivityDeadline: number;
18
+ message: string;
19
+ useNative: boolean;
20
+ };
21
+ export { CONTRACT_BALANCE } from '../../utils/constants';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CONTRACT_BALANCE = void 0;
4
+ // Export CONTRACT_BALANCE constant for convenience
5
+ var constants_1 = require("../../utils/constants");
6
+ Object.defineProperty(exports, "CONTRACT_BALANCE", { enumerable: true, get: function () { return constants_1.CONTRACT_BALANCE; } });
7
+ //# sourceMappingURL=across.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"across.js","sourceRoot":"","sources":["../../../../../src/entities/actions/across.ts"],"names":[],"mappings":";;;AAsBA,mDAAmD;AACnD,mDAAwD;AAA/C,6GAAA,gBAAgB,OAAA"}
@@ -1,3 +1,3 @@
1
- export * from './uniswap';
2
- export * from './unwrapWETH';
3
- export * from './across';
1
+ export * from './uniswap';
2
+ export * from './unwrapWETH';
3
+ export * from './across';
@@ -0,0 +1,7 @@
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
+ tslib_1.__exportStar(require("./across"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/entities/actions/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,uDAA4B;AAC5B,mDAAwB"}
@@ -1,39 +1,38 @@
1
- import { RoutePlanner } from '../../utils/routerCommands';
2
- import { URVersion } from '@uniswap/v4-sdk';
3
- import { Trade as RouterTrade, SwapOptions as RouterSwapOptions } from '@uniswap/router-sdk';
4
- import { Permit2Permit } from '../../utils/inputTokens';
5
- import { Currency, TradeType } from '@uniswap/sdk-core';
6
- import { Command, RouterActionType, TradeConfig } from '../Command';
7
- import { BigNumber, BigNumberish } from 'ethers';
8
- export declare type FlatFeeOptions = {
9
- amount: BigNumberish;
10
- recipient: string;
11
- };
12
- export declare enum TokenTransferMode {
13
- Permit2 = "Permit2",
14
- ApproveProxy = "ApproveProxy"
15
- }
16
- export declare type SwapOptions = Omit<RouterSwapOptions, 'inputTokenPermit'> & {
17
- useRouterBalance?: boolean;
18
- inputTokenPermit?: Permit2Permit;
19
- flatFee?: FlatFeeOptions;
20
- safeMode?: boolean;
21
- maxHopSlippage?: BigNumber[];
22
- urVersion?: URVersion;
23
- tokenTransferMode?: TokenTransferMode;
24
- chainId?: number;
25
- };
26
- export declare class UniswapTrade implements Command {
27
- trade: RouterTrade<Currency, Currency, TradeType>;
28
- options: SwapOptions;
29
- readonly tradeType: RouterActionType;
30
- readonly payerIsUser: boolean;
31
- constructor(trade: RouterTrade<Currency, Currency, TradeType>, options: SwapOptions);
32
- get isAllV4(): boolean;
33
- get inputRequiresWrap(): boolean;
34
- get inputRequiresUnwrap(): boolean;
35
- get outputRequiresWrap(): boolean;
36
- get outputRequiresUnwrap(): boolean;
37
- get outputRequiresTransition(): boolean;
38
- encode(planner: RoutePlanner, _config: TradeConfig): void;
39
- }
1
+ import { RoutePlanner } from '../../utils/routerCommands';
2
+ import { URVersion } from '@uniswap/v4-sdk';
3
+ import { Trade as RouterTrade, SwapOptions as RouterSwapOptions } from '@uniswap/router-sdk';
4
+ import { Permit2Permit } from '../../utils/inputTokens';
5
+ import { Currency, TradeType } from '@uniswap/sdk-core';
6
+ import { Command, RouterActionType, TradeConfig } from '../Command';
7
+ import { BigNumberish } from 'ethers';
8
+ export type FlatFeeOptions = {
9
+ amount: BigNumberish;
10
+ recipient: string;
11
+ };
12
+ export declare enum TokenTransferMode {
13
+ Permit2 = "Permit2",
14
+ ApproveProxy = "ApproveProxy"
15
+ }
16
+ export type SwapOptions = Omit<RouterSwapOptions, 'inputTokenPermit'> & {
17
+ useRouterBalance?: boolean;
18
+ inputTokenPermit?: Permit2Permit;
19
+ flatFee?: FlatFeeOptions;
20
+ safeMode?: boolean;
21
+ urVersion?: URVersion;
22
+ tokenTransferMode?: TokenTransferMode;
23
+ chainId?: number;
24
+ };
25
+ export declare class UniswapTrade implements Command {
26
+ trade: RouterTrade<Currency, Currency, TradeType>;
27
+ options: SwapOptions;
28
+ readonly tradeType: RouterActionType;
29
+ readonly payerIsUser: boolean;
30
+ constructor(trade: RouterTrade<Currency, Currency, TradeType>, options: SwapOptions);
31
+ get isAllV4(): boolean;
32
+ get inputRequiresWrap(): boolean;
33
+ get inputRequiresUnwrap(): boolean;
34
+ get outputRequiresWrap(): boolean;
35
+ get outputRequiresUnwrap(): boolean;
36
+ get outputRequiresTransition(): boolean;
37
+ encode(planner: RoutePlanner, _config: TradeConfig): void;
38
+ }