@imtbl/sdk 0.34.1-alpha → 0.35.1

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
@@ -3791,7 +3791,7 @@ class MultiRollupApiClients {
3791
3791
  }
3792
3792
 
3793
3793
  // eslint-disable-next-line @typescript-eslint/naming-convention
3794
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.34.1-alpha' };
3794
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.35.1' };
3795
3795
  const createConfig = ({ basePath, headers, }) => {
3796
3796
  if (!basePath.trim()) {
3797
3797
  throw Error('basePath can not be empty');
@@ -3851,7 +3851,7 @@ class APIError extends Error {
3851
3851
 
3852
3852
  /* eslint-disable implicit-arrow-linebreak */
3853
3853
  const defaultHeaders = {
3854
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.34.1-alpha',
3854
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.35.1',
3855
3855
  };
3856
3856
  /**
3857
3857
  * createAPIConfiguration to create a custom Configuration
@@ -4262,7 +4262,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
4262
4262
  chainID,
4263
4263
  coreContractAddress,
4264
4264
  registrationContractAddress,
4265
- sdkVersion: 'ts-immutable-sdk-0.34.1-alpha',
4265
+ sdkVersion: 'ts-immutable-sdk-0.35.1',
4266
4266
  });
4267
4267
  /**
4268
4268
  * Sets `sdkVersion` at the time of build
@@ -11720,14 +11720,24 @@ var FailedOrderCancellation;
11720
11720
  /* eslint-disable */
11721
11721
  var Fee;
11722
11722
  (function (Fee) {
11723
- (function (fee_type) {
11724
- fee_type["ROYALTY"] = "ROYALTY";
11725
- fee_type["MAKER_ECOSYSTEM"] = "MAKER_ECOSYSTEM";
11726
- fee_type["TAKER_ECOSYSTEM"] = "TAKER_ECOSYSTEM";
11727
- fee_type["PROTOCOL"] = "PROTOCOL";
11728
- })(Fee.fee_type || (Fee.fee_type = {}));
11723
+ (function (type) {
11724
+ type["ROYALTY"] = "ROYALTY";
11725
+ type["MAKER_ECOSYSTEM"] = "MAKER_ECOSYSTEM";
11726
+ type["TAKER_ECOSYSTEM"] = "TAKER_ECOSYSTEM";
11727
+ type["PROTOCOL"] = "PROTOCOL";
11728
+ })(Fee.type || (Fee.type = {}));
11729
11729
  })(Fee || (Fee = {}));
11730
11730
 
11731
+ /* istanbul ignore file */
11732
+ /* tslint:disable */
11733
+ /* eslint-disable */
11734
+ var Order;
11735
+ (function (Order) {
11736
+ (function (type) {
11737
+ type["LISTING"] = "LISTING";
11738
+ })(Order.type || (Order.type = {}));
11739
+ })(Order || (Order = {}));
11740
+
11731
11741
  /* istanbul ignore file */
11732
11742
  /* tslint:disable */
11733
11743
  /* eslint-disable */
@@ -11780,14 +11790,14 @@ var ActionType;
11780
11790
 
11781
11791
  function mapFromOpenApiOrder(order) {
11782
11792
  const buyItems = order.buy.map((item) => {
11783
- if (item.item_type === 'ERC20') {
11793
+ if (item.type === 'ERC20') {
11784
11794
  return {
11785
11795
  type: 'ERC20',
11786
11796
  contractAddress: item.contract_address,
11787
11797
  amount: item.amount,
11788
11798
  };
11789
11799
  }
11790
- if (item.item_type === 'NATIVE') {
11800
+ if (item.type === 'NATIVE') {
11791
11801
  return {
11792
11802
  type: 'NATIVE',
11793
11803
  amount: item.amount,
@@ -11796,7 +11806,7 @@ function mapFromOpenApiOrder(order) {
11796
11806
  throw new Error('Buy items must be either ERC20 or NATIVE');
11797
11807
  });
11798
11808
  const sellItems = order.sell.map((item) => {
11799
- if (item.item_type === 'ERC721') {
11809
+ if (item.type === 'ERC721') {
11800
11810
  return {
11801
11811
  type: 'ERC721',
11802
11812
  contractAddress: item.contract_address,
@@ -11807,20 +11817,22 @@ function mapFromOpenApiOrder(order) {
11807
11817
  });
11808
11818
  return {
11809
11819
  id: order.id,
11820
+ type: order.type,
11810
11821
  accountAddress: order.account_address,
11811
11822
  buy: buyItems,
11812
11823
  sell: sellItems,
11813
11824
  fees: order.fees.map((fee) => ({
11814
11825
  amount: fee.amount,
11815
- recipient: fee.recipient,
11816
- type: fee.fee_type,
11826
+ recipientAddress: fee.recipient_address,
11827
+ type: fee.type,
11817
11828
  })),
11818
11829
  chain: order.chain,
11819
11830
  createdAt: order.created_at,
11820
11831
  endAt: order.end_at,
11832
+ orderHash: order.order_hash,
11821
11833
  protocolData: {
11822
- counter: order.protocol_data.counter,
11823
11834
  orderType: order.protocol_data.order_type,
11835
+ counter: order.protocol_data.counter,
11824
11836
  seaportAddress: order.protocol_data.seaport_address,
11825
11837
  seaportVersion: order.protocol_data.seaport_version,
11826
11838
  zoneAddress: order.protocol_data.zone_address,
@@ -11834,14 +11846,14 @@ function mapFromOpenApiOrder(order) {
11834
11846
  }
11835
11847
  function mapFromOpenApiTrade(trade) {
11836
11848
  const buyItems = trade.buy.map((item) => {
11837
- if (item.item_type === 'ERC20') {
11849
+ if (item.type === 'ERC20') {
11838
11850
  return {
11839
11851
  type: 'ERC20',
11840
11852
  contractAddress: item.contract_address,
11841
11853
  amount: item.amount,
11842
11854
  };
11843
11855
  }
11844
- if (item.item_type === 'NATIVE') {
11856
+ if (item.type === 'NATIVE') {
11845
11857
  return {
11846
11858
  type: 'NATIVE',
11847
11859
  amount: item.amount,
@@ -11850,7 +11862,7 @@ function mapFromOpenApiTrade(trade) {
11850
11862
  throw new Error('Buy items must be either ERC20 or NATIVE');
11851
11863
  });
11852
11864
  const sellItems = trade.sell.map((item) => {
11853
- if (item.item_type === 'ERC721') {
11865
+ if (item.type === 'ERC721') {
11854
11866
  return {
11855
11867
  type: 'ERC721',
11856
11868
  contractAddress: item.contract_address,
@@ -11866,8 +11878,8 @@ function mapFromOpenApiTrade(trade) {
11866
11878
  sell: sellItems,
11867
11879
  buyerFees: trade.buyer_fees.map((fee) => ({
11868
11880
  amount: fee.amount,
11869
- recipient: fee.recipient,
11870
- type: fee.fee_type,
11881
+ recipientAddress: fee.recipient_address,
11882
+ type: fee.type,
11871
11883
  })),
11872
11884
  chain: trade.chain,
11873
11885
  indexedAt: trade.indexed_at,
@@ -11981,7 +11993,7 @@ chainId) {
11981
11993
 
11982
11994
  function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress) {
11983
11995
  const considerationItems = order.buy.map((buyItem) => {
11984
- switch (buyItem.item_type) {
11996
+ switch (buyItem.type) {
11985
11997
  case 'NATIVE':
11986
11998
  return {
11987
11999
  startAmount: buyItem.amount,
@@ -12013,9 +12025,9 @@ function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress)
12013
12025
  });
12014
12026
  const fees = order.fees.map((fee) => ({
12015
12027
  amount: fee.amount,
12016
- itemType: order.buy[0].item_type === 'ERC20' ? ItemType$1.ERC20 : ItemType$1.NATIVE,
12017
- recipient: fee.recipient,
12018
- token: order.buy[0].item_type === 'ERC20'
12028
+ itemType: order.buy[0].type === 'ERC20' ? ItemType$1.ERC20 : ItemType$1.NATIVE,
12029
+ recipient: fee.recipient_address,
12030
+ token: order.buy[0].type === 'ERC20'
12019
12031
  ? order.buy[0].contract_address
12020
12032
  : ethers.constants.AddressZero,
12021
12033
  identifierOrCriteria: '0',
@@ -12307,11 +12319,10 @@ class ImmutableApiClient {
12307
12319
  return this.orderbookService.createListing({
12308
12320
  chainName: this.chainName,
12309
12321
  requestBody: {
12310
- order_hash: orderHash,
12311
12322
  account_address: orderComponents.offerer,
12312
12323
  buy: [
12313
12324
  {
12314
- item_type: Number(orderComponents.consideration[0].itemType)
12325
+ type: Number(orderComponents.consideration[0].itemType)
12315
12326
  === ItemType$1.NATIVE
12316
12327
  ? 'NATIVE'
12317
12328
  : 'ERC20',
@@ -12321,10 +12332,11 @@ class ImmutableApiClient {
12321
12332
  ],
12322
12333
  fees: makerFees.map((x) => ({
12323
12334
  amount: x.amount,
12324
- fee_type: FeeType.MAKER_ECOSYSTEM,
12325
- recipient: x.recipient,
12335
+ type: FeeType.MAKER_ECOSYSTEM,
12336
+ recipient_address: x.recipientAddress,
12326
12337
  })),
12327
12338
  end_at: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
12339
+ order_hash: orderHash,
12328
12340
  protocol_data: {
12329
12341
  order_type: ProtocolData.order_type.FULL_RESTRICTED,
12330
12342
  zone_address: orderComponents.zone,
@@ -12337,7 +12349,7 @@ class ImmutableApiClient {
12337
12349
  {
12338
12350
  contract_address: orderComponents.offer[0].token,
12339
12351
  token_id: orderComponents.offer[0].identifierOrCriteria,
12340
- item_type: 'ERC721',
12352
+ type: 'ERC721',
12341
12353
  },
12342
12354
  ],
12343
12355
  signature: orderSignature,
@@ -12370,8 +12382,8 @@ function getOrderbookConfig(environment) {
12370
12382
  switch (environment) {
12371
12383
  case Environment$1.SANDBOX:
12372
12384
  return {
12373
- seaportContractAddress: '0x2CFA8f64e1B49A2DF28532D1D30Cda45117cF778',
12374
- zoneContractAddress: '0x1Bb4Fb11Ba021Bd0104F0Ee8E5F5c728Bc83d7F1',
12385
+ seaportContractAddress: '0x3A0C2Ba54D6CBd3121F01b96dFd20e99D1696C9D',
12386
+ zoneContractAddress: '0x2EA937879beeF3393853A74Ad62F9ad7DA0B9E81',
12375
12387
  apiEndpoint: 'https://api.sandbox.immutable.com',
12376
12388
  chainName: TESTNET_CHAIN_NAME,
12377
12389
  provider: new ethers.providers.JsonRpcProvider('https://rpc.testnet.immutable.com'),
@@ -12534,8 +12546,8 @@ class Orderbook {
12534
12546
  order_id: listingId,
12535
12547
  fees: takerFees.map((fee) => ({
12536
12548
  amount: fee.amount,
12537
- fee_type: FeeType.TAKER_ECOSYSTEM,
12538
- recipient: fee.recipient,
12549
+ type: FeeType.TAKER_ECOSYSTEM,
12550
+ recipient_address: fee.recipientAddress,
12539
12551
  })),
12540
12552
  },
12541
12553
  ]);
@@ -12557,8 +12569,8 @@ class Orderbook {
12557
12569
  order_id: listingRequest.listingId,
12558
12570
  fees: listingRequest.takerFees.map((fee) => ({
12559
12571
  amount: fee.amount,
12560
- fee_type: FeeType.TAKER_ECOSYSTEM,
12561
- recipient: fee.recipient,
12572
+ type: FeeType.TAKER_ECOSYSTEM,
12573
+ recipient_address: fee.recipientAddress,
12562
12574
  })),
12563
12575
  })));
12564
12576
  try {
@@ -28427,7 +28439,6 @@ class UniswapV3Pool__factory extends ethers.ContractFactory {
28427
28439
  }
28428
28440
  }
28429
28441
 
28430
- const DEFAULT_GAS_QUOTE = 2000000;
28431
28442
  // TODO: Better description of function and args
28432
28443
  async function multicallSingleCallDataMultipleContracts(multicallContract, functionName, addresses) {
28433
28444
  // Encode args - generate calldata for contract
@@ -28449,22 +28460,6 @@ async function multicallSingleCallDataMultipleContracts(multicallContract, funct
28449
28460
  }
28450
28461
  return multicallContract.callStatic.multicall(calls);
28451
28462
  }
28452
- // TODO: Better description of function and args
28453
- async function multicallMultipleCallDataSingContract(multicallContract, calldata, address, options) {
28454
- // Create call objects
28455
- const calls = new Array(calldata.length);
28456
- // TODO: use object.keys of something similar to avoid iterating over
28457
- // entire object prototype
28458
- // eslint-disable-next-line no-restricted-syntax, guard-for-in
28459
- for (const i in calldata) {
28460
- calls[i] = {
28461
- target: address,
28462
- callData: calldata[i],
28463
- gasLimit: options?.gasRequired ?? DEFAULT_GAS_QUOTE,
28464
- };
28465
- }
28466
- return multicallContract.callStatic.multicall(calls);
28467
- }
28468
28463
  const getCallData = (methodName, contractInterface) => {
28469
28464
  // Create ethers function fragment
28470
28465
  const fragment = contractInterface?.getFunction(methodName);
@@ -28624,35 +28619,27 @@ const getDefaultDeadlineSeconds = () => Math.floor(Date.now() / 1000) + DEFAULT_
28624
28619
 
28625
28620
  const amountIndex = 0;
28626
28621
  const gasEstimateIndex = 3;
28627
- async function getQuotesForRoutes(multicallContract, quoterContractAddress, routes, amountSpecified, tradeType) {
28628
- const callData = routes.map((route) => v3Sdk.SwapQuoter.quoteCallParameters(route, toCurrencyAmount(amountSpecified), tradeType, {
28622
+ async function getQuotesForRoutes(provider, quoterContractAddress, routes, amountSpecified, tradeType) {
28623
+ const callDatas = routes.map((route) => v3Sdk.SwapQuoter.quoteCallParameters(route, toCurrencyAmount(amountSpecified), tradeType, {
28629
28624
  useQuoterV2: true,
28630
28625
  }).calldata);
28631
- let quoteResults;
28632
- try {
28633
- quoteResults = await multicallMultipleCallDataSingContract(multicallContract, callData, quoterContractAddress);
28634
- }
28635
- catch (e) {
28636
- const message = e instanceof Error ? e.message : 'Unknown Error';
28637
- throw new ProviderCallError(`failed multicall: ${message}`);
28638
- }
28639
- const decodedQuoteResults = [];
28640
- // TODO: for..in loops iterate over the entire prototype chain,
28641
- // Use Object.{keys,values,entries}, and iterate over the resulting array.
28642
- // eslint-disable-next-line no-restricted-syntax, guard-for-in
28643
- for (const i in quoteResults.returnData) {
28644
- const functionSig = callData[i].substring(0, 10);
28626
+ const promises = await Promise.allSettled(callDatas.map((data) => provider.send('eth_call', [
28627
+ { to: quoterContractAddress, data }, 'latest',
28628
+ ])));
28629
+ const decodedQuoteResults = promises.reduce((quoteResults, promiseResult, i) => {
28630
+ if (promiseResult.status === 'rejected')
28631
+ return quoteResults;
28632
+ const functionSig = callDatas[i].substring(0, 10);
28645
28633
  const returnTypes = quoteReturnMapping[functionSig];
28646
28634
  if (!returnTypes) {
28647
28635
  throw new Error('No quoting function signature found');
28648
28636
  }
28649
- if (quoteResults.returnData[i].returnData === '0x') {
28637
+ if (promiseResult.value === '0x') {
28650
28638
  // There is no quote result for the swap using this route, so don't include it in results
28651
- // eslint-disable-next-line no-continue
28652
- continue;
28639
+ return quoteResults;
28653
28640
  }
28654
28641
  try {
28655
- const decodedQuoteResult = ethers.ethers.utils.defaultAbiCoder.decode(returnTypes, quoteResults.returnData[i].returnData);
28642
+ const decodedQuoteResult = ethers.utils.defaultAbiCoder.decode(returnTypes, promiseResult.value);
28656
28643
  if (decodedQuoteResult) {
28657
28644
  // The 0th element in each decoded data is going to be the amountOut or amountIn.
28658
28645
  const quoteAmount = decodedQuoteResult[amountIndex];
@@ -28660,11 +28647,11 @@ async function getQuotesForRoutes(multicallContract, quoterContractAddress, rout
28660
28647
  throw new Error('Expected BigNumber');
28661
28648
  const input = uniswapTokenToERC20(routes[i].input);
28662
28649
  const output = uniswapTokenToERC20(routes[i].output);
28663
- decodedQuoteResults.push({
28650
+ quoteResults.push({
28664
28651
  route: routes[i],
28665
28652
  amountIn: tradeType === Uniswap.TradeType.EXACT_INPUT ? amountSpecified : newAmount(quoteAmount, input),
28666
28653
  amountOut: tradeType === Uniswap.TradeType.EXACT_INPUT ? newAmount(quoteAmount, output) : amountSpecified,
28667
- gasEstimate: ethers.ethers.BigNumber.from(decodedQuoteResult[gasEstimateIndex]),
28654
+ gasEstimate: ethers.BigNumber.from(decodedQuoteResult[gasEstimateIndex]),
28668
28655
  tradeType,
28669
28656
  });
28670
28657
  }
@@ -28674,7 +28661,8 @@ async function getQuotesForRoutes(multicallContract, quoterContractAddress, rout
28674
28661
  // Other quotes for routes may still succeed, so do nothing
28675
28662
  // and continue processing
28676
28663
  }
28677
- }
28664
+ return quoteResults;
28665
+ }, new Array());
28678
28666
  return decodedQuoteResults;
28679
28667
  }
28680
28668
 
@@ -28802,19 +28790,24 @@ const fetchValidPools = async (multicallContract, erc20Pair, commonRoutingERC20s
28802
28790
 
28803
28791
  class Router {
28804
28792
  provider;
28793
+ multicallContract;
28805
28794
  routingTokens;
28806
28795
  routingContracts;
28807
- constructor(provider, routingTokens, routingContracts) {
28796
+ constructor(provider, multicallContract, routingTokens, routingContracts) {
28808
28797
  this.provider = provider;
28798
+ this.multicallContract = multicallContract;
28799
+ this.routingTokens = routingTokens;
28800
+ this.routingContracts = routingContracts;
28801
+ this.provider = provider;
28802
+ this.multicallContract = multicallContract;
28809
28803
  this.routingTokens = routingTokens;
28810
28804
  this.routingContracts = routingContracts;
28811
28805
  }
28812
28806
  async findOptimalRoute(amountSpecified, otherToken, tradeType, maxHops = 2) {
28813
28807
  const [tokenIn, tokenOut] = this.determineERC20InAndERC20Out(tradeType, amountSpecified, otherToken);
28814
- const multicallContract = Multicall__factory.connect(this.routingContracts.multicallAddress, this.provider);
28815
28808
  const erc20Pair = [tokenIn, tokenOut];
28816
28809
  // Get all pools and use these to get all possible routes.
28817
- const pools = await fetchValidPools(multicallContract, erc20Pair, this.routingTokens, this.routingContracts.factoryAddress);
28810
+ const pools = await fetchValidPools(this.multicallContract, erc20Pair, this.routingTokens, this.routingContracts.coreFactory);
28818
28811
  const noValidPools = pools.length === 0;
28819
28812
  if (noValidPools) {
28820
28813
  throw new NoRoutesAvailableError();
@@ -28828,10 +28821,10 @@ class Router {
28828
28821
  throw new NoRoutesAvailableError();
28829
28822
  }
28830
28823
  // Get the best quote from all of the given routes
28831
- return await this.getBestQuoteFromRoutes(multicallContract, routes, amountSpecified, tradeType);
28824
+ return await this.getBestQuoteFromRoutes(routes, amountSpecified, tradeType);
28832
28825
  }
28833
- async getBestQuoteFromRoutes(multicallContract, routes, amountSpecified, tradeType) {
28834
- const quotes = await getQuotesForRoutes(multicallContract, this.routingContracts.quoterAddress, routes, amountSpecified, tradeType);
28826
+ async getBestQuoteFromRoutes(routes, amountSpecified, tradeType) {
28827
+ const quotes = await getQuotesForRoutes(this.provider, this.routingContracts.quoterV2, routes, amountSpecified, tradeType);
28835
28828
  if (quotes.length === 0) {
28836
28829
  throw new NoRoutesAvailableError();
28837
28830
  }
@@ -29560,6 +29553,7 @@ const toPublicQuote = (amount, amountWithMaxSlippage, slippage, fees) => ({
29560
29553
  });
29561
29554
  class Exchange {
29562
29555
  provider;
29556
+ batchProvider;
29563
29557
  router;
29564
29558
  chainId;
29565
29559
  nativeToken;
@@ -29577,12 +29571,16 @@ class Exchange {
29577
29571
  this.secondaryFees = config.secondaryFees;
29578
29572
  this.routerContractAddress = config.chain.contracts.peripheryRouter;
29579
29573
  this.secondaryFeeContractAddress = config.chain.contracts.secondaryFee;
29580
- this.provider = new ethers.ethers.providers.JsonRpcProvider(config.chain.rpcUrl);
29581
- this.router = new Router(this.provider, config.chain.commonRoutingTokens, {
29582
- multicallAddress: config.chain.contracts.multicall,
29583
- factoryAddress: config.chain.contracts.coreFactory,
29584
- quoterAddress: config.chain.contracts.quoterV2,
29585
- });
29574
+ this.provider = new ethers.ethers.providers.StaticJsonRpcProvider({
29575
+ url: config.chain.rpcUrl,
29576
+ skipFetchSetup: true,
29577
+ }, config.chain.chainId);
29578
+ this.batchProvider = new ethers.ethers.providers.JsonRpcBatchProvider({
29579
+ url: config.chain.rpcUrl,
29580
+ skipFetchSetup: true,
29581
+ }, config.chain.chainId);
29582
+ const multicallContract = Multicall__factory.connect(config.chain.contracts.multicall, this.provider);
29583
+ this.router = new Router(this.batchProvider, multicallContract, config.chain.commonRoutingTokens, config.chain.contracts);
29586
29584
  }
29587
29585
  static validate(tokenInAddress, tokenOutAddress, maxHops, slippagePercent, fromAddress) {
29588
29586
  assert(isValidNonZeroAddress(fromAddress), new InvalidAddressError('invalid from address'));
@@ -29594,11 +29592,11 @@ class Exchange {
29594
29592
  assert(slippagePercent <= 50, new InvalidSlippageError('slippage percent must be less than or equal to 50'));
29595
29593
  assert(slippagePercent >= 0, new InvalidSlippageError('slippage percent must be greater than or equal to 0'));
29596
29594
  }
29597
- async getSecondaryFees() {
29595
+ async getSecondaryFees(provider) {
29598
29596
  if (this.secondaryFees.length === 0) {
29599
29597
  return [];
29600
29598
  }
29601
- const secondaryFeeContract = SecondaryFee__factory.connect(this.secondaryFeeContractAddress, this.provider);
29599
+ const secondaryFeeContract = SecondaryFee__factory.connect(this.secondaryFeeContractAddress, provider);
29602
29600
  if (await secondaryFeeContract.paused()) {
29603
29601
  // Do not use secondary fees if the contract is paused
29604
29602
  return [];
@@ -29619,11 +29617,13 @@ class Exchange {
29619
29617
  async getUnsignedSwapTx(fromAddress, tokenInLiteral, tokenOutLiteral, amount, slippagePercent, maxHops, deadline, tradeType) {
29620
29618
  Exchange.validate(tokenInLiteral, tokenOutLiteral, maxHops, slippagePercent, fromAddress);
29621
29619
  // get the decimals of the tokens that will be swapped
29622
- const [tokenInDecimals, tokenOutDecimals, secondaryFees] = await Promise.all([
29623
- getTokenDecimals(tokenInLiteral, this.provider, this.nativeToken),
29624
- getTokenDecimals(tokenOutLiteral, this.provider, this.nativeToken),
29625
- this.getSecondaryFees(),
29626
- ]);
29620
+ const promises = [
29621
+ getTokenDecimals(tokenInLiteral, this.batchProvider, this.nativeToken),
29622
+ getTokenDecimals(tokenOutLiteral, this.batchProvider, this.nativeToken),
29623
+ this.getSecondaryFees(this.batchProvider),
29624
+ fetchGasPrice(this.batchProvider, this.nativeToken),
29625
+ ];
29626
+ const [tokenInDecimals, tokenOutDecimals, secondaryFees, gasPrice] = await Promise.all(promises);
29627
29627
  const tokenIn = this.parseTokenLiteral(tokenInLiteral, tokenInDecimals);
29628
29628
  const tokenOut = this.parseTokenLiteral(tokenOutLiteral, tokenOutDecimals);
29629
29629
  // determine which amount was specified for the swap from the TradeType
@@ -29632,10 +29632,7 @@ class Exchange {
29632
29632
  const fees = new Fees(secondaryFees, tokenIn);
29633
29633
  const ourQuoteReqAmount = getOurQuoteReqAmount(amountSpecified, fees, tradeType, this.nativeTokenService);
29634
29634
  // Quotes will always use ERC20s. If the user-specified token is Native, we use the Wrapped Native Token pool
29635
- const [ourQuote, gasPrice] = await Promise.all([
29636
- this.router.findOptimalRoute(ourQuoteReqAmount, this.nativeTokenService.maybeWrapToken(otherToken), tradeType, maxHops),
29637
- fetchGasPrice(this.provider, this.nativeToken),
29638
- ]);
29635
+ const ourQuote = await this.router.findOptimalRoute(ourQuoteReqAmount, this.nativeTokenService.maybeWrapToken(otherToken), tradeType, maxHops);
29639
29636
  const adjustedQuote = adjustQuoteWithFees(ourQuote, amountSpecified, fees, this.nativeTokenService);
29640
29637
  const swap = getSwap(tokenIn, tokenOut, adjustedQuote, fromAddress, slippagePercent, deadline, this.routerContractAddress, this.secondaryFeeContractAddress, gasPrice, secondaryFees);
29641
29638
  const { quotedAmount, quotedAmountWithMaxSlippage } = prepareUserQuote(this.nativeTokenService, adjustedQuote, slippagePercent, otherToken);
@@ -30572,7 +30569,7 @@ const GAS_OVERRIDES = {
30572
30569
  maxPriorityFeePerGas: ethers.BigNumber.from(101e9),
30573
30570
  };
30574
30571
 
30575
- const SDK_VERSION_MARKER = '0.34.1-alpha';
30572
+ const SDK_VERSION_MARKER = '0.35.1';
30576
30573
  // This SDK version is replaced by the `yarn build` command ran on the root level
30577
30574
  const globalPackageVersion = () => SDK_VERSION_MARKER;
30578
30575
 
@@ -33603,7 +33600,7 @@ const calculateFees = (orderFees, weiAmount, decimals = 18) => {
33603
33600
  if (currentFeeBn.gt(0)) {
33604
33601
  calculateFeesResult.push({
33605
33602
  amount: currentFeeBn.toString(),
33606
- recipient: orderFee.recipient,
33603
+ recipientAddress: orderFee.recipient,
33607
33604
  });
33608
33605
  }
33609
33606
  } // for
package/dist/index.d.ts CHANGED
@@ -14919,17 +14919,17 @@ type Fee$2 = {
14919
14919
  /**
14920
14920
  * Fee type
14921
14921
  */
14922
- fee_type: Fee$2.fee_type;
14922
+ type: Fee$2.type;
14923
14923
  /**
14924
14924
  * Wallet address of fee recipient
14925
14925
  */
14926
- recipient: string;
14926
+ recipient_address: string;
14927
14927
  };
14928
14928
  declare namespace Fee$2 {
14929
14929
  /**
14930
14930
  * Fee type
14931
14931
  */
14932
- enum fee_type {
14932
+ enum type {
14933
14933
  ROYALTY = "ROYALTY",
14934
14934
  MAKER_ECOSYSTEM = "MAKER_ECOSYSTEM",
14935
14935
  TAKER_ECOSYSTEM = "TAKER_ECOSYSTEM",
@@ -14937,17 +14937,36 @@ declare namespace Fee$2 {
14937
14937
  }
14938
14938
  }
14939
14939
 
14940
+ type ERC1155Item = {
14941
+ /**
14942
+ * Token type user is offering, which in this case is ERC1155
14943
+ */
14944
+ type: 'ERC1155';
14945
+ /**
14946
+ * Address of ERC1155 token
14947
+ */
14948
+ contract_address: string;
14949
+ /**
14950
+ * ID of ERC1155 token
14951
+ */
14952
+ token_id: string;
14953
+ /**
14954
+ * A string representing the price at which the user is willing to sell the token. This value is provided in the smallest unit of the token (e.g., wei for Ethereum).
14955
+ */
14956
+ amount: string;
14957
+ };
14958
+
14940
14959
  type ERC20Item$1 = {
14941
14960
  /**
14942
14961
  * Token type user is offering, which in this case is ERC20
14943
14962
  */
14944
- item_type: 'ERC20';
14963
+ type: 'ERC20';
14945
14964
  /**
14946
14965
  * Address of ERC20 token
14947
14966
  */
14948
14967
  contract_address: string;
14949
14968
  /**
14950
- * A string representing the starting price at which the user is willing to sell the token. This value is provided in the smallest unit of the token (e.g., wei for Ethereum).
14969
+ * A string representing the price at which the user is willing to sell the token. This value is provided in the smallest unit of the token (e.g., wei for Ethereum).
14951
14970
  */
14952
14971
  amount: string;
14953
14972
  };
@@ -14956,7 +14975,7 @@ type ERC721Item$1 = {
14956
14975
  /**
14957
14976
  * Token type user is offering, which in this case is ERC721
14958
14977
  */
14959
- item_type: 'ERC721';
14978
+ type: 'ERC721';
14960
14979
  /**
14961
14980
  * Address of ERC721 token
14962
14981
  */
@@ -14971,28 +14990,28 @@ type NativeItem$1 = {
14971
14990
  /**
14972
14991
  * Token type user is offering, which in this case is the native IMX token
14973
14992
  */
14974
- item_type: 'NATIVE';
14993
+ type: 'NATIVE';
14975
14994
  /**
14976
- * A string representing the starting price at which the user is willing to sell the token. This value is provided in the smallest unit of the token (e.g., wei for Ethereum).
14995
+ * A string representing the price at which the user is willing to sell the token. This value is provided in the smallest unit of the token (e.g., wei for Ethereum).
14977
14996
  */
14978
14997
  amount: string;
14979
14998
  };
14980
14999
 
14981
- type Item = (NativeItem$1 | ERC20Item$1 | ERC721Item$1);
15000
+ type Item = (NativeItem$1 | ERC20Item$1 | ERC721Item$1 | ERC1155Item);
14982
15001
 
14983
15002
  type ProtocolData = {
14984
15003
  /**
14985
- * The Order type
15004
+ * Seaport order type
14986
15005
  */
14987
15006
  order_type: ProtocolData.order_type;
14988
- /**
14989
- * Immutable zone address
14990
- */
14991
- zone_address: string;
14992
15007
  /**
14993
15008
  * big.Int or uint256 string for order counter
14994
15009
  */
14995
15010
  counter: string;
15011
+ /**
15012
+ * Immutable zone address
15013
+ */
15014
+ zone_address: string;
14996
15015
  /**
14997
15016
  * Immutable Seaport contract address
14998
15017
  */
@@ -15004,7 +15023,7 @@ type ProtocolData = {
15004
15023
  };
15005
15024
  declare namespace ProtocolData {
15006
15025
  /**
15007
- * The Order type
15026
+ * Seaport order type
15008
15027
  */
15009
15028
  enum order_type {
15010
15029
  FULL_RESTRICTED = "FULL_RESTRICTED"
@@ -15156,6 +15175,7 @@ type Order$1 = {
15156
15175
  * Global Order identifier
15157
15176
  */
15158
15177
  id: string;
15178
+ order_hash: string;
15159
15179
  protocol_data: ProtocolData;
15160
15180
  /**
15161
15181
  * A random value added to the create Order request
@@ -15171,11 +15191,23 @@ type Order$1 = {
15171
15191
  */
15172
15192
  start_at: string;
15173
15193
  status: OrderStatus;
15194
+ /**
15195
+ * Order type
15196
+ */
15197
+ type: Order$1.type;
15174
15198
  /**
15175
15199
  * Time the Order is last updated
15176
15200
  */
15177
15201
  updated_at: string;
15178
15202
  };
15203
+ declare namespace Order$1 {
15204
+ /**
15205
+ * Order type
15206
+ */
15207
+ enum type {
15208
+ LISTING = "LISTING"
15209
+ }
15210
+ }
15179
15211
 
15180
15212
  type FulfillableOrder = {
15181
15213
  extra_data: string;
@@ -15538,7 +15570,7 @@ declare enum FeeType {
15538
15570
  ROYALTY = "ROYALTY"
15539
15571
  }
15540
15572
  interface FeeValue {
15541
- recipient: string;
15573
+ recipientAddress: string;
15542
15574
  amount: string;
15543
15575
  }
15544
15576
  interface Fee$1 extends FeeValue {
@@ -15608,6 +15640,7 @@ interface CancelOrdersOnChainResponse {
15608
15640
  }
15609
15641
  interface Order {
15610
15642
  id: string;
15643
+ type: 'LISTING';
15611
15644
  accountAddress: string;
15612
15645
  buy: (ERC20Item | NativeItem)[];
15613
15646
  sell: ERC721Item[];
@@ -15626,6 +15659,7 @@ interface Order {
15626
15659
  * Time after which the Order is expired
15627
15660
  */
15628
15661
  endAt: string;
15662
+ orderHash: string;
15629
15663
  protocolData: {
15630
15664
  orderType: 'FULL_RESTRICTED';
15631
15665
  zoneAddress: string;