@imtbl/sdk 0.27.11 → 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.
package/dist/index.cjs CHANGED
@@ -3632,7 +3632,7 @@ class MultiRollupApiClients {
3632
3632
  }
3633
3633
 
3634
3634
  // eslint-disable-next-line @typescript-eslint/naming-convention
3635
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.27.11' };
3635
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.27.12' };
3636
3636
  const createConfig = ({ basePath, headers, }) => {
3637
3637
  if (!basePath.trim()) {
3638
3638
  throw Error('basePath can not be empty');
@@ -3692,7 +3692,7 @@ class APIError extends Error {
3692
3692
 
3693
3693
  /* eslint-disable implicit-arrow-linebreak */
3694
3694
  const defaultHeaders = {
3695
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.27.11',
3695
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.27.12',
3696
3696
  };
3697
3697
  /**
3698
3698
  * createAPIConfiguration to create a custom Configuration
@@ -4084,14 +4084,14 @@ class BlockchainData {
4084
4084
  var blockchain_data = /*#__PURE__*/Object.freeze({
4085
4085
  __proto__: null,
4086
4086
  APIError: APIError,
4087
- ActivitiesApi: activitiesApiTypes,
4087
+ ActivitiesTypes: activitiesApiTypes,
4088
4088
  BlockchainData: BlockchainData,
4089
- ChainsApi: chainsApiTypes,
4090
- CollectionsApi: collectionsApiTypes,
4091
- MetadataApi: metadataApiTypes,
4092
- NFTOwnersApi: nftOwnersApiTypes,
4093
- NFTsApi: nftsApiTypes,
4094
- TokensApi: tokensApiTypes
4089
+ ChainsTypes: chainsApiTypes,
4090
+ CollectionsTypes: collectionsApiTypes,
4091
+ MetadataTypes: metadataApiTypes,
4092
+ NFTOwnersTypes: nftOwnersApiTypes,
4093
+ NFTsTypes: nftsApiTypes,
4094
+ TokensTypes: tokensApiTypes
4095
4095
  });
4096
4096
 
4097
4097
  /**
@@ -4103,7 +4103,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
4103
4103
  chainID,
4104
4104
  coreContractAddress,
4105
4105
  registrationContractAddress,
4106
- sdkVersion: 'ts-immutable-sdk-0.27.11',
4106
+ sdkVersion: 'ts-immutable-sdk-0.27.12',
4107
4107
  });
4108
4108
  /**
4109
4109
  * Sets `sdkVersion` at the time of build
@@ -11245,7 +11245,7 @@ class OrdersService {
11245
11245
  * @returns ListListingsResult OK response.
11246
11246
  * @throws ApiError
11247
11247
  */
11248
- listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, sellItemTokenId, pageSize, sortBy, sortDirection, pageCursor, }) {
11248
+ listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, sellItemTokenId, fromUpdatedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
11249
11249
  return this.httpRequest.request({
11250
11250
  method: 'GET',
11251
11251
  url: '/v1/chains/{chain_name}/orders/listings',
@@ -11257,6 +11257,7 @@ class OrdersService {
11257
11257
  'sell_item_contract_address': sellItemContractAddress,
11258
11258
  'buy_item_contract_address': buyItemContractAddress,
11259
11259
  'sell_item_token_id': sellItemTokenId,
11260
+ 'from_updated_at': fromUpdatedAt,
11260
11261
  'page_size': pageSize,
11261
11262
  'sort_by': sortBy,
11262
11263
  'sort_direction': sortDirection,
@@ -11340,7 +11341,7 @@ class OrdersService {
11340
11341
  * @returns ListTradeResult OK response.
11341
11342
  * @throws ApiError
11342
11343
  */
11343
- listTrades({ chainName, accountAddress, pageSize, sortBy, sortDirection, pageCursor, }) {
11344
+ listTrades({ chainName, accountAddress, fromIndexedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
11344
11345
  return this.httpRequest.request({
11345
11346
  method: 'GET',
11346
11347
  url: '/v1/chains/{chain_name}/trades',
@@ -11349,6 +11350,7 @@ class OrdersService {
11349
11350
  },
11350
11351
  query: {
11351
11352
  'account_address': accountAddress,
11353
+ 'from_indexed_at': fromIndexedAt,
11352
11354
  'page_size': pageSize,
11353
11355
  'sort_by': sortBy,
11354
11356
  'sort_direction': sortDirection,
@@ -11414,6 +11416,16 @@ var CancelledOrderStatus;
11414
11416
  })(CancelledOrderStatus.cancellation_type || (CancelledOrderStatus.cancellation_type = {}));
11415
11417
  })(CancelledOrderStatus || (CancelledOrderStatus = {}));
11416
11418
 
11419
+ /* istanbul ignore file */
11420
+ /* tslint:disable */
11421
+ /* eslint-disable */
11422
+ var FailedOrderCancellation;
11423
+ (function (FailedOrderCancellation) {
11424
+ (function (reason_code) {
11425
+ reason_code["ALREADY_FILLED"] = "ALREADY_FILLED";
11426
+ })(FailedOrderCancellation.reason_code || (FailedOrderCancellation.reason_code = {}));
11427
+ })(FailedOrderCancellation || (FailedOrderCancellation = {}));
11428
+
11417
11429
  /* istanbul ignore file */
11418
11430
  /* tslint:disable */
11419
11431
  /* eslint-disable */
@@ -30093,6 +30105,20 @@ class $fd8a8472dcc3ec2b$export$ef140a6b05dfc786 {
30093
30105
 
30094
30106
 
30095
30107
 
30108
+ const $458d407830d66110$export$e6a390ea6399b7d8 = (config, debugString, seconds)=>{
30109
+ // eslint-disable-next-line no-console
30110
+ if (!config.isProduction) console.debug(debugString, seconds);
30111
+ };
30112
+ const $458d407830d66110$export$5280dbcb91c8b391 = async (config, debugString, promise)=>{
30113
+ const startTime = performance.now();
30114
+ const result = await promise;
30115
+ const endTime = performance.now();
30116
+ const elapsedTimeInSeconds = (endTime - startTime) / 1000;
30117
+ $458d407830d66110$export$e6a390ea6399b7d8(config, debugString, elapsedTimeInSeconds);
30118
+ return result;
30119
+ };
30120
+
30121
+
30096
30122
  const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (config, web3Provider, walletAddress)=>await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
30097
30123
  const networkInfo = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(config, web3Provider);
30098
30124
  if (!networkInfo.isSupported) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Chain:${networkInfo.chainId} is not a supported chain`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR, {
@@ -30247,12 +30273,12 @@ const $1564e43dde50bb61$export$fee49741664a4d7e = async (config, web3Provider, w
30247
30273
  // Please remove this hack once https://immutable.atlassian.net/browse/WT-1710
30248
30274
  // is done.
30249
30275
  const isL1Chain = ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config) === chainId;
30250
- return await $1564e43dde50bb61$export$8c978679845804d4(walletAddress, chainId, isL1Chain ? tokens : []);
30276
+ return ($458d407830d66110$export$5280dbcb91c8b391)(config, `Time to fetch balances using blockscout for ${chainId}`, $1564e43dde50bb61$export$8c978679845804d4(walletAddress, chainId, isL1Chain ? tokens : []));
30251
30277
  }
30252
30278
  // This fallback to use ERC20s calls which is a best effort solution
30253
30279
  // Fails in fetching data from the RCP calls might result in some
30254
30280
  // missing data.
30255
- return await $1564e43dde50bb61$export$a3238cee431627c6(config, web3Provider, walletAddress, tokens);
30281
+ return await ($458d407830d66110$export$5280dbcb91c8b391)(config, `Time to fetch balances using RPC for ${chainId}`, $1564e43dde50bb61$export$a3238cee431627c6(config, web3Provider, walletAddress, tokens));
30256
30282
  };
30257
30283
 
30258
30284
 
@@ -30493,7 +30519,7 @@ async function $67fc622a2b913d5f$export$7cf6178417769841(chainId, config) {
30493
30519
  overrides: dexConfig?.overrides
30494
30520
  });
30495
30521
  }
30496
- async function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
30522
+ function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
30497
30523
  return new (Orderbook)({
30498
30524
  baseConfig: {
30499
30525
  environment: config.environment
@@ -31294,8 +31320,8 @@ const $5e9bcae98dc8ff19$export$1165ca270f090a66 = (isDevelopment, isProduction)=
31294
31320
 
31295
31321
 
31296
31322
 
31297
- const $1fda5c40669a566d$export$1fac8e857d728583 = async ()=>false;
31298
- const $1fda5c40669a566d$export$2e83e9eeaf217e20 = async (config)=>{
31323
+ const $1fda5c40669a566d$export$5d79dcabf4595ae0 = async ()=>true;
31324
+ const $1fda5c40669a566d$export$2c2bcd6e0d9a9969 = async (config)=>{
31299
31325
  const availability = ($5e9bcae98dc8ff19$export$1165ca270f090a66)(config.isDevelopment, config.isProduction);
31300
31326
  try {
31301
31327
  return await availability.checkDexAvailability();
@@ -31316,18 +31342,18 @@ const $7f2e17f026d4fc8d$export$86d9f998ddda013e = async (config, provider)=>{
31316
31342
  const geoBlockingChecks = [];
31317
31343
  if (availableRoutingOptions.onRamp) geoBlockingChecks.push({
31318
31344
  id: "onRamp",
31319
- promise: ($1fda5c40669a566d$export$1fac8e857d728583)()
31345
+ promise: ($1fda5c40669a566d$export$5d79dcabf4595ae0)()
31320
31346
  });
31321
31347
  if (availableRoutingOptions.swap) geoBlockingChecks.push({
31322
31348
  id: "swap",
31323
- promise: ($1fda5c40669a566d$export$2e83e9eeaf217e20)(config)
31349
+ promise: ($1fda5c40669a566d$export$2c2bcd6e0d9a9969)(config)
31324
31350
  });
31325
31351
  if (geoBlockingChecks.length > 0) {
31326
31352
  const promises = geoBlockingChecks.map((geoBlockingCheck)=>geoBlockingCheck.promise);
31327
31353
  const geoBlockingStatus = await Promise.allSettled(promises);
31328
31354
  geoBlockingStatus.forEach((result, index)=>{
31329
31355
  const statusId = geoBlockingChecks[index].id;
31330
- availableRoutingOptions[statusId] = availableRoutingOptions[statusId] && result.status === "fulfilled" && !result.value;
31356
+ availableRoutingOptions[statusId] = availableRoutingOptions[statusId] && result.status === "fulfilled" && result.value;
31331
31357
  });
31332
31358
  }
31333
31359
  // Bridge not available if passport provider
@@ -31434,7 +31460,7 @@ const $049bba630af05555$export$6946a1f17c2bbf26 = async (config, chainId, wallet
31434
31460
  }
31435
31461
  // Resolve all the quotes and link them back to the swappable token
31436
31462
  // The swappable token array is in the same position in the array as the quote in the promise array
31437
- const dexTransactionResponse = await Promise.allSettled(dexTransactionResponsePromises);
31463
+ const dexTransactionResponse = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to resolve swap quotes from the dex", Promise.allSettled(dexTransactionResponsePromises));
31438
31464
  dexTransactionResponse.forEach((response, index)=>{
31439
31465
  if (response.status === "rejected") return; // Ignore any requests to dex that failed to resolve
31440
31466
  const swappableToken = fromToken[index];
@@ -31451,15 +31477,6 @@ const $049bba630af05555$export$6946a1f17c2bbf26 = async (config, chainId, wallet
31451
31477
  };
31452
31478
 
31453
31479
 
31454
- const $3ee85f12225c19f3$export$fb80fe94a81a3132 = async (config, dexQuoteCache, walletAddress, requiredToken, swappableTokens)=>{
31455
- const dexQuotes = dexQuoteCache.get(requiredToken.address);
31456
- if (dexQuotes && dexQuotes.size > 0) return dexQuotes;
31457
- const quotes = await ($049bba630af05555$export$6946a1f17c2bbf26)(config, ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config), walletAddress, requiredToken, swappableTokens);
31458
- dexQuoteCache.set(requiredToken.address, quotes);
31459
- return quotes;
31460
- };
31461
-
31462
-
31463
31480
  const $91807edfd7057288$var$constructFees = (approvalGasFees, swapGasFees, swapFees)=>{
31464
31481
  let approvalGasFeeAmount = (ethers.BigNumber).from(0);
31465
31482
  let approvalGasFeeFormatted = "0";
@@ -31587,11 +31604,17 @@ const $91807edfd7057288$export$7b6318fc1a8067b3 = (l2Balances, approval)=>{
31587
31604
  approvalGasTokenAddress: approvalGasTokenAddress
31588
31605
  };
31589
31606
  };
31590
- const $91807edfd7057288$export$38077235fe748d40 = (l2Balances, swapFees, approvalFees, tokenBeingSwapped)=>{
31607
+ const $91807edfd7057288$export$38077235fe748d40 = (l2Balances, approvalFees, swapGasFees, swapFees, tokenBeingSwapped)=>{
31591
31608
  // Set up a map of token addresses to amounts for each of the swap fees
31592
31609
  const feeMap = new Map();
31593
31610
  // Add the approval fee to list of fees
31594
31611
  if (approvalFees.approvalGasTokenAddress !== "") feeMap.set(approvalFees.approvalGasTokenAddress, approvalFees.approvalGasFee);
31612
+ // Add the swap gas fee to list of fees
31613
+ if (swapGasFees) {
31614
+ const fee = feeMap.get(swapGasFees.token.address);
31615
+ if (fee) feeMap.set(swapGasFees.token.address, fee.add(swapGasFees.value));
31616
+ else feeMap.set(swapGasFees.token.address, swapGasFees.value);
31617
+ }
31595
31618
  // Add the token being swapped to list of fees to ensure the user can cover the fee + the token swap
31596
31619
  if (tokenBeingSwapped) {
31597
31620
  const fee = feeMap.get(tokenBeingSwapped.address);
@@ -31640,7 +31663,7 @@ const $91807edfd7057288$export$567a0c83c08c514b = (l2balance, balanceRequirement
31640
31663
  // that is going to be swapped from another item requirement then return true
31641
31664
  return remainingBalance.gte(amountBeingSwapped);
31642
31665
  };
31643
- const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutingOptions, dexQuoteCache, walletAddress, balanceRequirement, tokenBalanceResults, swappableTokens, balanceRequirements)=>{
31666
+ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutingOptions, walletAddress, balanceRequirement, tokenBalanceResults, swappableTokens, balanceRequirements)=>{
31644
31667
  const fundingSteps = [];
31645
31668
  if (!availableRoutingOptions.swap) return fundingSteps;
31646
31669
  if (swappableTokens.length === 0) return fundingSteps;
@@ -31651,7 +31674,7 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
31651
31674
  if (!l2TokenBalanceResult) return fundingSteps;
31652
31675
  const l2Balances = l2TokenBalanceResult.balances;
31653
31676
  if (l2Balances.length === 0) return fundingSteps;
31654
- const quotes = await ($3ee85f12225c19f3$export$fb80fe94a81a3132)(config, dexQuoteCache, walletAddress, requiredToken, swappableTokens);
31677
+ const quotes = await ($049bba630af05555$export$6946a1f17c2bbf26)(config, ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config), walletAddress, requiredToken, swappableTokens);
31655
31678
  const quoteTokenAddresses = Array.from(quotes.keys());
31656
31679
  for (const quoteTokenAddress of quoteTokenAddresses){
31657
31680
  const quote = quotes.get(quoteTokenAddress);
@@ -31668,7 +31691,7 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
31668
31691
  // If user does not have enough to cover approval fees then continue
31669
31692
  if (!approvalFees.sufficient) continue;
31670
31693
  // If user does not have enough to cover swap fees then continue
31671
- if (!$91807edfd7057288$export$38077235fe748d40(l2Balances, quote.quote.fees, approvalFees, {
31694
+ if (!$91807edfd7057288$export$38077235fe748d40(l2Balances, approvalFees, quote.swap, quote.quote.fees, {
31672
31695
  amount: amountOfQuoteTokenRequired.value,
31673
31696
  address: quoteTokenAddress
31674
31697
  })) continue;
@@ -32073,13 +32096,14 @@ const $7500587317643fc8$export$c3e193fd573f1a94 = async (config, swappableTokens
32073
32096
 
32074
32097
 
32075
32098
 
32076
- const $d54df4a884f14123$export$d46f2133747ffd93 = async (config, dexQuoteCache, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens)=>{
32099
+
32100
+ const $d54df4a884f14123$export$d46f2133747ffd93 = async (config, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens)=>{
32077
32101
  const filteredSwappableTokensAddresses = [];
32078
32102
  for (const token of filteredSwappableTokens){
32079
32103
  if (!token.address) continue;
32080
32104
  filteredSwappableTokensAddresses.push(token.address);
32081
32105
  }
32082
- const dexQuotes = await ($3ee85f12225c19f3$export$fb80fe94a81a3132)(config, dexQuoteCache, ownerAddress, {
32106
+ const dexQuotes = await ($049bba630af05555$export$6946a1f17c2bbf26)(config, ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config), ownerAddress, {
32083
32107
  address: requiredTokenAddress,
32084
32108
  amount: insufficientRequirement.delta.balance
32085
32109
  }, filteredSwappableTokensAddresses);
@@ -32189,7 +32213,7 @@ const $afd57acae9471ac5$export$d9b96654eebdaf2a = (bridgeFundingSteps, swapFundi
32189
32213
  }
32190
32214
  return bridgeAndSwapRoutes;
32191
32215
  };
32192
- const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, feeEstimates, tokenBalances, bridgeableTokens, swappableTokens, balanceRequirements)=>{
32216
+ const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, feeEstimates, tokenBalances, bridgeableTokens, swappableTokens, balanceRequirements)=>{
32193
32217
  const { l1balances: l1balances, l2balances: l2balances } = ($7bb5af1d8b5d9127$export$8280985cc3da7882)(config, tokenBalances);
32194
32218
  const requiredTokenAddress = insufficientRequirement.required.token.address;
32195
32219
  if ($afd57acae9471ac5$export$b94e88f4f8805f71(bridgeableTokens, swappableTokens, l1balances, l2balances, availableRoutingOptions, requiredTokenAddress)) return [];
@@ -32200,7 +32224,7 @@ const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProvide
32200
32224
  const filteredSwappableTokens = $afd57acae9471ac5$export$ed7c59bd8d1bb5a7(requiredTokenAddress, bridgeableTokens, swappableTokens, l1tol2Addresses);
32201
32225
  if (filteredSwappableTokens.length === 0) return [];
32202
32226
  // Fetch all the dex quotes from the list of swappable tokens
32203
- const dexQuotes = await ($d54df4a884f14123$export$d46f2133747ffd93)(config, dexQuoteCache, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens);
32227
+ const dexQuotes = await ($d54df4a884f14123$export$d46f2133747ffd93)(config, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens);
32204
32228
  // Construct bridge requirements based on L2 balances, slippage and swap fees
32205
32229
  const bridgeRequirements = ($62e968a3dd87940e$export$df667c749c93b110)(dexQuotes, l1balances, l2balances, l1tol2Addresses, balanceRequirements);
32206
32230
  if (bridgeRequirements.length === 0) return [];
@@ -32243,7 +32267,7 @@ const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProvide
32243
32267
  // Modify the users L2 balance to include the amount as if the user successfully bridged
32244
32268
  const modifiedTokenBalances = $afd57acae9471ac5$var$modifyTokenBalancesWithBridgedAmount(config, tokenBalances, l2balances, bridgedTokens, swappableTokens);
32245
32269
  // Call the swap route with the faked bridged balances
32246
- const swapRoutes = await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, dexQuoteCache, ownerAddress, insufficientRequirement, modifiedTokenBalances, swappableTokensAfterBridging, balanceRequirements);
32270
+ const swapRoutes = await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, ownerAddress, insufficientRequirement, modifiedTokenBalances, swappableTokensAfterBridging, balanceRequirements);
32247
32271
  if (!swapRoutes) return [];
32248
32272
  const originalBalanceSwapRoutes = $afd57acae9471ac5$export$1fc63300bde5e690(tokenBalances, swapRoutes);
32249
32273
  return $afd57acae9471ac5$export$d9b96654eebdaf2a(bridgeResults, originalBalanceSwapRoutes, l1tol2Addresses);
@@ -32285,6 +32309,7 @@ const $5649bc8af91da370$export$1fb2bd867f4a9be3 = async (config, availableRoutin
32285
32309
 
32286
32310
 
32287
32311
 
32312
+
32288
32313
  const $c16168a9c28ae4fd$var$hasAvailableRoutingOptions = (availableRoutingOptions)=>availableRoutingOptions.bridge || availableRoutingOptions.swap || availableRoutingOptions.onRamp;
32289
32314
  const $c16168a9c28ae4fd$export$31ce7ba1a2956195 = (balanceRequirements)=>{
32290
32315
  let insufficientBalanceCount = 0;
@@ -32308,7 +32333,7 @@ const $c16168a9c28ae4fd$export$ab86023c267660 = async (config, readOnlyProviders
32308
32333
  if (availableRoutingOptions.bridge && insufficientRequirement) bridgeFundingStep = await ($fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa)(config, readOnlyProviders, ownerAddress, availableRoutingOptions, bridgeRequirement, tokenBalances, feeEstimates);
32309
32334
  return bridgeFundingStep;
32310
32335
  };
32311
- const $c16168a9c28ae4fd$export$814624e957fa0f11 = async (config, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, swapTokenAllowList, balanceRequirements)=>{
32336
+ const $c16168a9c28ae4fd$export$814624e957fa0f11 = async (config, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, swapTokenAllowList, balanceRequirements)=>{
32312
32337
  const fundingSteps = [];
32313
32338
  if (!availableRoutingOptions.swap) return fundingSteps;
32314
32339
  if (insufficientRequirement === undefined) return fundingSteps;
@@ -32319,9 +32344,9 @@ const $c16168a9c28ae4fd$export$814624e957fa0f11 = async (config, availableRoutin
32319
32344
  if (swapTokenAllowList.length === 0) return fundingSteps;
32320
32345
  const swappableTokens = swapTokenAllowList.filter((token)=>token.address).map((token)=>token.address);
32321
32346
  if (swappableTokens.length === 0) return fundingSteps;
32322
- return await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, dexQuoteCache, ownerAddress, insufficientRequirement, tokenBalances, swappableTokens, balanceRequirements);
32347
+ return await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, ownerAddress, insufficientRequirement, tokenBalances, swappableTokens, balanceRequirements);
32323
32348
  };
32324
- const $c16168a9c28ae4fd$export$2becd43da9d21f73 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, tokenAllowList, feeEstimates, balanceRequirements)=>{
32349
+ const $c16168a9c28ae4fd$export$2becd43da9d21f73 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, tokenAllowList, feeEstimates, balanceRequirements)=>{
32325
32350
  if (!insufficientRequirement) return [];
32326
32351
  const l1balancesResult = tokenBalances.get(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config));
32327
32352
  const l2balancesResult = tokenBalances.get(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
@@ -32339,7 +32364,7 @@ const $c16168a9c28ae4fd$export$2becd43da9d21f73 = async (config, readOnlyProvide
32339
32364
  });
32340
32365
  const swapTokenAllowList = tokenAllowList?.swap ?? [];
32341
32366
  if (insufficientRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE && insufficientRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) return [];
32342
- const routes = await ($afd57acae9471ac5$export$f95ed27e871fe308)(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, feeEstimates, tokenBalances, bridgeableL1Addresses, swapTokenAllowList, balanceRequirements);
32367
+ const routes = await ($afd57acae9471ac5$export$f95ed27e871fe308)(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, feeEstimates, tokenBalances, bridgeableL1Addresses, swapTokenAllowList, balanceRequirements);
32343
32368
  return routes;
32344
32369
  };
32345
32370
  const $c16168a9c28ae4fd$export$e1b6e4d22d0365ee = async (config, availableRoutingOptions, insufficientRequirement)=>{
@@ -32361,20 +32386,18 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
32361
32386
  message: err.message
32362
32387
  });
32363
32388
  }
32364
- const tokenBalances = await ($33acec7b4a26c053$export$23ddeb2642d2f9d)(config, readOnlyProviders, ownerAddress, availableRoutingOptions);
32365
- const allowList = await ($5a5ccedc98d53d25$export$1ad29657d49c5440)(config, tokenBalances, availableRoutingOptions);
32366
- // Bridge and swap fee cache
32389
+ const tokenBalances = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get token balances inside router", ($33acec7b4a26c053$export$23ddeb2642d2f9d)(config, readOnlyProviders, ownerAddress, availableRoutingOptions));
32390
+ const allowList = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get routing allowlist", ($5a5ccedc98d53d25$export$1ad29657d49c5440)(config, tokenBalances, availableRoutingOptions));
32391
+ // Fee estimate cache
32367
32392
  const feeEstimates = new Map();
32368
- // Dex quotes cache
32369
- const dexQuoteCache = new Map();
32370
32393
  // Ensures only 1 balance requirement is insufficient
32371
32394
  const insufficientRequirement = $c16168a9c28ae4fd$export$31ce7ba1a2956195(balanceRequirements);
32372
32395
  const routePromises = [];
32373
32396
  routePromises.push($c16168a9c28ae4fd$export$ab86023c267660(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, feeEstimates));
32374
- routePromises.push($c16168a9c28ae4fd$export$814624e957fa0f11(config, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, allowList.swap, balanceRequirements));
32397
+ routePromises.push($c16168a9c28ae4fd$export$814624e957fa0f11(config, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, allowList.swap, balanceRequirements));
32375
32398
  routePromises.push($c16168a9c28ae4fd$export$e1b6e4d22d0365ee(config, availableRoutingOptions, insufficientRequirement));
32376
- routePromises.push($c16168a9c28ae4fd$export$2becd43da9d21f73(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, allowList, feeEstimates, balanceRequirements));
32377
- const resolved = await Promise.all(routePromises);
32399
+ routePromises.push($c16168a9c28ae4fd$export$2becd43da9d21f73(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, allowList, feeEstimates, balanceRequirements));
32400
+ const resolved = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to resolve all routes", Promise.all(routePromises));
32378
32401
  let bridgeFundingStep;
32379
32402
  let swapFundingSteps = [];
32380
32403
  let onRampFundingStep;
@@ -32441,26 +32464,31 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
32441
32464
  };
32442
32465
 
32443
32466
 
32467
+
32444
32468
  const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemRequirements, transactionOrGasAmount)=>{
32445
32469
  const ownerAddress = await provider.getSigner().getAddress();
32446
32470
  let aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(itemRequirements);
32447
- const erc20Allowances = await ($fc8b338399d890f3$export$d93c00812189e36)(provider, ownerAddress, aggregatedItems);
32448
- const erc721Allowances = await ($35c3fc7013888ba5$export$be546c525d418988)(provider, ownerAddress, aggregatedItems);
32449
- const aggregatedAllowances = ($ddc6bcd0896481e5$export$2fbfa41a4de56a89)(erc20Allowances, erc721Allowances);
32450
- const gasItem = await ($7d1bfafb81e64d74$export$3a4140bd9e983e4e)(provider, aggregatedAllowances, transactionOrGasAmount);
32471
+ const erc20AllowancePromise = ($fc8b338399d890f3$export$d93c00812189e36)(provider, ownerAddress, aggregatedItems);
32472
+ const erc721AllowancePromise = ($35c3fc7013888ba5$export$be546c525d418988)(provider, ownerAddress, aggregatedItems);
32473
+ const resolvedAllowances = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to calculate token allowances", Promise.all([
32474
+ erc20AllowancePromise,
32475
+ erc721AllowancePromise
32476
+ ]));
32477
+ const aggregatedAllowances = ($ddc6bcd0896481e5$export$2fbfa41a4de56a89)(resolvedAllowances[0], resolvedAllowances[1]);
32478
+ const gasItem = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to run gas calculator", ($7d1bfafb81e64d74$export$3a4140bd9e983e4e)(provider, aggregatedAllowances, transactionOrGasAmount));
32451
32479
  if (gasItem !== null) {
32452
32480
  aggregatedItems.push(gasItem);
32453
32481
  aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(aggregatedItems);
32454
32482
  }
32455
- const balanceCheckResult = await ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems);
32483
+ const balanceCheckResult = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to run balance checks", ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems));
32456
32484
  const { sufficient: sufficient } = balanceCheckResult;
32457
32485
  const transactionRequirements = balanceCheckResult.balanceRequirements;
32458
32486
  if (sufficient) return {
32459
32487
  sufficient: sufficient,
32460
32488
  transactionRequirements: transactionRequirements
32461
32489
  };
32462
- const availableRoutingOptions = await ($7f2e17f026d4fc8d$export$86d9f998ddda013e)(config, provider);
32463
- const routingOutcome = await ($c16168a9c28ae4fd$export$92606e71d0a264ff)(config, ownerAddress, balanceCheckResult, availableRoutingOptions);
32490
+ const availableRoutingOptions = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to fetch available routing options", ($7f2e17f026d4fc8d$export$86d9f998ddda013e)(config, provider));
32491
+ const routingOutcome = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Total time to run the routing calculator", ($c16168a9c28ae4fd$export$92606e71d0a264ff)(config, ownerAddress, balanceCheckResult, availableRoutingOptions));
32464
32492
  return {
32465
32493
  sufficient: sufficient,
32466
32494
  transactionRequirements: transactionRequirements,
@@ -32643,6 +32671,7 @@ const $9051cee080948594$export$1e69c9cfc42e28d8 = (orderFees, weiAmount, decimal
32643
32671
  };
32644
32672
 
32645
32673
 
32674
+
32646
32675
  const $64863c39386de592$export$4249179755829904 = (type, contractAddress, amount, spenderAddress)=>{
32647
32676
  switch(type){
32648
32677
  case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20:
@@ -32681,8 +32710,8 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32681
32710
  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);
32682
32711
  const { id: id, takerFees: takerFees } = orders[0];
32683
32712
  try {
32684
- orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
32685
- order = await orderbook.getListing(id);
32713
+ orderbook = $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
32714
+ order = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to fetch the listing from the orderbook", orderbook.getListing(id));
32686
32715
  const { seaportContractAddress: seaportContractAddress } = orderbook.config();
32687
32716
  spenderAddress = seaportContractAddress;
32688
32717
  } catch (err) {
@@ -32699,23 +32728,26 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32699
32728
  let decimals = 18;
32700
32729
  if (order.result.buy[0].type === "ERC20") {
32701
32730
  const tokenContract = $06a6c5c23f7f2479$export$fbbc17f6e6e58544(order.result.buy[0].contractAddress, ($d85ad1457a3f1a83$export$db5daa1b5156ccfe), provider);
32702
- decimals = await tokenContract.decimals();
32731
+ decimals = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get decimals of token contract for the buy token", tokenContract.decimals());
32703
32732
  }
32704
32733
  let fees = [];
32705
32734
  if (takerFees && takerFees.length > 0) fees = ($9051cee080948594$export$1e69c9cfc42e28d8)(takerFees, buyToken.amount, decimals);
32706
32735
  let unsignedApprovalTransactions = [];
32707
32736
  let unsignedFulfillmentTransactions = [];
32708
32737
  let orderActions = [];
32738
+ const fulfillOrderStartTime = new Date().getTime();
32709
32739
  try {
32710
- const fulfillerAddress = await provider.getSigner().getAddress();
32711
- const { actions: actions } = await orderbook.fulfillOrder(id, fulfillerAddress, fees);
32740
+ const fulfillerAddress = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the address from the provider", provider.getSigner().getAddress());
32741
+ const { actions: actions } = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to call fulfillOrder from the orderbook", orderbook.fulfillOrder(id, fulfillerAddress, fees));
32712
32742
  orderActions = actions;
32713
- unsignedApprovalTransactions = await (0, $a7367d01c6e76b1c$export$f64a20a30eb98855)(actions);
32714
- } catch {
32715
- // Silently ignore error as this is usually thrown if user does not have enough balance
32743
+ unsignedApprovalTransactions = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to construct the unsigned approval transactions", (0, $a7367d01c6e76b1c$export$f64a20a30eb98855)(actions));
32744
+ } catch (err) {
32745
+ // Silently ignore error as this is usually thrown if user does not have enough balance
32746
+ const elapsedTimeInSeconds = (new Date().getTime() - fulfillOrderStartTime) / 1000;
32747
+ ($458d407830d66110$export$e6a390ea6399b7d8)(config, "Time to call fulfillOrder from the orderbook", elapsedTimeInSeconds);
32716
32748
  }
32717
32749
  try {
32718
- unsignedFulfillmentTransactions = await (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions);
32750
+ unsignedFulfillmentTransactions = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to construct the unsigned fulfillment transactions", (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions));
32719
32751
  } catch {
32720
32752
  // if cannot estimate gas then silently continue and use gas limit in smartCheckout
32721
32753
  // but get the fulfillment transactions after they have approved the spending
@@ -32747,7 +32779,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32747
32779
  const itemRequirements = [
32748
32780
  $64863c39386de592$export$4249179755829904(type, contractAddress, amount, spenderAddress)
32749
32781
  ];
32750
- const smartCheckoutResult = await ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, $64863c39386de592$export$8f2ff92ab8657f0b(gasLimit, unsignedFulfillmentTransactions));
32782
+ const smartCheckoutResult = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Total time running smart checkout", ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, $64863c39386de592$export$8f2ff92ab8657f0b(gasLimit, unsignedFulfillmentTransactions)));
32751
32783
  if (smartCheckoutResult.sufficient) {
32752
32784
  const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedApprovalTransactions);
32753
32785
  if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
@@ -32789,15 +32821,16 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32789
32821
 
32790
32822
 
32791
32823
 
32824
+
32792
32825
  const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, orderIds)=>{
32793
32826
  let unsignedCancelOrderTransaction;
32794
32827
  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);
32795
32828
  // Update this when bulk cancel is supported
32796
32829
  const orderId = orderIds[0];
32797
32830
  try {
32798
- const offererAddress = await provider.getSigner().getAddress();
32799
- const orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
32800
- const cancelOrderResponse = await orderbook.cancelOrder(orderId, offererAddress);
32831
+ const offererAddress = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the address from the provider", provider.getSigner().getAddress());
32832
+ const orderbook = $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
32833
+ const cancelOrderResponse = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the cancel order from the orderbook", orderbook.cancelOrder(orderId, offererAddress));
32801
32834
  unsignedCancelOrderTransaction = cancelOrderResponse.unsignedCancelOrderTransaction;
32802
32835
  } catch (err) {
32803
32836
  throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while cancelling the order listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CANCEL_ORDER_LISTING_ERROR, {
@@ -32830,6 +32863,7 @@ const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, order
32830
32863
 
32831
32864
 
32832
32865
 
32866
+
32833
32867
  const $9085b221b72ac69e$export$af768ccdf17d5c04 = (id, contractAddress, spenderAddress)=>({
32834
32868
  type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
32835
32869
  id: id,
@@ -32858,15 +32892,15 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
32858
32892
  if (buyToken.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) {
32859
32893
  // get this from the allowed list
32860
32894
  const buyTokenContract = new (ethers.Contract)(buyToken.contractAddress, JSON.stringify(($d85ad1457a3f1a83$export$db5daa1b5156ccfe)), provider);
32861
- decimals = await buyTokenContract.decimals();
32895
+ decimals = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get decimals of token contract for the buy token", buyTokenContract.decimals());
32862
32896
  }
32863
32897
  const buyTokenOrNative = $9085b221b72ac69e$export$586d02673c66d423(buyToken, decimals);
32864
32898
  try {
32865
- const walletAddress = await provider.getSigner().getAddress();
32866
- orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
32899
+ const walletAddress = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the address from the provider", provider.getSigner().getAddress());
32900
+ orderbook = $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
32867
32901
  const { seaportContractAddress: seaportContractAddress } = orderbook.config();
32868
32902
  spenderAddress = seaportContractAddress;
32869
- listing = await orderbook.prepareListing({
32903
+ listing = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to prepare the listing from the orderbook", orderbook.prepareListing({
32870
32904
  makerAddress: walletAddress,
32871
32905
  buy: buyTokenOrNative,
32872
32906
  sell: {
@@ -32874,7 +32908,7 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
32874
32908
  contractAddress: sellToken.collectionAddress,
32875
32909
  tokenId: sellToken.id
32876
32910
  }
32877
- });
32911
+ }));
32878
32912
  } catch (err) {
32879
32913
  throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while preparing the listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PREPARE_ORDER_LISTING_ERROR, {
32880
32914
  message: err.message,
@@ -32885,13 +32919,13 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
32885
32919
  const itemRequirements = [
32886
32920
  $9085b221b72ac69e$export$af768ccdf17d5c04(sellToken.id, sellToken.collectionAddress, spenderAddress)
32887
32921
  ];
32888
- const smartCheckoutResult = await ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, {
32922
+ const smartCheckoutResult = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Total time running smart checkout", ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, {
32889
32923
  type: ($4b58188d47aafe8d$export$65c64e46348ee3c1).GAS,
32890
32924
  gasToken: {
32891
32925
  type: ($4b58188d47aafe8d$export$537fa3efd10ed435).NATIVE,
32892
32926
  limit: (ethers.BigNumber).from((constants).estimatedFulfillmentGasGwei)
32893
32927
  }
32894
- });
32928
+ }));
32895
32929
  if (smartCheckoutResult.sufficient) {
32896
32930
  const unsignedTransactions = await ($a7367d01c6e76b1c$export$c5b3365853cb6159)(listing.actions);
32897
32931
  const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedTransactions.approvalTransactions);
@@ -33295,7 +33329,7 @@ var $045213b18e9f1f94$export$75be0f6af9650f2c;
33295
33329
  })($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
33296
33330
 
33297
33331
 
33298
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.27.11";
33332
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.27.12";
33299
33333
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
33300
33334
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
33301
33335