@uniswap/universal-router-sdk 1.5.7 → 2.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.
@@ -73,6 +73,8 @@ var RouterTradeType;
73
73
  RouterTradeType["UniswapTrade"] = "UniswapTrade";
74
74
  RouterTradeType["NFTTrade"] = "NFTTrade";
75
75
  RouterTradeType["UnwrapWETH"] = "UnwrapWETH";
76
+ RouterTradeType["WrapSTETH"] = "WrapSTETH";
77
+ RouterTradeType["UnwrapSTETH"] = "UnwrapSTETH";
76
78
  })(RouterTradeType || (RouterTradeType = {}));
77
79
 
78
80
  var NFTTrade = function NFTTrade(market, orders) {
@@ -141,6 +143,8 @@ var CommandType;
141
143
  CommandType[CommandType["SEAPORT_V1_4"] = 32] = "SEAPORT_V1_4";
142
144
  CommandType[CommandType["EXECUTE_SUB_PLAN"] = 33] = "EXECUTE_SUB_PLAN";
143
145
  CommandType[CommandType["APPROVE_ERC20"] = 34] = "APPROVE_ERC20";
146
+ CommandType[CommandType["WRAP_STETH"] = 35] = "WRAP_STETH";
147
+ CommandType[CommandType["UNWRAP_STETH"] = 36] = "UNWRAP_STETH";
144
148
  })(CommandType || (CommandType = {}));
145
149
  var ALLOW_REVERT_FLAG = 0x80;
146
150
  var REVERTIBLE_COMMANDS = /*#__PURE__*/new Set([CommandType.SEAPORT_V1_5, CommandType.SEAPORT_V1_4, CommandType.NFTX, CommandType.LOOKS_RARE_V2, CommandType.X2Y2_721, CommandType.X2Y2_1155, CommandType.FOUNDATION, CommandType.SUDOSWAP, CommandType.NFT20, CommandType.EXECUTE_SUB_PLAN, CommandType.CRYPTOPUNKS, CommandType.ELEMENT_MARKET]);
@@ -148,7 +152,7 @@ var PERMIT_STRUCT = '((address token,uint160 amount,uint48 expiration,uint48 non
148
152
  var PERMIT_BATCH_STRUCT = '((address token,uint160 amount,uint48 expiration,uint48 nonce)[] details,address spender,uint256 sigDeadline)';
149
153
  var PERMIT2_TRANSFER_FROM_STRUCT = '(address from,address to,uint160 amount,address token)';
150
154
  var PERMIT2_TRANSFER_FROM_BATCH_STRUCT = PERMIT2_TRANSFER_FROM_STRUCT + '[]';
