@imtbl/sdk 0.27.10 → 0.27.12

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.
@@ -14685,8 +14685,11 @@ function poolEquals(poolA, poolB) {
14685
14685
  return (poolA === poolB ||
14686
14686
  (poolA.token0.equals(poolB.token0) && poolA.token1.equals(poolB.token1) && poolA.fee === poolB.fee));
14687
14687
  }
14688
- async function getERC20Decimals(tokenAddress, provider) {
14689
- const decimalsFunctionSig = ethers.utils.id('decimals()').substring(0, 10);
14688
+ const decimalsFunctionSig = ethers.utils.id('decimals()').substring(0, 10);
14689
+ async function getTokenDecimals(tokenAddress, provider, nativeToken) {
14690
+ if (tokenAddress === 'native') {
14691
+ return nativeToken.decimals;
14692
+ }
14690
14693
  try {
14691
14694
  const decimalsResult = await provider.call({
14692
14695
  to: tokenAddress,
@@ -14714,6 +14717,7 @@ function isValidNonZeroAddress(address) {
14714
14717
  return false;
14715
14718
  }
14716
14719
  }
14720
+ const isValidTokenLiteral = (address) => address === 'native' ? true : isValidNonZeroAddress(address);
14717
14721
  const erc20ToUniswapToken = (token) =>
14718
14722
  // eslint-disable-next-line implicit-arrow-linebreak
14719
14723
  new Uniswap.Token(token.chainId, token.address, token.decimals, token.symbol, token.name);
@@ -15168,12 +15172,13 @@ const getUnsignedERC20ApproveTransaction = (ownerAddress, tokenAmount, spenderAd
15168
15172
  from: ownerAddress,
15169
15173
  };
15170
15174
  };
15171
- const prepareApproval = (tradeType, amountSpecified, amountWithSlippage, contracts, secondaryFees) => {
15172
- const amountOfTokenIn = tradeType === TradeType.EXACT_INPUT ? amountSpecified : amountWithSlippage;
15173
- const spender = secondaryFees.length === 0
15174
- ? contracts.routerAddress
15175
- : contracts.secondaryFeeAddress;
15176
- return { spender, amount: amountOfTokenIn };
15175
+ const prepareApproval = (tradeType, userSpecifiedAmount, quotedAmountWithSlippage, contracts, secondaryFees) => {
15176
+ const amountInToApprove = tradeType === TradeType.EXACT_INPUT ? userSpecifiedAmount : quotedAmountWithSlippage;
15177
+ if (!isERC20Amount(amountInToApprove)) {
15178
+ return null;
15179
+ }
15180
+ const spender = secondaryFees.length === 0 ? contracts.routerAddress : contracts.secondaryFeeAddress;
15181
+ return { spender, amount: amountInToApprove };
15177
15182
  };
15178
15183
  /**
15179
15184
  * Get an unsigned approval transaction if needed
@@ -15218,6 +15223,38 @@ const getApproval = async (provider, ownerAddress, preparedApproval, gasPrice) =
15218
15223
  };
15219
15224
  };
15220
15225
 
15226
+ const canUnwrapToken = (token) => token.type === 'native';
15227
+ class NativeTokenService {
15228
+ nativeToken;
15229
+ wrappedToken;
15230
+ constructor(nativeToken, wrappedToken) {
15231
+ this.nativeToken = nativeToken;
15232
+ this.wrappedToken = wrappedToken;
15233
+ }
15234
+ wrapAmount(amount) {
15235
+ if (!canUnwrapToken(amount.token)) {
15236
+ throw new Error(`cannot wrap non-native token: ${amount.token.address}`);
15237
+ }
15238
+ return newAmount(amount.value, this.wrappedToken);
15239
+ }
15240
+ unwrapAmount(amount) {
15241
+ const isWrappedToken = amount.token.address.toLowerCase() !== this.wrappedToken.address.toLowerCase();
15242
+ if (isWrappedToken) {
15243
+ throw new Error(`cannot unwrap non-wrapped token ${amount.token.address}`);
15244
+ }
15245
+ return newAmount(amount.value, this.nativeToken);
15246
+ }
15247
+ maybeWrapToken(token) {
15248
+ if (canUnwrapToken(token)) {
15249
+ return this.wrappedToken;
15250
+ }
15251
+ return token;
15252
+ }
15253
+ maybeWrapAmount(amount) {
15254
+ return newAmount(amount.value, this.maybeWrapToken(amount.token));
15255
+ }
15256
+ }
15257
+
15221
15258
  // slippageToPercent takes the slippage as a percentage (e.g. 0.1) and
15222
15259
  // converts it to the Uniswap equivalent type
15223
15260
  const slippageToFraction = (slippage) => {
@@ -15237,11 +15274,11 @@ const slippageToFraction = (slippage) => {
15237
15274
  return new Percent(numerator, denominator);
15238
15275
  };
15239
15276
 
15240
- function getQuoteAmountFromTradeType(tradeInfo) {
15241
- if (tradeInfo.tradeType === TradeType.EXACT_INPUT) {
15242
- return tradeInfo.amountOut;
15277
+ function getQuoteAmountFromTradeType(routerQuote) {
15278
+ if (routerQuote.tradeType === TradeType.EXACT_INPUT) {
15279
+ return routerQuote.amountOut;
15243
15280
  }
15244
- return tradeInfo.amountIn;
15281
+ return routerQuote.amountIn;
15245
15282
  }
15246
15283
  function applySlippage(tradeType, amount, slippage) {
15247
15284
  const slippageTolerance = slippageToFraction(slippage);
@@ -15250,6 +15287,18 @@ function applySlippage(tradeType, amount, slippage) {
15250
15287
  const amountWithSlippage = maybeInverted.multiply(amount.toString()).quotient;
15251
15288
  return ethers.BigNumber.from(amountWithSlippage.toString());
15252
15289
  }
15290
+ const prepareUserQuote = (nativeTokenService, routerQuote, slippage, tokenOfQuotedAmount) => {
15291
+ const erc20QuoteAmount = getQuoteAmountFromTradeType(routerQuote);
15292
+ // If the quote amount is the native token, we need to unwrap it if the user originally specified the native token
15293
+ const quotedAmount = canUnwrapToken(tokenOfQuotedAmount)
15294
+ ? nativeTokenService.unwrapAmount(erc20QuoteAmount)
15295
+ : erc20QuoteAmount;
15296
+ const quotedAmountWithMaxSlippage = newAmount(applySlippage(routerQuote.tradeType, quotedAmount.value, slippage), tokenOfQuotedAmount);
15297
+ return {
15298
+ quotedAmount,
15299
+ quotedAmountWithMaxSlippage,
15300
+ };
15301
+ };
15253
15302
  function getOurQuoteReqAmount(amountSpecified, // the amount specified by the user, either exactIn or exactOut
15254
15303
  fees, tradeType, nativeTokenService) {
15255
15304
  if (tradeType === TradeType.EXACT_OUTPUT) {
@@ -15317,39 +15366,6 @@ class Fees {
15317
15366
  }
15318
15367
  }
15319
15368
 
15320
- class NativeTokenService {
15321
- nativeToken;
15322
- wrappedToken;
15323
- constructor(nativeToken, wrappedToken) {
15324
- this.nativeToken = nativeToken;
15325
- this.wrappedToken = wrappedToken;
15326
- }
15327
- wrapAmount(amount) {
15328
- if (!this.isNativeToken(amount.token)) {
15329
- throw new Error(`cannot wrap non-native token: ${amount.token.address}`);
15330
- }
15331
- return newAmount(amount.value, this.wrappedToken);
15332
- }
15333
- unwrapAmount(amount) {
15334
- if (amount.token !== this.wrappedToken) {
15335
- throw new Error(`cannot unwrap non-wrapped token ${amount.token.address}`);
15336
- }
15337
- return newAmount(amount.value, this.nativeToken);
15338
- }
15339
- maybeWrapToken(token) {
15340
- if (this.isNativeToken(token)) {
15341
- return this.wrappedToken;
15342
- }
15343
- return token;
15344
- }
15345
- maybeWrapAmount(amount) {
15346
- return newAmount(amount.value, this.maybeWrapToken(amount.token));
15347
- }
15348
- isNativeToken(token) {
15349
- return token === this.nativeToken;
15350
- }
15351
- }
15352
-
15353
15369
  const IMMUTABLE_TESTNET_RPC_URL = 'https://rpc.testnet.immutable.com';
15354
15370
  const IMMUTABLE_TESTNET_CHAIN_ID = 13472;
15355
15371
  const TIMX_IMMUTABLE_TESTNET = {
@@ -15381,7 +15397,9 @@ function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountI
15381
15397
  recipient: fee.recipient,
15382
15398
  }));
15383
15399
  if (trade.tradeType === TradeType.EXACT_INPUT) {
15384
- return secondaryFeeContract.encodeFunctionData('exactInputSingleWithSecondaryFee', [secondaryFeeValues, {
15400
+ return secondaryFeeContract.encodeFunctionData('exactInputSingleWithSecondaryFee', [
15401
+ secondaryFeeValues,
15402
+ {
15385
15403
  tokenIn: route.tokenPath[0].address,
15386
15404
  tokenOut: route.tokenPath[1].address,
15387
15405
  fee: route.pools[0].fee,
@@ -15389,9 +15407,12 @@ function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountI
15389
15407
  amountIn,
15390
15408
  amountOutMinimum: amountOut,
15391
15409
  sqrtPriceLimitX96: 0,
15392
- }]);
15410
+ },
15411
+ ]);
15393
15412
  }
15394
- return secondaryFeeContract.encodeFunctionData('exactOutputSingleWithSecondaryFee', [secondaryFeeValues, {
15413
+ return secondaryFeeContract.encodeFunctionData('exactOutputSingleWithSecondaryFee', [
15414
+ secondaryFeeValues,
15415
+ {
15395
15416
  tokenIn: route.tokenPath[0].address,
15396
15417
  tokenOut: route.tokenPath[1].address,
15397
15418
  fee: route.pools[0].fee,
@@ -15399,7 +15420,8 @@ function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountI
15399
15420
  amountInMaximum: amountIn,
15400
15421
  amountOut,
15401
15422
  sqrtPriceLimitX96: 0,
15402
- }]);
15423
+ },
15424
+ ]);
15403
15425
  }
15404
15426
  function buildSwapParametersForMultiPoolSwap(fromAddress, trade, route, amountIn, amountOut, secondaryFees, secondaryFeeContract) {
15405
15427
  const path = encodeRouteToPath(route, trade.tradeType === TradeType.EXACT_OUTPUT);
@@ -15408,19 +15430,25 @@ function buildSwapParametersForMultiPoolSwap(fromAddress, trade, route, amountIn
15408
15430
  recipient: fee.recipient,
15409
15431
  }));
15410
15432
  if (trade.tradeType === TradeType.EXACT_INPUT) {
15411
- return secondaryFeeContract.encodeFunctionData('exactInputWithSecondaryFee', [secondaryFeeValues, {
15433
+ return secondaryFeeContract.encodeFunctionData('exactInputWithSecondaryFee', [
15434
+ secondaryFeeValues,
15435
+ {
15412
15436
  path,
15413
15437
  recipient: fromAddress,
15414
15438
  amountIn,
15415
15439
  amountOutMinimum: amountOut,
15416
- }]);
15440
+ },
15441
+ ]);
15417
15442
  }
15418
- return secondaryFeeContract.encodeFunctionData('exactOutputWithSecondaryFee', [secondaryFeeValues, {
15443
+ return secondaryFeeContract.encodeFunctionData('exactOutputWithSecondaryFee', [
15444
+ secondaryFeeValues,
15445
+ {
15419
15446
  path,
15420
15447
  recipient: fromAddress,
15421
15448
  amountInMaximum: amountIn,
15422
15449
  amountOut,
15423
- }]);
15450
+ },
15451
+ ]);
15424
15452
  }
15425
15453
  /**
15426
15454
  * Builds swap parameters
@@ -15445,7 +15473,10 @@ function buildSwapParameters(fromAddress, trade, options, secondaryFees, seconda
15445
15473
  function createSwapCallParametersWithFees(trade, fromAddress, swapOptions, secondaryFees) {
15446
15474
  const secondaryFeeContract = SecondaryFee__factory.createInterface();
15447
15475
  const swapWithFeesCalldata = buildSwapParameters(fromAddress, trade, swapOptions, secondaryFees, secondaryFeeContract);
15448
- return secondaryFeeContract.encodeFunctionData(multicallWithDeadlineFunctionSignature, [swapOptions.deadlineOrPreviousBlockhash, [swapWithFeesCalldata]]);
15476
+ return secondaryFeeContract.encodeFunctionData(multicallWithDeadlineFunctionSignature, [
15477
+ swapOptions.deadlineOrPreviousBlockhash,
15478
+ [swapWithFeesCalldata],
15479
+ ]);
15449
15480
  }
15450
15481
  function createSwapParameters(adjustedQuote, fromAddress, slippage, deadline, secondaryFees) {
15451
15482
  // Create an unchecked trade to be used in generating swap parameters.
@@ -15485,7 +15516,7 @@ function getSwap(adjustedQuote, fromAddress, slippage, deadline, peripheryRouter
15485
15516
  const adjustAmountIn = (ourQuote, amountSpecified, fees, nativeTokenService) => {
15486
15517
  if (ourQuote.tradeType === TradeType.EXACT_OUTPUT) {
15487
15518
  // when doing exact output, calculate the fees based on the amountIn
15488
- const amountToAdd = nativeTokenService.isNativeToken(fees.token)
15519
+ const amountToAdd = canUnwrapToken(fees.token)
15489
15520
  ? nativeTokenService.unwrapAmount(ourQuote.amountIn)
15490
15521
  : ourQuote.amountIn;
15491
15522
  fees.addAmount(amountToAdd);
@@ -15602,8 +15633,8 @@ class ExchangeConfiguration {
15602
15633
  }
15603
15634
 
15604
15635
  const toPublicQuote = (amount, amountWithMaxSlippage, slippage, fees) => ({
15605
- amount,
15606
- amountWithMaxSlippage,
15636
+ amount: toPublicAmount(amount),
15637
+ amountWithMaxSlippage: toPublicAmount(amountWithMaxSlippage),
15607
15638
  slippage,
15608
15639
  fees: fees.withAmounts().map((fee) => ({
15609
15640
  ...fee,
@@ -15638,8 +15669,8 @@ class Exchange {
15638
15669
  }
15639
15670
  static validate(tokenInAddress, tokenOutAddress, maxHops, slippagePercent, fromAddress) {
15640
15671
  assert(isValidNonZeroAddress(fromAddress), new InvalidAddressError('invalid from address'));
15641
- assert(isValidNonZeroAddress(tokenInAddress), new InvalidAddressError('invalid token in address'));
15642
- assert(isValidNonZeroAddress(tokenOutAddress), new InvalidAddressError('invalid token out address'));
15672
+ assert(isValidTokenLiteral(tokenInAddress), new InvalidAddressError('invalid token in address'));
15673
+ assert(isValidTokenLiteral(tokenOutAddress), new InvalidAddressError('invalid token out address'));
15643
15674
  assert(tokenInAddress.toLocaleLowerCase() !== tokenOutAddress.toLocaleLowerCase(), new DuplicateAddressesError());
15644
15675
  assert(maxHops <= MAX_MAX_HOPS, new InvalidMaxHopsError('max hops must be less than or equal to 10'));
15645
15676
  assert(maxHops >= MIN_MAX_HOPS, new InvalidMaxHopsError('max hops must be greater than or equal to 1'));
@@ -15657,61 +15688,63 @@ class Exchange {
15657
15688
  }
15658
15689
  return this.secondaryFees;
15659
15690
  }
15660
- async getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, amount, slippagePercent, maxHops, deadline, tradeType) {
15661
- Exchange.validate(tokenInAddress, tokenOutAddress, maxHops, slippagePercent, fromAddress);
15691
+ parseTokenLiteral(tokenLiteral, decimals) {
15692
+ if (tokenLiteral === 'native') {
15693
+ return this.nativeToken;
15694
+ }
15695
+ return {
15696
+ type: 'erc20',
15697
+ address: tokenLiteral,
15698
+ chainId: this.chainId,
15699
+ decimals,
15700
+ };
15701
+ }
15702
+ async getUnsignedSwapTx(fromAddress, tokenInLiteral, tokenOutLiteral, amount, slippagePercent, maxHops, deadline, tradeType) {
15703
+ Exchange.validate(tokenInLiteral, tokenOutLiteral, maxHops, slippagePercent, fromAddress);
15662
15704
  // get the decimals of the tokens that will be swapped
15663
15705
  const [tokenInDecimals, tokenOutDecimals, secondaryFees] = await Promise.all([
15664
- getERC20Decimals(tokenInAddress, this.provider),
15665
- getERC20Decimals(tokenOutAddress, this.provider),
15706
+ getTokenDecimals(tokenInLiteral, this.provider, this.nativeToken),
15707
+ getTokenDecimals(tokenOutLiteral, this.provider, this.nativeToken),
15666
15708
  this.getSecondaryFees(),
15667
15709
  ]);
15668
- const tokenIn = {
15669
- type: 'erc20',
15670
- address: tokenInAddress,
15671
- chainId: this.chainId,
15672
- decimals: tokenInDecimals,
15673
- };
15674
- const tokenOut = {
15675
- type: 'erc20',
15676
- address: tokenOutAddress,
15677
- chainId: this.chainId,
15678
- decimals: tokenOutDecimals,
15679
- };
15710
+ const tokenIn = this.parseTokenLiteral(tokenInLiteral, tokenInDecimals);
15711
+ const tokenOut = this.parseTokenLiteral(tokenOutLiteral, tokenOutDecimals);
15680
15712
  // determine which amount was specified for the swap from the TradeType
15681
15713
  const [tokenSpecified, otherToken] = tradeType === TradeType.EXACT_INPUT ? [tokenIn, tokenOut] : [tokenOut, tokenIn];
15682
15714
  const amountSpecified = newAmount(amount, tokenSpecified);
15683
15715
  const fees = new Fees(secondaryFees, tokenIn);
15684
15716
  const ourQuoteReqAmount = getOurQuoteReqAmount(amountSpecified, fees, tradeType, this.nativeTokenService);
15685
- // get quote and gas details
15717
+ // Quotes will always use ERC20s. If the user-specified token is Native, we use the Wrapped Native Token pool
15686
15718
  const [ourQuote, gasPrice] = await Promise.all([
15687
- this.router.findOptimalRoute(ourQuoteReqAmount, otherToken, tradeType, maxHops),
15719
+ this.router.findOptimalRoute(ourQuoteReqAmount, this.nativeTokenService.maybeWrapToken(otherToken), tradeType, maxHops),
15688
15720
  fetchGasPrice(this.provider, this.nativeToken),
15689
15721
  ]);
15690
15722
  const adjustedQuote = adjustQuoteWithFees(ourQuote, amountSpecified, fees, this.nativeTokenService);
15691
15723
  const swap = getSwap(adjustedQuote, fromAddress, slippagePercent, deadline, this.routerContractAddress, this.secondaryFeeContractAddress, gasPrice, secondaryFees, this.nativeTokenService);
15692
- const quotedAmount = getQuoteAmountFromTradeType(adjustedQuote);
15693
- const amountWithMaxSlippage = newAmount(applySlippage(adjustedQuote.tradeType, quotedAmount.value, slippagePercent), otherToken);
15694
- const preparedApproval = prepareApproval(tradeType, amountSpecified, amountWithMaxSlippage, {
15724
+ const { quotedAmount, quotedAmountWithMaxSlippage } = prepareUserQuote(this.nativeTokenService, adjustedQuote, slippagePercent, otherToken);
15725
+ const preparedApproval = prepareApproval(tradeType, amountSpecified, quotedAmountWithMaxSlippage, {
15695
15726
  routerAddress: this.routerContractAddress,
15696
15727
  secondaryFeeAddress: this.secondaryFeeContractAddress,
15697
15728
  }, secondaryFees);
15698
15729
  // preparedApproval always uses the tokenIn address because we are always selling the tokenIn
15699
- const approval = await getApproval(this.provider, fromAddress, preparedApproval, gasPrice);
15700
- const quote = toPublicQuote(quotedAmount, amountWithMaxSlippage, slippagePercent, fees);
15730
+ const approval = preparedApproval
15731
+ ? await getApproval(this.provider, fromAddress, preparedApproval, gasPrice)
15732
+ : null;
15733
+ const quote = toPublicQuote(quotedAmount, quotedAmountWithMaxSlippage, slippagePercent, fees);
15701
15734
  return { quote, approval, swap };
15702
15735
  }
15703
15736
  /**
15704
15737
  * Get the unsigned swap transaction given the amount to sell.
15705
15738
  * Includes quote details for the swap.
15706
15739
  *
15707
- * @param {string} fromAddress The public address that will sign and submit the transaction.
15708
- * @param {string} tokenInAddress Token address to sell.
15709
- * @param {string} tokenOutAddress Token address to buy.
15710
- * @param {ethers.BigNumberish} amountIn Amount to sell.
15711
- * @param {number} slippagePercent (optional) The percentage of slippage tolerance. Default = 0.1. Max = 50. Min = 0.
15712
- * @param {number} maxHops (optional) Maximum hops allowed in optimal route. Default is 2.
15713
- * @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes.
15714
- * @return {TransactionResponse} The result containing the unsigned transaction and details of the swap.
15740
+ * @param {string} fromAddress The public address that will sign and submit the transaction
15741
+ * @param {string} tokenInAddress Token address or 'native' to sell
15742
+ * @param {string} tokenOutAddress Token address or 'native' to buy
15743
+ * @param {ethers.BigNumberish} amountIn Amount to sell in the smallest unit of the token-in
15744
+ * @param {number} slippagePercent (optional) The percentage of slippage tolerance. Default = 0.1. Max = 50. Min = 0
15745
+ * @param {number} maxHops (optional) Maximum hops allowed in optimal route. Default is 2
15746
+ * @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes
15747
+ * @return {TransactionResponse} The result containing the unsigned transaction and details of the swap
15715
15748
  */
15716
15749
  async getUnsignedSwapTxFromAmountIn(fromAddress, tokenInAddress, tokenOutAddress, amountIn, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline = DEFAULT_DEADLINE) {
15717
15750
  return await this.getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, ethers.BigNumber.from(amountIn), slippagePercent, maxHops, deadline, TradeType.EXACT_INPUT);
@@ -15720,14 +15753,14 @@ class Exchange {
15720
15753
  * Get the unsigned swap transaction given the amount to buy.
15721
15754
  * Includes quote details for the swap.
15722
15755
  *
15723
- * @param {string} fromAddress The public address that will sign and submit the transaction.
15724
- * @param {string} tokenInAddress Token address to sell.
15725
- * @param {string} tokenOutAddress Token address to buy.
15726
- * @param {ethers.BigNumberish} amountOut Amount to buy.
15727
- * @param {number} slippagePercent (optional) The percentage of slippage tolerance. Default = 0.1. Max = 50. Min = 0.
15728
- * @param {number} maxHops (optional) Maximum hops allowed in optimal route. Default is 2.
15729
- * @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes.
15730
- * @return {TransactionResponse} The result containing the unsigned transaction and details of the swap.
15756
+ * @param {string} fromAddress The public address that will sign and submit the transaction
15757
+ * @param {string} tokenInAddress ERC20 contract address or 'native' to sell
15758
+ * @param {string} tokenOutAddress ERC20 contract address or 'native' to buy
15759
+ * @param {ethers.BigNumberish} amountOut Amount to buy in the smallest unit of the token-out
15760
+ * @param {number} slippagePercent (optional) The percentage of slippage tolerance. Default = 0.1. Max = 50. Min = 0
15761
+ * @param {number} maxHops (optional) Maximum hops allowed in optimal route. Default is 2
15762
+ * @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes
15763
+ * @return {TransactionResponse} The result containing the unsigned transaction and details of the swap
15731
15764
  */
15732
15765
  async getUnsignedSwapTxFromAmountOut(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline = DEFAULT_DEADLINE) {
15733
15766
  return await this.getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, ethers.BigNumber.from(amountOut), slippagePercent, maxHops, deadline, TradeType.EXACT_OUTPUT);
@@ -16154,7 +16187,7 @@ class OrdersService {
16154
16187
  * @returns ListListingsResult OK response.
16155
16188
  * @throws ApiError
16156
16189
  */
16157
- listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, sellItemTokenId, pageSize, sortBy, sortDirection, pageCursor, }) {
16190
+ listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, sellItemTokenId, fromUpdatedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
16158
16191
  return this.httpRequest.request({
16159
16192
  method: 'GET',
16160
16193
  url: '/v1/chains/{chain_name}/orders/listings',
@@ -16166,6 +16199,7 @@ class OrdersService {
16166
16199
  'sell_item_contract_address': sellItemContractAddress,
16167
16200
  'buy_item_contract_address': buyItemContractAddress,
16168
16201
  'sell_item_token_id': sellItemTokenId,
16202
+ 'from_updated_at': fromUpdatedAt,
16169
16203
  'page_size': pageSize,
16170
16204
  'sort_by': sortBy,
16171
16205
  'sort_direction': sortDirection,
@@ -16249,7 +16283,7 @@ class OrdersService {
16249
16283
  * @returns ListTradeResult OK response.
16250
16284
  * @throws ApiError
16251
16285
  */
16252
- listTrades({ chainName, accountAddress, pageSize, sortBy, sortDirection, pageCursor, }) {
16286
+ listTrades({ chainName, accountAddress, fromIndexedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
16253
16287
  return this.httpRequest.request({
16254
16288
  method: 'GET',
16255
16289
  url: '/v1/chains/{chain_name}/trades',
@@ -16258,6 +16292,7 @@ class OrdersService {
16258
16292
  },
16259
16293
  query: {
16260
16294
  'account_address': accountAddress,
16295
+ 'from_indexed_at': fromIndexedAt,
16261
16296
  'page_size': pageSize,
16262
16297
  'sort_by': sortBy,
16263
16298
  'sort_direction': sortDirection,
@@ -16323,6 +16358,16 @@ var CancelledOrderStatus;
16323
16358
  })(CancelledOrderStatus.cancellation_type || (CancelledOrderStatus.cancellation_type = {}));
16324
16359
  })(CancelledOrderStatus || (CancelledOrderStatus = {}));
16325
16360
 
16361
+ /* istanbul ignore file */
16362
+ /* tslint:disable */
16363
+ /* eslint-disable */
16364
+ var FailedOrderCancellation;
16365
+ (function (FailedOrderCancellation) {
16366
+ (function (reason_code) {
16367
+ reason_code["ALREADY_FILLED"] = "ALREADY_FILLED";
16368
+ })(FailedOrderCancellation.reason_code || (FailedOrderCancellation.reason_code = {}));
16369
+ })(FailedOrderCancellation || (FailedOrderCancellation = {}));
16370
+
16326
16371
  /* istanbul ignore file */
16327
16372
  /* tslint:disable */
16328
16373
  /* eslint-disable */
@@ -20554,7 +20599,7 @@ class APIError extends Error {
20554
20599
 
20555
20600
  /* eslint-disable implicit-arrow-linebreak */
20556
20601
  const defaultHeaders = {
20557
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.27.10',
20602
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.27.12',
20558
20603
  };
20559
20604
  /**
20560
20605
  * createAPIConfiguration to create a custom Configuration
@@ -21180,6 +21225,14 @@ const $d85ad1457a3f1a83$export$fc55ed5a42b458ba = {
21180
21225
  [($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET]: {
21181
21226
  url: "https://explorer.mainnet.immutable.com",
21182
21227
  nativeToken: $d85ad1457a3f1a83$export$6f24f3cef7d501c4.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET).nativeCurrency
21228
+ },
21229
+ [($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA]: {
21230
+ url: "https://eth-sepolia.blockscout.com",
21231
+ nativeToken: $d85ad1457a3f1a83$export$3e81fc0987227f10.get(($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA).nativeCurrency
21232
+ },
21233
+ [($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM]: {
21234
+ url: "https://eth.blockscout.com/",
21235
+ nativeToken: $d85ad1457a3f1a83$export$6f24f3cef7d501c4.get(($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM).nativeCurrency
21183
21236
  }
21184
21237
  };
21185
21238
  const $d85ad1457a3f1a83$export$db5daa1b5156ccfe = [
@@ -21779,6 +21832,7 @@ const $efe60cea83bfc4e8$export$473cec51305fdae8 = async (config, { type: type =
21779
21832
 
21780
21833
 
21781
21834
 
21835
+
21782
21836
  const $fd8a8472dcc3ec2b$var$CACHE_DATA_TTL = 60; // seconds
21783
21837
  class $fd8a8472dcc3ec2b$export$ef140a6b05dfc786 {
21784
21838
  url;
@@ -21912,6 +21966,20 @@ class $fd8a8472dcc3ec2b$export$ef140a6b05dfc786 {
21912
21966
 
21913
21967
 
21914
21968
 
21969
+ const $458d407830d66110$export$e6a390ea6399b7d8 = (config, debugString, seconds)=>{
21970
+ // eslint-disable-next-line no-console
21971
+ if (!config.isProduction) console.debug(debugString, seconds);
21972
+ };
21973
+ const $458d407830d66110$export$5280dbcb91c8b391 = async (config, debugString, promise)=>{
21974
+ const startTime = performance.now();
21975
+ const result = await promise;
21976
+ const endTime = performance.now();
21977
+ const elapsedTimeInSeconds = (endTime - startTime) / 1000;
21978
+ $458d407830d66110$export$e6a390ea6399b7d8(config, debugString, elapsedTimeInSeconds);
21979
+ return result;
21980
+ };
21981
+
21982
+
21915
21983
  const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (config, web3Provider, walletAddress)=>await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
21916
21984
  const networkInfo = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(config, web3Provider);
21917
21985
  if (!networkInfo.isSupported) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Chain:${networkInfo.chainId} is not a supported chain`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR, {
@@ -21951,18 +22019,23 @@ async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAdd
21951
22019
  type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC20_BALANCE_ERROR
21952
22020
  });
21953
22021
  }
21954
- // Blockscout client singleton
21955
- let $1564e43dde50bb61$var$blockscoutClient;
21956
- const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId, rename)=>{
22022
+ // Blockscout client singleton per chain id
22023
+ const $1564e43dde50bb61$var$blockscoutClientMap = new Map();
22024
+ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId, filterTokens)=>{
21957
22025
  // Shuffle the mapping of the tokens configuration so it is a hashmap
21958
22026
  // for faster access to tokens config objects.
21959
- const mapRename = Object.assign({}, ...rename.map((t)=>({
22027
+ const shouldFilter = filterTokens.length > 0;
22028
+ const mapFilterTokens = Object.assign({}, ...filterTokens.map((t)=>({
21960
22029
  [t.address || ""]: t
21961
22030
  })));
21962
- // Ensure singleton is present and match the selected chain
21963
- if (!$1564e43dde50bb61$var$blockscoutClient || $1564e43dde50bb61$var$blockscoutClient.chainId !== chainId) $1564e43dde50bb61$var$blockscoutClient = new ($fd8a8472dcc3ec2b$export$ef140a6b05dfc786)({
21964
- chainId: chainId
21965
- });
22031
+ // Get blockscout client for the given chain
22032
+ let blockscoutClient = $1564e43dde50bb61$var$blockscoutClientMap.get(chainId);
22033
+ if (!blockscoutClient) {
22034
+ blockscoutClient = new ($fd8a8472dcc3ec2b$export$ef140a6b05dfc786)({
22035
+ chainId: chainId
22036
+ });
22037
+ $1564e43dde50bb61$var$blockscoutClientMap.set(chainId, blockscoutClient);
22038
+ }
21966
22039
  // Hold the items in an array for post-fetching processing
21967
22040
  const items = [];
21968
22041
  const tokenType = ($887a00f8f72d61f0$export$5bd1ea2b3d18210).ERC20;
@@ -21972,7 +22045,7 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
21972
22045
  try {
21973
22046
  do {
21974
22047
  // eslint-disable-next-line no-await-in-loop
21975
- resp = await $1564e43dde50bb61$var$blockscoutClient.getTokensByWalletAddress({
22048
+ resp = await blockscoutClient.getTokensByWalletAddress({
21976
22049
  walletAddress: walletAddress,
21977
22050
  tokenType: tokenType,
21978
22051
  nextPage: resp?.next_page_params
@@ -21990,7 +22063,7 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
21990
22063
  if (err?.code !== (HttpStatusCode).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getTokensByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
21991
22064
  }
21992
22065
  try {
21993
- const respNative = await $1564e43dde50bb61$var$blockscoutClient.getNativeTokenByWalletAddress({
22066
+ const respNative = await blockscoutClient.getNativeTokenByWalletAddress({
21994
22067
  walletAddress: walletAddress
21995
22068
  });
21996
22069
  items.push(respNative);
@@ -22004,24 +22077,26 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
22004
22077
  // or simply an incorrect wallet address was provided.
22005
22078
  if (err?.code !== (HttpStatusCode).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getNativeTokenByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
22006
22079
  }
22080
+ const balances = [];
22081
+ items.forEach((item)=>{
22082
+ if (shouldFilter && !mapFilterTokens[item.token.address]) return;
22083
+ const tokenData = item.token || {};
22084
+ const balance = (BigNumber$1).from(item.value);
22085
+ let decimals = parseInt(tokenData.decimals, 10);
22086
+ if (Number.isNaN(decimals)) decimals = ($d85ad1457a3f1a83$export$903389470ba9433c);
22087
+ const token = {
22088
+ ...tokenData,
22089
+ decimals: decimals
22090
+ };
22091
+ const formattedBalance = (utils).formatUnits(item.value, token.decimals);
22092
+ balances.push({
22093
+ balance: balance,
22094
+ formattedBalance: formattedBalance,
22095
+ token: token
22096
+ });
22097
+ });
22007
22098
  return {
22008
- balances: items.map((item)=>{
22009
- const tokenData = item.token || {};
22010
- const balance = (BigNumber$1).from(item.value);
22011
- const renamed = mapRename[tokenData.address] || {};
22012
- const token = {
22013
- ...tokenData,
22014
- name: renamed.name ?? tokenData.name,
22015
- symbol: renamed.symbol ?? tokenData.symbol,
22016
- decimals: parseInt(tokenData.decimals, 10)
22017
- };
22018
- const formattedBalance = (utils).formatUnits(item.value, token.decimals);
22019
- return {
22020
- balance: balance,
22021
- formattedBalance: formattedBalance,
22022
- token: token
22023
- };
22024
- })
22099
+ balances: balances
22025
22100
  };
22026
22101
  };
22027
22102
  const $1564e43dde50bb61$export$a3238cee431627c6 = async (config, web3Provider, walletAddress, tokens)=>{
@@ -22052,11 +22127,19 @@ const $1564e43dde50bb61$export$fee49741664a4d7e = async (config, web3Provider, w
22052
22127
  // eslint-disable-next-line no-console
22053
22128
  console.error(err);
22054
22129
  }
22055
- if (flag && ($fd8a8472dcc3ec2b$export$ef140a6b05dfc786).isChainSupported(chainId)) return await $1564e43dde50bb61$export$8c978679845804d4(walletAddress, chainId, tokens);
22130
+ if (flag && ($fd8a8472dcc3ec2b$export$ef140a6b05dfc786).isChainSupported(chainId)) {
22131
+ // This is a hack because the widgets are still using the tokens symbol
22132
+ // to drive the conversions. If we remove all the token symbols from e.g. zkevm
22133
+ // then we would not have fiat conversions.
22134
+ // Please remove this hack once https://immutable.atlassian.net/browse/WT-1710
22135
+ // is done.
22136
+ const isL1Chain = ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config) === chainId;
22137
+ return ($458d407830d66110$export$5280dbcb91c8b391)(config, `Time to fetch balances using blockscout for ${chainId}`, $1564e43dde50bb61$export$8c978679845804d4(walletAddress, chainId, isL1Chain ? tokens : []));
22138
+ }
22056
22139
  // This fallback to use ERC20s calls which is a best effort solution
22057
22140
  // Fails in fetching data from the RCP calls might result in some
22058
22141
  // missing data.
22059
- return await $1564e43dde50bb61$export$a3238cee431627c6(config, web3Provider, walletAddress, tokens);
22142
+ return await ($458d407830d66110$export$5280dbcb91c8b391)(config, `Time to fetch balances using RPC for ${chainId}`, $1564e43dde50bb61$export$a3238cee431627c6(config, web3Provider, walletAddress, tokens));
22060
22143
  };
22061
22144
 
22062
22145
 
@@ -22297,7 +22380,7 @@ async function $67fc622a2b913d5f$export$7cf6178417769841(chainId, config) {
22297
22380
  overrides: dexConfig?.overrides
22298
22381
  });
22299
22382
  }
22300
- async function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
22383
+ function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
22301
22384
  return new (Orderbook)({
22302
22385
  baseConfig: {
22303
22386
  environment: config.environment
@@ -23098,8 +23181,8 @@ const $5e9bcae98dc8ff19$export$1165ca270f090a66 = (isDevelopment, isProduction)=
23098
23181
 
23099
23182
 
23100
23183
 
23101
- const $1fda5c40669a566d$export$1fac8e857d728583 = async ()=>false;
23102
- const $1fda5c40669a566d$export$2e83e9eeaf217e20 = async (config)=>{
23184
+ const $1fda5c40669a566d$export$5d79dcabf4595ae0 = async ()=>true;
23185
+ const $1fda5c40669a566d$export$2c2bcd6e0d9a9969 = async (config)=>{
23103
23186
  const availability = ($5e9bcae98dc8ff19$export$1165ca270f090a66)(config.isDevelopment, config.isProduction);
23104
23187
  try {
23105
23188
  return await availability.checkDexAvailability();
@@ -23120,18 +23203,18 @@ const $7f2e17f026d4fc8d$export$86d9f998ddda013e = async (config, provider)=>{
23120
23203
  const geoBlockingChecks = [];
23121
23204
  if (availableRoutingOptions.onRamp) geoBlockingChecks.push({
23122
23205
  id: "onRamp",
23123
- promise: ($1fda5c40669a566d$export$1fac8e857d728583)()
23206
+ promise: ($1fda5c40669a566d$export$5d79dcabf4595ae0)()
23124
23207
  });
23125
23208
  if (availableRoutingOptions.swap) geoBlockingChecks.push({
23126
23209
  id: "swap",
23127
- promise: ($1fda5c40669a566d$export$2e83e9eeaf217e20)(config)
23210
+ promise: ($1fda5c40669a566d$export$2c2bcd6e0d9a9969)(config)
23128
23211
  });
23129
23212
  if (geoBlockingChecks.length > 0) {
23130
23213
  const promises = geoBlockingChecks.map((geoBlockingCheck)=>geoBlockingCheck.promise);
23131
23214
  const geoBlockingStatus = await Promise.allSettled(promises);
23132
23215
  geoBlockingStatus.forEach((result, index)=>{
23133
23216
  const statusId = geoBlockingChecks[index].id;
23134
- availableRoutingOptions[statusId] = availableRoutingOptions[statusId] && result.status === "fulfilled" && !result.value;
23217
+ availableRoutingOptions[statusId] = availableRoutingOptions[statusId] && result.status === "fulfilled" && result.value;
23135
23218
  });
23136
23219
  }
23137
23220
  // Bridge not available if passport provider
@@ -23238,7 +23321,7 @@ const $049bba630af05555$export$6946a1f17c2bbf26 = async (config, chainId, wallet
23238
23321
  }
23239
23322
  // Resolve all the quotes and link them back to the swappable token
23240
23323
  // The swappable token array is in the same position in the array as the quote in the promise array
23241
- const dexTransactionResponse = await Promise.allSettled(dexTransactionResponsePromises);
23324
+ const dexTransactionResponse = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to resolve swap quotes from the dex", Promise.allSettled(dexTransactionResponsePromises));
23242
23325
  dexTransactionResponse.forEach((response, index)=>{
23243
23326
  if (response.status === "rejected") return; // Ignore any requests to dex that failed to resolve
23244
23327
  const swappableToken = fromToken[index];
@@ -23255,15 +23338,6 @@ const $049bba630af05555$export$6946a1f17c2bbf26 = async (config, chainId, wallet
23255
23338
  };
23256
23339
 
23257
23340
 
23258
- const $3ee85f12225c19f3$export$fb80fe94a81a3132 = async (config, dexQuoteCache, walletAddress, requiredToken, swappableTokens)=>{
23259
- const dexQuotes = dexQuoteCache.get(requiredToken.address);
23260
- if (dexQuotes && dexQuotes.size > 0) return dexQuotes;
23261
- const quotes = await ($049bba630af05555$export$6946a1f17c2bbf26)(config, ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config), walletAddress, requiredToken, swappableTokens);
23262
- dexQuoteCache.set(requiredToken.address, quotes);
23263
- return quotes;
23264
- };
23265
-
23266
-
23267
23341
  const $91807edfd7057288$var$constructFees = (approvalGasFees, swapGasFees, swapFees)=>{
23268
23342
  let approvalGasFeeAmount = (BigNumber$1).from(0);
23269
23343
  let approvalGasFeeFormatted = "0";
@@ -23391,11 +23465,17 @@ const $91807edfd7057288$export$7b6318fc1a8067b3 = (l2Balances, approval)=>{
23391
23465
  approvalGasTokenAddress: approvalGasTokenAddress
23392
23466
  };
23393
23467
  };
23394
- const $91807edfd7057288$export$38077235fe748d40 = (l2Balances, swapFees, approvalFees, tokenBeingSwapped)=>{
23468
+ const $91807edfd7057288$export$38077235fe748d40 = (l2Balances, approvalFees, swapGasFees, swapFees, tokenBeingSwapped)=>{
23395
23469
  // Set up a map of token addresses to amounts for each of the swap fees
23396
23470
  const feeMap = new Map();
23397
23471
  // Add the approval fee to list of fees
23398
23472
  if (approvalFees.approvalGasTokenAddress !== "") feeMap.set(approvalFees.approvalGasTokenAddress, approvalFees.approvalGasFee);
23473
+ // Add the swap gas fee to list of fees
23474
+ if (swapGasFees) {
23475
+ const fee = feeMap.get(swapGasFees.token.address);
23476
+ if (fee) feeMap.set(swapGasFees.token.address, fee.add(swapGasFees.value));
23477
+ else feeMap.set(swapGasFees.token.address, swapGasFees.value);
23478
+ }
23399
23479
  // Add the token being swapped to list of fees to ensure the user can cover the fee + the token swap
23400
23480
  if (tokenBeingSwapped) {
23401
23481
  const fee = feeMap.get(tokenBeingSwapped.address);
@@ -23444,7 +23524,7 @@ const $91807edfd7057288$export$567a0c83c08c514b = (l2balance, balanceRequirement
23444
23524
  // that is going to be swapped from another item requirement then return true
23445
23525
  return remainingBalance.gte(amountBeingSwapped);
23446
23526
  };
23447
- const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutingOptions, dexQuoteCache, walletAddress, balanceRequirement, tokenBalanceResults, swappableTokens, balanceRequirements)=>{
23527
+ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutingOptions, walletAddress, balanceRequirement, tokenBalanceResults, swappableTokens, balanceRequirements)=>{
23448
23528
  const fundingSteps = [];
23449
23529
  if (!availableRoutingOptions.swap) return fundingSteps;
23450
23530
  if (swappableTokens.length === 0) return fundingSteps;
@@ -23455,7 +23535,7 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
23455
23535
  if (!l2TokenBalanceResult) return fundingSteps;
23456
23536
  const l2Balances = l2TokenBalanceResult.balances;
23457
23537
  if (l2Balances.length === 0) return fundingSteps;
23458
- const quotes = await ($3ee85f12225c19f3$export$fb80fe94a81a3132)(config, dexQuoteCache, walletAddress, requiredToken, swappableTokens);
23538
+ const quotes = await ($049bba630af05555$export$6946a1f17c2bbf26)(config, ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config), walletAddress, requiredToken, swappableTokens);
23459
23539
  const quoteTokenAddresses = Array.from(quotes.keys());
23460
23540
  for (const quoteTokenAddress of quoteTokenAddresses){
23461
23541
  const quote = quotes.get(quoteTokenAddress);
@@ -23472,7 +23552,7 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
23472
23552
  // If user does not have enough to cover approval fees then continue
23473
23553
  if (!approvalFees.sufficient) continue;
23474
23554
  // If user does not have enough to cover swap fees then continue
23475
- if (!$91807edfd7057288$export$38077235fe748d40(l2Balances, quote.quote.fees, approvalFees, {
23555
+ if (!$91807edfd7057288$export$38077235fe748d40(l2Balances, approvalFees, quote.swap, quote.quote.fees, {
23476
23556
  amount: amountOfQuoteTokenRequired.value,
23477
23557
  address: quoteTokenAddress
23478
23558
  })) continue;
@@ -23877,13 +23957,14 @@ const $7500587317643fc8$export$c3e193fd573f1a94 = async (config, swappableTokens
23877
23957
 
23878
23958
 
23879
23959
 
23880
- const $d54df4a884f14123$export$d46f2133747ffd93 = async (config, dexQuoteCache, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens)=>{
23960
+
23961
+ const $d54df4a884f14123$export$d46f2133747ffd93 = async (config, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens)=>{
23881
23962
  const filteredSwappableTokensAddresses = [];
23882
23963
  for (const token of filteredSwappableTokens){
23883
23964
  if (!token.address) continue;
23884
23965
  filteredSwappableTokensAddresses.push(token.address);
23885
23966
  }
23886
- const dexQuotes = await ($3ee85f12225c19f3$export$fb80fe94a81a3132)(config, dexQuoteCache, ownerAddress, {
23967
+ const dexQuotes = await ($049bba630af05555$export$6946a1f17c2bbf26)(config, ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config), ownerAddress, {
23887
23968
  address: requiredTokenAddress,
23888
23969
  amount: insufficientRequirement.delta.balance
23889
23970
  }, filteredSwappableTokensAddresses);
@@ -23993,7 +24074,7 @@ const $afd57acae9471ac5$export$d9b96654eebdaf2a = (bridgeFundingSteps, swapFundi
23993
24074
  }
23994
24075
  return bridgeAndSwapRoutes;
23995
24076
  };
23996
- const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, feeEstimates, tokenBalances, bridgeableTokens, swappableTokens, balanceRequirements)=>{
24077
+ const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, feeEstimates, tokenBalances, bridgeableTokens, swappableTokens, balanceRequirements)=>{
23997
24078
  const { l1balances: l1balances, l2balances: l2balances } = ($7bb5af1d8b5d9127$export$8280985cc3da7882)(config, tokenBalances);
23998
24079
  const requiredTokenAddress = insufficientRequirement.required.token.address;
23999
24080
  if ($afd57acae9471ac5$export$b94e88f4f8805f71(bridgeableTokens, swappableTokens, l1balances, l2balances, availableRoutingOptions, requiredTokenAddress)) return [];
@@ -24004,7 +24085,7 @@ const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProvide
24004
24085
  const filteredSwappableTokens = $afd57acae9471ac5$export$ed7c59bd8d1bb5a7(requiredTokenAddress, bridgeableTokens, swappableTokens, l1tol2Addresses);
24005
24086
  if (filteredSwappableTokens.length === 0) return [];
24006
24087
  // Fetch all the dex quotes from the list of swappable tokens
24007
- const dexQuotes = await ($d54df4a884f14123$export$d46f2133747ffd93)(config, dexQuoteCache, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens);
24088
+ const dexQuotes = await ($d54df4a884f14123$export$d46f2133747ffd93)(config, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens);
24008
24089
  // Construct bridge requirements based on L2 balances, slippage and swap fees
24009
24090
  const bridgeRequirements = ($62e968a3dd87940e$export$df667c749c93b110)(dexQuotes, l1balances, l2balances, l1tol2Addresses, balanceRequirements);
24010
24091
  if (bridgeRequirements.length === 0) return [];
@@ -24047,7 +24128,7 @@ const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProvide
24047
24128
  // Modify the users L2 balance to include the amount as if the user successfully bridged
24048
24129
  const modifiedTokenBalances = $afd57acae9471ac5$var$modifyTokenBalancesWithBridgedAmount(config, tokenBalances, l2balances, bridgedTokens, swappableTokens);
24049
24130
  // Call the swap route with the faked bridged balances
24050
- const swapRoutes = await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, dexQuoteCache, ownerAddress, insufficientRequirement, modifiedTokenBalances, swappableTokensAfterBridging, balanceRequirements);
24131
+ const swapRoutes = await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, ownerAddress, insufficientRequirement, modifiedTokenBalances, swappableTokensAfterBridging, balanceRequirements);
24051
24132
  if (!swapRoutes) return [];
24052
24133
  const originalBalanceSwapRoutes = $afd57acae9471ac5$export$1fc63300bde5e690(tokenBalances, swapRoutes);
24053
24134
  return $afd57acae9471ac5$export$d9b96654eebdaf2a(bridgeResults, originalBalanceSwapRoutes, l1tol2Addresses);
@@ -24089,6 +24170,7 @@ const $5649bc8af91da370$export$1fb2bd867f4a9be3 = async (config, availableRoutin
24089
24170
 
24090
24171
 
24091
24172
 
24173
+
24092
24174
  const $c16168a9c28ae4fd$var$hasAvailableRoutingOptions = (availableRoutingOptions)=>availableRoutingOptions.bridge || availableRoutingOptions.swap || availableRoutingOptions.onRamp;
24093
24175
  const $c16168a9c28ae4fd$export$31ce7ba1a2956195 = (balanceRequirements)=>{
24094
24176
  let insufficientBalanceCount = 0;
@@ -24112,7 +24194,7 @@ const $c16168a9c28ae4fd$export$ab86023c267660 = async (config, readOnlyProviders
24112
24194
  if (availableRoutingOptions.bridge && insufficientRequirement) bridgeFundingStep = await ($fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa)(config, readOnlyProviders, ownerAddress, availableRoutingOptions, bridgeRequirement, tokenBalances, feeEstimates);
24113
24195
  return bridgeFundingStep;
24114
24196
  };
24115
- const $c16168a9c28ae4fd$export$814624e957fa0f11 = async (config, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, swapTokenAllowList, balanceRequirements)=>{
24197
+ const $c16168a9c28ae4fd$export$814624e957fa0f11 = async (config, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, swapTokenAllowList, balanceRequirements)=>{
24116
24198
  const fundingSteps = [];
24117
24199
  if (!availableRoutingOptions.swap) return fundingSteps;
24118
24200
  if (insufficientRequirement === undefined) return fundingSteps;
@@ -24123,9 +24205,9 @@ const $c16168a9c28ae4fd$export$814624e957fa0f11 = async (config, availableRoutin
24123
24205
  if (swapTokenAllowList.length === 0) return fundingSteps;
24124
24206
  const swappableTokens = swapTokenAllowList.filter((token)=>token.address).map((token)=>token.address);
24125
24207
  if (swappableTokens.length === 0) return fundingSteps;
24126
- return await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, dexQuoteCache, ownerAddress, insufficientRequirement, tokenBalances, swappableTokens, balanceRequirements);
24208
+ return await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, ownerAddress, insufficientRequirement, tokenBalances, swappableTokens, balanceRequirements);
24127
24209
  };
24128
- const $c16168a9c28ae4fd$export$2becd43da9d21f73 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, tokenAllowList, feeEstimates, balanceRequirements)=>{
24210
+ const $c16168a9c28ae4fd$export$2becd43da9d21f73 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, tokenAllowList, feeEstimates, balanceRequirements)=>{
24129
24211
  if (!insufficientRequirement) return [];
24130
24212
  const l1balancesResult = tokenBalances.get(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config));
24131
24213
  const l2balancesResult = tokenBalances.get(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
@@ -24143,7 +24225,7 @@ const $c16168a9c28ae4fd$export$2becd43da9d21f73 = async (config, readOnlyProvide
24143
24225
  });
24144
24226
  const swapTokenAllowList = tokenAllowList?.swap ?? [];
24145
24227
  if (insufficientRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE && insufficientRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) return [];
24146
- const routes = await ($afd57acae9471ac5$export$f95ed27e871fe308)(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, feeEstimates, tokenBalances, bridgeableL1Addresses, swapTokenAllowList, balanceRequirements);
24228
+ const routes = await ($afd57acae9471ac5$export$f95ed27e871fe308)(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, feeEstimates, tokenBalances, bridgeableL1Addresses, swapTokenAllowList, balanceRequirements);
24147
24229
  return routes;
24148
24230
  };
24149
24231
  const $c16168a9c28ae4fd$export$e1b6e4d22d0365ee = async (config, availableRoutingOptions, insufficientRequirement)=>{
@@ -24165,20 +24247,18 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
24165
24247
  message: err.message
24166
24248
  });
24167
24249
  }
24168
- const tokenBalances = await ($33acec7b4a26c053$export$23ddeb2642d2f9d)(config, readOnlyProviders, ownerAddress, availableRoutingOptions);
24169
- const allowList = await ($5a5ccedc98d53d25$export$1ad29657d49c5440)(config, tokenBalances, availableRoutingOptions);
24170
- // Bridge and swap fee cache
24250
+ const tokenBalances = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get token balances inside router", ($33acec7b4a26c053$export$23ddeb2642d2f9d)(config, readOnlyProviders, ownerAddress, availableRoutingOptions));
24251
+ const allowList = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get routing allowlist", ($5a5ccedc98d53d25$export$1ad29657d49c5440)(config, tokenBalances, availableRoutingOptions));
24252
+ // Fee estimate cache
24171
24253
  const feeEstimates = new Map();
24172
- // Dex quotes cache
24173
- const dexQuoteCache = new Map();
24174
24254
  // Ensures only 1 balance requirement is insufficient
24175
24255
  const insufficientRequirement = $c16168a9c28ae4fd$export$31ce7ba1a2956195(balanceRequirements);
24176
24256
  const routePromises = [];
24177
24257
  routePromises.push($c16168a9c28ae4fd$export$ab86023c267660(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, feeEstimates));
24178
- routePromises.push($c16168a9c28ae4fd$export$814624e957fa0f11(config, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, allowList.swap, balanceRequirements));
24258
+ routePromises.push($c16168a9c28ae4fd$export$814624e957fa0f11(config, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, allowList.swap, balanceRequirements));
24179
24259
  routePromises.push($c16168a9c28ae4fd$export$e1b6e4d22d0365ee(config, availableRoutingOptions, insufficientRequirement));
24180
- routePromises.push($c16168a9c28ae4fd$export$2becd43da9d21f73(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, allowList, feeEstimates, balanceRequirements));
24181
- const resolved = await Promise.all(routePromises);
24260
+ routePromises.push($c16168a9c28ae4fd$export$2becd43da9d21f73(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, allowList, feeEstimates, balanceRequirements));
24261
+ const resolved = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to resolve all routes", Promise.all(routePromises));
24182
24262
  let bridgeFundingStep;
24183
24263
  let swapFundingSteps = [];
24184
24264
  let onRampFundingStep;
@@ -24245,26 +24325,31 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
24245
24325
  };
24246
24326
 
24247
24327
 
24328
+
24248
24329
  const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemRequirements, transactionOrGasAmount)=>{
24249
24330
  const ownerAddress = await provider.getSigner().getAddress();
24250
24331
  let aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(itemRequirements);
24251
- const erc20Allowances = await ($fc8b338399d890f3$export$d93c00812189e36)(provider, ownerAddress, aggregatedItems);
24252
- const erc721Allowances = await ($35c3fc7013888ba5$export$be546c525d418988)(provider, ownerAddress, aggregatedItems);
24253
- const aggregatedAllowances = ($ddc6bcd0896481e5$export$2fbfa41a4de56a89)(erc20Allowances, erc721Allowances);
24254
- const gasItem = await ($7d1bfafb81e64d74$export$3a4140bd9e983e4e)(provider, aggregatedAllowances, transactionOrGasAmount);
24332
+ const erc20AllowancePromise = ($fc8b338399d890f3$export$d93c00812189e36)(provider, ownerAddress, aggregatedItems);
24333
+ const erc721AllowancePromise = ($35c3fc7013888ba5$export$be546c525d418988)(provider, ownerAddress, aggregatedItems);
24334
+ const resolvedAllowances = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to calculate token allowances", Promise.all([
24335
+ erc20AllowancePromise,
24336
+ erc721AllowancePromise
24337
+ ]));
24338
+ const aggregatedAllowances = ($ddc6bcd0896481e5$export$2fbfa41a4de56a89)(resolvedAllowances[0], resolvedAllowances[1]);
24339
+ const gasItem = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to run gas calculator", ($7d1bfafb81e64d74$export$3a4140bd9e983e4e)(provider, aggregatedAllowances, transactionOrGasAmount));
24255
24340
  if (gasItem !== null) {
24256
24341
  aggregatedItems.push(gasItem);
24257
24342
  aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(aggregatedItems);
24258
24343
  }
24259
- const balanceCheckResult = await ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems);
24344
+ const balanceCheckResult = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to run balance checks", ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems));
24260
24345
  const { sufficient: sufficient } = balanceCheckResult;
24261
24346
  const transactionRequirements = balanceCheckResult.balanceRequirements;
24262
24347
  if (sufficient) return {
24263
24348
  sufficient: sufficient,
24264
24349
  transactionRequirements: transactionRequirements
24265
24350
  };
24266
- const availableRoutingOptions = await ($7f2e17f026d4fc8d$export$86d9f998ddda013e)(config, provider);
24267
- const routingOutcome = await ($c16168a9c28ae4fd$export$92606e71d0a264ff)(config, ownerAddress, balanceCheckResult, availableRoutingOptions);
24351
+ const availableRoutingOptions = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to fetch available routing options", ($7f2e17f026d4fc8d$export$86d9f998ddda013e)(config, provider));
24352
+ const routingOutcome = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Total time to run the routing calculator", ($c16168a9c28ae4fd$export$92606e71d0a264ff)(config, ownerAddress, balanceCheckResult, availableRoutingOptions));
24268
24353
  return {
24269
24354
  sufficient: sufficient,
24270
24355
  transactionRequirements: transactionRequirements,
@@ -24447,6 +24532,7 @@ const $9051cee080948594$export$1e69c9cfc42e28d8 = (orderFees, weiAmount, decimal
24447
24532
  };
24448
24533
 
24449
24534
 
24535
+
24450
24536
  const $64863c39386de592$export$4249179755829904 = (type, contractAddress, amount, spenderAddress)=>{
24451
24537
  switch(type){
24452
24538
  case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20:
@@ -24485,8 +24571,8 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
24485
24571
  if (orders.length === 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No orders were provided to the orders array. Please provide at least one order.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).FULFILL_ORDER_LISTING_ERROR);
24486
24572
  const { id: id, takerFees: takerFees } = orders[0];
24487
24573
  try {
24488
- orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
24489
- order = await orderbook.getListing(id);
24574
+ orderbook = $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
24575
+ order = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to fetch the listing from the orderbook", orderbook.getListing(id));
24490
24576
  const { seaportContractAddress: seaportContractAddress } = orderbook.config();
24491
24577
  spenderAddress = seaportContractAddress;
24492
24578
  } catch (err) {
@@ -24503,23 +24589,26 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
24503
24589
  let decimals = 18;
24504
24590
  if (order.result.buy[0].type === "ERC20") {
24505
24591
  const tokenContract = $06a6c5c23f7f2479$export$fbbc17f6e6e58544(order.result.buy[0].contractAddress, ($d85ad1457a3f1a83$export$db5daa1b5156ccfe), provider);
24506
- decimals = await tokenContract.decimals();
24592
+ decimals = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get decimals of token contract for the buy token", tokenContract.decimals());
24507
24593
  }
24508
24594
  let fees = [];
24509
24595
  if (takerFees && takerFees.length > 0) fees = ($9051cee080948594$export$1e69c9cfc42e28d8)(takerFees, buyToken.amount, decimals);
24510
24596
  let unsignedApprovalTransactions = [];
24511
24597
  let unsignedFulfillmentTransactions = [];
24512
24598
  let orderActions = [];
24599
+ const fulfillOrderStartTime = new Date().getTime();
24513
24600
  try {
24514
- const fulfillerAddress = await provider.getSigner().getAddress();
24515
- const { actions: actions } = await orderbook.fulfillOrder(id, fulfillerAddress, fees);
24601
+ const fulfillerAddress = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the address from the provider", provider.getSigner().getAddress());
24602
+ const { actions: actions } = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to call fulfillOrder from the orderbook", orderbook.fulfillOrder(id, fulfillerAddress, fees));
24516
24603
  orderActions = actions;
24517
- unsignedApprovalTransactions = await (0, $a7367d01c6e76b1c$export$f64a20a30eb98855)(actions);
24518
- } catch {
24519
- // Silently ignore error as this is usually thrown if user does not have enough balance
24604
+ unsignedApprovalTransactions = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to construct the unsigned approval transactions", (0, $a7367d01c6e76b1c$export$f64a20a30eb98855)(actions));
24605
+ } catch (err) {
24606
+ // Silently ignore error as this is usually thrown if user does not have enough balance
24607
+ const elapsedTimeInSeconds = (new Date().getTime() - fulfillOrderStartTime) / 1000;
24608
+ ($458d407830d66110$export$e6a390ea6399b7d8)(config, "Time to call fulfillOrder from the orderbook", elapsedTimeInSeconds);
24520
24609
  }
24521
24610
  try {
24522
- unsignedFulfillmentTransactions = await (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions);
24611
+ unsignedFulfillmentTransactions = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to construct the unsigned fulfillment transactions", (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions));
24523
24612
  } catch {
24524
24613
  // if cannot estimate gas then silently continue and use gas limit in smartCheckout
24525
24614
  // but get the fulfillment transactions after they have approved the spending
@@ -24551,7 +24640,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
24551
24640
  const itemRequirements = [
24552
24641
  $64863c39386de592$export$4249179755829904(type, contractAddress, amount, spenderAddress)
24553
24642
  ];
24554
- const smartCheckoutResult = await ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, $64863c39386de592$export$8f2ff92ab8657f0b(gasLimit, unsignedFulfillmentTransactions));
24643
+ const smartCheckoutResult = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Total time running smart checkout", ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, $64863c39386de592$export$8f2ff92ab8657f0b(gasLimit, unsignedFulfillmentTransactions)));
24555
24644
  if (smartCheckoutResult.sufficient) {
24556
24645
  const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedApprovalTransactions);
24557
24646
  if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
@@ -24593,15 +24682,16 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
24593
24682
 
24594
24683
 
24595
24684
 
24685
+
24596
24686
  const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, orderIds)=>{
24597
24687
  let unsignedCancelOrderTransaction;
24598
24688
  if (orderIds.length === 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No orderIds were provided to the orderIds array. Please provide at least one orderId.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CANCEL_ORDER_LISTING_ERROR);
24599
24689
  // Update this when bulk cancel is supported
24600
24690
  const orderId = orderIds[0];
24601
24691
  try {
24602
- const offererAddress = await provider.getSigner().getAddress();
24603
- const orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
24604
- const cancelOrderResponse = await orderbook.cancelOrder(orderId, offererAddress);
24692
+ const offererAddress = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the address from the provider", provider.getSigner().getAddress());
24693
+ const orderbook = $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
24694
+ const cancelOrderResponse = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the cancel order from the orderbook", orderbook.cancelOrder(orderId, offererAddress));
24605
24695
  unsignedCancelOrderTransaction = cancelOrderResponse.unsignedCancelOrderTransaction;
24606
24696
  } catch (err) {
24607
24697
  throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while cancelling the order listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CANCEL_ORDER_LISTING_ERROR, {
@@ -24634,6 +24724,7 @@ const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, order
24634
24724
 
24635
24725
 
24636
24726
 
24727
+
24637
24728
  const $9085b221b72ac69e$export$af768ccdf17d5c04 = (id, contractAddress, spenderAddress)=>({
24638
24729
  type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
24639
24730
  id: id,
@@ -24662,15 +24753,15 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
24662
24753
  if (buyToken.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) {
24663
24754
  // get this from the allowed list
24664
24755
  const buyTokenContract = new (Contract$1)(buyToken.contractAddress, JSON.stringify(($d85ad1457a3f1a83$export$db5daa1b5156ccfe)), provider);
24665
- decimals = await buyTokenContract.decimals();
24756
+ decimals = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get decimals of token contract for the buy token", buyTokenContract.decimals());
24666
24757
  }
24667
24758
  const buyTokenOrNative = $9085b221b72ac69e$export$586d02673c66d423(buyToken, decimals);
24668
24759
  try {
24669
- const walletAddress = await provider.getSigner().getAddress();
24670
- orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
24760
+ const walletAddress = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the address from the provider", provider.getSigner().getAddress());
24761
+ orderbook = $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
24671
24762
  const { seaportContractAddress: seaportContractAddress } = orderbook.config();
24672
24763
  spenderAddress = seaportContractAddress;
24673
- listing = await orderbook.prepareListing({
24764
+ listing = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to prepare the listing from the orderbook", orderbook.prepareListing({
24674
24765
  makerAddress: walletAddress,
24675
24766
  buy: buyTokenOrNative,
24676
24767
  sell: {
@@ -24678,7 +24769,7 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
24678
24769
  contractAddress: sellToken.collectionAddress,
24679
24770
  tokenId: sellToken.id
24680
24771
  }
24681
- });
24772
+ }));
24682
24773
  } catch (err) {
24683
24774
  throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while preparing the listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PREPARE_ORDER_LISTING_ERROR, {
24684
24775
  message: err.message,
@@ -24689,13 +24780,13 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
24689
24780
  const itemRequirements = [
24690
24781
  $9085b221b72ac69e$export$af768ccdf17d5c04(sellToken.id, sellToken.collectionAddress, spenderAddress)
24691
24782
  ];
24692
- const smartCheckoutResult = await ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, {
24783
+ const smartCheckoutResult = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Total time running smart checkout", ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, {
24693
24784
  type: ($4b58188d47aafe8d$export$65c64e46348ee3c1).GAS,
24694
24785
  gasToken: {
24695
24786
  type: ($4b58188d47aafe8d$export$537fa3efd10ed435).NATIVE,
24696
24787
  limit: (BigNumber$1).from((constants).estimatedFulfillmentGasGwei)
24697
24788
  }
24698
- });
24789
+ }));
24699
24790
  if (smartCheckoutResult.sufficient) {
24700
24791
  const unsignedTransactions = await ($a7367d01c6e76b1c$export$c5b3365853cb6159)(listing.actions);
24701
24792
  const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedTransactions.approvalTransactions);
@@ -25026,7 +25117,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
25026
25117
  const tokenList = await $efe60cea83bfc4e8$export$473cec51305fdae8(this.config, {
25027
25118
  type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ONRAMP
25028
25119
  });
25029
- const token = tokenList.tokens.find((t)=>t.address?.toLowerCase() === params.tokenAddress?.toLowerCase());
25120
+ const token = tokenList.tokens?.find((t)=>t.address?.toLowerCase() === params.tokenAddress?.toLowerCase());
25030
25121
  if (token) {
25031
25122
  tokenAmount = params.tokenAmount;
25032
25123
  tokenSymbol = token.symbol;