@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.
package/dist/index.js CHANGED
@@ -3610,7 +3610,7 @@ class MultiRollupApiClients {
3610
3610
  }
3611
3611
 
3612
3612
  // eslint-disable-next-line @typescript-eslint/naming-convention
3613
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.27.10' };
3613
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.27.12' };
3614
3614
  const createConfig = ({ basePath, headers, }) => {
3615
3615
  if (!basePath.trim()) {
3616
3616
  throw Error('basePath can not be empty');
@@ -3670,7 +3670,7 @@ class APIError extends Error {
3670
3670
 
3671
3671
  /* eslint-disable implicit-arrow-linebreak */
3672
3672
  const defaultHeaders = {
3673
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.27.10',
3673
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.27.12',
3674
3674
  };
3675
3675
  /**
3676
3676
  * createAPIConfiguration to create a custom Configuration
@@ -4062,14 +4062,14 @@ class BlockchainData {
4062
4062
  var blockchain_data = /*#__PURE__*/Object.freeze({
4063
4063
  __proto__: null,
4064
4064
  APIError: APIError,
4065
- ActivitiesApi: activitiesApiTypes,
4065
+ ActivitiesTypes: activitiesApiTypes,
4066
4066
  BlockchainData: BlockchainData,
4067
- ChainsApi: chainsApiTypes,
4068
- CollectionsApi: collectionsApiTypes,
4069
- MetadataApi: metadataApiTypes,
4070
- NFTOwnersApi: nftOwnersApiTypes,
4071
- NFTsApi: nftsApiTypes,
4072
- TokensApi: tokensApiTypes
4067
+ ChainsTypes: chainsApiTypes,
4068
+ CollectionsTypes: collectionsApiTypes,
4069
+ MetadataTypes: metadataApiTypes,
4070
+ NFTOwnersTypes: nftOwnersApiTypes,
4071
+ NFTsTypes: nftsApiTypes,
4072
+ TokensTypes: tokensApiTypes
4073
4073
  });
4074
4074
 
4075
4075
  /**
@@ -4081,7 +4081,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
4081
4081
  chainID,
4082
4082
  coreContractAddress,
4083
4083
  registrationContractAddress,
4084
- sdkVersion: 'ts-immutable-sdk-0.27.10',
4084
+ sdkVersion: 'ts-immutable-sdk-0.27.12',
4085
4085
  });
4086
4086
  /**
4087
4087
  * Sets `sdkVersion` at the time of build
@@ -11223,7 +11223,7 @@ class OrdersService {
11223
11223
  * @returns ListListingsResult OK response.
11224
11224
  * @throws ApiError
11225
11225
  */
11226
- listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, sellItemTokenId, pageSize, sortBy, sortDirection, pageCursor, }) {
11226
+ listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, sellItemTokenId, fromUpdatedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
11227
11227
  return this.httpRequest.request({
11228
11228
  method: 'GET',
11229
11229
  url: '/v1/chains/{chain_name}/orders/listings',
@@ -11235,6 +11235,7 @@ class OrdersService {
11235
11235
  'sell_item_contract_address': sellItemContractAddress,
11236
11236
  'buy_item_contract_address': buyItemContractAddress,
11237
11237
  'sell_item_token_id': sellItemTokenId,
11238
+ 'from_updated_at': fromUpdatedAt,
11238
11239
  'page_size': pageSize,
11239
11240
  'sort_by': sortBy,
11240
11241
  'sort_direction': sortDirection,
@@ -11318,7 +11319,7 @@ class OrdersService {
11318
11319
  * @returns ListTradeResult OK response.
11319
11320
  * @throws ApiError
11320
11321
  */
11321
- listTrades({ chainName, accountAddress, pageSize, sortBy, sortDirection, pageCursor, }) {
11322
+ listTrades({ chainName, accountAddress, fromIndexedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
11322
11323
  return this.httpRequest.request({
11323
11324
  method: 'GET',
11324
11325
  url: '/v1/chains/{chain_name}/trades',
@@ -11327,6 +11328,7 @@ class OrdersService {
11327
11328
  },
11328
11329
  query: {
11329
11330
  'account_address': accountAddress,
11331
+ 'from_indexed_at': fromIndexedAt,
11330
11332
  'page_size': pageSize,
11331
11333
  'sort_by': sortBy,
11332
11334
  'sort_direction': sortDirection,
@@ -11392,6 +11394,16 @@ var CancelledOrderStatus;
11392
11394
  })(CancelledOrderStatus.cancellation_type || (CancelledOrderStatus.cancellation_type = {}));
11393
11395
  })(CancelledOrderStatus || (CancelledOrderStatus = {}));
11394
11396
 
11397
+ /* istanbul ignore file */
11398
+ /* tslint:disable */
11399
+ /* eslint-disable */
11400
+ var FailedOrderCancellation;
11401
+ (function (FailedOrderCancellation) {
11402
+ (function (reason_code) {
11403
+ reason_code["ALREADY_FILLED"] = "ALREADY_FILLED";
11404
+ })(FailedOrderCancellation.reason_code || (FailedOrderCancellation.reason_code = {}));
11405
+ })(FailedOrderCancellation || (FailedOrderCancellation = {}));
11406
+
11395
11407
  /* istanbul ignore file */
11396
11408
  /* tslint:disable */
11397
11409
  /* eslint-disable */
@@ -28011,8 +28023,11 @@ function poolEquals(poolA, poolB) {
28011
28023
  return (poolA === poolB ||
28012
28024
  (poolA.token0.equals(poolB.token0) && poolA.token1.equals(poolB.token1) && poolA.fee === poolB.fee));
28013
28025
  }
28014
- async function getERC20Decimals(tokenAddress, provider) {
28015
- const decimalsFunctionSig = ethers.utils.id('decimals()').substring(0, 10);
28026
+ const decimalsFunctionSig = ethers.utils.id('decimals()').substring(0, 10);
28027
+ async function getTokenDecimals(tokenAddress, provider, nativeToken) {
28028
+ if (tokenAddress === 'native') {
28029
+ return nativeToken.decimals;
28030
+ }
28016
28031
  try {
28017
28032
  const decimalsResult = await provider.call({
28018
28033
  to: tokenAddress,
@@ -28040,6 +28055,7 @@ function isValidNonZeroAddress(address) {
28040
28055
  return false;
28041
28056
  }
28042
28057
  }
28058
+ const isValidTokenLiteral = (address) => address === 'native' ? true : isValidNonZeroAddress(address);
28043
28059
  const erc20ToUniswapToken = (token) =>
28044
28060
  // eslint-disable-next-line implicit-arrow-linebreak
28045
28061
  new Uniswap.Token(token.chainId, token.address, token.decimals, token.symbol, token.name);
@@ -28494,12 +28510,13 @@ const getUnsignedERC20ApproveTransaction = (ownerAddress, tokenAmount, spenderAd
28494
28510
  from: ownerAddress,
28495
28511
  };
28496
28512
  };
28497
- const prepareApproval = (tradeType, amountSpecified, amountWithSlippage, contracts, secondaryFees) => {
28498
- const amountOfTokenIn = tradeType === TradeType.EXACT_INPUT ? amountSpecified : amountWithSlippage;
28499
- const spender = secondaryFees.length === 0
28500
- ? contracts.routerAddress
28501
- : contracts.secondaryFeeAddress;
28502
- return { spender, amount: amountOfTokenIn };
28513
+ const prepareApproval = (tradeType, userSpecifiedAmount, quotedAmountWithSlippage, contracts, secondaryFees) => {
28514
+ const amountInToApprove = tradeType === TradeType.EXACT_INPUT ? userSpecifiedAmount : quotedAmountWithSlippage;
28515
+ if (!isERC20Amount(amountInToApprove)) {
28516
+ return null;
28517
+ }
28518
+ const spender = secondaryFees.length === 0 ? contracts.routerAddress : contracts.secondaryFeeAddress;
28519
+ return { spender, amount: amountInToApprove };
28503
28520
  };
28504
28521
  /**
28505
28522
  * Get an unsigned approval transaction if needed
@@ -28544,6 +28561,38 @@ const getApproval = async (provider, ownerAddress, preparedApproval, gasPrice) =
28544
28561
  };
28545
28562
  };
28546
28563
 
28564
+ const canUnwrapToken = (token) => token.type === 'native';
28565
+ class NativeTokenService {
28566
+ nativeToken;
28567
+ wrappedToken;
28568
+ constructor(nativeToken, wrappedToken) {
28569
+ this.nativeToken = nativeToken;
28570
+ this.wrappedToken = wrappedToken;
28571
+ }
28572
+ wrapAmount(amount) {
28573
+ if (!canUnwrapToken(amount.token)) {
28574
+ throw new Error(`cannot wrap non-native token: ${amount.token.address}`);
28575
+ }
28576
+ return newAmount(amount.value, this.wrappedToken);
28577
+ }
28578
+ unwrapAmount(amount) {
28579
+ const isWrappedToken = amount.token.address.toLowerCase() !== this.wrappedToken.address.toLowerCase();
28580
+ if (isWrappedToken) {
28581
+ throw new Error(`cannot unwrap non-wrapped token ${amount.token.address}`);
28582
+ }
28583
+ return newAmount(amount.value, this.nativeToken);
28584
+ }
28585
+ maybeWrapToken(token) {
28586
+ if (canUnwrapToken(token)) {
28587
+ return this.wrappedToken;
28588
+ }
28589
+ return token;
28590
+ }
28591
+ maybeWrapAmount(amount) {
28592
+ return newAmount(amount.value, this.maybeWrapToken(amount.token));
28593
+ }
28594
+ }
28595
+
28547
28596
  // slippageToPercent takes the slippage as a percentage (e.g. 0.1) and
28548
28597
  // converts it to the Uniswap equivalent type
28549
28598
  const slippageToFraction = (slippage) => {
@@ -28563,11 +28612,11 @@ const slippageToFraction = (slippage) => {
28563
28612
  return new Percent(numerator, denominator);
28564
28613
  };
28565
28614
 
28566
- function getQuoteAmountFromTradeType(tradeInfo) {
28567
- if (tradeInfo.tradeType === TradeType.EXACT_INPUT) {
28568
- return tradeInfo.amountOut;
28615
+ function getQuoteAmountFromTradeType(routerQuote) {
28616
+ if (routerQuote.tradeType === TradeType.EXACT_INPUT) {
28617
+ return routerQuote.amountOut;
28569
28618
  }
28570
- return tradeInfo.amountIn;
28619
+ return routerQuote.amountIn;
28571
28620
  }
28572
28621
  function applySlippage(tradeType, amount, slippage) {
28573
28622
  const slippageTolerance = slippageToFraction(slippage);
@@ -28576,6 +28625,18 @@ function applySlippage(tradeType, amount, slippage) {
28576
28625
  const amountWithSlippage = maybeInverted.multiply(amount.toString()).quotient;
28577
28626
  return ethers.BigNumber.from(amountWithSlippage.toString());
28578
28627
  }
28628
+ const prepareUserQuote = (nativeTokenService, routerQuote, slippage, tokenOfQuotedAmount) => {
28629
+ const erc20QuoteAmount = getQuoteAmountFromTradeType(routerQuote);
28630
+ // If the quote amount is the native token, we need to unwrap it if the user originally specified the native token
28631
+ const quotedAmount = canUnwrapToken(tokenOfQuotedAmount)
28632
+ ? nativeTokenService.unwrapAmount(erc20QuoteAmount)
28633
+ : erc20QuoteAmount;
28634
+ const quotedAmountWithMaxSlippage = newAmount(applySlippage(routerQuote.tradeType, quotedAmount.value, slippage), tokenOfQuotedAmount);
28635
+ return {
28636
+ quotedAmount,
28637
+ quotedAmountWithMaxSlippage,
28638
+ };
28639
+ };
28579
28640
  function getOurQuoteReqAmount(amountSpecified, // the amount specified by the user, either exactIn or exactOut
28580
28641
  fees, tradeType, nativeTokenService) {
28581
28642
  if (tradeType === TradeType.EXACT_OUTPUT) {
@@ -28643,39 +28704,6 @@ class Fees {
28643
28704
  }
28644
28705
  }
28645
28706
 
28646
- class NativeTokenService {
28647
- nativeToken;
28648
- wrappedToken;
28649
- constructor(nativeToken, wrappedToken) {
28650
- this.nativeToken = nativeToken;
28651
- this.wrappedToken = wrappedToken;
28652
- }
28653
- wrapAmount(amount) {
28654
- if (!this.isNativeToken(amount.token)) {
28655
- throw new Error(`cannot wrap non-native token: ${amount.token.address}`);
28656
- }
28657
- return newAmount(amount.value, this.wrappedToken);
28658
- }
28659
- unwrapAmount(amount) {
28660
- if (amount.token !== this.wrappedToken) {
28661
- throw new Error(`cannot unwrap non-wrapped token ${amount.token.address}`);
28662
- }
28663
- return newAmount(amount.value, this.nativeToken);
28664
- }
28665
- maybeWrapToken(token) {
28666
- if (this.isNativeToken(token)) {
28667
- return this.wrappedToken;
28668
- }
28669
- return token;
28670
- }
28671
- maybeWrapAmount(amount) {
28672
- return newAmount(amount.value, this.maybeWrapToken(amount.token));
28673
- }
28674
- isNativeToken(token) {
28675
- return token === this.nativeToken;
28676
- }
28677
- }
28678
-
28679
28707
  const IMMUTABLE_TESTNET_RPC_URL = 'https://rpc.testnet.immutable.com';
28680
28708
  const IMMUTABLE_TESTNET_CHAIN_ID = 13472;
28681
28709
  const TIMX_IMMUTABLE_TESTNET = {
@@ -28707,7 +28735,9 @@ function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountI
28707
28735
  recipient: fee.recipient,
28708
28736
  }));
28709
28737
  if (trade.tradeType === TradeType.EXACT_INPUT) {
28710
- return secondaryFeeContract.encodeFunctionData('exactInputSingleWithSecondaryFee', [secondaryFeeValues, {
28738
+ return secondaryFeeContract.encodeFunctionData('exactInputSingleWithSecondaryFee', [
28739
+ secondaryFeeValues,
28740
+ {
28711
28741
  tokenIn: route.tokenPath[0].address,
28712
28742
  tokenOut: route.tokenPath[1].address,
28713
28743
  fee: route.pools[0].fee,
@@ -28715,9 +28745,12 @@ function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountI
28715
28745
  amountIn,
28716
28746
  amountOutMinimum: amountOut,
28717
28747
  sqrtPriceLimitX96: 0,
28718
- }]);
28748
+ },
28749
+ ]);
28719
28750
  }
28720
- return secondaryFeeContract.encodeFunctionData('exactOutputSingleWithSecondaryFee', [secondaryFeeValues, {
28751
+ return secondaryFeeContract.encodeFunctionData('exactOutputSingleWithSecondaryFee', [
28752
+ secondaryFeeValues,
28753
+ {
28721
28754
  tokenIn: route.tokenPath[0].address,
28722
28755
  tokenOut: route.tokenPath[1].address,
28723
28756
  fee: route.pools[0].fee,
@@ -28725,7 +28758,8 @@ function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountI
28725
28758
  amountInMaximum: amountIn,
28726
28759
  amountOut,
28727
28760
  sqrtPriceLimitX96: 0,
28728
- }]);
28761
+ },
28762
+ ]);
28729
28763
  }
28730
28764
  function buildSwapParametersForMultiPoolSwap(fromAddress, trade, route, amountIn, amountOut, secondaryFees, secondaryFeeContract) {
28731
28765
  const path = encodeRouteToPath(route, trade.tradeType === TradeType.EXACT_OUTPUT);
@@ -28734,19 +28768,25 @@ function buildSwapParametersForMultiPoolSwap(fromAddress, trade, route, amountIn
28734
28768
  recipient: fee.recipient,
28735
28769
  }));
28736
28770
  if (trade.tradeType === TradeType.EXACT_INPUT) {
28737
- return secondaryFeeContract.encodeFunctionData('exactInputWithSecondaryFee', [secondaryFeeValues, {
28771
+ return secondaryFeeContract.encodeFunctionData('exactInputWithSecondaryFee', [
28772
+ secondaryFeeValues,
28773
+ {
28738
28774
  path,
28739
28775
  recipient: fromAddress,
28740
28776
  amountIn,
28741
28777
  amountOutMinimum: amountOut,
28742
- }]);
28778
+ },
28779
+ ]);
28743
28780
  }
28744
- return secondaryFeeContract.encodeFunctionData('exactOutputWithSecondaryFee', [secondaryFeeValues, {
28781
+ return secondaryFeeContract.encodeFunctionData('exactOutputWithSecondaryFee', [
28782
+ secondaryFeeValues,
28783
+ {
28745
28784
  path,
28746
28785
  recipient: fromAddress,
28747
28786
  amountInMaximum: amountIn,
28748
28787
  amountOut,
28749
- }]);
28788
+ },
28789
+ ]);
28750
28790
  }
28751
28791
  /**
28752
28792
  * Builds swap parameters
@@ -28771,7 +28811,10 @@ function buildSwapParameters(fromAddress, trade, options, secondaryFees, seconda
28771
28811
  function createSwapCallParametersWithFees(trade, fromAddress, swapOptions, secondaryFees) {
28772
28812
  const secondaryFeeContract = SecondaryFee__factory.createInterface();
28773
28813
  const swapWithFeesCalldata = buildSwapParameters(fromAddress, trade, swapOptions, secondaryFees, secondaryFeeContract);
28774
- return secondaryFeeContract.encodeFunctionData(multicallWithDeadlineFunctionSignature, [swapOptions.deadlineOrPreviousBlockhash, [swapWithFeesCalldata]]);
28814
+ return secondaryFeeContract.encodeFunctionData(multicallWithDeadlineFunctionSignature, [
28815
+ swapOptions.deadlineOrPreviousBlockhash,
28816
+ [swapWithFeesCalldata],
28817
+ ]);
28775
28818
  }
28776
28819
  function createSwapParameters(adjustedQuote, fromAddress, slippage, deadline, secondaryFees) {
28777
28820
  // Create an unchecked trade to be used in generating swap parameters.
@@ -28811,7 +28854,7 @@ function getSwap(adjustedQuote, fromAddress, slippage, deadline, peripheryRouter
28811
28854
  const adjustAmountIn = (ourQuote, amountSpecified, fees, nativeTokenService) => {
28812
28855
  if (ourQuote.tradeType === TradeType.EXACT_OUTPUT) {
28813
28856
  // when doing exact output, calculate the fees based on the amountIn
28814
- const amountToAdd = nativeTokenService.isNativeToken(fees.token)
28857
+ const amountToAdd = canUnwrapToken(fees.token)
28815
28858
  ? nativeTokenService.unwrapAmount(ourQuote.amountIn)
28816
28859
  : ourQuote.amountIn;
28817
28860
  fees.addAmount(amountToAdd);
@@ -28928,8 +28971,8 @@ class ExchangeConfiguration {
28928
28971
  }
28929
28972
 
28930
28973
  const toPublicQuote = (amount, amountWithMaxSlippage, slippage, fees) => ({
28931
- amount,
28932
- amountWithMaxSlippage,
28974
+ amount: toPublicAmount(amount),
28975
+ amountWithMaxSlippage: toPublicAmount(amountWithMaxSlippage),
28933
28976
  slippage,
28934
28977
  fees: fees.withAmounts().map((fee) => ({
28935
28978
  ...fee,
@@ -28964,8 +29007,8 @@ class Exchange {
28964
29007
  }
28965
29008
  static validate(tokenInAddress, tokenOutAddress, maxHops, slippagePercent, fromAddress) {
28966
29009
  assert(isValidNonZeroAddress(fromAddress), new InvalidAddressError('invalid from address'));
28967
- assert(isValidNonZeroAddress(tokenInAddress), new InvalidAddressError('invalid token in address'));
28968
- assert(isValidNonZeroAddress(tokenOutAddress), new InvalidAddressError('invalid token out address'));
29010
+ assert(isValidTokenLiteral(tokenInAddress), new InvalidAddressError('invalid token in address'));
29011
+ assert(isValidTokenLiteral(tokenOutAddress), new InvalidAddressError('invalid token out address'));
28969
29012
  assert(tokenInAddress.toLocaleLowerCase() !== tokenOutAddress.toLocaleLowerCase(), new DuplicateAddressesError());
28970
29013
  assert(maxHops <= MAX_MAX_HOPS, new InvalidMaxHopsError('max hops must be less than or equal to 10'));
28971
29014
  assert(maxHops >= MIN_MAX_HOPS, new InvalidMaxHopsError('max hops must be greater than or equal to 1'));
@@ -28983,61 +29026,63 @@ class Exchange {
28983
29026
  }
28984
29027
  return this.secondaryFees;
28985
29028
  }
28986
- async getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, amount, slippagePercent, maxHops, deadline, tradeType) {
28987
- Exchange.validate(tokenInAddress, tokenOutAddress, maxHops, slippagePercent, fromAddress);
29029
+ parseTokenLiteral(tokenLiteral, decimals) {
29030
+ if (tokenLiteral === 'native') {
29031
+ return this.nativeToken;
29032
+ }
29033
+ return {
29034
+ type: 'erc20',
29035
+ address: tokenLiteral,
29036
+ chainId: this.chainId,
29037
+ decimals,
29038
+ };
29039
+ }
29040
+ async getUnsignedSwapTx(fromAddress, tokenInLiteral, tokenOutLiteral, amount, slippagePercent, maxHops, deadline, tradeType) {
29041
+ Exchange.validate(tokenInLiteral, tokenOutLiteral, maxHops, slippagePercent, fromAddress);
28988
29042
  // get the decimals of the tokens that will be swapped
28989
29043
  const [tokenInDecimals, tokenOutDecimals, secondaryFees] = await Promise.all([
28990
- getERC20Decimals(tokenInAddress, this.provider),
28991
- getERC20Decimals(tokenOutAddress, this.provider),
29044
+ getTokenDecimals(tokenInLiteral, this.provider, this.nativeToken),
29045
+ getTokenDecimals(tokenOutLiteral, this.provider, this.nativeToken),
28992
29046
  this.getSecondaryFees(),
28993
29047
  ]);
28994
- const tokenIn = {
28995
- type: 'erc20',
28996
- address: tokenInAddress,
28997
- chainId: this.chainId,
28998
- decimals: tokenInDecimals,
28999
- };
29000
- const tokenOut = {
29001
- type: 'erc20',
29002
- address: tokenOutAddress,
29003
- chainId: this.chainId,
29004
- decimals: tokenOutDecimals,
29005
- };
29048
+ const tokenIn = this.parseTokenLiteral(tokenInLiteral, tokenInDecimals);
29049
+ const tokenOut = this.parseTokenLiteral(tokenOutLiteral, tokenOutDecimals);
29006
29050
  // determine which amount was specified for the swap from the TradeType
29007
29051
  const [tokenSpecified, otherToken] = tradeType === TradeType.EXACT_INPUT ? [tokenIn, tokenOut] : [tokenOut, tokenIn];
29008
29052
  const amountSpecified = newAmount(amount, tokenSpecified);
29009
29053
  const fees = new Fees(secondaryFees, tokenIn);
29010
29054
  const ourQuoteReqAmount = getOurQuoteReqAmount(amountSpecified, fees, tradeType, this.nativeTokenService);
29011
- // get quote and gas details
29055
+ // Quotes will always use ERC20s. If the user-specified token is Native, we use the Wrapped Native Token pool
29012
29056
  const [ourQuote, gasPrice] = await Promise.all([
29013
- this.router.findOptimalRoute(ourQuoteReqAmount, otherToken, tradeType, maxHops),
29057
+ this.router.findOptimalRoute(ourQuoteReqAmount, this.nativeTokenService.maybeWrapToken(otherToken), tradeType, maxHops),
29014
29058
  fetchGasPrice(this.provider, this.nativeToken),
29015
29059
  ]);
29016
29060
  const adjustedQuote = adjustQuoteWithFees(ourQuote, amountSpecified, fees, this.nativeTokenService);
29017
29061
  const swap = getSwap(adjustedQuote, fromAddress, slippagePercent, deadline, this.routerContractAddress, this.secondaryFeeContractAddress, gasPrice, secondaryFees, this.nativeTokenService);
29018
- const quotedAmount = getQuoteAmountFromTradeType(adjustedQuote);
29019
- const amountWithMaxSlippage = newAmount(applySlippage(adjustedQuote.tradeType, quotedAmount.value, slippagePercent), otherToken);
29020
- const preparedApproval = prepareApproval(tradeType, amountSpecified, amountWithMaxSlippage, {
29062
+ const { quotedAmount, quotedAmountWithMaxSlippage } = prepareUserQuote(this.nativeTokenService, adjustedQuote, slippagePercent, otherToken);
29063
+ const preparedApproval = prepareApproval(tradeType, amountSpecified, quotedAmountWithMaxSlippage, {
29021
29064
  routerAddress: this.routerContractAddress,
29022
29065
  secondaryFeeAddress: this.secondaryFeeContractAddress,
29023
29066
  }, secondaryFees);
29024
29067
  // preparedApproval always uses the tokenIn address because we are always selling the tokenIn
29025
- const approval = await getApproval(this.provider, fromAddress, preparedApproval, gasPrice);
29026
- const quote = toPublicQuote(quotedAmount, amountWithMaxSlippage, slippagePercent, fees);
29068
+ const approval = preparedApproval
29069
+ ? await getApproval(this.provider, fromAddress, preparedApproval, gasPrice)
29070
+ : null;
29071
+ const quote = toPublicQuote(quotedAmount, quotedAmountWithMaxSlippage, slippagePercent, fees);
29027
29072
  return { quote, approval, swap };
29028
29073
  }
29029
29074
  /**
29030
29075
  * Get the unsigned swap transaction given the amount to sell.
29031
29076
  * Includes quote details for the swap.
29032
29077
  *
29033
- * @param {string} fromAddress The public address that will sign and submit the transaction.
29034
- * @param {string} tokenInAddress Token address to sell.
29035
- * @param {string} tokenOutAddress Token address to buy.
29036
- * @param {ethers.BigNumberish} amountIn Amount to sell.
29037
- * @param {number} slippagePercent (optional) The percentage of slippage tolerance. Default = 0.1. Max = 50. Min = 0.
29038
- * @param {number} maxHops (optional) Maximum hops allowed in optimal route. Default is 2.
29039
- * @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes.
29040
- * @return {TransactionResponse} The result containing the unsigned transaction and details of the swap.
29078
+ * @param {string} fromAddress The public address that will sign and submit the transaction
29079
+ * @param {string} tokenInAddress Token address or 'native' to sell
29080
+ * @param {string} tokenOutAddress Token address or 'native' to buy
29081
+ * @param {ethers.BigNumberish} amountIn Amount to sell in the smallest unit of the token-in
29082
+ * @param {number} slippagePercent (optional) The percentage of slippage tolerance. Default = 0.1. Max = 50. Min = 0
29083
+ * @param {number} maxHops (optional) Maximum hops allowed in optimal route. Default is 2
29084
+ * @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes
29085
+ * @return {TransactionResponse} The result containing the unsigned transaction and details of the swap
29041
29086
  */
29042
29087
  async getUnsignedSwapTxFromAmountIn(fromAddress, tokenInAddress, tokenOutAddress, amountIn, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline = DEFAULT_DEADLINE) {
29043
29088
  return await this.getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, ethers.BigNumber.from(amountIn), slippagePercent, maxHops, deadline, TradeType.EXACT_INPUT);
@@ -29046,14 +29091,14 @@ class Exchange {
29046
29091
  * Get the unsigned swap transaction given the amount to buy.
29047
29092
  * Includes quote details for the swap.
29048
29093
  *
29049
- * @param {string} fromAddress The public address that will sign and submit the transaction.
29050
- * @param {string} tokenInAddress Token address to sell.
29051
- * @param {string} tokenOutAddress Token address to buy.
29052
- * @param {ethers.BigNumberish} amountOut Amount to buy.
29053
- * @param {number} slippagePercent (optional) The percentage of slippage tolerance. Default = 0.1. Max = 50. Min = 0.
29054
- * @param {number} maxHops (optional) Maximum hops allowed in optimal route. Default is 2.
29055
- * @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes.
29056
- * @return {TransactionResponse} The result containing the unsigned transaction and details of the swap.
29094
+ * @param {string} fromAddress The public address that will sign and submit the transaction
29095
+ * @param {string} tokenInAddress ERC20 contract address or 'native' to sell
29096
+ * @param {string} tokenOutAddress ERC20 contract address or 'native' to buy
29097
+ * @param {ethers.BigNumberish} amountOut Amount to buy in the smallest unit of the token-out
29098
+ * @param {number} slippagePercent (optional) The percentage of slippage tolerance. Default = 0.1. Max = 50. Min = 0
29099
+ * @param {number} maxHops (optional) Maximum hops allowed in optimal route. Default is 2
29100
+ * @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes
29101
+ * @return {TransactionResponse} The result containing the unsigned transaction and details of the swap
29057
29102
  */
29058
29103
  async getUnsignedSwapTxFromAmountOut(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline = DEFAULT_DEADLINE) {
29059
29104
  return await this.getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, ethers.BigNumber.from(amountOut), slippagePercent, maxHops, deadline, TradeType.EXACT_OUTPUT);
@@ -29297,6 +29342,14 @@ const $d85ad1457a3f1a83$export$fc55ed5a42b458ba = {
29297
29342
  [($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET]: {
29298
29343
  url: "https://explorer.mainnet.immutable.com",
29299
29344
  nativeToken: $d85ad1457a3f1a83$export$6f24f3cef7d501c4.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET).nativeCurrency
29345
+ },
29346
+ [($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA]: {
29347
+ url: "https://eth-sepolia.blockscout.com",
29348
+ nativeToken: $d85ad1457a3f1a83$export$3e81fc0987227f10.get(($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA).nativeCurrency
29349
+ },
29350
+ [($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM]: {
29351
+ url: "https://eth.blockscout.com/",
29352
+ nativeToken: $d85ad1457a3f1a83$export$6f24f3cef7d501c4.get(($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM).nativeCurrency
29300
29353
  }
29301
29354
  };
29302
29355
  const $d85ad1457a3f1a83$export$db5daa1b5156ccfe = [
@@ -29896,6 +29949,7 @@ const $efe60cea83bfc4e8$export$473cec51305fdae8 = async (config, { type: type =
29896
29949
 
29897
29950
 
29898
29951
 
29952
+
29899
29953
  const $fd8a8472dcc3ec2b$var$CACHE_DATA_TTL = 60; // seconds
29900
29954
  class $fd8a8472dcc3ec2b$export$ef140a6b05dfc786 {
29901
29955
  url;
@@ -30029,6 +30083,20 @@ class $fd8a8472dcc3ec2b$export$ef140a6b05dfc786 {
30029
30083
 
30030
30084
 
30031
30085
 
30086
+ const $458d407830d66110$export$e6a390ea6399b7d8 = (config, debugString, seconds)=>{
30087
+ // eslint-disable-next-line no-console
30088
+ if (!config.isProduction) console.debug(debugString, seconds);
30089
+ };
30090
+ const $458d407830d66110$export$5280dbcb91c8b391 = async (config, debugString, promise)=>{
30091
+ const startTime = performance.now();
30092
+ const result = await promise;
30093
+ const endTime = performance.now();
30094
+ const elapsedTimeInSeconds = (endTime - startTime) / 1000;
30095
+ $458d407830d66110$export$e6a390ea6399b7d8(config, debugString, elapsedTimeInSeconds);
30096
+ return result;
30097
+ };
30098
+
30099
+
30032
30100
  const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (config, web3Provider, walletAddress)=>await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
30033
30101
  const networkInfo = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(config, web3Provider);
30034
30102
  if (!networkInfo.isSupported) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Chain:${networkInfo.chainId} is not a supported chain`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR, {
@@ -30068,18 +30136,23 @@ async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAdd
30068
30136
  type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC20_BALANCE_ERROR
30069
30137
  });
30070
30138
  }
30071
- // Blockscout client singleton
30072
- let $1564e43dde50bb61$var$blockscoutClient;
30073
- const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId, rename)=>{
30139
+ // Blockscout client singleton per chain id
30140
+ const $1564e43dde50bb61$var$blockscoutClientMap = new Map();
30141
+ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId, filterTokens)=>{
30074
30142
  // Shuffle the mapping of the tokens configuration so it is a hashmap
30075
30143
  // for faster access to tokens config objects.
30076
- const mapRename = Object.assign({}, ...rename.map((t)=>({
30144
+ const shouldFilter = filterTokens.length > 0;
30145
+ const mapFilterTokens = Object.assign({}, ...filterTokens.map((t)=>({
30077
30146
  [t.address || ""]: t
30078
30147
  })));
30079
- // Ensure singleton is present and match the selected chain
30080
- if (!$1564e43dde50bb61$var$blockscoutClient || $1564e43dde50bb61$var$blockscoutClient.chainId !== chainId) $1564e43dde50bb61$var$blockscoutClient = new ($fd8a8472dcc3ec2b$export$ef140a6b05dfc786)({
30081
- chainId: chainId
30082
- });
30148
+ // Get blockscout client for the given chain
30149
+ let blockscoutClient = $1564e43dde50bb61$var$blockscoutClientMap.get(chainId);
30150
+ if (!blockscoutClient) {
30151
+ blockscoutClient = new ($fd8a8472dcc3ec2b$export$ef140a6b05dfc786)({
30152
+ chainId: chainId
30153
+ });
30154
+ $1564e43dde50bb61$var$blockscoutClientMap.set(chainId, blockscoutClient);
30155
+ }
30083
30156
  // Hold the items in an array for post-fetching processing
30084
30157
  const items = [];
30085
30158
  const tokenType = ($887a00f8f72d61f0$export$5bd1ea2b3d18210).ERC20;
@@ -30089,7 +30162,7 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
30089
30162
  try {
30090
30163
  do {
30091
30164
  // eslint-disable-next-line no-await-in-loop
30092
- resp = await $1564e43dde50bb61$var$blockscoutClient.getTokensByWalletAddress({
30165
+ resp = await blockscoutClient.getTokensByWalletAddress({
30093
30166
  walletAddress: walletAddress,
30094
30167
  tokenType: tokenType,
30095
30168
  nextPage: resp?.next_page_params
@@ -30107,7 +30180,7 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
30107
30180
  if (err?.code !== (HttpStatusCode$2).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getTokensByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
30108
30181
  }
30109
30182
  try {
30110
- const respNative = await $1564e43dde50bb61$var$blockscoutClient.getNativeTokenByWalletAddress({
30183
+ const respNative = await blockscoutClient.getNativeTokenByWalletAddress({
30111
30184
  walletAddress: walletAddress
30112
30185
  });
30113
30186
  items.push(respNative);
@@ -30121,24 +30194,26 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
30121
30194
  // or simply an incorrect wallet address was provided.
30122
30195
  if (err?.code !== (HttpStatusCode$2).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getNativeTokenByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
30123
30196
  }
30197
+ const balances = [];
30198
+ items.forEach((item)=>{
30199
+ if (shouldFilter && !mapFilterTokens[item.token.address]) return;
30200
+ const tokenData = item.token || {};
30201
+ const balance = (BigNumber$1).from(item.value);
30202
+ let decimals = parseInt(tokenData.decimals, 10);
30203
+ if (Number.isNaN(decimals)) decimals = ($d85ad1457a3f1a83$export$903389470ba9433c);
30204
+ const token = {
30205
+ ...tokenData,
30206
+ decimals: decimals
30207
+ };
30208
+ const formattedBalance = (utils$1).formatUnits(item.value, token.decimals);
30209
+ balances.push({
30210
+ balance: balance,
30211
+ formattedBalance: formattedBalance,
30212
+ token: token
30213
+ });
30214
+ });
30124
30215
  return {
30125
- balances: items.map((item)=>{
30126
- const tokenData = item.token || {};
30127
- const balance = (BigNumber$1).from(item.value);
30128
- const renamed = mapRename[tokenData.address] || {};
30129
- const token = {
30130
- ...tokenData,
30131
- name: renamed.name ?? tokenData.name,
30132
- symbol: renamed.symbol ?? tokenData.symbol,
30133
- decimals: parseInt(tokenData.decimals, 10)
30134
- };
30135
- const formattedBalance = (utils$1).formatUnits(item.value, token.decimals);
30136
- return {
30137
- balance: balance,
30138
- formattedBalance: formattedBalance,
30139
- token: token
30140
- };
30141
- })
30216
+ balances: balances
30142
30217
  };
30143
30218
  };
30144
30219
  const $1564e43dde50bb61$export$a3238cee431627c6 = async (config, web3Provider, walletAddress, tokens)=>{
@@ -30169,11 +30244,19 @@ const $1564e43dde50bb61$export$fee49741664a4d7e = async (config, web3Provider, w
30169
30244
  // eslint-disable-next-line no-console
30170
30245
  console.error(err);
30171
30246
  }
30172
- if (flag && ($fd8a8472dcc3ec2b$export$ef140a6b05dfc786).isChainSupported(chainId)) return await $1564e43dde50bb61$export$8c978679845804d4(walletAddress, chainId, tokens);
30247
+ if (flag && ($fd8a8472dcc3ec2b$export$ef140a6b05dfc786).isChainSupported(chainId)) {
30248
+ // This is a hack because the widgets are still using the tokens symbol
30249
+ // to drive the conversions. If we remove all the token symbols from e.g. zkevm
30250
+ // then we would not have fiat conversions.
30251
+ // Please remove this hack once https://immutable.atlassian.net/browse/WT-1710
30252
+ // is done.
30253
+ const isL1Chain = ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config) === chainId;
30254
+ return ($458d407830d66110$export$5280dbcb91c8b391)(config, `Time to fetch balances using blockscout for ${chainId}`, $1564e43dde50bb61$export$8c978679845804d4(walletAddress, chainId, isL1Chain ? tokens : []));
30255
+ }
30173
30256
  // This fallback to use ERC20s calls which is a best effort solution
30174
30257
  // Fails in fetching data from the RCP calls might result in some
30175
30258
  // missing data.
30176
- return await $1564e43dde50bb61$export$a3238cee431627c6(config, web3Provider, walletAddress, tokens);
30259
+ return await ($458d407830d66110$export$5280dbcb91c8b391)(config, `Time to fetch balances using RPC for ${chainId}`, $1564e43dde50bb61$export$a3238cee431627c6(config, web3Provider, walletAddress, tokens));
30177
30260
  };
30178
30261
 
30179
30262
 
@@ -30414,7 +30497,7 @@ async function $67fc622a2b913d5f$export$7cf6178417769841(chainId, config) {
30414
30497
  overrides: dexConfig?.overrides
30415
30498
  });
30416
30499
  }
30417
- async function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
30500
+ function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
30418
30501
  return new (Orderbook)({
30419
30502
  baseConfig: {
30420
30503
  environment: config.environment
@@ -31215,8 +31298,8 @@ const $5e9bcae98dc8ff19$export$1165ca270f090a66 = (isDevelopment, isProduction)=
31215
31298
 
31216
31299
 
31217
31300
 
31218
- const $1fda5c40669a566d$export$1fac8e857d728583 = async ()=>false;
31219
- const $1fda5c40669a566d$export$2e83e9eeaf217e20 = async (config)=>{
31301
+ const $1fda5c40669a566d$export$5d79dcabf4595ae0 = async ()=>true;
31302
+ const $1fda5c40669a566d$export$2c2bcd6e0d9a9969 = async (config)=>{
31220
31303
  const availability = ($5e9bcae98dc8ff19$export$1165ca270f090a66)(config.isDevelopment, config.isProduction);
31221
31304
  try {
31222
31305
  return await availability.checkDexAvailability();
@@ -31237,18 +31320,18 @@ const $7f2e17f026d4fc8d$export$86d9f998ddda013e = async (config, provider)=>{
31237
31320
  const geoBlockingChecks = [];
31238
31321
  if (availableRoutingOptions.onRamp) geoBlockingChecks.push({
31239
31322
  id: "onRamp",
31240
- promise: ($1fda5c40669a566d$export$1fac8e857d728583)()
31323
+ promise: ($1fda5c40669a566d$export$5d79dcabf4595ae0)()
31241
31324
  });
31242
31325
  if (availableRoutingOptions.swap) geoBlockingChecks.push({
31243
31326
  id: "swap",
31244
- promise: ($1fda5c40669a566d$export$2e83e9eeaf217e20)(config)
31327
+ promise: ($1fda5c40669a566d$export$2c2bcd6e0d9a9969)(config)
31245
31328
  });
31246
31329
  if (geoBlockingChecks.length > 0) {
31247
31330
  const promises = geoBlockingChecks.map((geoBlockingCheck)=>geoBlockingCheck.promise);
31248
31331
  const geoBlockingStatus = await Promise.allSettled(promises);
31249
31332
  geoBlockingStatus.forEach((result, index)=>{
31250
31333
  const statusId = geoBlockingChecks[index].id;
31251
- availableRoutingOptions[statusId] = availableRoutingOptions[statusId] && result.status === "fulfilled" && !result.value;
31334
+ availableRoutingOptions[statusId] = availableRoutingOptions[statusId] && result.status === "fulfilled" && result.value;
31252
31335
  });
31253
31336
  }
31254
31337
  // Bridge not available if passport provider
@@ -31355,7 +31438,7 @@ const $049bba630af05555$export$6946a1f17c2bbf26 = async (config, chainId, wallet
31355
31438
  }
31356
31439
  // Resolve all the quotes and link them back to the swappable token
31357
31440
  // The swappable token array is in the same position in the array as the quote in the promise array
31358
- const dexTransactionResponse = await Promise.allSettled(dexTransactionResponsePromises);
31441
+ const dexTransactionResponse = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to resolve swap quotes from the dex", Promise.allSettled(dexTransactionResponsePromises));
31359
31442
  dexTransactionResponse.forEach((response, index)=>{
31360
31443
  if (response.status === "rejected") return; // Ignore any requests to dex that failed to resolve
31361
31444
  const swappableToken = fromToken[index];
@@ -31372,15 +31455,6 @@ const $049bba630af05555$export$6946a1f17c2bbf26 = async (config, chainId, wallet
31372
31455
  };
31373
31456
 
31374
31457
 
31375
- const $3ee85f12225c19f3$export$fb80fe94a81a3132 = async (config, dexQuoteCache, walletAddress, requiredToken, swappableTokens)=>{
31376
- const dexQuotes = dexQuoteCache.get(requiredToken.address);
31377
- if (dexQuotes && dexQuotes.size > 0) return dexQuotes;
31378
- const quotes = await ($049bba630af05555$export$6946a1f17c2bbf26)(config, ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config), walletAddress, requiredToken, swappableTokens);
31379
- dexQuoteCache.set(requiredToken.address, quotes);
31380
- return quotes;
31381
- };
31382
-
31383
-
31384
31458
  const $91807edfd7057288$var$constructFees = (approvalGasFees, swapGasFees, swapFees)=>{
31385
31459
  let approvalGasFeeAmount = (BigNumber$1).from(0);
31386
31460
  let approvalGasFeeFormatted = "0";
@@ -31508,11 +31582,17 @@ const $91807edfd7057288$export$7b6318fc1a8067b3 = (l2Balances, approval)=>{
31508
31582
  approvalGasTokenAddress: approvalGasTokenAddress
31509
31583
  };
31510
31584
  };
31511
- const $91807edfd7057288$export$38077235fe748d40 = (l2Balances, swapFees, approvalFees, tokenBeingSwapped)=>{
31585
+ const $91807edfd7057288$export$38077235fe748d40 = (l2Balances, approvalFees, swapGasFees, swapFees, tokenBeingSwapped)=>{
31512
31586
  // Set up a map of token addresses to amounts for each of the swap fees
31513
31587
  const feeMap = new Map();
31514
31588
  // Add the approval fee to list of fees
31515
31589
  if (approvalFees.approvalGasTokenAddress !== "") feeMap.set(approvalFees.approvalGasTokenAddress, approvalFees.approvalGasFee);
31590
+ // Add the swap gas fee to list of fees
31591
+ if (swapGasFees) {
31592
+ const fee = feeMap.get(swapGasFees.token.address);
31593
+ if (fee) feeMap.set(swapGasFees.token.address, fee.add(swapGasFees.value));
31594
+ else feeMap.set(swapGasFees.token.address, swapGasFees.value);
31595
+ }
31516
31596
  // Add the token being swapped to list of fees to ensure the user can cover the fee + the token swap
31517
31597
  if (tokenBeingSwapped) {
31518
31598
  const fee = feeMap.get(tokenBeingSwapped.address);
@@ -31561,7 +31641,7 @@ const $91807edfd7057288$export$567a0c83c08c514b = (l2balance, balanceRequirement
31561
31641
  // that is going to be swapped from another item requirement then return true
31562
31642
  return remainingBalance.gte(amountBeingSwapped);
31563
31643
  };
31564
- const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutingOptions, dexQuoteCache, walletAddress, balanceRequirement, tokenBalanceResults, swappableTokens, balanceRequirements)=>{
31644
+ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutingOptions, walletAddress, balanceRequirement, tokenBalanceResults, swappableTokens, balanceRequirements)=>{
31565
31645
  const fundingSteps = [];
31566
31646
  if (!availableRoutingOptions.swap) return fundingSteps;
31567
31647
  if (swappableTokens.length === 0) return fundingSteps;
@@ -31572,7 +31652,7 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
31572
31652
  if (!l2TokenBalanceResult) return fundingSteps;
31573
31653
  const l2Balances = l2TokenBalanceResult.balances;
31574
31654
  if (l2Balances.length === 0) return fundingSteps;
31575
- const quotes = await ($3ee85f12225c19f3$export$fb80fe94a81a3132)(config, dexQuoteCache, walletAddress, requiredToken, swappableTokens);
31655
+ const quotes = await ($049bba630af05555$export$6946a1f17c2bbf26)(config, ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config), walletAddress, requiredToken, swappableTokens);
31576
31656
  const quoteTokenAddresses = Array.from(quotes.keys());
31577
31657
  for (const quoteTokenAddress of quoteTokenAddresses){
31578
31658
  const quote = quotes.get(quoteTokenAddress);
@@ -31589,7 +31669,7 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
31589
31669
  // If user does not have enough to cover approval fees then continue
31590
31670
  if (!approvalFees.sufficient) continue;
31591
31671
  // If user does not have enough to cover swap fees then continue
31592
- if (!$91807edfd7057288$export$38077235fe748d40(l2Balances, quote.quote.fees, approvalFees, {
31672
+ if (!$91807edfd7057288$export$38077235fe748d40(l2Balances, approvalFees, quote.swap, quote.quote.fees, {
31593
31673
  amount: amountOfQuoteTokenRequired.value,
31594
31674
  address: quoteTokenAddress
31595
31675
  })) continue;
@@ -31994,13 +32074,14 @@ const $7500587317643fc8$export$c3e193fd573f1a94 = async (config, swappableTokens
31994
32074
 
31995
32075
 
31996
32076
 
31997
- const $d54df4a884f14123$export$d46f2133747ffd93 = async (config, dexQuoteCache, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens)=>{
32077
+
32078
+ const $d54df4a884f14123$export$d46f2133747ffd93 = async (config, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens)=>{
31998
32079
  const filteredSwappableTokensAddresses = [];
31999
32080
  for (const token of filteredSwappableTokens){
32000
32081
  if (!token.address) continue;
32001
32082
  filteredSwappableTokensAddresses.push(token.address);
32002
32083
  }
32003
- const dexQuotes = await ($3ee85f12225c19f3$export$fb80fe94a81a3132)(config, dexQuoteCache, ownerAddress, {
32084
+ const dexQuotes = await ($049bba630af05555$export$6946a1f17c2bbf26)(config, ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config), ownerAddress, {
32004
32085
  address: requiredTokenAddress,
32005
32086
  amount: insufficientRequirement.delta.balance
32006
32087
  }, filteredSwappableTokensAddresses);
@@ -32110,7 +32191,7 @@ const $afd57acae9471ac5$export$d9b96654eebdaf2a = (bridgeFundingSteps, swapFundi
32110
32191
  }
32111
32192
  return bridgeAndSwapRoutes;
32112
32193
  };
32113
- const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, feeEstimates, tokenBalances, bridgeableTokens, swappableTokens, balanceRequirements)=>{
32194
+ const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, feeEstimates, tokenBalances, bridgeableTokens, swappableTokens, balanceRequirements)=>{
32114
32195
  const { l1balances: l1balances, l2balances: l2balances } = ($7bb5af1d8b5d9127$export$8280985cc3da7882)(config, tokenBalances);
32115
32196
  const requiredTokenAddress = insufficientRequirement.required.token.address;
32116
32197
  if ($afd57acae9471ac5$export$b94e88f4f8805f71(bridgeableTokens, swappableTokens, l1balances, l2balances, availableRoutingOptions, requiredTokenAddress)) return [];
@@ -32121,7 +32202,7 @@ const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProvide
32121
32202
  const filteredSwappableTokens = $afd57acae9471ac5$export$ed7c59bd8d1bb5a7(requiredTokenAddress, bridgeableTokens, swappableTokens, l1tol2Addresses);
32122
32203
  if (filteredSwappableTokens.length === 0) return [];
32123
32204
  // Fetch all the dex quotes from the list of swappable tokens
32124
- const dexQuotes = await ($d54df4a884f14123$export$d46f2133747ffd93)(config, dexQuoteCache, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens);
32205
+ const dexQuotes = await ($d54df4a884f14123$export$d46f2133747ffd93)(config, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens);
32125
32206
  // Construct bridge requirements based on L2 balances, slippage and swap fees
32126
32207
  const bridgeRequirements = ($62e968a3dd87940e$export$df667c749c93b110)(dexQuotes, l1balances, l2balances, l1tol2Addresses, balanceRequirements);
32127
32208
  if (bridgeRequirements.length === 0) return [];
@@ -32164,7 +32245,7 @@ const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProvide
32164
32245
  // Modify the users L2 balance to include the amount as if the user successfully bridged
32165
32246
  const modifiedTokenBalances = $afd57acae9471ac5$var$modifyTokenBalancesWithBridgedAmount(config, tokenBalances, l2balances, bridgedTokens, swappableTokens);
32166
32247
  // Call the swap route with the faked bridged balances
32167
- const swapRoutes = await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, dexQuoteCache, ownerAddress, insufficientRequirement, modifiedTokenBalances, swappableTokensAfterBridging, balanceRequirements);
32248
+ const swapRoutes = await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, ownerAddress, insufficientRequirement, modifiedTokenBalances, swappableTokensAfterBridging, balanceRequirements);
32168
32249
  if (!swapRoutes) return [];
32169
32250
  const originalBalanceSwapRoutes = $afd57acae9471ac5$export$1fc63300bde5e690(tokenBalances, swapRoutes);
32170
32251
  return $afd57acae9471ac5$export$d9b96654eebdaf2a(bridgeResults, originalBalanceSwapRoutes, l1tol2Addresses);
@@ -32206,6 +32287,7 @@ const $5649bc8af91da370$export$1fb2bd867f4a9be3 = async (config, availableRoutin
32206
32287
 
32207
32288
 
32208
32289
 
32290
+
32209
32291
  const $c16168a9c28ae4fd$var$hasAvailableRoutingOptions = (availableRoutingOptions)=>availableRoutingOptions.bridge || availableRoutingOptions.swap || availableRoutingOptions.onRamp;
32210
32292
  const $c16168a9c28ae4fd$export$31ce7ba1a2956195 = (balanceRequirements)=>{
32211
32293
  let insufficientBalanceCount = 0;
@@ -32229,7 +32311,7 @@ const $c16168a9c28ae4fd$export$ab86023c267660 = async (config, readOnlyProviders
32229
32311
  if (availableRoutingOptions.bridge && insufficientRequirement) bridgeFundingStep = await ($fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa)(config, readOnlyProviders, ownerAddress, availableRoutingOptions, bridgeRequirement, tokenBalances, feeEstimates);
32230
32312
  return bridgeFundingStep;
32231
32313
  };
32232
- const $c16168a9c28ae4fd$export$814624e957fa0f11 = async (config, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, swapTokenAllowList, balanceRequirements)=>{
32314
+ const $c16168a9c28ae4fd$export$814624e957fa0f11 = async (config, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, swapTokenAllowList, balanceRequirements)=>{
32233
32315
  const fundingSteps = [];
32234
32316
  if (!availableRoutingOptions.swap) return fundingSteps;
32235
32317
  if (insufficientRequirement === undefined) return fundingSteps;
@@ -32240,9 +32322,9 @@ const $c16168a9c28ae4fd$export$814624e957fa0f11 = async (config, availableRoutin
32240
32322
  if (swapTokenAllowList.length === 0) return fundingSteps;
32241
32323
  const swappableTokens = swapTokenAllowList.filter((token)=>token.address).map((token)=>token.address);
32242
32324
  if (swappableTokens.length === 0) return fundingSteps;
32243
- return await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, dexQuoteCache, ownerAddress, insufficientRequirement, tokenBalances, swappableTokens, balanceRequirements);
32325
+ return await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, ownerAddress, insufficientRequirement, tokenBalances, swappableTokens, balanceRequirements);
32244
32326
  };
32245
- const $c16168a9c28ae4fd$export$2becd43da9d21f73 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, tokenAllowList, feeEstimates, balanceRequirements)=>{
32327
+ const $c16168a9c28ae4fd$export$2becd43da9d21f73 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, tokenAllowList, feeEstimates, balanceRequirements)=>{
32246
32328
  if (!insufficientRequirement) return [];
32247
32329
  const l1balancesResult = tokenBalances.get(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config));
32248
32330
  const l2balancesResult = tokenBalances.get(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
@@ -32260,7 +32342,7 @@ const $c16168a9c28ae4fd$export$2becd43da9d21f73 = async (config, readOnlyProvide
32260
32342
  });
32261
32343
  const swapTokenAllowList = tokenAllowList?.swap ?? [];
32262
32344
  if (insufficientRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE && insufficientRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) return [];
32263
- const routes = await ($afd57acae9471ac5$export$f95ed27e871fe308)(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, feeEstimates, tokenBalances, bridgeableL1Addresses, swapTokenAllowList, balanceRequirements);
32345
+ const routes = await ($afd57acae9471ac5$export$f95ed27e871fe308)(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, feeEstimates, tokenBalances, bridgeableL1Addresses, swapTokenAllowList, balanceRequirements);
32264
32346
  return routes;
32265
32347
  };
32266
32348
  const $c16168a9c28ae4fd$export$e1b6e4d22d0365ee = async (config, availableRoutingOptions, insufficientRequirement)=>{
@@ -32282,20 +32364,18 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
32282
32364
  message: err.message
32283
32365
  });
32284
32366
  }
32285
- const tokenBalances = await ($33acec7b4a26c053$export$23ddeb2642d2f9d)(config, readOnlyProviders, ownerAddress, availableRoutingOptions);
32286
- const allowList = await ($5a5ccedc98d53d25$export$1ad29657d49c5440)(config, tokenBalances, availableRoutingOptions);
32287
- // Bridge and swap fee cache
32367
+ const tokenBalances = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get token balances inside router", ($33acec7b4a26c053$export$23ddeb2642d2f9d)(config, readOnlyProviders, ownerAddress, availableRoutingOptions));
32368
+ const allowList = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get routing allowlist", ($5a5ccedc98d53d25$export$1ad29657d49c5440)(config, tokenBalances, availableRoutingOptions));
32369
+ // Fee estimate cache
32288
32370
  const feeEstimates = new Map();
32289
- // Dex quotes cache
32290
- const dexQuoteCache = new Map();
32291
32371
  // Ensures only 1 balance requirement is insufficient
32292
32372
  const insufficientRequirement = $c16168a9c28ae4fd$export$31ce7ba1a2956195(balanceRequirements);
32293
32373
  const routePromises = [];
32294
32374
  routePromises.push($c16168a9c28ae4fd$export$ab86023c267660(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, feeEstimates));
32295
- routePromises.push($c16168a9c28ae4fd$export$814624e957fa0f11(config, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, allowList.swap, balanceRequirements));
32375
+ routePromises.push($c16168a9c28ae4fd$export$814624e957fa0f11(config, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, allowList.swap, balanceRequirements));
32296
32376
  routePromises.push($c16168a9c28ae4fd$export$e1b6e4d22d0365ee(config, availableRoutingOptions, insufficientRequirement));
32297
- routePromises.push($c16168a9c28ae4fd$export$2becd43da9d21f73(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, allowList, feeEstimates, balanceRequirements));
32298
- const resolved = await Promise.all(routePromises);
32377
+ routePromises.push($c16168a9c28ae4fd$export$2becd43da9d21f73(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, allowList, feeEstimates, balanceRequirements));
32378
+ const resolved = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to resolve all routes", Promise.all(routePromises));
32299
32379
  let bridgeFundingStep;
32300
32380
  let swapFundingSteps = [];
32301
32381
  let onRampFundingStep;
@@ -32362,26 +32442,31 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
32362
32442
  };
32363
32443
 
32364
32444
 
32445
+
32365
32446
  const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemRequirements, transactionOrGasAmount)=>{
32366
32447
  const ownerAddress = await provider.getSigner().getAddress();
32367
32448
  let aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(itemRequirements);
32368
- const erc20Allowances = await ($fc8b338399d890f3$export$d93c00812189e36)(provider, ownerAddress, aggregatedItems);
32369
- const erc721Allowances = await ($35c3fc7013888ba5$export$be546c525d418988)(provider, ownerAddress, aggregatedItems);
32370
- const aggregatedAllowances = ($ddc6bcd0896481e5$export$2fbfa41a4de56a89)(erc20Allowances, erc721Allowances);
32371
- const gasItem = await ($7d1bfafb81e64d74$export$3a4140bd9e983e4e)(provider, aggregatedAllowances, transactionOrGasAmount);
32449
+ const erc20AllowancePromise = ($fc8b338399d890f3$export$d93c00812189e36)(provider, ownerAddress, aggregatedItems);
32450
+ const erc721AllowancePromise = ($35c3fc7013888ba5$export$be546c525d418988)(provider, ownerAddress, aggregatedItems);
32451
+ const resolvedAllowances = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to calculate token allowances", Promise.all([
32452
+ erc20AllowancePromise,
32453
+ erc721AllowancePromise
32454
+ ]));
32455
+ const aggregatedAllowances = ($ddc6bcd0896481e5$export$2fbfa41a4de56a89)(resolvedAllowances[0], resolvedAllowances[1]);
32456
+ const gasItem = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to run gas calculator", ($7d1bfafb81e64d74$export$3a4140bd9e983e4e)(provider, aggregatedAllowances, transactionOrGasAmount));
32372
32457
  if (gasItem !== null) {
32373
32458
  aggregatedItems.push(gasItem);
32374
32459
  aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(aggregatedItems);
32375
32460
  }
32376
- const balanceCheckResult = await ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems);
32461
+ const balanceCheckResult = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to run balance checks", ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems));
32377
32462
  const { sufficient: sufficient } = balanceCheckResult;
32378
32463
  const transactionRequirements = balanceCheckResult.balanceRequirements;
32379
32464
  if (sufficient) return {
32380
32465
  sufficient: sufficient,
32381
32466
  transactionRequirements: transactionRequirements
32382
32467
  };
32383
- const availableRoutingOptions = await ($7f2e17f026d4fc8d$export$86d9f998ddda013e)(config, provider);
32384
- const routingOutcome = await ($c16168a9c28ae4fd$export$92606e71d0a264ff)(config, ownerAddress, balanceCheckResult, availableRoutingOptions);
32468
+ const availableRoutingOptions = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to fetch available routing options", ($7f2e17f026d4fc8d$export$86d9f998ddda013e)(config, provider));
32469
+ const routingOutcome = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Total time to run the routing calculator", ($c16168a9c28ae4fd$export$92606e71d0a264ff)(config, ownerAddress, balanceCheckResult, availableRoutingOptions));
32385
32470
  return {
32386
32471
  sufficient: sufficient,
32387
32472
  transactionRequirements: transactionRequirements,
@@ -32564,6 +32649,7 @@ const $9051cee080948594$export$1e69c9cfc42e28d8 = (orderFees, weiAmount, decimal
32564
32649
  };
32565
32650
 
32566
32651
 
32652
+
32567
32653
  const $64863c39386de592$export$4249179755829904 = (type, contractAddress, amount, spenderAddress)=>{
32568
32654
  switch(type){
32569
32655
  case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20:
@@ -32602,8 +32688,8 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32602
32688
  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);
32603
32689
  const { id: id, takerFees: takerFees } = orders[0];
32604
32690
  try {
32605
- orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
32606
- order = await orderbook.getListing(id);
32691
+ orderbook = $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
32692
+ order = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to fetch the listing from the orderbook", orderbook.getListing(id));
32607
32693
  const { seaportContractAddress: seaportContractAddress } = orderbook.config();
32608
32694
  spenderAddress = seaportContractAddress;
32609
32695
  } catch (err) {
@@ -32620,23 +32706,26 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32620
32706
  let decimals = 18;
32621
32707
  if (order.result.buy[0].type === "ERC20") {
32622
32708
  const tokenContract = $06a6c5c23f7f2479$export$fbbc17f6e6e58544(order.result.buy[0].contractAddress, ($d85ad1457a3f1a83$export$db5daa1b5156ccfe), provider);
32623
- decimals = await tokenContract.decimals();
32709
+ decimals = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get decimals of token contract for the buy token", tokenContract.decimals());
32624
32710
  }
32625
32711
  let fees = [];
32626
32712
  if (takerFees && takerFees.length > 0) fees = ($9051cee080948594$export$1e69c9cfc42e28d8)(takerFees, buyToken.amount, decimals);
32627
32713
  let unsignedApprovalTransactions = [];
32628
32714
  let unsignedFulfillmentTransactions = [];
32629
32715
  let orderActions = [];
32716
+ const fulfillOrderStartTime = new Date().getTime();
32630
32717
  try {
32631
- const fulfillerAddress = await provider.getSigner().getAddress();
32632
- const { actions: actions } = await orderbook.fulfillOrder(id, fulfillerAddress, fees);
32718
+ const fulfillerAddress = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the address from the provider", provider.getSigner().getAddress());
32719
+ const { actions: actions } = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to call fulfillOrder from the orderbook", orderbook.fulfillOrder(id, fulfillerAddress, fees));
32633
32720
  orderActions = actions;
32634
- unsignedApprovalTransactions = await (0, $a7367d01c6e76b1c$export$f64a20a30eb98855)(actions);
32635
- } catch {
32636
- // Silently ignore error as this is usually thrown if user does not have enough balance
32721
+ unsignedApprovalTransactions = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to construct the unsigned approval transactions", (0, $a7367d01c6e76b1c$export$f64a20a30eb98855)(actions));
32722
+ } catch (err) {
32723
+ // Silently ignore error as this is usually thrown if user does not have enough balance
32724
+ const elapsedTimeInSeconds = (new Date().getTime() - fulfillOrderStartTime) / 1000;
32725
+ ($458d407830d66110$export$e6a390ea6399b7d8)(config, "Time to call fulfillOrder from the orderbook", elapsedTimeInSeconds);
32637
32726
  }
32638
32727
  try {
32639
- unsignedFulfillmentTransactions = await (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions);
32728
+ unsignedFulfillmentTransactions = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to construct the unsigned fulfillment transactions", (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions));
32640
32729
  } catch {
32641
32730
  // if cannot estimate gas then silently continue and use gas limit in smartCheckout
32642
32731
  // but get the fulfillment transactions after they have approved the spending
@@ -32668,7 +32757,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32668
32757
  const itemRequirements = [
32669
32758
  $64863c39386de592$export$4249179755829904(type, contractAddress, amount, spenderAddress)
32670
32759
  ];
32671
- const smartCheckoutResult = await ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, $64863c39386de592$export$8f2ff92ab8657f0b(gasLimit, unsignedFulfillmentTransactions));
32760
+ const smartCheckoutResult = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Total time running smart checkout", ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, $64863c39386de592$export$8f2ff92ab8657f0b(gasLimit, unsignedFulfillmentTransactions)));
32672
32761
  if (smartCheckoutResult.sufficient) {
32673
32762
  const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedApprovalTransactions);
32674
32763
  if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
@@ -32710,15 +32799,16 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
32710
32799
 
32711
32800
 
32712
32801
 
32802
+
32713
32803
  const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, orderIds)=>{
32714
32804
  let unsignedCancelOrderTransaction;
32715
32805
  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);
32716
32806
  // Update this when bulk cancel is supported
32717
32807
  const orderId = orderIds[0];
32718
32808
  try {
32719
- const offererAddress = await provider.getSigner().getAddress();
32720
- const orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
32721
- const cancelOrderResponse = await orderbook.cancelOrder(orderId, offererAddress);
32809
+ const offererAddress = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the address from the provider", provider.getSigner().getAddress());
32810
+ const orderbook = $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
32811
+ const cancelOrderResponse = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the cancel order from the orderbook", orderbook.cancelOrder(orderId, offererAddress));
32722
32812
  unsignedCancelOrderTransaction = cancelOrderResponse.unsignedCancelOrderTransaction;
32723
32813
  } catch (err) {
32724
32814
  throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while cancelling the order listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CANCEL_ORDER_LISTING_ERROR, {
@@ -32751,6 +32841,7 @@ const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, order
32751
32841
 
32752
32842
 
32753
32843
 
32844
+
32754
32845
  const $9085b221b72ac69e$export$af768ccdf17d5c04 = (id, contractAddress, spenderAddress)=>({
32755
32846
  type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
32756
32847
  id: id,
@@ -32779,15 +32870,15 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
32779
32870
  if (buyToken.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) {
32780
32871
  // get this from the allowed list
32781
32872
  const buyTokenContract = new (Contract$1)(buyToken.contractAddress, JSON.stringify(($d85ad1457a3f1a83$export$db5daa1b5156ccfe)), provider);
32782
- decimals = await buyTokenContract.decimals();
32873
+ decimals = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get decimals of token contract for the buy token", buyTokenContract.decimals());
32783
32874
  }
32784
32875
  const buyTokenOrNative = $9085b221b72ac69e$export$586d02673c66d423(buyToken, decimals);
32785
32876
  try {
32786
- const walletAddress = await provider.getSigner().getAddress();
32787
- orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
32877
+ const walletAddress = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the address from the provider", provider.getSigner().getAddress());
32878
+ orderbook = $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
32788
32879
  const { seaportContractAddress: seaportContractAddress } = orderbook.config();
32789
32880
  spenderAddress = seaportContractAddress;
32790
- listing = await orderbook.prepareListing({
32881
+ listing = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to prepare the listing from the orderbook", orderbook.prepareListing({
32791
32882
  makerAddress: walletAddress,
32792
32883
  buy: buyTokenOrNative,
32793
32884
  sell: {
@@ -32795,7 +32886,7 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
32795
32886
  contractAddress: sellToken.collectionAddress,
32796
32887
  tokenId: sellToken.id
32797
32888
  }
32798
- });
32889
+ }));
32799
32890
  } catch (err) {
32800
32891
  throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while preparing the listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PREPARE_ORDER_LISTING_ERROR, {
32801
32892
  message: err.message,
@@ -32806,13 +32897,13 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
32806
32897
  const itemRequirements = [
32807
32898
  $9085b221b72ac69e$export$af768ccdf17d5c04(sellToken.id, sellToken.collectionAddress, spenderAddress)
32808
32899
  ];
32809
- const smartCheckoutResult = await ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, {
32900
+ const smartCheckoutResult = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Total time running smart checkout", ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, {
32810
32901
  type: ($4b58188d47aafe8d$export$65c64e46348ee3c1).GAS,
32811
32902
  gasToken: {
32812
32903
  type: ($4b58188d47aafe8d$export$537fa3efd10ed435).NATIVE,
32813
32904
  limit: (BigNumber$1).from((constants).estimatedFulfillmentGasGwei)
32814
32905
  }
32815
- });
32906
+ }));
32816
32907
  if (smartCheckoutResult.sufficient) {
32817
32908
  const unsignedTransactions = await ($a7367d01c6e76b1c$export$c5b3365853cb6159)(listing.actions);
32818
32909
  const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedTransactions.approvalTransactions);
@@ -33143,7 +33234,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
33143
33234
  const tokenList = await $efe60cea83bfc4e8$export$473cec51305fdae8(this.config, {
33144
33235
  type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ONRAMP
33145
33236
  });
33146
- const token = tokenList.tokens.find((t)=>t.address?.toLowerCase() === params.tokenAddress?.toLowerCase());
33237
+ const token = tokenList.tokens?.find((t)=>t.address?.toLowerCase() === params.tokenAddress?.toLowerCase());
33147
33238
  if (token) {
33148
33239
  tokenAmount = params.tokenAmount;
33149
33240
  tokenSymbol = token.symbol;
@@ -33216,7 +33307,7 @@ var $045213b18e9f1f94$export$75be0f6af9650f2c;
33216
33307
  })($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
33217
33308
 
33218
33309
 
33219
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.27.10";
33310
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.27.12";
33220
33311
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
33221
33312
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
33222
33313
 
@@ -33350,7 +33441,7 @@ var $207ed853f11d19d5$export$5a0ace85cae72d45;
33350
33441
  IMTBLWidgetEvents["IMTBL_SWAP_WIDGET_EVENT"] = "imtbl-swap-widget";
33351
33442
  IMTBLWidgetEvents["IMTBL_BRIDGE_WIDGET_EVENT"] = "imtbl-bridge-widget";
33352
33443
  IMTBLWidgetEvents["IMTBL_ONRAMP_WIDGET_EVENT"] = "imtbl-onramp-widget";
33353
- IMTBLWidgetEvents["IMTBL_PRIMARY_REVENUE_WIDGET_EVENT"] = "imtbl-sale-widget";
33444
+ IMTBLWidgetEvents["IMTBL_SALE_WIDGET_EVENT"] = "imtbl-sale-widget";
33354
33445
  })($207ed853f11d19d5$export$5a0ace85cae72d45 || ($207ed853f11d19d5$export$5a0ace85cae72d45 = {}));
33355
33446
 
33356
33447