151
- var ABI_DEFINITION = (_ABI_DEFINITION = {}, _ABI_DEFINITION[CommandType.EXECUTE_SUB_PLAN] = ['bytes', 'bytes[]'], _ABI_DEFINITION[CommandType.PERMIT2_PERMIT] = [PERMIT_STRUCT, 'bytes'], _ABI_DEFINITION[CommandType.PERMIT2_PERMIT_BATCH] = [PERMIT_BATCH_STRUCT, 'bytes'], _ABI_DEFINITION[CommandType.PERMIT2_TRANSFER_FROM] = ['address', 'address', 'uint160'], _ABI_DEFINITION[CommandType.PERMIT2_TRANSFER_FROM_BATCH] = [PERMIT2_TRANSFER_FROM_BATCH_STRUCT], _ABI_DEFINITION[CommandType.V3_SWAP_EXACT_IN] = ['address', 'uint256', 'uint256', 'bytes', 'bool'], _ABI_DEFINITION[CommandType.V3_SWAP_EXACT_OUT] = ['address', 'uint256', 'uint256', 'bytes', 'bool'], _ABI_DEFINITION[CommandType.V2_SWAP_EXACT_IN] = ['address', 'uint256', 'uint256', 'address[]', 'bool'], _ABI_DEFINITION[CommandType.V2_SWAP_EXACT_OUT] = ['address', 'uint256', 'uint256', 'address[]', 'bool'], _ABI_DEFINITION[CommandType.WRAP_ETH] = ['address', 'uint256'], _ABI_DEFINITION[CommandType.UNWRAP_WETH] = ['address', 'uint256'], _ABI_DEFINITION[CommandType.SWEEP] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.SWEEP_ERC721] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.SWEEP_ERC1155] = ['address', 'address', 'uint256', 'uint256'], _ABI_DEFINITION[CommandType.TRANSFER] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.PAY_PORTION] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.BALANCE_CHECK_ERC20] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.OWNER_CHECK_721] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.OWNER_CHECK_1155] = ['address', 'address', 'uint256', 'uint256'], _ABI_DEFINITION[CommandType.APPROVE_ERC20] = ['address', 'uint256'], _ABI_DEFINITION[CommandType.SEAPORT_V1_5] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.SEAPORT_V1_4] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.NFTX] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.LOOKS_RARE_V2] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.X2Y2_721] = ['uint256', 'bytes', 'address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.X2Y2_1155] = ['uint256', 'bytes', 'address', 'address', 'uint256', 'uint256'], _ABI_DEFINITION[CommandType.FOUNDATION] = ['uint256', 'bytes', 'address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.SUDOSWAP] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.NFT20] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.CRYPTOPUNKS] = ['uint256', 'address', 'uint256'], _ABI_DEFINITION[CommandType.ELEMENT_MARKET] = ['uint256', 'bytes'], _ABI_DEFINITION);
155
+ var ABI_DEFINITION = (_ABI_DEFINITION = {}, _ABI_DEFINITION[CommandType.EXECUTE_SUB_PLAN] = ['bytes', 'bytes[]'], _ABI_DEFINITION[CommandType.PERMIT2_PERMIT] = [PERMIT_STRUCT, 'bytes'], _ABI_DEFINITION[CommandType.PERMIT2_PERMIT_BATCH] = [PERMIT_BATCH_STRUCT, 'bytes'], _ABI_DEFINITION[CommandType.PERMIT2_TRANSFER_FROM] = ['address', 'address', 'uint160'], _ABI_DEFINITION[CommandType.PERMIT2_TRANSFER_FROM_BATCH] = [PERMIT2_TRANSFER_FROM_BATCH_STRUCT], _ABI_DEFINITION[CommandType.V3_SWAP_EXACT_IN] = ['address', 'uint256', 'uint256', 'bytes', 'bool'], _ABI_DEFINITION[CommandType.V3_SWAP_EXACT_OUT] = ['address', 'uint256', 'uint256', 'bytes', 'bool'], _ABI_DEFINITION[CommandType.V2_SWAP_EXACT_IN] = ['address', 'uint256', 'uint256', 'address[]', 'bool'], _ABI_DEFINITION[CommandType.V2_SWAP_EXACT_OUT] = ['address', 'uint256', 'uint256', 'address[]', 'bool'], _ABI_DEFINITION[CommandType.WRAP_ETH] = ['address', 'uint256'], _ABI_DEFINITION[CommandType.UNWRAP_WETH] = ['address', 'uint256'], _ABI_DEFINITION[CommandType.SWEEP] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.SWEEP_ERC721] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.SWEEP_ERC1155] = ['address', 'address', 'uint256', 'uint256'], _ABI_DEFINITION[CommandType.TRANSFER] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.PAY_PORTION] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.BALANCE_CHECK_ERC20] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.OWNER_CHECK_721] = ['address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.OWNER_CHECK_1155] = ['address', 'address', 'uint256', 'uint256'], _ABI_DEFINITION[CommandType.APPROVE_ERC20] = ['address', 'uint256'], _ABI_DEFINITION[CommandType.WRAP_STETH] = ['address', 'uint256'], _ABI_DEFINITION[CommandType.UNWRAP_STETH] = ['address', 'uint256'], _ABI_DEFINITION[CommandType.SEAPORT_V1_5] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.SEAPORT_V1_4] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.NFTX] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.LOOKS_RARE_V2] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.X2Y2_721] = ['uint256', 'bytes', 'address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.X2Y2_1155] = ['uint256', 'bytes', 'address', 'address', 'uint256', 'uint256'], _ABI_DEFINITION[CommandType.FOUNDATION] = ['uint256', 'bytes', 'address', 'address', 'uint256'], _ABI_DEFINITION[CommandType.SUDOSWAP] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.NFT20] = ['uint256', 'bytes'], _ABI_DEFINITION[CommandType.CRYPTOPUNKS] = ['uint256', 'address', 'uint256'], _ABI_DEFINITION[CommandType.ELEMENT_MARKET] = ['uint256', 'bytes'], _ABI_DEFINITION);
152
156
  var RoutePlanner = /*#__PURE__*/function () {
153
157
  function RoutePlanner() {
154
158
  this.commands = '0x';
@@ -183,67 +187,97 @@ function createCommand(type, parameters) {
183
187
  }
184
188
 
185
189
  var _CHAIN_CONFIGS;
186
- var WETH_NOT_SUPPORTED_ON_CHAIN = '0x0000000000000000000000000000000000000000';
190
+ var NOT_SUPPORTED_ON_CHAIN = '0x0000000000000000000000000000000000000000';
187
191
  var CHAIN_CONFIGS = (_CHAIN_CONFIGS = {}, _CHAIN_CONFIGS[1] = {
188
- router: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
192
+ router: '0x3F6328669a86bef431Dc6F9201A5B90F7975a023',
189
193
  weth: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
194
+ steth: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
195
+ wsteth: '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
190
196
  creationBlock: 17143817
191
197
  }, _CHAIN_CONFIGS[5] = {
192
- router: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
198
+ router: '0x3F6328669a86bef431Dc6F9201A5B90F7975a023',
193
199
  weth: '0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6',
200
+ steth: '0x1643E812aE58766192Cf7D2Cf9567dF2C37e9B7F',
201
+ wsteth: '0x6320cD32aA674d2898A68ec82e869385Fc5f7E2f',
194
202
  creationBlock: 8940568
195
203
  }, _CHAIN_CONFIGS[11155111] = {
196
204
  router: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
197
205
  weth: '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',
206
+ steth: NOT_SUPPORTED_ON_CHAIN,
207
+ wsteth: NOT_SUPPORTED_ON_CHAIN,
198
208
  creationBlock: 3543575
199
209
  }, _CHAIN_CONFIGS[137] = {
200
- router: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
210
+ router: '0x643770E279d5D0733F21d6DC03A8efbABf3255B4',
201
211
  weth: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
202
- creationBlock: 42294741
212
+ steth: NOT_SUPPORTED_ON_CHAIN,
213
+ wsteth: NOT_SUPPORTED_ON_CHAIN,
214
+ creationBlock: 46866777
203
215
  }, _CHAIN_CONFIGS[80001] = {
204
216
  router: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
205
217
  weth: '0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889',
218
+ steth: NOT_SUPPORTED_ON_CHAIN,
219
+ wsteth: NOT_SUPPORTED_ON_CHAIN,
206
220
  creationBlock: 35176052
207
221
  }, _CHAIN_CONFIGS[10] = {
208
- router: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
222
+ router: '0xeC8B0F7Ffe3ae75d7FfAb09429e3675bb63503e4',
209
223
  weth: '0x4200000000000000000000000000000000000006',
210
- creationBlock: 96333990
224
+ steth: NOT_SUPPORTED_ON_CHAIN,
225
+ wsteth: NOT_SUPPORTED_ON_CHAIN,
226
+ creationBlock: 108825869
211
227
  }, _CHAIN_CONFIGS[420] = {
212
228
  router: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
213
229
  weth: '0x4200000000000000000000000000000000000006',
230
+ steth: NOT_SUPPORTED_ON_CHAIN,
231
+ wsteth: NOT_SUPPORTED_ON_CHAIN,
214
232
  creationBlock: 8887728
215
233
  }, _CHAIN_CONFIGS[42161] = {
216
- router: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
234
+ router: '0xeC8B0F7Ffe3ae75d7FfAb09429e3675bb63503e4',
217
235
  weth: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
218
- creationBlock: 87206402
236
+ steth: NOT_SUPPORTED_ON_CHAIN,
237
+ wsteth: NOT_SUPPORTED_ON_CHAIN,
238
+ creationBlock: 125861718
219
239
  }, _CHAIN_CONFIGS[421613] = {
220
240
  router: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
221
241
  weth: '0xe39Ab88f8A4777030A534146A9Ca3B52bd5D43A3',
242
+ steth: NOT_SUPPORTED_ON_CHAIN,
243
+ wsteth: NOT_SUPPORTED_ON_CHAIN,
222
244
  creationBlock: 18815277
223
245
  }, _CHAIN_CONFIGS[42220] = {
224
- router: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
225
- weth: WETH_NOT_SUPPORTED_ON_CHAIN,
226
- creationBlock: 19106929
246
+ router: '0x88a3ED7F21A3fCF6adb86b6F878C5B7a02D20e9b',
247
+ weth: NOT_SUPPORTED_ON_CHAIN,
248
+ steth: NOT_SUPPORTED_ON_CHAIN,
249
+ wsteth: NOT_SUPPORTED_ON_CHAIN,
250
+ creationBlock: 21116361
227
251
  }, _CHAIN_CONFIGS[44787] = {
228
252
  router: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
229
- weth: WETH_NOT_SUPPORTED_ON_CHAIN,
253
+ weth: NOT_SUPPORTED_ON_CHAIN,
254
+ steth: NOT_SUPPORTED_ON_CHAIN,
255
+ wsteth: NOT_SUPPORTED_ON_CHAIN,
230
256
  creationBlock: 17566658
231
257
  }, _CHAIN_CONFIGS[56] = {
232
- router: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
258
+ router: '0xeC8B0F7Ffe3ae75d7FfAb09429e3675bb63503e4',
233
259
  weth: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
234
- creationBlock: 27915533
260
+ steth: NOT_SUPPORTED_ON_CHAIN,
261
+ wsteth: NOT_SUPPORTED_ON_CHAIN,
262
+ creationBlock: 31254967
235
263
  }, _CHAIN_CONFIGS[43114] = {
236
- router: '0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD',
264
+ router: '0x82635AF6146972cD6601161c4472ffe97237D292',
237
265
  weth: '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7',
238
- creationBlock: 31583684
266
+ steth: NOT_SUPPORTED_ON_CHAIN,
267
+ wsteth: NOT_SUPPORTED_ON_CHAIN,
268
+ creationBlock: 34491144
239
269
  }, _CHAIN_CONFIGS[84531] = {
240
270
  router: '0xd0872d928672ae2ff74bdb2f5130ac12229cafaf',
241
271
  weth: '0x4200000000000000000000000000000000000006',
272
+ steth: NOT_SUPPORTED_ON_CHAIN,
273
+ wsteth: NOT_SUPPORTED_ON_CHAIN,
242
274
  creationBlock: 6915289
243
275
  }, _CHAIN_CONFIGS[8453] = {
244
- router: '0x198EF79F1F515F02dFE9e3115eD9fC07183f02fC',
276
+ router: '0xeC8B0F7Ffe3ae75d7FfAb09429e3675bb63503e4',
245
277
  weth: '0x4200000000000000000000000000000000000006',
246
- creationBlock: 1452376
278
+ steth: NOT_SUPPORTED_ON_CHAIN,
279
+ wsteth: NOT_SUPPORTED_ON_CHAIN,
280
+ creationBlock: 3229053
247
281
  }, _CHAIN_CONFIGS);
248
282
  var UNIVERSAL_ROUTER_ADDRESS = function UNIVERSAL_ROUTER_ADDRESS(chainId) {
249
283
  if (!(chainId in CHAIN_CONFIGS)) throw new Error("Universal Router not deployed on chain " + chainId);
@@ -255,9 +289,14 @@ var UNIVERSAL_ROUTER_CREATION_BLOCK = function UNIVERSAL_ROUTER_CREATION_BLOCK(c
255
289
  };
256
290
  var WETH_ADDRESS = function WETH_ADDRESS(chainId) {
257
291
  if (!(chainId in CHAIN_CONFIGS)) throw new Error("Universal Router not deployed on chain " + chainId);
258
- if (CHAIN_CONFIGS[chainId].weth == WETH_NOT_SUPPORTED_ON_CHAIN) throw new Error("Chain " + chainId + " does not have WETH");
292
+ if (CHAIN_CONFIGS[chainId].weth == NOT_SUPPORTED_ON_CHAIN) throw new Error("Chain " + chainId + " does not have WETH");
259
293
  return CHAIN_CONFIGS[chainId].weth;
260
294
  };
295
+ var STETH_ADDRESS = function STETH_ADDRESS(chainId) {
296
+ if (!(chainId in CHAIN_CONFIGS)) throw new Error("Universal Router not deployed on chain " + chainId);
297
+ if (CHAIN_CONFIGS[chainId].steth == NOT_SUPPORTED_ON_CHAIN) throw new Error("Chain " + chainId + " does not have STETH support");
298
+ return CHAIN_CONFIGS[chainId].steth;
299
+ };
261
300
  var PERMIT2_ADDRESS = '0x000000000022D473030F116dDEE9F6B43aC78BA3';
262
301
  var CONTRACT_BALANCE = /*#__PURE__*/BigNumber.from(2).pow(255);
263
302
  var ETH_ADDRESS = '0x0000000000000000000000000000000000000000';
@@ -279,11 +318,12 @@ var UniswapTrade = /*#__PURE__*/function () {
279
318
  this.trade = trade;
280
319
  this.options = options;
281
320
  this.tradeType = RouterTradeType.UniswapTrade;
321
+ if (!!options.fee && !!options.flatFee) throw new Error('Only one fee option permitted');
282
322
  }
283
323
  var _proto = UniswapTrade.prototype;
284
324
  _proto.encode = function encode(planner, _config) {
285
325
  var _this$options$recipie;
286
- var payerIsUser = true;
326
+ var payerIsUser = !this.options.payerIsRouter;
287
327
  // If the input currency is the native currency, we need to wrap it with the router as the recipient
288
328
  if (this.trade.inputAmount.currency.isNative) {
289
329
  // TODO: optimize if only one v2 pool we can directly send this to the pool
@@ -300,7 +340,7 @@ var UniswapTrade = /*#__PURE__*/function () {
300
340
  var performAggregatedSlippageCheck = this.trade.tradeType === TradeType.EXACT_INPUT && this.trade.routes.length > 2;
301
341
  var outputIsNative = this.trade.outputAmount.currency.isNative;
302
342
  var inputIsNative = this.trade.inputAmount.currency.isNative;
303
- var routerMustCustody = performAggregatedSlippageCheck || outputIsNative || !!this.options.fee;
343
+ var routerMustCustody = performAggregatedSlippageCheck || outputIsNative || hasFeeOption(this.options);
304
344
  for (var _iterator = _createForOfIteratorHelperLoose(this.trade.swaps), _step; !(_step = _iterator()).done;) {
305
345
  var swap = _step.value;
306
346
  switch (swap.route.protocol) {
@@ -331,6 +371,18 @@ var UniswapTrade = /*#__PURE__*/function () {
331
371
  minimumAmountOut = minimumAmountOut.sub(minimumAmountOut.mul(feeBips).div(10000));
332
372
  }
333
373
  }
374
+ // If there is a flat fee, that absolute amount is sent to the fee recipient
375
+ // In the case where ETH is the output currency, the fee is taken in WETH (for gas reasons)
376
+ if (!!this.options.flatFee) {
377
+ var feeAmount = this.options.flatFee.amount;
378
+ if (minimumAmountOut.lt(feeAmount)) throw new Error('Flat fee amount greater than minimumAmountOut');
379
+ planner.addCommand(CommandType.TRANSFER, [this.trade.outputAmount.currency.wrapped.address, this.options.flatFee.recipient, feeAmount]);
380
+ // If the trade is exact output, and a fee was taken, we must adjust the amount out to be the amount after the fee
381
+ // Otherwise we continue as expected with the trade's normal expected output
382
+ if (this.trade.tradeType === TradeType.EXACT_OUTPUT) {
383
+ minimumAmountOut = minimumAmountOut.sub(feeAmount);
384
+ }
385
+ }
334
386
  // The remaining tokens that need to be sent to the user after the fee is taken will be caught
335
387
  // by this if-else clause.
336
388
  if (outputIsNative) {
@@ -445,6 +497,9 @@ function addMixedSwap(planner, swap, tradeType, options, payerIsUser, routerMust
445
497
  function riskOfPartialFill(trade) {
446
498
  return trade.priceImpact.greaterThan(REFUND_ETH_PRICE_IMPACT_THRESHOLD);
447
499
  }
500
+ function hasFeeOption(swapOptions) {
501
+ return !!swapOptions.fee || !!swapOptions.flatFee;
502
+ }
448
503
 
449
504
  var SIGNATURE_LENGTH = 65;
450
505
  var EIP_2098_SIGNATURE_LENGTH = 64;
@@ -571,11 +626,18 @@ var SwapRouter = /*#__PURE__*/function () {
571
626
  allowRevert: false
572
627
  });
573
628
  currentNativeValueInRouter = currentNativeValueInRouter.add(UnwrapWETH.amount);
629
+ /**
630
+ * is (Un)WrapSTETH
631
+ */
632
+ } else if (trade.tradeType == RouterTradeType.WrapSTETH || trade.tradeType == RouterTradeType.UnwrapSTETH) {
633
+ trade.encode(planner, {
634
+ allowRevert: false
635
+ });
574
636
  /**
575
637
  * else
576
638
  */
577
639
  } else {
578
- throw 'trade must be of instance: UniswapTrade or NFTTrade';
640
+ throw 'trade must be of instance: UniswapTrade, NFTTrade, UnwrapWETH, WrapSTETH';
579
641
  }
580
642
  }
581
643
  // TODO: matches current logic for now, but should eventually only sweep for multiple NFT trades
@@ -10528,5 +10590,45 @@ var UnwrapWETH = /*#__PURE__*/function () {
10528
10590
  return UnwrapWETH;
10529
10591
  }();
10530
10592
 
10531
- export { CryptopunkTrade, FoundationTrade, LooksRareV2Trade, Market, NFT20Trade, NFTTrade, NFTXTrade, PERMIT2_ADDRESS, ROUTER_AS_RECIPIENT, RouterTradeType, SeaportTrade, SudoswapTrade, SwapRouter, TokenType, UNIVERSAL_ROUTER_ADDRESS, UNIVERSAL_ROUTER_CREATION_BLOCK, UniswapTrade, UnwrapWETH, WETH_ADDRESS, X2Y2Trade };
10593
+ var WrapSTETH = /*#__PURE__*/function () {
10594
+ function WrapSTETH(amount, chainId, permit2, wrapAmount) {
10595
+ this.tradeType = RouterTradeType.WrapSTETH;
10596
+ this.stethAddress = STETH_ADDRESS(chainId);
10597
+ this.amount = amount;
10598
+ this.wrapAmount = wrapAmount != null ? wrapAmount : CONTRACT_BALANCE;
10599
+ if (!!permit2) {
10600
+ !(permit2.details.token.toLowerCase() === this.stethAddress.toLowerCase()) ? process.env.NODE_ENV !== "production" ? invariant(false, "must be permitting STETH address: " + this.stethAddress) : invariant(false) : void 0;
10601
+ !(permit2.details.amount >= amount) ? process.env.NODE_ENV !== "production" ? invariant(false, "Did not permit enough STETH for unwrapSTETH transaction") : invariant(false) : void 0;
10602
+ this.permit2Data = permit2;
10603
+ }
10604
+ }
10605
+ var _proto = WrapSTETH.prototype;
10606
+ _proto.encode = function encode(planner, _) {
10607
+ encodeInputTokenOptions(planner, {
10608
+ permit2Permit: this.permit2Data,
10609
+ permit2TransferFrom: {
10610
+ token: this.stethAddress,
10611
+ amount: this.amount.toString()
10612
+ }
10613
+ });
10614
+ planner.addCommand(CommandType.WRAP_STETH, [ROUTER_AS_RECIPIENT, this.wrapAmount]);
10615
+ };
10616
+ return WrapSTETH;
10617
+ }();
10618
+
10619
+ var UnwrapSTETH = /*#__PURE__*/function () {
10620
+ function UnwrapSTETH(recipient, amountMinimum, chainId) {
10621
+ this.tradeType = RouterTradeType.UnwrapSTETH;
10622
+ this.recipient = recipient;
10623
+ this.amountMinimum = amountMinimum;
10624
+ !(STETH_ADDRESS(chainId) != NOT_SUPPORTED_ON_CHAIN) ? process.env.NODE_ENV !== "production" ? invariant(false, "STETH not supported on chain " + chainId) : invariant(false) : void 0;
10625
+ }
10626
+ var _proto = UnwrapSTETH.prototype;
10627
+ _proto.encode = function encode(planner, _) {
10628
+ planner.addCommand(CommandType.UNWRAP_STETH, [this.recipient, this.amountMinimum]);
10629
+ };
10630
+ return UnwrapSTETH;
10631
+ }();
10632
+
10633
+ export { CryptopunkTrade, FoundationTrade, LooksRareV2Trade, Market, NFT20Trade, NFTTrade, NFTXTrade, PERMIT2_ADDRESS, ROUTER_AS_RECIPIENT, RouterTradeType, SeaportTrade, SudoswapTrade, SwapRouter, TokenType, UNIVERSAL_ROUTER_ADDRESS, UNIVERSAL_ROUTER_CREATION_BLOCK, UniswapTrade, UnwrapSTETH, UnwrapWETH, WETH_ADDRESS, WrapSTETH, X2Y2Trade };
10532
10634
  //# sourceMappingURL=universal-router-sdk.esm.js.map