@uniswap/universal-router-sdk 4.34.2 → 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.
- package/README.md +104 -96
- package/dist/{entities → cjs/src/entities}/Command.d.ts +12 -12
- package/dist/cjs/src/entities/Command.js +9 -0
- package/dist/cjs/src/entities/Command.js.map +1 -0
- package/dist/{entities → cjs/src/entities}/actions/across.d.ts +21 -21
- package/dist/cjs/src/entities/actions/across.js +7 -0
- package/dist/cjs/src/entities/actions/across.js.map +1 -0
- package/dist/{entities → cjs/src/entities}/actions/index.d.ts +3 -3
- package/dist/cjs/src/entities/actions/index.js +7 -0
- package/dist/cjs/src/entities/actions/index.js.map +1 -0
- package/dist/{entities → cjs/src/entities}/actions/uniswap.d.ts +38 -39
- package/dist/cjs/src/entities/actions/uniswap.js +532 -0
- package/dist/cjs/src/entities/actions/uniswap.js.map +1 -0
- package/dist/{entities → cjs/src/entities}/actions/unwrapWETH.d.ts +12 -12
- package/dist/cjs/src/entities/actions/unwrapWETH.js +33 -0
- package/dist/cjs/src/entities/actions/unwrapWETH.js.map +1 -0
- package/dist/{entities → cjs/src/entities}/index.d.ts +2 -2
- package/dist/cjs/src/entities/index.js +6 -0
- package/dist/cjs/src/entities/index.js.map +1 -0
- package/dist/{index.d.ts → cjs/src/index.d.ts} +12 -12
- package/dist/cjs/src/index.js +33 -0
- package/dist/cjs/src/index.js.map +1 -0
- package/dist/{swapRouter.d.ts → cjs/src/swapRouter.d.ts} +87 -87
- package/dist/cjs/src/swapRouter.js +276 -0
- package/dist/cjs/src/swapRouter.js.map +1 -0
- package/dist/{utils → cjs/src/utils}/commandParser.d.ts +34 -34
- package/dist/cjs/src/utils/commandParser.js +145 -0
- package/dist/cjs/src/utils/commandParser.js.map +1 -0
- package/dist/{utils → cjs/src/utils}/constants.d.ts +33 -33
- package/dist/cjs/src/utils/constants.js +541 -0
- package/dist/cjs/src/utils/constants.js.map +1 -0
- package/dist/{utils → cjs/src/utils}/eip712.d.ts +17 -17
- package/dist/cjs/src/utils/eip712.js +43 -0
- package/dist/cjs/src/utils/eip712.js.map +1 -0
- package/dist/{utils → cjs/src/utils}/getCurrencyAddress.d.ts +2 -2
- package/dist/cjs/src/utils/getCurrencyAddress.js +9 -0
- package/dist/cjs/src/utils/getCurrencyAddress.js.map +1 -0
- package/dist/{utils → cjs/src/utils}/inputTokens.d.ts +23 -23
- package/dist/cjs/src/utils/inputTokens.js +58 -0
- package/dist/cjs/src/utils/inputTokens.js.map +1 -0
- package/dist/{utils → cjs/src/utils}/numbers.d.ts +7 -6
- package/dist/cjs/src/utils/numbers.js +27 -0
- package/dist/cjs/src/utils/numbers.js.map +1 -0
- package/dist/{utils → cjs/src/utils}/pathCurrency.d.ts +3 -3
- package/dist/cjs/src/utils/pathCurrency.js +27 -0
- package/dist/cjs/src/utils/pathCurrency.js.map +1 -0
- package/dist/{utils → cjs/src/utils}/routerCommands.d.ts +77 -72
- package/dist/cjs/src/utils/routerCommands.js +334 -0
- package/dist/cjs/src/utils/routerCommands.js.map +1 -0
- package/dist/{utils → cjs/src/utils}/routerTradeAdapter.d.ts +73 -73
- package/dist/cjs/src/utils/routerTradeAdapter.js +139 -0
- package/dist/cjs/src/utils/routerTradeAdapter.js.map +1 -0
- package/dist/esm/src/entities/Command.d.ts +12 -0
- package/dist/esm/src/entities/Command.js +6 -0
- package/dist/esm/src/entities/Command.js.map +1 -0
- package/dist/esm/src/entities/actions/across.d.ts +21 -0
- package/dist/esm/src/entities/actions/across.js +3 -0
- package/dist/esm/src/entities/actions/across.js.map +1 -0
- package/dist/esm/src/entities/actions/index.d.ts +3 -0
- package/dist/esm/src/entities/actions/index.js +4 -0
- package/dist/esm/src/entities/actions/index.js.map +1 -0
- package/dist/esm/src/entities/actions/uniswap.d.ts +38 -0
- package/dist/esm/src/entities/actions/uniswap.js +528 -0
- package/dist/esm/src/entities/actions/uniswap.js.map +1 -0
- package/dist/esm/src/entities/actions/unwrapWETH.d.ts +12 -0
- package/dist/esm/src/entities/actions/unwrapWETH.js +28 -0
- package/dist/esm/src/entities/actions/unwrapWETH.js.map +1 -0
- package/dist/esm/src/entities/index.d.ts +2 -0
- package/dist/esm/src/entities/index.js +3 -0
- package/dist/esm/src/entities/index.js.map +1 -0
- package/dist/esm/src/index.d.ts +12 -0
- package/dist/esm/src/index.js +9 -0
- package/dist/esm/src/index.js.map +1 -0
- package/dist/esm/src/swapRouter.d.ts +87 -0
- package/dist/esm/src/swapRouter.js +271 -0
- package/dist/esm/src/swapRouter.js.map +1 -0
- package/dist/esm/src/utils/commandParser.d.ts +34 -0
- package/dist/esm/src/utils/commandParser.js +137 -0
- package/dist/esm/src/utils/commandParser.js.map +1 -0
- package/dist/esm/src/utils/constants.d.ts +33 -0
- package/dist/esm/src/utils/constants.js +534 -0
- package/dist/esm/src/utils/constants.js.map +1 -0
- package/dist/esm/src/utils/eip712.d.ts +17 -0
- package/dist/esm/src/utils/eip712.js +38 -0
- package/dist/esm/src/utils/eip712.js.map +1 -0
- package/dist/esm/src/utils/getCurrencyAddress.d.ts +2 -0
- package/dist/esm/src/utils/getCurrencyAddress.js +5 -0
- package/dist/esm/src/utils/getCurrencyAddress.js.map +1 -0
- package/dist/esm/src/utils/inputTokens.d.ts +23 -0
- package/dist/esm/src/utils/inputTokens.js +51 -0
- package/dist/esm/src/utils/inputTokens.js.map +1 -0
- package/dist/esm/src/utils/numbers.d.ts +7 -0
- package/dist/esm/src/utils/numbers.js +19 -0
- package/dist/esm/src/utils/numbers.js.map +1 -0
- package/dist/esm/src/utils/pathCurrency.d.ts +3 -0
- package/dist/esm/src/utils/pathCurrency.js +23 -0
- package/dist/esm/src/utils/pathCurrency.js.map +1 -0
- package/dist/esm/src/utils/routerCommands.d.ts +77 -0
- package/dist/esm/src/utils/routerCommands.js +329 -0
- package/dist/esm/src/utils/routerCommands.js.map +1 -0
- package/dist/esm/src/utils/routerTradeAdapter.d.ts +73 -0
- package/dist/esm/src/utils/routerTradeAdapter.js +134 -0
- package/dist/esm/src/utils/routerTradeAdapter.js.map +1 -0
- package/dist/types/src/entities/Command.d.ts +12 -0
- package/dist/types/src/entities/actions/across.d.ts +21 -0
- package/dist/types/src/entities/actions/index.d.ts +3 -0
- package/dist/types/src/entities/actions/uniswap.d.ts +38 -0
- package/dist/types/src/entities/actions/unwrapWETH.d.ts +12 -0
- package/dist/types/src/entities/index.d.ts +2 -0
- package/dist/types/src/index.d.ts +12 -0
- package/dist/types/src/swapRouter.d.ts +87 -0
- package/dist/types/src/utils/commandParser.d.ts +34 -0
- package/dist/types/src/utils/constants.d.ts +33 -0
- package/dist/types/src/utils/eip712.d.ts +17 -0
- package/dist/types/src/utils/getCurrencyAddress.d.ts +2 -0
- package/dist/types/src/utils/inputTokens.d.ts +23 -0
- package/dist/types/src/utils/numbers.d.ts +7 -0
- package/dist/types/src/utils/pathCurrency.d.ts +3 -0
- package/dist/types/src/utils/routerCommands.d.ts +77 -0
- package/dist/types/src/utils/routerTradeAdapter.d.ts +73 -0
- package/package.json +31 -22
- package/dist/index.js +0 -8
- package/dist/test/forge/writeInterop.d.ts +0 -2
- package/dist/test/utils/addresses.d.ts +0 -5
- package/dist/test/utils/hexToDecimalString.d.ts +0 -2
- package/dist/test/utils/permit2.d.ts +0 -7
- package/dist/test/utils/uniswapData.d.ts +0 -24
- package/dist/universal-router-sdk.cjs.development.js +0 -1925
- package/dist/universal-router-sdk.cjs.development.js.map +0 -1
- package/dist/universal-router-sdk.cjs.production.min.js +0 -2
- package/dist/universal-router-sdk.cjs.production.min.js.map +0 -1
- package/dist/universal-router-sdk.esm.js +0 -1912
- 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
|
|
42
|
+
## Per-Hop Slippage Protection
|
|
43
43
|
|
|
44
|
-
Universal Router v2.1 adds granular slippage protection for multi-hop V4
|
|
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
|
-
|
|
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 {
|
|
53
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
59
|
-
|
|
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
|
-
|
|
85
|
+
Slippage is expressed as a **price** with 18 decimals of precision:
|
|
72
86
|
|
|
73
|
-
-
|
|
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
|
|
89
|
+
If the calculated price for hop `i` exceeds `maxHopSlippage[i]`, the transaction reverts.
|
|
77
90
|
|
|
78
|
-
|
|
79
|
-
- `V4TooMuchRequestedPerHop` for exact output swaps
|
|
91
|
+
### Mixed Routes
|
|
80
92
|
|
|
81
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
|
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
|
|
105
|
-
-
|
|
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),
|
|
137
|
-
data: '0x' + '0'.repeat(64),
|
|
138
|
-
sender: wallet.address,
|
|
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,
|
|
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',
|
|
186
|
-
nonce: NONCE_SKIP_CHECK,
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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,
|
|
254
|
+
recipient: userAddress, // Can be different address on destination
|
|
243
255
|
inputToken: WETH_MAINNET,
|
|
244
256
|
outputToken: WETH_OPTIMISM,
|
|
245
|
-
inputAmount: CONTRACT_BALANCE,
|
|
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',
|
|
253
|
-
useNative: false,
|
|
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]
|
|
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,
|
|
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
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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,
|
|
320
|
+
inputToken: WETH_ADDRESS, // Must be WETH address
|
|
313
321
|
outputToken: WETH_ON_DESTINATION,
|
|
314
|
-
useNative: true,
|
|
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
|
|
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
|
|
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 {
|
|
8
|
-
export
|
|
9
|
-
amount: BigNumberish;
|
|
10
|
-
recipient: string;
|
|
11
|
-
};
|
|
12
|
-
export declare enum TokenTransferMode {
|
|
13
|
-
Permit2 = "Permit2",
|
|
14
|
-
ApproveProxy = "ApproveProxy"
|
|
15
|
-
}
|
|
16
|
-
export
|
|
17
|
-
useRouterBalance?: boolean;
|
|
18
|
-
inputTokenPermit?: Permit2Permit;
|
|
19
|
-
flatFee?: FlatFeeOptions;
|
|
20
|
-
safeMode?: boolean;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
readonly
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
get
|
|
33
|
-
get
|
|
34
|
-
get
|
|
35
|
-
get
|
|
36
|
-
get
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
}
|