@imtbl/sdk 0.8.0-alpha → 0.11.0-alpha

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
@@ -5,7 +5,7 @@ import jwt_decode from 'jwt-decode';
5
5
  import * as crypto from 'crypto';
6
6
  import { Magic } from 'magic-sdk';
7
7
  import { OpenIdExtension } from '@magic-ext/oidc';
8
- import { BigNumber as BigNumber$1, ethers, providers, constants, utils as utils$1, Contract as Contract$1, ContractFactory } from 'ethers';
8
+ import { BigNumber as BigNumber$1, ethers, providers, constants as constants$1, utils as utils$1, Contract as Contract$1, ContractFactory } from 'ethers';
9
9
  import BN$2 from 'bn.js';
10
10
  import * as encUtils from 'enc-utils';
11
11
  import { Web3Provider, JsonRpcProvider } from '@ethersproject/providers';
@@ -17,7 +17,7 @@ import { Seaport as Seaport$1 } from '@opensea/seaport-js';
17
17
  import { parseUnits } from '@ethersproject/units';
18
18
  import { BigNumber as BigNumber$2 } from '@ethersproject/bignumber';
19
19
  import detectEthereumProvider from '@metamask/detect-provider';
20
- import { Token, TradeType, CurrencyAmount, Percent } from '@uniswap/sdk-core';
20
+ import { Token, TradeType, Percent, CurrencyAmount } from '@uniswap/sdk-core';
21
21
  import assert from 'assert';
22
22
  import { FeeAmount, Route, SwapQuoter, Pool, Trade, toHex as toHex$1, encodeRouteToPath } from '@uniswap/v3-sdk';
23
23
  import { keccak256 as keccak256$1 } from '@ethersproject/solidity';
@@ -2398,7 +2398,7 @@ class MultiRollupApiClients {
2398
2398
  }
2399
2399
 
2400
2400
  // eslint-disable-next-line @typescript-eslint/naming-convention
2401
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.8.0-alpha' };
2401
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.11.0-alpha' };
2402
2402
  const createConfig = ({ basePath, headers, }) => {
2403
2403
  if (!basePath.trim()) {
2404
2404
  throw Error('basePath can not be empty');
@@ -2458,7 +2458,7 @@ class APIError extends Error {
2458
2458
 
2459
2459
  /* eslint-disable implicit-arrow-linebreak */
2460
2460
  const defaultHeaders = {
2461
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.8.0-alpha',
2461
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.11.0-alpha',
2462
2462
  };
2463
2463
  /**
2464
2464
  * createAPIConfiguration to create a custom Configuration
@@ -2730,7 +2730,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
2730
2730
  chainID,
2731
2731
  coreContractAddress,
2732
2732
  registrationContractAddress,
2733
- sdkVersion: 'ts-immutable-sdk-0.8.0-alpha',
2733
+ sdkVersion: 'ts-immutable-sdk-0.11.0-alpha',
2734
2734
  });
2735
2735
  /**
2736
2736
  * Sets `sdkVersion` at the time of build
@@ -9412,6 +9412,28 @@ class OrdersService {
9412
9412
  },
9413
9413
  });
9414
9414
  }
9415
+ /**
9416
+ * Retrieve fulfillment data for orders
9417
+ * Retrieve signed fulfillment data based on the list of order IDs and corresponding fees.
9418
+ * @returns any Successful response
9419
+ * @throws ApiError
9420
+ */
9421
+ fulfillmentData({ chainName, requestBody, }) {
9422
+ return this.httpRequest.request({
9423
+ method: 'POST',
9424
+ url: '/v1/chains/{chain_name}/orders/fulfillment-data',
9425
+ path: {
9426
+ 'chain_name': chainName,
9427
+ },
9428
+ body: requestBody,
9429
+ mediaType: 'application/json',
9430
+ errors: {
9431
+ 400: `Bad Request (400)`,
9432
+ 404: `The specified resource was not found (404)`,
9433
+ 500: `Internal Server Error (500)`,
9434
+ },
9435
+ });
9436
+ }
9415
9437
  }
9416
9438
 
9417
9439
  class OrderBookClient {
@@ -9419,7 +9441,7 @@ class OrderBookClient {
9419
9441
  request;
9420
9442
  constructor(config, HttpRequest = AxiosHttpRequest) {
9421
9443
  this.request = new HttpRequest({
9422
- BASE: config?.BASE ?? 'https://api.dev.immutable.com',
9444
+ BASE: config?.BASE ?? 'https://api.sandbox.immutable.com',
9423
9445
  VERSION: config?.VERSION ?? '1.0.0',
9424
9446
  WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
9425
9447
  CREDENTIALS: config?.CREDENTIALS ?? 'include',
@@ -9488,7 +9510,7 @@ var ActionType;
9488
9510
  // TODO: Resolve these from seaport-js.
9489
9511
  // There is some bundling issue that is preventing this from working
9490
9512
  const SEAPORT_CONTRACT_NAME = 'ImmutableSeaport';
9491
- const SEAPORT_CONTRACT_VERSION_V1_4 = '1.4';
9513
+ // export const SEAPORT_CONTRACT_VERSION_V1_4 = '1.4';
9492
9514
  const SEAPORT_CONTRACT_VERSION_V1_5 = '1.5';
9493
9515
  const EIP_712_ORDER_TYPE = {
9494
9516
  OrderComponents: [
@@ -9579,7 +9601,7 @@ function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress)
9579
9601
  endAmount: buyItem.start_amount,
9580
9602
  itemType: ItemType.NATIVE,
9581
9603
  recipient: order.account_address,
9582
- token: constants.AddressZero,
9604
+ token: constants$1.AddressZero,
9583
9605
  identifierOrCriteria: '0',
9584
9606
  };
9585
9607
  case 'ERC20':
@@ -9588,7 +9610,7 @@ function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress)
9588
9610
  endAmount: buyItem.start_amount,
9589
9611
  itemType: ItemType.ERC20,
9590
9612
  recipient: order.account_address,
9591
- token: buyItem.contract_address || constants.AddressZero,
9613
+ token: buyItem.contract_address || constants$1.AddressZero,
9592
9614
  identifierOrCriteria: '0',
9593
9615
  };
9594
9616
  default: // ERC721
@@ -9597,7 +9619,7 @@ function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress)
9597
9619
  endAmount: '1',
9598
9620
  itemType: ItemType.ERC721,
9599
9621
  recipient: order.account_address,
9600
- token: buyItem.contract_address || constants.AddressZero,
9622
+ token: buyItem.contract_address || constants$1.AddressZero,
9601
9623
  identifierOrCriteria: '0',
9602
9624
  };
9603
9625
  }
@@ -9609,11 +9631,11 @@ function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress)
9609
9631
  recipient: fee.recipient,
9610
9632
  token: order.buy[0].item_type === 'ERC20'
9611
9633
  ? order.buy[0].contract_address
9612
- : constants.AddressZero,
9634
+ : constants$1.AddressZero,
9613
9635
  identifierOrCriteria: '0',
9614
9636
  }));
9615
9637
  return {
9616
- conduitKey: constants.HashZero,
9638
+ conduitKey: constants$1.HashZero,
9617
9639
  consideration: [...considerationItems, ...fees],
9618
9640
  offer: order.sell.map((sellItem) => {
9619
9641
  const erc721Item = sellItem;
@@ -9633,7 +9655,7 @@ function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress)
9633
9655
  zone: zoneAddress,
9634
9656
  totalOriginalConsiderationItems: 2,
9635
9657
  orderType: OrderType.FULL_RESTRICTED,
9636
- zoneHash: constants.HashZero,
9658
+ zoneHash: constants$1.HashZero,
9637
9659
  };
9638
9660
  }
9639
9661
 
@@ -9678,7 +9700,7 @@ class Seaport {
9678
9700
  orderHash: this.getSeaportLib().getOrderHash(orderComponents),
9679
9701
  };
9680
9702
  }
9681
- async fulfillOrder(order, account) {
9703
+ async fulfillOrder(order, account, extraData) {
9682
9704
  const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
9683
9705
  const seaportLib = this.getSeaportLib(order);
9684
9706
  const { actions: seaportActions } = await seaportLib.fulfillOrders({
@@ -9688,7 +9710,7 @@ class Seaport {
9688
9710
  parameters: orderComponents,
9689
9711
  signature: order.signature,
9690
9712
  },
9691
- extraData: order.protocol_data.operator_signature,
9713
+ extraData,
9692
9714
  }],
9693
9715
  });
9694
9716
  const fulfillmentActions = [];
@@ -9756,7 +9778,7 @@ class Seaport {
9756
9778
  const { chainId } = await this.provider.getNetwork();
9757
9779
  const domainData = {
9758
9780
  name: SEAPORT_CONTRACT_NAME,
9759
- version: SEAPORT_CONTRACT_VERSION_V1_4,
9781
+ version: SEAPORT_CONTRACT_VERSION_V1_5,
9760
9782
  chainId,
9761
9783
  verifyingContract: this.seaportContractAddress,
9762
9784
  };
@@ -9768,10 +9790,10 @@ class Seaport {
9768
9790
  }
9769
9791
  getSeaportLib(order) {
9770
9792
  const seaportAddress = order?.protocol_data?.seaport_address ?? this.seaportContractAddress;
9771
- let seaportVersion = SEAPORT_CONTRACT_VERSION_V1_4;
9772
- if (order?.protocol_data?.seaport_version === SEAPORT_CONTRACT_VERSION_V1_5) {
9773
- seaportVersion = SEAPORT_CONTRACT_VERSION_V1_5;
9774
- }
9793
+ const seaportVersion = SEAPORT_CONTRACT_VERSION_V1_5;
9794
+ // if (order?.protocol_data?.seaport_version === SEAPORT_CONTRACT_VERSION_V1_5) {
9795
+ // seaportVersion = SEAPORT_CONTRACT_VERSION_V1_5;
9796
+ // }
9775
9797
  return this.seaportLibFactory.create(seaportVersion, seaportAddress);
9776
9798
  }
9777
9799
  }
@@ -9785,6 +9807,12 @@ class ImmutableApiClient {
9785
9807
  this.chainName = chainName;
9786
9808
  this.seaportAddress = seaportAddress;
9787
9809
  }
9810
+ async fulfillmentData(requests) {
9811
+ return this.orderbookService.fulfillmentData({
9812
+ chainName: this.chainName,
9813
+ requestBody: requests,
9814
+ });
9815
+ }
9788
9816
  async getListing(listingId) {
9789
9817
  return this.orderbookService.getListing({
9790
9818
  chainName: this.chainName,
@@ -9840,7 +9868,7 @@ class ImmutableApiClient {
9840
9868
  order_type: CreateOrderProtocolData.order_type.FULL_RESTRICTED,
9841
9869
  zone_address: orderComponents.zone,
9842
9870
  seaport_address: this.seaportAddress,
9843
- seaport_version: SEAPORT_CONTRACT_VERSION_V1_4,
9871
+ seaport_version: SEAPORT_CONTRACT_VERSION_V1_5,
9844
9872
  counter: orderComponents.counter.toString(),
9845
9873
  },
9846
9874
  salt: orderComponents.salt,
@@ -9881,9 +9909,9 @@ function getOrderbookConfig(environment) {
9881
9909
  switch (environment) {
9882
9910
  case Environment$1.SANDBOX:
9883
9911
  return {
9884
- seaportContractAddress: '0x410000346E270aDbC89b2b688177d3AE76348dE9',
9885
- zoneContractAddress: '0x979C2aCA989A56554Eb63E01e576E3179Cdad5A0',
9886
- apiEndpoint: 'https://order-book-mr.sandbox.imtbl.com',
9912
+ seaportContractAddress: '0x7Fb7Da6De152597830eD16361633e362A2F59410',
9913
+ zoneContractAddress: '0x63441cBfBd15Dd8f5E92598E535661Ac5aCB808E',
9914
+ apiEndpoint: 'https://api.sandbox.immutable.com',
9887
9915
  chainName: TESTNET_CHAIN_NAME,
9888
9916
  provider: new providers.JsonRpcProvider('https://rpc.testnet.immutable.com'),
9889
9917
  };
@@ -10831,7 +10859,7 @@ class SeaportLibFactory {
10831
10859
  this.provider = provider;
10832
10860
  }
10833
10861
  create(orderSeaportVersion, orderSeaportAddress) {
10834
- const seaportVersion = orderSeaportVersion ?? SEAPORT_CONTRACT_VERSION_V1_4;
10862
+ const seaportVersion = orderSeaportVersion ?? SEAPORT_CONTRACT_VERSION_V1_5;
10835
10863
  const seaportContractAddress = orderSeaportAddress ?? this.defaultSeaportContractAddress;
10836
10864
  return new Seaport$1(this.provider, {
10837
10865
  seaportVersion,
@@ -10870,6 +10898,13 @@ class Orderbook {
10870
10898
  const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
10871
10899
  this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress);
10872
10900
  }
10901
+ /**
10902
+ * Return the configuration for the orderbook module.
10903
+ * @return {OrderbookModuleConfiguration} The configuration for the orderbook module.
10904
+ */
10905
+ config() {
10906
+ return this.orderbookConfig;
10907
+ }
10873
10908
  /**
10874
10909
  * Get an order by ID
10875
10910
  * @param {string} listingId - The listingId to find.
@@ -10921,11 +10956,20 @@ class Orderbook {
10921
10956
  * @return {FulfillOrderResponse} Approval and fulfilment transactions.
10922
10957
  */
10923
10958
  async fulfillOrder(listingId, takerAddress) {
10924
- const orderResult = await this.apiClient.getListing(listingId);
10925
- if (orderResult.result.status !== OrderStatus.ACTIVE) {
10926
- throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.result.status}`);
10959
+ const fulfillmentDataRes = await this.apiClient.fulfillmentData([{
10960
+ order_id: listingId,
10961
+ // fee: takerFee,
10962
+ fee: undefined,
10963
+ }]);
10964
+ if (fulfillmentDataRes.result.length !== 1) {
10965
+ throw new Error('unexpected fulfillment data result length');
10927
10966
  }
10928
- return this.seaport.fulfillOrder(orderResult.result, takerAddress);
10967
+ const extraData = fulfillmentDataRes.result[0].extra_data;
10968
+ const orderResult = fulfillmentDataRes.result[0].order;
10969
+ if (orderResult.status !== OrderStatus.ACTIVE) {
10970
+ throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.status}`);
10971
+ }
10972
+ return this.seaport.fulfillOrder(orderResult, takerAddress, extraData);
10929
10973
  }
10930
10974
  /**
10931
10975
  * Get an unsigned cancel order transaction. Orders can only be cancelled by
@@ -10949,12 +10993,21 @@ class Orderbook {
10949
10993
  }
10950
10994
  }
10951
10995
 
10996
+ // Consumers might want an estimated gas limit for fulfilling an order
10997
+ // without calling the transaction builder. This is an estimate that
10998
+ // should work for all fulfillment scenarios.
10999
+ const ESTIMATED_FULFILLMENT_GAS_GWEI = 400000;
11000
+ const constants = {
11001
+ estimatedFulfillmentGasGwei: ESTIMATED_FULFILLMENT_GAS_GWEI,
11002
+ };
11003
+
10952
11004
  var orderbook = /*#__PURE__*/Object.freeze({
10953
11005
  __proto__: null,
10954
11006
  get ActionType () { return ActionType; },
10955
11007
  Orderbook: Orderbook,
10956
11008
  get SignablePurpose () { return SignablePurpose; },
10957
- get TransactionPurpose () { return TransactionPurpose; }
11009
+ get TransactionPurpose () { return TransactionPurpose; },
11010
+ constants: constants
10958
11011
  });
10959
11012
 
10960
11013
  function isChainValid(chainID, config) {
@@ -16045,10 +16098,10 @@ class BigNumber {
16045
16098
  Object.freeze(this);
16046
16099
  }
16047
16100
  fromTwos(value) {
16048
- return toBigNumber$1(toBN(this).fromTwos(value));
16101
+ return toBigNumber(toBN(this).fromTwos(value));
16049
16102
  }
16050
16103
  toTwos(value) {
16051
- return toBigNumber$1(toBN(this).toTwos(value));
16104
+ return toBigNumber(toBN(this).toTwos(value));
16052
16105
  }
16053
16106
  abs() {
16054
16107
  if (this._hex[0] === "-") {
@@ -16057,73 +16110,73 @@ class BigNumber {
16057
16110
  return this;
16058
16111
  }
16059
16112
  add(other) {
16060
- return toBigNumber$1(toBN(this).add(toBN(other)));
16113
+ return toBigNumber(toBN(this).add(toBN(other)));
16061
16114
  }
16062
16115
  sub(other) {
16063
- return toBigNumber$1(toBN(this).sub(toBN(other)));
16116
+ return toBigNumber(toBN(this).sub(toBN(other)));
16064
16117
  }
16065
16118
  div(other) {
16066
16119
  const o = BigNumber.from(other);
16067
16120
  if (o.isZero()) {
16068
16121
  throwFault("division-by-zero", "div");
16069
16122
  }
16070
- return toBigNumber$1(toBN(this).div(toBN(other)));
16123
+ return toBigNumber(toBN(this).div(toBN(other)));
16071
16124
  }
16072
16125
  mul(other) {
16073
- return toBigNumber$1(toBN(this).mul(toBN(other)));
16126
+ return toBigNumber(toBN(this).mul(toBN(other)));
16074
16127
  }
16075
16128
  mod(other) {
16076
16129
  const value = toBN(other);
16077
16130
  if (value.isNeg()) {
16078
16131
  throwFault("division-by-zero", "mod");
16079
16132
  }
16080
- return toBigNumber$1(toBN(this).umod(value));
16133
+ return toBigNumber(toBN(this).umod(value));
16081
16134
  }
16082
16135
  pow(other) {
16083
16136
  const value = toBN(other);
16084
16137
  if (value.isNeg()) {
16085
16138
  throwFault("negative-power", "pow");
16086
16139
  }
16087
- return toBigNumber$1(toBN(this).pow(value));
16140
+ return toBigNumber(toBN(this).pow(value));
16088
16141
  }
16089
16142
  and(other) {
16090
16143
  const value = toBN(other);
16091
16144
  if (this.isNegative() || value.isNeg()) {
16092
16145
  throwFault("unbound-bitwise-result", "and");
16093
16146
  }
16094
- return toBigNumber$1(toBN(this).and(value));
16147
+ return toBigNumber(toBN(this).and(value));
16095
16148
  }
16096
16149
  or(other) {
16097
16150
  const value = toBN(other);
16098
16151
  if (this.isNegative() || value.isNeg()) {
16099
16152
  throwFault("unbound-bitwise-result", "or");
16100
16153
  }
16101
- return toBigNumber$1(toBN(this).or(value));
16154
+ return toBigNumber(toBN(this).or(value));
16102
16155
  }
16103
16156
  xor(other) {
16104
16157
  const value = toBN(other);
16105
16158
  if (this.isNegative() || value.isNeg()) {
16106
16159
  throwFault("unbound-bitwise-result", "xor");
16107
16160
  }
16108
- return toBigNumber$1(toBN(this).xor(value));
16161
+ return toBigNumber(toBN(this).xor(value));
16109
16162
  }
16110
16163
  mask(value) {
16111
16164
  if (this.isNegative() || value < 0) {
16112
16165
  throwFault("negative-width", "mask");
16113
16166
  }
16114
- return toBigNumber$1(toBN(this).maskn(value));
16167
+ return toBigNumber(toBN(this).maskn(value));
16115
16168
  }
16116
16169
  shl(value) {
16117
16170
  if (this.isNegative() || value < 0) {
16118
16171
  throwFault("negative-width", "shl");
16119
16172
  }
16120
- return toBigNumber$1(toBN(this).shln(value));
16173
+ return toBigNumber(toBN(this).shln(value));
16121
16174
  }
16122
16175
  shr(value) {
16123
16176
  if (this.isNegative() || value < 0) {
16124
16177
  throwFault("negative-width", "shr");
16125
16178
  }
16126
- return toBigNumber$1(toBN(this).shrn(value));
16179
+ return toBigNumber(toBN(this).shrn(value));
16127
16180
  }
16128
16181
  eq(other) {
16129
16182
  return toBN(this).eq(toBN(other));
@@ -16286,7 +16339,7 @@ function toHex(value) {
16286
16339
  }
16287
16340
  return value;
16288
16341
  }
16289
- function toBigNumber$1(value) {
16342
+ function toBigNumber(value) {
16290
16343
  return BigNumber.from(toHex(value));
16291
16344
  }
16292
16345
  function toBN(value) {
@@ -24859,70 +24912,6 @@ const getApproval = async (nativeToken, provider, ownerAddress, tokenAddress, pr
24859
24912
  };
24860
24913
  };
24861
24914
 
24862
- const quoteReturnMapping = {
24863
- // eslint-disable-next-line @typescript-eslint/naming-convention
24864
- '0xcdca1753': ['uint256', 'uint160[]', 'uint32[]', 'uint256'],
24865
- // eslint-disable-next-line @typescript-eslint/naming-convention
24866
- '0xc6a5026a': ['uint256', 'uint160', 'uint32', 'uint256'],
24867
- // eslint-disable-next-line @typescript-eslint/naming-convention
24868
- '0x2f80bb1d': ['uint256', 'uint160[]', 'uint32[]', 'uint256'],
24869
- // eslint-disable-next-line @typescript-eslint/naming-convention
24870
- '0xbd21704a': ['uint256', 'uint160', 'uint32', 'uint256'],
24871
- };
24872
- /**
24873
- * Returns true if poolA is equivalent to poolB
24874
- * @param poolA one of the two pools
24875
- * @param poolB the other pool
24876
- */
24877
- function poolEquals(poolA, poolB) {
24878
- return (poolA === poolB
24879
- || (poolA.token0.equals(poolB.token0)
24880
- && poolA.token1.equals(poolB.token1)
24881
- && poolA.fee === poolB.fee));
24882
- }
24883
- async function getERC20Decimals(tokenAddress, provider) {
24884
- const decimalsFunctionSig = ethers.utils.id('decimals()').substring(0, 10);
24885
- try {
24886
- const decimalsResult = await provider.call({
24887
- to: tokenAddress,
24888
- data: decimalsFunctionSig,
24889
- });
24890
- return parseInt(decimalsResult, 16);
24891
- }
24892
- catch (e) {
24893
- const message = e instanceof Error ? e.message : 'Unknown Error';
24894
- throw new ProviderCallError(`failed to get ERC20 decimals: ${message}`);
24895
- }
24896
- }
24897
- /**
24898
- * Based on https://github.com/ethers-io/ethers.js/blob/main/src.ts/address/checks.ts#L51
24899
- */
24900
- function isValidNonZeroAddress(address) {
24901
- if (address === ethers.constants.AddressZero) {
24902
- return false;
24903
- }
24904
- try {
24905
- ethers.utils.getAddress(address);
24906
- return true;
24907
- }
24908
- catch (error) {
24909
- return false;
24910
- }
24911
- }
24912
- const tokenInfoToUniswapToken = (tokenInfo) => new Token(tokenInfo.chainId, tokenInfo.address, tokenInfo.decimals, tokenInfo.symbol, tokenInfo.name);
24913
- const uniswapTokenToTokenInfo = (token) => ({
24914
- chainId: token.chainId,
24915
- address: token.address,
24916
- decimals: token.decimals,
24917
- symbol: token.symbol,
24918
- name: token.name,
24919
- });
24920
- const toBigNumber = (amount) => (ethers.BigNumber.from(amount.multiply(amount.decimalScale).toExact()));
24921
- const newAmount = (amount, token) => ({
24922
- value: amount,
24923
- token,
24924
- });
24925
-
24926
24915
  // slippageToPercent takes the slippage as a percentage (e.g. 0.1) and
24927
24916
  // converts it to the Uniswap equivalent type
24928
24917
  const slippageToFraction = (slippage) => {
@@ -24942,17 +24931,11 @@ const slippageToFraction = (slippage) => {
24942
24931
  return new Percent(numerator, denominator);
24943
24932
  };
24944
24933
 
24945
- function getQuoteAmountFromTradeType(tradeInfo, tokenInfo) {
24934
+ function getQuoteAmountFromTradeType(tradeInfo) {
24946
24935
  if (tradeInfo.tradeType === TradeType.EXACT_INPUT) {
24947
- return {
24948
- token: tokenInfo,
24949
- value: tradeInfo.amountOut,
24950
- };
24936
+ return tradeInfo.amountOut;
24951
24937
  }
24952
- return {
24953
- token: tokenInfo,
24954
- value: tradeInfo.amountIn,
24955
- };
24938
+ return tradeInfo.amountIn;
24956
24939
  }
24957
24940
  function applySlippage(tradeType, amount, slippage) {
24958
24941
  const slippageTolerance = slippageToFraction(slippage);
@@ -24961,8 +24944,8 @@ function applySlippage(tradeType, amount, slippage) {
24961
24944
  const amountWithSlippage = maybeInverted.multiply(amount.toString()).quotient;
24962
24945
  return ethers.BigNumber.from(amountWithSlippage.toString());
24963
24946
  }
24964
- function prepareUserQuote(otherCurrency, tradeInfo, slippage, fees) {
24965
- const resultToken = otherCurrency.wrapped;
24947
+ function prepareUserQuote(otherToken, tradeInfo, slippage, fees) {
24948
+ const resultToken = otherToken.wrapped;
24966
24949
  const tokenInfo = {
24967
24950
  chainId: resultToken.chainId,
24968
24951
  address: resultToken.address,
@@ -24970,7 +24953,7 @@ function prepareUserQuote(otherCurrency, tradeInfo, slippage, fees) {
24970
24953
  symbol: resultToken.symbol,
24971
24954
  name: resultToken.name,
24972
24955
  };
24973
- const quote = getQuoteAmountFromTradeType(tradeInfo, tokenInfo);
24956
+ const quote = getQuoteAmountFromTradeType(tradeInfo);
24974
24957
  const amountWithSlippage = applySlippage(tradeInfo.tradeType, quote.value, slippage);
24975
24958
  return {
24976
24959
  amount: quote,
@@ -24987,8 +24970,8 @@ function getOurQuoteReqAmount(amount, fees, tradeType) {
24987
24970
  // For an exact output swap, we do not need to subtract fees from the given amount
24988
24971
  return amount;
24989
24972
  }
24990
- fees.addAmount(toBigNumber(amount));
24991
- return CurrencyAmount.fromRawAmount(amount.currency, fees.amountLessFees().toString());
24973
+ fees.addAmount(amount);
24974
+ return fees.amountLessFees();
24992
24975
  }
24993
24976
 
24994
24977
  // 0.1% default slippage
@@ -25140,6 +25123,11 @@ class Multicall__factory extends ContractFactory {
25140
25123
  const _abi$1$1 = [
25141
25124
  {
25142
25125
  inputs: [
25126
+ {
25127
+ internalType: "address",
25128
+ name: "_admin",
25129
+ type: "address",
25130
+ },
25143
25131
  {
25144
25132
  internalType: "address",
25145
25133
  name: "_uniRouter",
@@ -25180,36 +25168,92 @@ const _abi$1$1 = [
25180
25168
  name: "FeeTaken",
25181
25169
  type: "event",
25182
25170
  },
25171
+ {
25172
+ anonymous: false,
25173
+ inputs: [
25174
+ {
25175
+ indexed: false,
25176
+ internalType: "address",
25177
+ name: "account",
25178
+ type: "address",
25179
+ },
25180
+ ],
25181
+ name: "Paused",
25182
+ type: "event",
25183
+ },
25184
+ {
25185
+ anonymous: false,
25186
+ inputs: [
25187
+ {
25188
+ indexed: true,
25189
+ internalType: "bytes32",
25190
+ name: "role",
25191
+ type: "bytes32",
25192
+ },
25193
+ {
25194
+ indexed: true,
25195
+ internalType: "bytes32",
25196
+ name: "previousAdminRole",
25197
+ type: "bytes32",
25198
+ },
25199
+ {
25200
+ indexed: true,
25201
+ internalType: "bytes32",
25202
+ name: "newAdminRole",
25203
+ type: "bytes32",
25204
+ },
25205
+ ],
25206
+ name: "RoleAdminChanged",
25207
+ type: "event",
25208
+ },
25183
25209
  {
25184
25210
  anonymous: false,
25185
25211
  inputs: [
25212
+ {
25213
+ indexed: true,
25214
+ internalType: "bytes32",
25215
+ name: "role",
25216
+ type: "bytes32",
25217
+ },
25186
25218
  {
25187
25219
  indexed: true,
25188
25220
  internalType: "address",
25189
- name: "previousOwner",
25221
+ name: "account",
25190
25222
  type: "address",
25191
25223
  },
25192
25224
  {
25193
25225
  indexed: true,
25194
25226
  internalType: "address",
25195
- name: "newOwner",
25227
+ name: "sender",
25196
25228
  type: "address",
25197
25229
  },
25198
25230
  ],
25199
- name: "OwnershipTransferred",
25231
+ name: "RoleGranted",
25200
25232
  type: "event",
25201
25233
  },
25202
25234
  {
25203
25235
  anonymous: false,
25204
25236
  inputs: [
25205
25237
  {
25206
- indexed: false,
25238
+ indexed: true,
25239
+ internalType: "bytes32",
25240
+ name: "role",
25241
+ type: "bytes32",
25242
+ },
25243
+ {
25244
+ indexed: true,
25207
25245
  internalType: "address",
25208
25246
  name: "account",
25209
25247
  type: "address",
25210
25248
  },
25249
+ {
25250
+ indexed: true,
25251
+ internalType: "address",
25252
+ name: "sender",
25253
+ type: "address",
25254
+ },
25211
25255
  ],
25212
- name: "Paused",
25256
+ name: "RoleRevoked",
25213
25257
  type: "event",
25214
25258
  },
25215
25259
  {
@@ -25230,9 +25274,9 @@ const _abi$1$1 = [
25230
25274
  name: "BASIS_POINT_PRECISION",
25231
25275
  outputs: [
25232
25276
  {
25233
- internalType: "uint16",
25277
+ internalType: "uint256",
25234
25278
  name: "",
25235
- type: "uint16",
25279
+ type: "uint256",
25236
25280
  },
25237
25281
  ],
25238
25282
  stateMutability: "view",
@@ -25240,7 +25284,20 @@ const _abi$1$1 = [
25240
25284
  },
25241
25285
  {
25242
25286
  inputs: [],
25243
- name: "MAX_SERVICE_FEE",
25287
+ name: "DEFAULT_ADMIN_ROLE",
25288
+ outputs: [
25289
+ {
25290
+ internalType: "bytes32",
25291
+ name: "",
25292
+ type: "bytes32",
25293
+ },
25294
+ ],
25295
+ stateMutability: "view",
25296
+ type: "function",
25297
+ },
25298
+ {
25299
+ inputs: [],
25300
+ name: "FEE_BASIS_POINTS_MAXIMUM",
25244
25301
  outputs: [
25245
25302
  {
25246
25303
  internalType: "uint16",
@@ -25251,6 +25308,45 @@ const _abi$1$1 = [
25251
25308
  stateMutability: "view",
25252
25309
  type: "function",
25253
25310
  },
25311
+ {
25312
+ inputs: [],
25313
+ name: "PAUSE",
25314
+ outputs: [
25315
+ {
25316
+ internalType: "bytes32",
25317
+ name: "",
25318
+ type: "bytes32",
25319
+ },
25320
+ ],
25321
+ stateMutability: "view",
25322
+ type: "function",
25323
+ },
25324
+ {
25325
+ inputs: [],
25326
+ name: "UNPAUSE",
25327
+ outputs: [
25328
+ {
25329
+ internalType: "bytes32",
25330
+ name: "",
25331
+ type: "bytes32",
25332
+ },
25333
+ ],
25334
+ stateMutability: "view",
25335
+ type: "function",
25336
+ },
25337
+ {
25338
+ inputs: [],
25339
+ name: "WITHDRAW",
25340
+ outputs: [
25341
+ {
25342
+ internalType: "bytes32",
25343
+ name: "",
25344
+ type: "bytes32",
25345
+ },
25346
+ ],
25347
+ stateMutability: "view",
25348
+ type: "function",
25349
+ },
25254
25350
  {
25255
25351
  inputs: [
25256
25352
  {
@@ -25261,13 +25357,13 @@ const _abi$1$1 = [
25261
25357
  type: "address",
25262
25358
  },
25263
25359
  {
25264
- internalType: "uint16",
25265
- name: "feePrcntBasisPoints",
25266
- type: "uint16",
25360
+ internalType: "uint256",
25361
+ name: "feeBasisPoints",
25362
+ type: "uint256",
25267
25363
  },
25268
25364
  ],
25269
- internalType: "struct ISecondaryFee.ServiceFeeParams[]",
25270
- name: "serviceFee",
25365
+ internalType: "struct ISecondaryFee.SecondaryFeeParams[]",
25366
+ name: "secondaryFees",
25271
25367
  type: "tuple[]",
25272
25368
  },
25273
25369
  {
@@ -25309,11 +25405,11 @@ const _abi$1$1 = [
25309
25405
  },
25310
25406
  ],
25311
25407
  internalType: "struct IV3SwapRouter.ExactInputSingleParams",
25312
- name: "params",
25408
+ name: "swapParams",
25313
25409
  type: "tuple",
25314
25410
  },
25315
25411
  ],
25316
- name: "exactInputSingleWithServiceFee",
25412
+ name: "exactInputSingleWithSecondaryFee",
25317
25413
  outputs: [
25318
25414
  {
25319
25415
  internalType: "uint256",
@@ -25334,13 +25430,13 @@ const _abi$1$1 = [
25334
25430
  type: "address",
25335
25431
  },
25336
25432
  {
25337
- internalType: "uint16",
25338
- name: "feePrcntBasisPoints",
25339
- type: "uint16",
25433
+ internalType: "uint256",
25434
+ name: "feeBasisPoints",
25435
+ type: "uint256",
25340
25436
  },
25341
25437
  ],
25342
- internalType: "struct ISecondaryFee.ServiceFeeParams[]",
25343
- name: "serviceFee",
25438
+ internalType: "struct ISecondaryFee.SecondaryFeeParams[]",
25439
+ name: "secondaryFees",
25344
25440
  type: "tuple[]",
25345
25441
  },
25346
25442
  {
@@ -25367,11 +25463,11 @@ const _abi$1$1 = [
25367
25463
  },
25368
25464
  ],
25369
25465
  internalType: "struct IV3SwapRouter.ExactInputParams",
25370
- name: "params",
25466
+ name: "swapParams",
25371
25467
  type: "tuple",
25372
25468
  },
25373
25469
  ],
25374
- name: "exactInputWithServiceFee",
25470
+ name: "exactInputWithSecondaryFee",
25375
25471
  outputs: [
25376
25472
  {
25377
25473
  internalType: "uint256",
@@ -25392,13 +25488,13 @@ const _abi$1$1 = [
25392
25488
  type: "address",
25393
25489
  },
25394
25490
  {
25395
- internalType: "uint16",
25396
- name: "feePrcntBasisPoints",
25397
- type: "uint16",
25491
+ internalType: "uint256",
25492
+ name: "feeBasisPoints",
25493
+ type: "uint256",
25398
25494
  },
25399
25495
  ],
25400
- internalType: "struct ISecondaryFee.ServiceFeeParams[]",
25401
- name: "serviceFee",
25496
+ internalType: "struct ISecondaryFee.SecondaryFeeParams[]",
25497
+ name: "secondaryFees",
25402
25498
  type: "tuple[]",
25403
25499
  },
25404
25500
  {
@@ -25440,15 +25536,15 @@ const _abi$1$1 = [
25440
25536
  },
25441
25537
  ],
25442
25538
  internalType: "struct IV3SwapRouter.ExactOutputSingleParams",
25443
- name: "params",
25539
+ name: "swapParams",
25444
25540
  type: "tuple",
25445
25541
  },
25446
25542
  ],
25447
- name: "exactOutputSingleWithServiceFee",
25543
+ name: "exactOutputSingleWithSecondaryFee",
25448
25544
  outputs: [
25449
25545
  {
25450
25546
  internalType: "uint256",
25451
- name: "amountIn",
25547
+ name: "",
25452
25548
  type: "uint256",
25453
25549
  },
25454
25550
  ],
@@ -25465,13 +25561,13 @@ const _abi$1$1 = [
25465
25561
  type: "address",
25466
25562
  },
25467
25563
  {
25468
- internalType: "uint16",
25469
- name: "feePrcntBasisPoints",
25470
- type: "uint16",
25564
+ internalType: "uint256",
25565
+ name: "feeBasisPoints",
25566
+ type: "uint256",
25471
25567
  },
25472
25568
  ],
25473
- internalType: "struct ISecondaryFee.ServiceFeeParams[]",
25474
- name: "serviceFee",
25569
+ internalType: "struct ISecondaryFee.SecondaryFeeParams[]",
25570
+ name: "secondaryFees",
25475
25571
  type: "tuple[]",
25476
25572
  },
25477
25573
  {
@@ -25498,21 +25594,82 @@ const _abi$1$1 = [
25498
25594
  },
25499
25595
  ],
25500
25596
  internalType: "struct IV3SwapRouter.ExactOutputParams",
25501
- name: "params",
25597
+ name: "swapParams",
25502
25598
  type: "tuple",
25503
25599
  },
25504
25600
  ],
25505
- name: "exactOutputWithServiceFee",
25601
+ name: "exactOutputWithSecondaryFee",
25506
25602
  outputs: [
25507
25603
  {
25508
25604
  internalType: "uint256",
25509
- name: "amountIn",
25605
+ name: "",
25510
25606
  type: "uint256",
25511
25607
  },
25512
25608
  ],
25513
25609
  stateMutability: "payable",
25514
25610
  type: "function",
25515
25611
  },
25612
+ {
25613
+ inputs: [
25614
+ {
25615
+ internalType: "bytes32",
25616
+ name: "role",
25617
+ type: "bytes32",
25618
+ },
25619
+ ],
25620
+ name: "getRoleAdmin",
25621
+ outputs: [
25622
+ {
25623
+ internalType: "bytes32",
25624
+ name: "",
25625
+ type: "bytes32",
25626
+ },
25627
+ ],
25628
+ stateMutability: "view",
25629
+ type: "function",
25630
+ },
25631
+ {
25632
+ inputs: [
25633
+ {
25634
+ internalType: "bytes32",
25635
+ name: "role",
25636
+ type: "bytes32",
25637
+ },
25638
+ {
25639
+ internalType: "address",
25640
+ name: "account",
25641
+ type: "address",
25642
+ },
25643
+ ],
25644
+ name: "grantRole",
25645
+ outputs: [],
25646
+ stateMutability: "nonpayable",
25647
+ type: "function",
25648
+ },
25649
+ {
25650
+ inputs: [
25651
+ {
25652
+ internalType: "bytes32",
25653
+ name: "role",
25654
+ type: "bytes32",
25655
+ },
25656
+ {
25657
+ internalType: "address",
25658
+ name: "account",
25659
+ type: "address",
25660
+ },
25661
+ ],
25662
+ name: "hasRole",
25663
+ outputs: [
25664
+ {
25665
+ internalType: "bool",
25666
+ name: "",
25667
+ type: "bool",
25668
+ },
25669
+ ],
25670
+ stateMutability: "view",
25671
+ type: "function",
25672
+ },
25516
25673
  {
25517
25674
  inputs: [
25518
25675
  {
@@ -25556,19 +25713,6 @@ const _abi$1$1 = [
25556
25713
  stateMutability: "nonpayable",
25557
25714
  type: "function",
25558
25715
  },
25559
- {
25560
- inputs: [],
25561
- name: "owner",
25562
- outputs: [
25563
- {
25564
- internalType: "address",
25565
- name: "",
25566
- type: "address",
25567
- },
25568
- ],
25569
- stateMutability: "view",
25570
- type: "function",
25571
- },
25572
25716
  {
25573
25717
  inputs: [],
25574
25718
  name: "pause",
@@ -25590,25 +25734,60 @@ const _abi$1$1 = [
25590
25734
  type: "function",
25591
25735
  },
25592
25736
  {
25593
- inputs: [],
25594
- name: "renounceOwnership",
25737
+ inputs: [
25738
+ {
25739
+ internalType: "bytes32",
25740
+ name: "role",
25741
+ type: "bytes32",
25742
+ },
25743
+ {
25744
+ internalType: "address",
25745
+ name: "account",
25746
+ type: "address",
25747
+ },
25748
+ ],
25749
+ name: "renounceRole",
25595
25750
  outputs: [],
25596
25751
  stateMutability: "nonpayable",
25597
25752
  type: "function",
25598
25753
  },
25599
25754
  {
25600
25755
  inputs: [
25756
+ {
25757
+ internalType: "bytes32",
25758
+ name: "role",
25759
+ type: "bytes32",
25760
+ },
25601
25761
  {
25602
25762
  internalType: "address",
25603
- name: "newOwner",
25763
+ name: "account",
25604
25764
  type: "address",
25605
25765
  },
25606
25766
  ],
25607
- name: "transferOwnership",
25767
+ name: "revokeRole",
25608
25768
  outputs: [],
25609
25769
  stateMutability: "nonpayable",
25610
25770
  type: "function",
25611
25771
  },
25772
+ {
25773
+ inputs: [
25774
+ {
25775
+ internalType: "bytes4",
25776
+ name: "interfaceId",
25777
+ type: "bytes4",
25778
+ },
25779
+ ],
25780
+ name: "supportsInterface",
25781
+ outputs: [
25782
+ {
25783
+ internalType: "bool",
25784
+ name: "",
25785
+ type: "bool",
25786
+ },
25787
+ ],
25788
+ stateMutability: "view",
25789
+ type: "function",
25790
+ },
25612
25791
  {
25613
25792
  inputs: [],
25614
25793
  name: "uniswapRouter",
@@ -25629,8 +25808,26 @@ const _abi$1$1 = [
25629
25808
  stateMutability: "nonpayable",
25630
25809
  type: "function",
25631
25810
  },
25811
+ {
25812
+ inputs: [
25813
+ {
25814
+ internalType: "address",
25815
+ name: "to",
25816
+ type: "address",
25817
+ },
25818
+ {
25819
+ internalType: "address",
25820
+ name: "erc20",
25821
+ type: "address",
25822
+ },
25823
+ ],
25824
+ name: "withdrawFunds",
25825
+ outputs: [],
25826
+ stateMutability: "nonpayable",
25827
+ type: "function",
25828
+ },
25632
25829
  ];
25633
- const _bytecode$1$1 = "0x60806040523480156200001157600080fd5b5060405162002123380380620021238339810160408190526200003491620000c2565b6200003f3362000072565b6000805460ff60a01b19169055600180546001600160a01b0319166001600160a01b0392909216919091179055620000f4565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060208284031215620000d557600080fd5b81516001600160a01b0381168114620000ed57600080fd5b9392505050565b61201f80620001046000396000f3fe6080604052600436106100e85760003560e01c8063735de9f71161008a578063ac9650d811610059578063ac9650d814610243578063d9a6f70514610263578063ed921d3c14610279578063f2fde38b1461028c57600080fd5b8063735de9f7146101c5578063742ac944146101fd5780638456cb59146102105780638da5cb5b1461022557600080fd5b80633f4ba83a116100c65780633f4ba83a1461014f5780635ae401dc146101665780635c975abb14610186578063715018a6146101b057600080fd5b80631411734e146100ed57806314d90e1b146101135780631fd168ff1461013c575b600080fd5b6101006100fb366004611a14565b6102ac565b6040519081526020015b60405180910390f35b34801561011f57600080fd5b506101296103e881565b60405161ffff909116815260200161010a565b61010061014a366004611a14565b61040a565b34801561015b57600080fd5b5061016461057a565b005b610179610174366004611ac0565b61058c565b60405161010a9190611b5b565b34801561019257600080fd5b50600054600160a01b900460ff16604051901515815260200161010a565b3480156101bc57600080fd5b506101646105e2565b3480156101d157600080fd5b506001546101e5906001600160a01b031681565b6040516001600160a01b03909116815260200161010a565b61010061020b366004611c50565b6105f4565b34801561021c57600080fd5b50610164610731565b34801561023157600080fd5b506000546001600160a01b03166101e5565b34801561024f57600080fd5b5061017961025e366004611ca5565b610741565b34801561026f57600080fd5b5061012961271081565b610100610287366004611c50565b610836565b34801561029857600080fd5b506101646102a7366004611ce6565b61095e565b60208101516000906001600160a01b031633148015906102d9575060208201516001600160a01b03163014155b156102ff5760405162461bcd60e51b81526004016102f690611d03565b60405180910390fd5b600061030e83600001516109d7565b905060008061037983866040015187602001518a8a808060200260200160405190810160405280939291908181526020016000905b8282101561036f5761036060408302860136819003810190611d50565b81526020019060010190610343565b50505050506109e3565b60408088018390526001600160a01b0380831660208a0152600154915163b858183f60e01b8152939550919350169063b858183f906103bc908890600401611dfc565b6020604051808303816000875af11580156103db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ff9190611e0f565b979650505050505050565b6040810151815160009190829061042090610ac4565b9050600061043185600001516109d7565b90506000806000806104a4868a606001518b604001518c602001518f8f808060200260200160405190810160405280939291908181526020016000905b8282101561049a5761048b60408302860136819003810190611d50565b8152602001906001019061046e565b5050505050610af2565b9350935093509350838960400181815250508289602001906001600160a01b031690816001600160a01b031681525050600160009054906101000a90046001600160a01b03166001600160a01b03166309b813468a6040518263ffffffff1660e01b81526004016105159190611dfc565b6020604051808303816000875af1158015610534573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105589190611e0f565b975061056c8787878c604001518587610bd3565b505050505050509392505050565b610582610e16565b61058a610e70565b565b6060834211156105d05760405162461bcd60e51b815260206004820152600f60248201526e111958591b1a5b99481c185cdcd959608a1b60448201526064016102f6565b6105da8383610741565b949350505050565b6105ea610e16565b61058a6000610ec5565b60608101516000906001600160a01b03163314801590610621575060608201516001600160a01b03163014155b1561063e5760405162461bcd60e51b81526004016102f690611d03565b6000806106a18460000151856080015186606001518989808060200260200160405190810160405280939291908181526020016000905b8282101561036f5761069260408302860136819003810190611d50565b81526020019060010190610675565b608086018290526001600160a01b0380821660608801526001546040516304e45aaf60e01b815293955091935016906304e45aaf906106e4908790600401611e28565b6020604051808303816000875af1158015610703573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107279190611e0f565b9695505050505050565b610739610e16565b61058a610f15565b6060816001600160401b0381111561075b5761075b61189c565b60405190808252806020026020018201604052801561078e57816020015b60608152602001906001900390816107795790505b50905060005b8281101561082e576107fe308585848181106107b2576107b2611e87565b90506020028101906107c49190611e9d565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610f5892505050565b82828151811061081057610810611e87565b6020026020010181905250808061082690611ef9565b915050610794565b505b92915050565b600080826080015190506000806000806108ab87600001518860a0015189608001518a606001518d8d808060200260200160405190810160405280939291908181526020016000905b8282101561049a5761089c60408302860136819003810190611d50565b8152602001906001019061087f565b60808b018490526001600160a01b0380841660608d0152600154604051635023b4df60e01b815295995093975091955093501690635023b4df906108f3908a90600401611e28565b6020604051808303816000875af1158015610912573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109369190611e0f565b955061095285886000015189602001518a608001518587610bd3565b50505050509392505050565b610966610e16565b6001600160a01b0381166109cb5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102f6565b6109d481610ec5565b50565b60006108308282610f84565b600080548190600160a01b900460ff16610a2257600080610a048786610fe9565b9092509050610a138288611f12565b9650610a1f88826111c6565b50505b6040516323b872dd60e01b8152336004820152306024820152604481018690526001600160a01b038716906323b872dd906064016020604051808303816000875af1158015610a75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a999190611f25565b50610aa48686611341565b306001600160a01b03851603610ab8573393505b50929491935090915050565b60008060148351610ad59190611f12565b90506000610ae584836014611438565b90506105da816000610f84565b6000806060818082610b0e60005460ff600160a01b9091041690565b610b2e57610b1c8988610fe9565b9092509050610b2b828a611f47565b98505b6001600160a01b0388163014610b42573097505b610b4c8b8b611341565b6040516323b872dd60e01b8152336004820152306024820152604481018b90526001600160a01b038c16906323b872dd906064016020604051808303816000875af1158015610b9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc39190611f25565b50979a9699509697505050505050565b600054600160a01b900460ff16610bee57610bee8482611545565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa158015610c35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c599190611e0f565b9050610c658385611f12565b811015610cb45760405162461bcd60e51b815260206004820181905260248201527f696e636f72726563742066656520616d6f756e7420646973747269627574656460448201526064016102f6565b60405163a9059cbb60e01b8152336004820152602481018890526001600160a01b0386169063a9059cbb906044016020604051808303816000875af1158015610d01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d259190611f25565b506040516370a0823160e01b81523060048201526000906001600160a01b038816906370a0823190602401602060405180830381865afa158015610d6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d919190611e0f565b90508015610e0c5760405163a9059cbb60e01b8152336004820152602481018290526001600160a01b0388169063a9059cbb906044016020604051808303816000875af1158015610de6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0a9190611f25565b505b5050505050505050565b6000546001600160a01b0316331461058a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102f6565b610e786116b4565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610f1d611704565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610ea83390565b6060610f7d8383604051806060016040528060278152602001611fc360279139611751565b9392505050565b6000610f91826014611f47565b83511015610fd95760405162461bcd60e51b8152602060048201526015602482015274746f416464726573735f6f75744f66426f756e647360581b60448201526064016102f6565b500160200151600160601b900490565b6000606081805b845181101561103a5784818151811061100b5761100b611e87565b60200260200101516020015161ffff16826110269190611f47565b91508061103281611ef9565b915050610ff0565b506103e881111561108d5760405162461bcd60e51b815260206004820152601d60248201527f5365727669636520666565203e204d41585f534552564943455f46454500000060448201526064016102f6565b60008085516001600160401b038111156110a9576110a961189c565b6040519080825280602002602001820160405280156110ee57816020015b60408051808201909152600080825260208201528152602001906001900390816110c75790505b50905060005b86518110156111b757600061271061ffff1688838151811061111857611118611e87565b60200260200101516020015161ffff168a6111339190611f5a565b61113d9190611f71565b9050604051806040016040528089848151811061115c5761115c611e87565b6020026020010151600001516001600160a01b031681526020018281525083838151811061118c5761118c611e87565b60209081029190910101526111a18185611f47565b93505080806111af90611ef9565b9150506110f4565b509093509150505b9250929050565b60005b815181101561133c57826001600160a01b03166323b872dd338484815181106111f4576111f4611e87565b60200260200101516000015185858151811061121257611212611e87565b60209081029190910181015101516040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015611274573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112989190611f25565b508181815181106112ab576112ab611e87565b6020026020010151600001516001600160a01b0316336001600160a01b0316846001600160a01b03167f1f9a9fdac86b6ca3c5300bec0b61555cded1f1a234378602dcca6c27085eac8e85858151811061130757611307611e87565b60200260200101516020015160405161132291815260200190565b60405180910390a48061133481611ef9565b9150506111c9565b505050565b600154604051636eb1769f60e11b81523060048201526001600160a01b039182166024820152829184169063dd62ed3e90604401602060405180830381865afa158015611392573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b69190611e0f565b10156114345760015460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529083169063095ea7b3906044016020604051808303816000875af1158015611410573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133c9190611f25565b5050565b60608161144681601f611f47565b10156114855760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b60448201526064016102f6565b61148f8284611f47565b845110156114d35760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b60448201526064016102f6565b6060821580156114f2576040519150600082526020820160405261153c565b6040519150601f8416801560200281840101858101878315602002848b0101015b8183101561152b578051835260209283019201611513565b5050858452601f01601f1916604052505b50949350505050565b60005b815181101561133c57826001600160a01b031663a9059cbb83838151811061157257611572611e87565b60200260200101516000015184848151811061159057611590611e87565b6020026020010151602001516040518363ffffffff1660e01b81526004016115cd9291906001600160a01b03929092168252602082015260400190565b6020604051808303816000875af11580156115ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116109190611f25565b5081818151811061162357611623611e87565b6020026020010151600001516001600160a01b0316336001600160a01b0316846001600160a01b03167f1f9a9fdac86b6ca3c5300bec0b61555cded1f1a234378602dcca6c27085eac8e85858151811061167f5761167f611e87565b60200260200101516020015160405161169a91815260200190565b60405180910390a4806116ac81611ef9565b915050611548565b600054600160a01b900460ff1661058a5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016102f6565b600054600160a01b900460ff161561058a5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016102f6565b6060600080856001600160a01b03168560405161176e9190611f93565b600060405180830381855af49150503d80600081146117a9576040519150601f19603f3d011682016040523d82523d6000602084013e6117ae565b606091505b50915091506107278683838760608315611829578251600003611822576001600160a01b0385163b6118225760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102f6565b50816105da565b6105da838381511561183e5781518083602001fd5b8060405162461bcd60e51b81526004016102f69190611faf565b60008083601f84011261186a57600080fd5b5081356001600160401b0381111561188157600080fd5b6020830191508360208260061b85010111156111bf57600080fd5b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b03811182821017156118d4576118d461189c565b60405290565b60405160e081016001600160401b03811182821017156118d4576118d461189c565b604051601f8201601f191681016001600160401b03811182821017156119245761192461189c565b604052919050565b6001600160a01b03811681146109d457600080fd5b803561194c8161192c565b919050565b60006080828403121561196357600080fd5b61196b6118b2565b905081356001600160401b038082111561198457600080fd5b818401915084601f83011261199857600080fd5b81356020828211156119ac576119ac61189c565b6119be601f8301601f191682016118fc565b925081835286818386010111156119d457600080fd5b818185018285013760008183850101528285526119f2818701611941565b8186015250505050604082013560408201526060820135606082015292915050565b600080600060408486031215611a2957600080fd5b83356001600160401b0380821115611a4057600080fd5b611a4c87838801611858565b90955093506020860135915080821115611a6557600080fd5b50611a7286828701611951565b9150509250925092565b60008083601f840112611a8e57600080fd5b5081356001600160401b03811115611aa557600080fd5b6020830191508360208260051b85010111156111bf57600080fd5b600080600060408486031215611ad557600080fd5b8335925060208401356001600160401b03811115611af257600080fd5b611afe86828701611a7c565b9497909650939450505050565b60005b83811015611b26578181015183820152602001611b0e565b50506000910152565b60008151808452611b47816020860160208601611b0b565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015611bb057603f19888603018452611b9e858351611b2f565b94509285019290850190600101611b82565b5092979650505050505050565b600060e08284031215611bcf57600080fd5b611bd76118da565b90508135611be48161192c565b81526020820135611bf48161192c565b6020820152604082013562ffffff81168114611c0f57600080fd5b6040820152611c2060608301611941565b60608201526080820135608082015260a082013560a0820152611c4560c08301611941565b60c082015292915050565b60008060006101008486031215611c6657600080fd5b83356001600160401b03811115611c7c57600080fd5b611c8886828701611858565b9094509250611c9c90508560208601611bbd565b90509250925092565b60008060208385031215611cb857600080fd5b82356001600160401b03811115611cce57600080fd5b611cda85828601611a7c565b90969095509350505050565b600060208284031215611cf857600080fd5b8135610f7d8161192c565b6020808252602d908201527f726563697069656e74206d757374206265206d73672e73656e646572206f722060408201526c1d1a1a5cc818dbdb9d1c9858dd609a1b606082015260800190565b600060408284031215611d6257600080fd5b604051604081018181106001600160401b0382111715611d8457611d8461189c565b6040528235611d928161192c565b8152602083013561ffff81168114611da957600080fd5b60208201529392505050565b6000815160808452611dca6080850182611b2f565b6020848101516001600160a01b0316908601526040808501519086015260609384015193909401929092525090919050565b602081526000610f7d6020830184611db5565b600060208284031215611e2157600080fd5b5051919050565b60e08101610830828480516001600160a01b03908116835260208083015182169084015260408083015162ffffff16908401526060808301518216908401526080808301519084015260a0828101519084015260c09182015116910152565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112611eb457600080fd5b8301803591506001600160401b03821115611ece57600080fd5b6020019150368190038213156111bf57600080fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611f0b57611f0b611ee3565b5060010190565b8181038181111561083057610830611ee3565b600060208284031215611f3757600080fd5b81518015158114610f7d57600080fd5b8082018082111561083057610830611ee3565b808202811582820484141761083057610830611ee3565b600082611f8e57634e487b7160e01b600052601260045260246000fd5b500490565b60008251611fa5818460208701611b0b565b9190910192915050565b602081526000610f7d6020830184611b2f56fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212203925f97cd63c2e61736a2a442ff1d4bf966f453350e9df354a849229f69092cf64736f6c63430008130033";
25830
+ const _bytecode$1$1 = "0x60806040523480156200001157600080fd5b506040516200278438038062002784833981016040819052620000349162000136565b6001805460ff191690556200004b60008362000078565b600180546001600160a01b0390921661010002610100600160a81b0319909216919091179055506200016e565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1662000115576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620000d43390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b80516001600160a01b03811681146200013157600080fd5b919050565b600080604083850312156200014a57600080fd5b620001558362000119565b9150620001656020840162000119565b90509250929050565b612606806200017e6000396000f3fe60806040526004361061013f5760003560e01c80635ae401dc116100b657806393751f631161006f57806393751f631461038c578063a217fddf146103b5578063ac9650d8146103ca578063d547741f146103ea578063d9a6f7051461040a578063e65fad971461042057600080fd5b80635ae401dc146102ae5780635c975abb146102ce578063735de9f7146102e65780638456cb59146103235780638f3914661461033857806391d148541461036c57600080fd5b80632f2ff15d116101085780632f2ff15d1461022057806336568abe14610240578063383ebb0b146102605780633f4ba83a146102735780635640f6591461028857806358e81a501461029b57600080fd5b80620fa9fb1461014457806301ffc9a714610166578063116944b21461019b57806316ba7197146101bc578063248a9ca3146101f0575b600080fd5b34801561015057600080fd5b5061016461015f366004611db4565b610454565b005b34801561017257600080fd5b50610186610181366004611ded565b61050d565b60405190151581526020015b60405180910390f35b6101ae6101a9366004611f85565b610544565b604051908152602001610192565b3480156101c857600080fd5b506101ae7f7a8dc26796a1e50e6e190b70259f58f6a4edd5b22280ceecc82b687b8e98286981565b3480156101fc57600080fd5b506101ae61020b366004611fda565b60009081526020819052604090206001015490565b34801561022c57600080fd5b5061016461023b366004611ff3565b610634565b34801561024c57600080fd5b5061016461025b366004611ff3565b610659565b6101ae61026e3660046120db565b6106dc565b34801561027f57600080fd5b5061016461084c565b6101ae6102963660046120db565b610889565b6101ae6102a9366004611f85565b61097f565b6102c16102bc366004612187565b610ad0565b6040516101929190612222565b3480156102da57600080fd5b5060015460ff16610186565b3480156102f257600080fd5b5060015461030b9061010090046001600160a01b031681565b6040516001600160a01b039091168152602001610192565b34801561032f57600080fd5b50610164610b1e565b34801561034457600080fd5b506101ae7fe7276a2a84d8de556657ec9cf93a55a7d66f096e529d0582ed08e9e2208b92b581565b34801561037857600080fd5b50610186610387366004611ff3565b610b59565b34801561039857600080fd5b506103a26103e881565b60405161ffff9091168152602001610192565b3480156103c157600080fd5b506101ae600081565b3480156103d657600080fd5b506102c16103e5366004612284565b610b82565b3480156103f657600080fd5b50610164610405366004611ff3565b610c76565b34801561041657600080fd5b506101ae61271081565b34801561042c57600080fd5b506101ae7ffcb9fcbfa83b897fb2d5cf4b58962164105c1e71489a37ef3ae0db3fdce576f681565b61047e7f7a8dc26796a1e50e6e190b70259f58f6a4edd5b22280ceecc82b687b8e98286933610b59565b61048757600080fd5b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156104ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f291906122c5565b90506105086001600160a01b0383168483610c9b565b505050565b60006001600160e01b03198216637965db0b60e01b148061053e57506301ffc9a760e01b6001600160e01b03198316145b92915050565b60006105b08260000151836080015184606001518787808060200260200160405190810160405280939291908181526020016000905b828210156105a657610597604083028601368190038101906122de565b8152602001906001019061057a565b5050505050610cfe565b60808301526001546040516304e45aaf60e01b81526101009091046001600160a01b0316906304e45aaf906105e9908590600401612335565b6020604051808303816000875af1158015610608573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061062c91906122c5565b949350505050565b60008281526020819052604090206001015461064f81610dbf565b6105088383610dcc565b6001600160a01b03811633146106ce5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6106d88282610e50565b5050565b6000806106ec8360000151610eb5565b905060008061075783866060015187602001518a8a808060200260200160405190810160405280939291908181526020016000905b8282101561074d5761073e604083028601368190038101906122de565b81526020019060010190610721565b5050505050610ee3565b606087018190526001546040516304dc09a360e11b81529294509092506000916101009091046001600160a01b0316906309b813469061079b9089906004016123db565b6020604051808303816000875af11580156107ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107de91906122c5565b905061083e8482858b8b808060200260200160405190810160405280939291908181526020016000905b8282101561083457610825604083028601368190038101906122de565b81526020019060010190610808565b5050505050610f96565b9450505050505b9392505050565b6108767fe7276a2a84d8de556657ec9cf93a55a7d66f096e529d0582ed08e9e2208b92b533610b59565b61087f57600080fd5b610887610ff7565b565b6000806108998360000151611049565b90506108f781846040015185602001518888808060200260200160405190810160405280939291908181526020016000905b828210156105a6576108e8604083028601368190038101906122de565b815260200190600101906108cb565b604084810191909152600154905163b858183f60e01b81526101009091046001600160a01b03169063b858183f906109339086906004016123db565b6020604051808303816000875af1158015610952573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097691906122c5565b95945050505050565b60008060006109e484600001518560a0015186606001518989808060200260200160405190810160405280939291908181526020016000905b8282101561074d576109d5604083028601368190038101906122de565b815260200190600101906109b8565b60a08601819052600154604051635023b4df60e01b81529294509092506000916101009091046001600160a01b031690635023b4df90610a28908890600401612335565b6020604051808303816000875af1158015610a47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a6b91906122c5565b9050610ac5856000015182858a8a808060200260200160405190810160405280939291908181526020016000905b8282101561083457610ab6604083028601368190038101906122de565b81526020019060010190610a99565b979650505050505050565b606083421115610b145760405162461bcd60e51b815260206004820152600f60248201526e111958591b1a5b99481c185cdcd959608a1b60448201526064016106c5565b61062c8383610b82565b610b487ffcb9fcbfa83b897fb2d5cf4b58962164105c1e71489a37ef3ae0db3fdce576f633610b59565b610b5157600080fd5b610887611055565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6060816001600160401b03811115610b9c57610b9c611e62565b604051908082528060200260200182016040528015610bcf57816020015b6060815260200190600190039081610bba5790505b50905060005b82811015610c6f57610c3f30858584818110610bf357610bf36123ee565b9050602002810190610c059190612404565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061109092505050565b828281518110610c5157610c516123ee565b60200260200101819052508080610c6790612460565b915050610bd5565b5092915050565b600082815260208190526040902060010154610c9181610dbf565b6105088383610e50565b6040516001600160a01b03831660248201526044810182905261050890849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526110b5565b60006001600160a01b0383163314610d585760405162461bcd60e51b815260206004820181905260248201527f73776170526563697069656e74206d757374206265206d73672e73656e64657260448201526064016106c5565b60015460ff16610d9757610d6b8261118a565b50600080610d79868561123d565b9092509050610d888287612479565b9550610d948782611366565b50505b610dac6001600160a01b03861633308761146f565b610db685856114ad565b50919392505050565b610dc981336115aa565b50565b610dd68282610b59565b6106d8576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610e0c3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610e5a8282610b59565b156106d8576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008060148351610ec69190612479565b90506000610ed684836014611603565b905061062c816000611710565b6000806001600160a01b0384163314610f3e5760405162461bcd60e51b815260206004820181905260248201527f73776170526563697069656e74206d757374206265206d73672e73656e64657260448201526064016106c5565b6000610f498461118a565b90506000610f598261271061248c565b9050610f688761271083611775565b9250610f7488846114ad565b610f896001600160a01b03891633308a61146f565b5094969095509350505050565b6000806000610fa5868561123d565b91509150610fb560015460ff1690565b610fc357610fc387826117b5565b610fed3383610fd28989612479565b610fdc9190612479565b6001600160a01b038a169190610c9b565b610ac5828761248c565b610fff6118bc565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600061053e8282611710565b61105d611905565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2583361102c565b606061084583836040518060600160405280602781526020016125aa6027913961194b565b600061110a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166119c39092919063ffffffff16565b905080516000148061112b57508080602001905181019061112b919061249f565b6105085760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016106c5565b6000805b82518110156111d4578281815181106111a9576111a96123ee565b602002602001015160200151826111c0919061248c565b9150806111cc81612460565b91505061118e565b506103e88111156112385760405162461bcd60e51b815260206004820152602860248201527f5365636f6e6461727920666565203e204645455f42415349535f504f494e54536044820152675f4d4158494d554d60c01b60648201526084016106c5565b919050565b6000606082516001600160401b0381111561125a5761125a611e62565b60405190808252806020026020018201604052801561129f57816020015b60408051808201909152600080825260208201528152602001906001900390816112785790505b50905060005b835181101561135e5760006112e48583815181106112c5576112c56123ee565b602002602001015160200151612710886119d29092919063ffffffff16565b90506040518060400160405280868481518110611303576113036123ee565b6020026020010151600001516001600160a01b0316815260200182815250838381518110611333576113336123ee565b6020908102919091010152611348818561248c565b935050808061135690612460565b9150506112a5565b509250929050565b60005b8151811015610508576113cc33838381518110611388576113886123ee565b6020026020010151600001518484815181106113a6576113a66123ee565b602002602001015160200151866001600160a01b031661146f909392919063ffffffff16565b8181815181106113de576113de6123ee565b6020026020010151600001516001600160a01b0316336001600160a01b0316846001600160a01b03167f1f9a9fdac86b6ca3c5300bec0b61555cded1f1a234378602dcca6c27085eac8e85858151811061143a5761143a6123ee565b60200260200101516020015160405161145591815260200190565b60405180910390a48061146781612460565b915050611369565b6040516001600160a01b03808516602483015283166044820152606481018290526114a79085906323b872dd60e01b90608401610cc7565b50505050565b600154604051636eb1769f60e11b81523060048201526001600160a01b0361010090920482166024820152829184169063dd62ed3e90604401602060405180830381865afa158015611503573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061152791906122c5565b10156106d85760015460405163095ea7b360e01b81526101009091046001600160a01b039081166004830152600019602483015283169063095ea7b3906044016020604051808303816000875af1158015611586573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610508919061249f565b6115b48282610b59565b6106d8576115c181611a74565b6115cc836020611a86565b6040516020016115dd9291906124c1565b60408051601f198184030181529082905262461bcd60e51b82526106c591600401612536565b60608161161181601f61248c565b10156116505760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b60448201526064016106c5565b61165a828461248c565b8451101561169e5760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b60448201526064016106c5565b6060821580156116bd5760405191506000825260208201604052611707565b6040519150601f8416801560200281840101858101878315602002848b0101015b818310156116f65780518352602092830192016116de565b5050858452601f01601f1916604052505b50949350505050565b600061171d82601461248c565b835110156117655760405162461bcd60e51b8152602060048201526015602482015274746f416464726573735f6f75744f66426f756e647360581b60448201526064016106c5565b500160200151600160601b900490565b60006117828484846119d2565b90506000828061179457611794612549565b84860911156108455760001981106117ab57600080fd5b6001019392505050565b60005b8151811015610508576118198282815181106117d6576117d66123ee565b6020026020010151600001518383815181106117f4576117f46123ee565b602002602001015160200151856001600160a01b0316610c9b9092919063ffffffff16565b81818151811061182b5761182b6123ee565b6020026020010151600001516001600160a01b0316336001600160a01b0316846001600160a01b03167f1f9a9fdac86b6ca3c5300bec0b61555cded1f1a234378602dcca6c27085eac8e858581518110611887576118876123ee565b6020026020010151602001516040516118a291815260200190565b60405180910390a4806118b481612460565b9150506117b8565b60015460ff166108875760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016106c5565b60015460ff16156108875760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016106c5565b6060600080856001600160a01b031685604051611968919061255f565b600060405180830381855af49150503d80600081146119a3576040519150601f19603f3d011682016040523d82523d6000602084013e6119a8565b606091505b50915091506119b986838387611c21565b9695505050505050565b606061062c8484600085611c9a565b600083830281600019858709828110838203039150508084116119f457600080fd5b80600003611a0757508290049050610845565b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b606061053e6001600160a01b03831660145b60606000611a9583600261257b565b611aa090600261248c565b6001600160401b03811115611ab757611ab7611e62565b6040519080825280601f01601f191660200182016040528015611ae1576020820181803683370190505b509050600360fc1b81600081518110611afc57611afc6123ee565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611b2b57611b2b6123ee565b60200101906001600160f81b031916908160001a9053506000611b4f84600261257b565b611b5a90600161248c565b90505b6001811115611bd2576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611b8e57611b8e6123ee565b1a60f81b828281518110611ba457611ba46123ee565b60200101906001600160f81b031916908160001a90535060049490941c93611bcb81612592565b9050611b5d565b5083156108455760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016106c5565b60608315611c90578251600003611c89576001600160a01b0385163b611c895760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106c5565b508161062c565b61062c8383611d6a565b606082471015611cfb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016106c5565b600080866001600160a01b03168587604051611d17919061255f565b60006040518083038185875af1925050503d8060008114611d54576040519150601f19603f3d011682016040523d82523d6000602084013e611d59565b606091505b5091509150610ac587838387611c21565b815115611d7a5781518083602001fd5b8060405162461bcd60e51b81526004016106c59190612536565b6001600160a01b0381168114610dc957600080fd5b803561123881611d94565b60008060408385031215611dc757600080fd5b8235611dd281611d94565b91506020830135611de281611d94565b809150509250929050565b600060208284031215611dff57600080fd5b81356001600160e01b03198116811461084557600080fd5b60008083601f840112611e2957600080fd5b5081356001600160401b03811115611e4057600080fd5b6020830191508360208260061b8501011115611e5b57600080fd5b9250929050565b634e487b7160e01b600052604160045260246000fd5b60405160e081016001600160401b0381118282101715611e9a57611e9a611e62565b60405290565b604051608081016001600160401b0381118282101715611e9a57611e9a611e62565b604051601f8201601f191681016001600160401b0381118282101715611eea57611eea611e62565b604052919050565b600060e08284031215611f0457600080fd5b611f0c611e78565b90508135611f1981611d94565b81526020820135611f2981611d94565b6020820152604082013562ffffff81168114611f4457600080fd5b6040820152611f5560608301611da9565b60608201526080820135608082015260a082013560a0820152611f7a60c08301611da9565b60c082015292915050565b60008060006101008486031215611f9b57600080fd5b83356001600160401b03811115611fb157600080fd5b611fbd86828701611e17565b9094509250611fd190508560208601611ef2565b90509250925092565b600060208284031215611fec57600080fd5b5035919050565b6000806040838503121561200657600080fd5b823591506020830135611de281611d94565b60006080828403121561202a57600080fd5b612032611ea0565b905081356001600160401b038082111561204b57600080fd5b818401915084601f83011261205f57600080fd5b813560208282111561207357612073611e62565b612085601f8301601f19168201611ec2565b9250818352868183860101111561209b57600080fd5b818185018285013760008183850101528285526120b9818701611da9565b8186015250505050604082013560408201526060820135606082015292915050565b6000806000604084860312156120f057600080fd5b83356001600160401b038082111561210757600080fd5b61211387838801611e17565b9095509350602086013591508082111561212c57600080fd5b5061213986828701612018565b9150509250925092565b60008083601f84011261215557600080fd5b5081356001600160401b0381111561216c57600080fd5b6020830191508360208260051b8501011115611e5b57600080fd5b60008060006040848603121561219c57600080fd5b8335925060208401356001600160401b038111156121b957600080fd5b6121c586828701612143565b9497909650939450505050565b60005b838110156121ed5781810151838201526020016121d5565b50506000910152565b6000815180845261220e8160208601602086016121d2565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b8281101561227757603f198886030184526122658583516121f6565b94509285019290850190600101612249565b5092979650505050505050565b6000806020838503121561229757600080fd5b82356001600160401b038111156122ad57600080fd5b6122b985828601612143565b90969095509350505050565b6000602082840312156122d757600080fd5b5051919050565b6000604082840312156122f057600080fd5b604051604081018181106001600160401b038211171561231257612312611e62565b604052823561232081611d94565b81526020928301359281019290925250919050565b60e0810161053e828480516001600160a01b03908116835260208083015182169084015260408083015162ffffff16908401526060808301518216908401526080808301519084015260a0828101519084015260c09182015116910152565b60008151608084526123a960808501826121f6565b6020848101516001600160a01b0316908601526040808501519086015260609384015193909401929092525090919050565b6020815260006108456020830184612394565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261241b57600080fd5b8301803591506001600160401b0382111561243557600080fd5b602001915036819003821315611e5b57600080fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016124725761247261244a565b5060010190565b8181038181111561053e5761053e61244a565b8082018082111561053e5761053e61244a565b6000602082840312156124b157600080fd5b8151801515811461084557600080fd5b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516124f98160178501602088016121d2565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161252a8160288401602088016121d2565b01602801949350505050565b60208152600061084560208301846121f6565b634e487b7160e01b600052601260045260246000fd5b600082516125718184602087016121d2565b9190910192915050565b808202811582820484141761053e5761053e61244a565b6000816125a1576125a161244a565b50600019019056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220c75a7db1b170ff1ce6888f2940825a25db3ebb624d8b84bd3f2372ebae2de1d464736f6c63430008130033";
25634
25831
  const isSuperArgs$1$1 = (xs) => xs.length > 1;
25635
25832
  class SecondaryFee__factory extends ContractFactory {
25636
25833
  constructor(...args) {
@@ -25641,11 +25838,11 @@ class SecondaryFee__factory extends ContractFactory {
25641
25838
  super(_abi$1$1, _bytecode$1$1, args[0]);
25642
25839
  }
25643
25840
  }
25644
- deploy(_uniRouter, overrides) {
25645
- return super.deploy(_uniRouter, overrides || {});
25841
+ deploy(_admin, _uniRouter, overrides) {
25842
+ return super.deploy(_admin, _uniRouter, overrides || {});
25646
25843
  }
25647
- getDeployTransaction(_uniRouter, overrides) {
25648
- return super.getDeployTransaction(_uniRouter, overrides || {});
25844
+ getDeployTransaction(_admin, _uniRouter, overrides) {
25845
+ return super.getDeployTransaction(_admin, _uniRouter, overrides || {});
25649
25846
  }
25650
25847
  attach(address) {
25651
25848
  return super.attach(address);
@@ -26731,10 +26928,87 @@ const getCallData = (methodName, contractInterface) => {
26731
26928
  return fragment ? contractInterface?.encodeFunctionData(fragment) : undefined;
26732
26929
  };
26733
26930
 
26931
+ const quoteReturnMapping = {
26932
+ // eslint-disable-next-line @typescript-eslint/naming-convention
26933
+ '0xcdca1753': ['uint256', 'uint160[]', 'uint32[]', 'uint256'],
26934
+ // eslint-disable-next-line @typescript-eslint/naming-convention
26935
+ '0xc6a5026a': ['uint256', 'uint160', 'uint32', 'uint256'],
26936
+ // eslint-disable-next-line @typescript-eslint/naming-convention
26937
+ '0x2f80bb1d': ['uint256', 'uint160[]', 'uint32[]', 'uint256'],
26938
+ // eslint-disable-next-line @typescript-eslint/naming-convention
26939
+ '0xbd21704a': ['uint256', 'uint160', 'uint32', 'uint256'],
26940
+ };
26941
+ /**
26942
+ * Returns true if poolA is equivalent to poolB
26943
+ * @param poolA one of the two pools
26944
+ * @param poolB the other pool
26945
+ */
26946
+ function poolEquals(poolA, poolB) {
26947
+ return (poolA === poolB
26948
+ || (poolA.token0.equals(poolB.token0)
26949
+ && poolA.token1.equals(poolB.token1)
26950
+ && poolA.fee === poolB.fee));
26951
+ }
26952
+ async function getERC20Decimals(tokenAddress, provider) {
26953
+ const decimalsFunctionSig = ethers.utils.id('decimals()').substring(0, 10);
26954
+ try {
26955
+ const decimalsResult = await provider.call({
26956
+ to: tokenAddress,
26957
+ data: decimalsFunctionSig,
26958
+ });
26959
+ return parseInt(decimalsResult, 16);
26960
+ }
26961
+ catch (e) {
26962
+ const message = e instanceof Error ? e.message : 'Unknown Error';
26963
+ throw new ProviderCallError(`failed to get ERC20 decimals: ${message}`);
26964
+ }
26965
+ }
26966
+ /**
26967
+ * Based on https://github.com/ethers-io/ethers.js/blob/main/src.ts/address/checks.ts#L51
26968
+ */
26969
+ function isValidNonZeroAddress(address) {
26970
+ if (address === ethers.constants.AddressZero) {
26971
+ return false;
26972
+ }
26973
+ try {
26974
+ ethers.utils.getAddress(address);
26975
+ return true;
26976
+ }
26977
+ catch (error) {
26978
+ return false;
26979
+ }
26980
+ }
26981
+ const tokenInfoToUniswapToken = (tokenInfo) => new Token(tokenInfo.chainId, tokenInfo.address, tokenInfo.decimals, tokenInfo.symbol, tokenInfo.name);
26982
+ const uniswapTokenToTokenInfo = (token) => ({
26983
+ chainId: token.chainId,
26984
+ address: token.address,
26985
+ decimals: token.decimals,
26986
+ symbol: token.symbol,
26987
+ name: token.name,
26988
+ });
26989
+ const toCurrencyAmount = (amount) => {
26990
+ const token = tokenInfoToUniswapToken(amount.token);
26991
+ return CurrencyAmount.fromRawAmount(token, amount.value.toString());
26992
+ };
26993
+ const newAmount = (amount, token) => ({
26994
+ value: amount,
26995
+ token,
26996
+ });
26997
+ const addAmount = (a, b) => {
26998
+ if (a.token.address !== b.token.address)
26999
+ throw new Error('Token mismatch');
27000
+ return { value: a.value.add(b.value), token: a.token };
27001
+ };
27002
+ const subtractAmount = (a, b) => {
27003
+ if (a.token.address !== b.token.address)
27004
+ throw new Error('Token mismatch');
27005
+ return { value: a.value.sub(b.value), token: a.token };
27006
+ };
27007
+
26734
27008
  const amountIndex = 0;
26735
27009
  const gasEstimateIndex = 3;
26736
27010
  async function getQuotesForRoutes(multicallContract, quoterContractAddress, routes, amountSpecified, tradeType) {
26737
- const callData = routes.map((route) => SwapQuoter.quoteCallParameters(route, amountSpecified, tradeType, {
27011
+ const callData = routes.map((route) => SwapQuoter.quoteCallParameters(route, toCurrencyAmount(amountSpecified), tradeType, {
26738
27012
  useQuoterV2: true,
26739
27013
  }).calldata);
26740
27014
  let quoteResults;
@@ -26760,27 +27034,26 @@ async function getQuotesForRoutes(multicallContract, quoterContractAddress, rout
26760
27034
  // eslint-disable-next-line no-continue
26761
27035
  continue;
26762
27036
  }
26763
- let decodedQuoteResult;
26764
27037
  try {
26765
- decodedQuoteResult = ethers.utils.defaultAbiCoder.decode(returnTypes, quoteResults.returnData[i].returnData);
27038
+ const decodedQuoteResult = ethers.utils.defaultAbiCoder.decode(returnTypes, quoteResults.returnData[i].returnData);
27039
+ if (decodedQuoteResult) {
27040
+ // The 0th element in each decoded data is going to be the amountOut or amountIn.
27041
+ const quoteAmount = decodedQuoteResult[amountIndex];
27042
+ if (!(quoteAmount instanceof BigNumber$1))
27043
+ throw new Error('Expected BigNumber');
27044
+ decodedQuoteResults.push({
27045
+ route: routes[i],
27046
+ amountIn: tradeType === TradeType.EXACT_INPUT ? amountSpecified : newAmount(quoteAmount, routes[i].input),
27047
+ amountOut: tradeType === TradeType.EXACT_INPUT ? newAmount(quoteAmount, routes[i].output) : amountSpecified,
27048
+ gasEstimate: ethers.BigNumber.from(decodedQuoteResult[gasEstimateIndex]),
27049
+ });
27050
+ }
26766
27051
  }
26767
27052
  catch {
26768
27053
  // Failed to get the quote for this particular route
26769
27054
  // Other quotes for routes may still succeed, so do nothing
26770
27055
  // and continue processing
26771
27056
  }
26772
- // TODO: ideally this is already a big number as we don't need a CurrencyAmount at this level
26773
- const amountSpecifiedBigNumber = toBigNumber(amountSpecified);
26774
- if (decodedQuoteResult) {
26775
- // The 0th element in each decoded data is going to be the amountOut or amountIn.
26776
- const quoteAmount = decodedQuoteResult[amountIndex];
26777
- decodedQuoteResults.push({
26778
- route: routes[i],
26779
- amountIn: tradeType === TradeType.EXACT_INPUT ? amountSpecifiedBigNumber : quoteAmount,
26780
- amountOut: tradeType === TradeType.EXACT_INPUT ? quoteAmount : amountSpecifiedBigNumber,
26781
- gasEstimate: ethers.BigNumber.from(decodedQuoteResult[gasEstimateIndex]),
26782
- });
26783
- }
26784
27057
  }
26785
27058
  return decodedQuoteResults;
26786
27059
  }
@@ -26916,10 +27189,10 @@ class Router {
26916
27189
  this.routingTokens = routingTokens;
26917
27190
  this.routingContracts = routingContracts;
26918
27191
  }
26919
- async findOptimalRoute(amountSpecified, otherCurrency, tradeType, maxHops = 2) {
26920
- const [currencyIn, currencyOut] = this.determineERC20InAndERC20Out(tradeType, amountSpecified, otherCurrency);
27192
+ async findOptimalRoute(amountSpecified, otherToken, tradeType, maxHops = 2) {
27193
+ const [tokenIn, tokenOut] = this.determineERC20InAndERC20Out(tradeType, amountSpecified, otherToken);
26921
27194
  const multicallContract = Multicall__factory.connect(this.routingContracts.multicallAddress, this.provider);
26922
- const erc20Pair = [currencyIn.wrapped, currencyOut.wrapped];
27195
+ const erc20Pair = [tokenIn, tokenOut];
26923
27196
  // Get all pools and use these to get all possible routes.
26924
27197
  const pools = await fetchValidPools(multicallContract, erc20Pair, this.routingTokens, this.routingContracts.factoryAddress);
26925
27198
  const noValidPools = pools.length === 0;
@@ -26929,7 +27202,7 @@ class Router {
26929
27202
  // Get all the possible routes from the given pools
26930
27203
  // TODO: Fix used before defined error
26931
27204
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
26932
- const routes = generateAllAcyclicPaths(currencyIn, currencyOut, pools, maxHops, [], [], currencyIn);
27205
+ const routes = generateAllAcyclicPaths(tokenIn, tokenOut, pools, maxHops, [], [], tokenIn);
26933
27206
  const noValidRoute = routes.length === 0;
26934
27207
  if (noValidRoute) {
26935
27208
  throw new NoRoutesAvailableError();
@@ -26939,9 +27212,7 @@ class Router {
26939
27212
  return {
26940
27213
  route,
26941
27214
  amountIn,
26942
- tokenIn: currencyIn,
26943
27215
  amountOut,
26944
- tokenOut: currencyOut,
26945
27216
  tradeType,
26946
27217
  gasEstimate,
26947
27218
  };
@@ -26977,7 +27248,7 @@ class Router {
26977
27248
  bestQuoteForAmountIn(quotes) {
26978
27249
  let bestQuote = quotes[0];
26979
27250
  for (let i = 1; i < quotes.length; i++) {
26980
- if (quotes[i].amountOut.gt(bestQuote.amountOut)) {
27251
+ if (quotes[i].amountOut.value.gt(bestQuote.amountOut.value)) {
26981
27252
  bestQuote = quotes[i];
26982
27253
  }
26983
27254
  }
@@ -26987,48 +27258,49 @@ class Router {
26987
27258
  bestQuoteForAmountOut(quotes) {
26988
27259
  let bestQuote = quotes[0];
26989
27260
  for (let i = 1; i < quotes.length; i++) {
26990
- if (quotes[i].amountIn.lt(bestQuote.amountIn)) {
27261
+ if (quotes[i].amountIn.value.lt(bestQuote.amountIn.value)) {
26991
27262
  bestQuote = quotes[i];
26992
27263
  }
26993
27264
  }
26994
27265
  return bestQuote;
26995
27266
  }
26996
27267
  // eslint-disable-next-line class-methods-use-this
26997
- determineERC20InAndERC20Out(tradeType, amountSpecified, otherCurrency) {
27268
+ determineERC20InAndERC20Out(tradeType, amountSpecified, otherToken) {
26998
27269
  // If the trade type is EXACT INPUT then we have specified the amount for the tokenIn
26999
27270
  return tradeType === TradeType.EXACT_INPUT
27000
- ? [amountSpecified?.currency, otherCurrency]
27001
- : [otherCurrency, amountSpecified?.currency];
27271
+ ? [amountSpecified.token, otherToken]
27272
+ : [otherToken, amountSpecified.token];
27002
27273
  }
27003
27274
  }
27004
- const generateAllAcyclicPaths = (currencyIn, // the currency we start with
27005
- currencyOut, // the currency we want to end up with
27275
+ const generateAllAcyclicPaths = (tokenIn, // the currency we start with
27276
+ tokenOut, // the currency we want to end up with
27006
27277
  pools, // list of all available pools
27007
27278
  maxHops, // the maximum number of pools that can be traversed
27008
27279
  currentRoute = [], // list of pools already traversed
27009
27280
  routes = [], // list of all routes found so far
27010
- startCurrencyIn = currencyIn) => {
27011
- const tokenIn = currencyIn.wrapped;
27012
- const tokenOut = currencyOut.wrapped;
27281
+ startTokenIn = tokenIn) => {
27282
+ const currencyIn = new Token(tokenIn.chainId, tokenIn.address, tokenIn.decimals);
27283
+ const currencyOut = new Token(tokenOut.chainId, tokenOut.address, tokenOut.decimals);
27284
+ const startCurrencyIn = new Token(startTokenIn.chainId, startTokenIn.address, startTokenIn.decimals);
27013
27285
  for (const pool of pools) {
27014
27286
  // if the pool doesn't have the tokenIn or if it has already been traversed,
27015
27287
  // skip to the next pool
27016
- const poolHasTokenIn = pool.involvesToken(tokenIn);
27288
+ const poolHasTokenIn = pool.involvesToken(currencyIn);
27017
27289
  const poolHasCycle = currentRoute.find((pathPool) => poolEquals(pool, pathPool));
27018
27290
  // eslint-disable-next-line no-continue
27019
27291
  if (!poolHasTokenIn || poolHasCycle)
27020
27292
  continue;
27021
27293
  // get the output token of the pool
27022
- const outputToken = pool.token0.equals(tokenIn) ? pool.token1 : pool.token0;
27294
+ const outputToken = pool.token0.equals(currencyIn) ? pool.token1 : pool.token0;
27023
27295
  // if we have found a route to the target currency, add it to the list of routes
27024
- const routeFound = outputToken.equals(tokenOut);
27296
+ const routeFound = outputToken.equals(currencyOut);
27025
27297
  if (routeFound) {
27026
27298
  routes.push(new Route([...currentRoute, pool], startCurrencyIn, currencyOut));
27027
27299
  }
27028
27300
  else if (maxHops > 1) {
27029
27301
  // otherwise, if we haven't exceeded the maximum number of pools that can be traversed,
27030
27302
  // recursively call this function with the output token as the new starting currency
27031
- generateAllAcyclicPaths(outputToken, currencyOut, pools, maxHops - 1, [...currentRoute, pool], routes, startCurrencyIn);
27303
+ generateAllAcyclicPaths(outputToken, tokenOut, pools, maxHops - 1, [...currentRoute, pool], routes, startTokenIn);
27032
27304
  }
27033
27305
  }
27034
27306
  return routes;
@@ -27036,39 +27308,38 @@ startCurrencyIn = currencyIn) => {
27036
27308
 
27037
27309
  class Fees {
27038
27310
  secondaryFees;
27039
- token;
27040
- amount = ethers.BigNumber.from(0);
27311
+ amount;
27041
27312
  constructor(secondaryFees, token) {
27042
27313
  this.secondaryFees = secondaryFees;
27043
- this.token = token;
27314
+ this.amount = { token, value: BigNumber$1.from(0) };
27044
27315
  }
27045
27316
  addAmount(amount) {
27046
- this.amount = this.amount.add(amount);
27317
+ this.amount = addAmount(this.amount, amount);
27047
27318
  }
27048
27319
  amountWithFeesApplied() {
27049
- return this.amount.add(this.total());
27320
+ return addAmount(this.amount, this.total());
27050
27321
  }
27051
27322
  amountLessFees() {
27052
- return this.amount.sub(this.total());
27323
+ return subtractAmount(this.amount, this.total());
27053
27324
  }
27054
27325
  withAmounts() {
27055
27326
  return this.secondaryFees.map((fee) => {
27056
- const feeAmount = this.amount
27057
- .mul(fee.feeBasisPoints)
27327
+ const feeAmount = this.amount.value
27328
+ .mul(fee.basisPoints)
27058
27329
  .div(BASIS_POINT_PRECISION);
27059
27330
  return {
27060
27331
  ...fee,
27061
- amount: newAmount(feeAmount, this.token),
27332
+ amount: newAmount(feeAmount, this.amount.token),
27062
27333
  };
27063
27334
  });
27064
27335
  }
27065
27336
  total() {
27066
- let totalFees = ethers.BigNumber.from(0);
27067
- for (let i = 0; i < this.secondaryFees.length; i++) {
27068
- const feeAmount = this.amount
27069
- .mul(this.secondaryFees[i].feeBasisPoints)
27337
+ let totalFees = newAmount(BigNumber$1.from(0), this.amount.token);
27338
+ for (const fee of this.secondaryFees) {
27339
+ const feeAmount = this.amount.value
27340
+ .mul(fee.basisPoints)
27070
27341
  .div(BASIS_POINT_PRECISION);
27071
- totalFees = totalFees.add(feeAmount);
27342
+ totalFees = addAmount(totalFees, newAmount(feeAmount, this.amount.token));
27072
27343
  }
27073
27344
  return totalFees;
27074
27345
  }
@@ -27092,11 +27363,11 @@ const zeroNativeCurrencyValue = '0x00';
27092
27363
  const multicallWithDeadlineFunctionSignature = 'multicall(uint256,bytes[])';
27093
27364
  function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountIn, amountOut, secondaryFees, secondaryFeeContract) {
27094
27365
  const secondaryFeeValues = secondaryFees.map((fee) => ({
27095
- feePrcntBasisPoints: fee.feeBasisPoints,
27096
- recipient: fee.feeRecipient,
27366
+ feeBasisPoints: fee.basisPoints,
27367
+ recipient: fee.recipient,
27097
27368
  }));
27098
27369
  if (trade.tradeType === TradeType.EXACT_INPUT) {
27099
- return secondaryFeeContract.encodeFunctionData('exactInputSingleWithServiceFee', [secondaryFeeValues, {
27370
+ return secondaryFeeContract.encodeFunctionData('exactInputSingleWithSecondaryFee', [secondaryFeeValues, {
27100
27371
  tokenIn: route.tokenPath[0].address,
27101
27372
  tokenOut: route.tokenPath[1].address,
27102
27373
  fee: route.pools[0].fee,
@@ -27106,7 +27377,7 @@ function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountI
27106
27377
  sqrtPriceLimitX96: 0,
27107
27378
  }]);
27108
27379
  }
27109
- return secondaryFeeContract.encodeFunctionData('exactOutputSingleWithServiceFee', [secondaryFeeValues, {
27380
+ return secondaryFeeContract.encodeFunctionData('exactOutputSingleWithSecondaryFee', [secondaryFeeValues, {
27110
27381
  tokenIn: route.tokenPath[0].address,
27111
27382
  tokenOut: route.tokenPath[1].address,
27112
27383
  fee: route.pools[0].fee,
@@ -27119,18 +27390,18 @@ function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountI
27119
27390
  function buildSwapParametersForMultiPoolSwap(fromAddress, trade, route, amountIn, amountOut, secondaryFees, secondaryFeeContract) {
27120
27391
  const path = encodeRouteToPath(route, trade.tradeType === TradeType.EXACT_OUTPUT);
27121
27392
  const secondaryFeeValues = secondaryFees.map((fee) => ({
27122
- feePrcntBasisPoints: fee.feeBasisPoints,
27123
- recipient: fee.feeRecipient,
27393
+ feeBasisPoints: fee.basisPoints,
27394
+ recipient: fee.recipient,
27124
27395
  }));
27125
27396
  if (trade.tradeType === TradeType.EXACT_INPUT) {
27126
- return secondaryFeeContract.encodeFunctionData('exactInputWithServiceFee', [secondaryFeeValues, {
27397
+ return secondaryFeeContract.encodeFunctionData('exactInputWithSecondaryFee', [secondaryFeeValues, {
27127
27398
  path,
27128
27399
  recipient: fromAddress,
27129
27400
  amountIn,
27130
27401
  amountOutMinimum: amountOut,
27131
27402
  }]);
27132
27403
  }
27133
- return secondaryFeeContract.encodeFunctionData('exactOutputWithServiceFee', [secondaryFeeValues, {
27404
+ return secondaryFeeContract.encodeFunctionData('exactOutputWithSecondaryFee', [secondaryFeeValues, {
27134
27405
  path,
27135
27406
  recipient: fromAddress,
27136
27407
  amountInMaximum: amountIn,
@@ -27166,8 +27437,8 @@ function createSwapParameters(adjustedQuote, fromAddress, slippage, deadline, se
27166
27437
  // Create an unchecked trade to be used in generating swap parameters.
27167
27438
  const uncheckedTrade = Trade.createUncheckedTrade({
27168
27439
  route: adjustedQuote.route,
27169
- inputAmount: CurrencyAmount.fromRawAmount(adjustedQuote.tokenIn, adjustedQuote.amountIn.toString()),
27170
- outputAmount: CurrencyAmount.fromRawAmount(adjustedQuote.tokenOut, adjustedQuote.amountOut.toString()),
27440
+ inputAmount: toCurrencyAmount(adjustedQuote.amountIn),
27441
+ outputAmount: toCurrencyAmount(adjustedQuote.amountOut),
27171
27442
  tradeType: adjustedQuote.tradeType,
27172
27443
  });
27173
27444
  const slippageTolerance = slippageToFraction(slippage);
@@ -27205,8 +27476,6 @@ function prepareSwap(ourQuote, amountSpecified, fees) {
27205
27476
  return {
27206
27477
  gasEstimate: ourQuote.gasEstimate,
27207
27478
  route: ourQuote.route,
27208
- tokenIn: ourQuote.tokenIn,
27209
- tokenOut: ourQuote.tokenOut,
27210
27479
  amountIn: fees.amountWithFeesApplied(),
27211
27480
  amountOut: amountSpecified,
27212
27481
  tradeType: ourQuote.tradeType,
@@ -27215,8 +27484,6 @@ function prepareSwap(ourQuote, amountSpecified, fees) {
27215
27484
  return {
27216
27485
  gasEstimate: ourQuote.gasEstimate,
27217
27486
  route: ourQuote.route,
27218
- tokenIn: ourQuote.tokenIn,
27219
- tokenOut: ourQuote.tokenOut,
27220
27487
  amountIn: amountSpecified,
27221
27488
  amountOut: ourQuote.amountOut,
27222
27489
  tradeType: ourQuote.tradeType,
@@ -27229,7 +27496,7 @@ const CONTRACTS_FOR_CHAIN_ID = {
27229
27496
  coreFactory: '0x8AC26EfCbf5D700b37A27aA00E6934e6904e7B8e',
27230
27497
  quoterV2: '0x0Afe6F5f4DC34461A801420634239FFaD50A2e44',
27231
27498
  peripheryRouter: '0x87854A7D4b9BaC3D37f4516A1Ac7F36fB5ad539f',
27232
- secondaryFee: '0x8dBE1f0900C5e92ad87A54521902a33ba1598C51',
27499
+ secondaryFee: '0x5893A5c7bc615Dfd36D7383366d00FFFca5f7178',
27233
27500
  },
27234
27501
  };
27235
27502
  const SUPPORTED_SANDBOX_CHAINS = {
@@ -27262,13 +27529,13 @@ function validateOverrides(overrides) {
27262
27529
  function validateSecondaryFees(secondaryFees) {
27263
27530
  let totalSecondaryFeeBasisPoints = 0;
27264
27531
  for (const secondaryFee of secondaryFees) {
27265
- if (!isValidNonZeroAddress(secondaryFee.feeRecipient)) {
27266
- throw new InvalidConfigurationError(`Invalid secondary fee recipient address: ${secondaryFee.feeRecipient}`);
27532
+ if (!isValidNonZeroAddress(secondaryFee.recipient)) {
27533
+ throw new InvalidConfigurationError(`Invalid secondary fee recipient address: ${secondaryFee.recipient}`);
27267
27534
  }
27268
- if (secondaryFee.feeBasisPoints < 0 || secondaryFee.feeBasisPoints > MAX_SECONDARY_FEE_BASIS_POINTS) {
27269
- throw new InvalidConfigurationError(`Invalid secondary fee basis points: ${secondaryFee.feeBasisPoints}`);
27535
+ if (secondaryFee.basisPoints < 0 || secondaryFee.basisPoints > MAX_SECONDARY_FEE_BASIS_POINTS) {
27536
+ throw new InvalidConfigurationError(`Invalid secondary fee basis points: ${secondaryFee.basisPoints}`);
27270
27537
  }
27271
- totalSecondaryFeeBasisPoints += secondaryFee.feeBasisPoints;
27538
+ totalSecondaryFeeBasisPoints += secondaryFee.basisPoints;
27272
27539
  }
27273
27540
  if (totalSecondaryFeeBasisPoints > MAX_SECONDARY_FEE_BASIS_POINTS) {
27274
27541
  throw new InvalidConfigurationError(`Invalid total secondary fee basis points: ${totalSecondaryFeeBasisPoints}`);
@@ -27338,12 +27605,24 @@ class Exchange {
27338
27605
  assert(slippagePercent <= 50, new InvalidSlippageError('slippage percent must be less than or equal to 50'));
27339
27606
  assert(slippagePercent >= 0, new InvalidSlippageError('slippage percent must be greater than or equal to 0'));
27340
27607
  }
27608
+ async getSecondaryFees() {
27609
+ if (this.secondaryFees.length === 0) {
27610
+ return [];
27611
+ }
27612
+ const secondaryFeeContract = SecondaryFee__factory.connect(this.router.routingContracts.secondaryFeeAddress, this.provider);
27613
+ if (await secondaryFeeContract.paused()) {
27614
+ // Do not use secondary fees if the contract is paused
27615
+ return [];
27616
+ }
27617
+ return this.secondaryFees;
27618
+ }
27341
27619
  async getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, amount, slippagePercent, maxHops, deadline, tradeType) {
27342
27620
  Exchange.validate(tokenInAddress, tokenOutAddress, maxHops, slippagePercent, fromAddress);
27343
27621
  // get the decimals of the tokens that will be swapped
27344
- const [tokenInDecimals, tokenOutDecimals] = await Promise.all([
27622
+ const [tokenInDecimals, tokenOutDecimals, secondaryFees] = await Promise.all([
27345
27623
  getERC20Decimals(tokenInAddress, this.provider),
27346
27624
  getERC20Decimals(tokenOutAddress, this.provider),
27625
+ this.getSecondaryFees(),
27347
27626
  ]);
27348
27627
  const tokenIn = new Token(this.chainId, tokenInAddress, tokenInDecimals);
27349
27628
  const tokenOut = new Token(this.chainId, tokenOutAddress, tokenOutDecimals);
@@ -27351,22 +27630,24 @@ class Exchange {
27351
27630
  let amountSpecified;
27352
27631
  let otherToken;
27353
27632
  if (tradeType === TradeType.EXACT_INPUT) {
27354
- amountSpecified = CurrencyAmount.fromRawAmount(tokenIn, amount.toString());
27633
+ amountSpecified = newAmount(amount, tokenIn);
27355
27634
  otherToken = tokenOut;
27356
27635
  }
27357
27636
  else {
27358
- amountSpecified = CurrencyAmount.fromRawAmount(tokenOut, amount.toString());
27637
+ amountSpecified = newAmount(amount, tokenOut);
27359
27638
  otherToken = tokenIn;
27360
27639
  }
27361
- const fees = new Fees(this.secondaryFees, uniswapTokenToTokenInfo(tokenIn));
27640
+ const fees = new Fees(secondaryFees, uniswapTokenToTokenInfo(tokenIn));
27362
27641
  const ourQuoteReqAmount = getOurQuoteReqAmount(amountSpecified, fees, tradeType);
27363
- const ourQuote = await this.router.findOptimalRoute(ourQuoteReqAmount, otherToken, tradeType, maxHops);
27364
- // get gas details
27365
- const gasPrice = await fetchGasPrice(this.provider);
27366
- const adjustedQuote = prepareSwap(ourQuote, amount, fees);
27367
- const swap = getSwap(this.nativeToken, adjustedQuote, fromAddress, slippagePercent, deadline, this.router.routingContracts.peripheryRouterAddress, this.router.routingContracts.secondaryFeeAddress, gasPrice, this.secondaryFees);
27642
+ // get quote and gas details
27643
+ const [ourQuote, gasPrice] = await Promise.all([
27644
+ this.router.findOptimalRoute(ourQuoteReqAmount, otherToken, tradeType, maxHops),
27645
+ fetchGasPrice(this.provider),
27646
+ ]);
27647
+ const adjustedQuote = prepareSwap(ourQuote, amountSpecified, fees);
27648
+ const swap = getSwap(this.nativeToken, adjustedQuote, fromAddress, slippagePercent, deadline, this.router.routingContracts.peripheryRouterAddress, this.router.routingContracts.secondaryFeeAddress, gasPrice, secondaryFees);
27368
27649
  const userQuote = prepareUserQuote(otherToken, adjustedQuote, slippagePercent, fees);
27369
- const preparedApproval = prepareApproval(tradeType, amount, userQuote.amountWithMaxSlippage.value, this.router.routingContracts, this.secondaryFees);
27650
+ const preparedApproval = prepareApproval(tradeType, amount, userQuote.amountWithMaxSlippage.value, this.router.routingContracts, secondaryFees);
27370
27651
  // we always use the tokenIn address because we are always selling the tokenIn
27371
27652
  const approval = await getApproval(this.nativeToken, this.provider, fromAddress, tokenInAddress, preparedApproval, gasPrice);
27372
27653
  return {
@@ -27472,17 +27753,6 @@ const $762782b6c862d954$export$db5daa1b5156ccfe = [
27472
27753
  ];
27473
27754
 
27474
27755
 
27475
- var $aa144554f9ef124b$export$1fc8f52ad1810e52;
27476
- (function(ItemType) {
27477
- ItemType["NATIVE"] = "NATIVE";
27478
- ItemType["ERC20"] = "ERC20";
27479
- ItemType["ERC721"] = "ERC721";
27480
- })($aa144554f9ef124b$export$1fc8f52ad1810e52 || ($aa144554f9ef124b$export$1fc8f52ad1810e52 = {}));
27481
- var $aa144554f9ef124b$export$537fa3efd10ed435;
27482
- (function(GasTokenType) {
27483
- GasTokenType["NATIVE"] = "NATIVE";
27484
- GasTokenType["ERC20"] = "ERC20";
27485
- })($aa144554f9ef124b$export$537fa3efd10ed435 || ($aa144554f9ef124b$export$537fa3efd10ed435 = {}));
27486
27756
 
27487
27757
 
27488
27758
  /**
@@ -27566,8 +27836,8 @@ var $4f91c5f280efe242$export$a75605c67ea83a5a;
27566
27836
 
27567
27837
  var $e768639828688ca3$export$2d7a51a18d87e21d;
27568
27838
  (function(WalletProviderName) {
27569
- WalletProviderName["METAMASK"] = "metamask";
27570
27839
  WalletProviderName["PASSPORT"] = "passport";
27840
+ WalletProviderName["METAMASK"] = "metamask";
27571
27841
  })($e768639828688ca3$export$2d7a51a18d87e21d || ($e768639828688ca3$export$2d7a51a18d87e21d = {}));
27572
27842
  const $e768639828688ca3$export$44dde05038008549 = {
27573
27843
  allowMistmatchedChainId: false,
@@ -27690,6 +27960,31 @@ const $d85ad1457a3f1a83$export$3a9ebede6a150274 = new Map([
27690
27960
  ]);
27691
27961
 
27692
27962
 
27963
+ var $4b58188d47aafe8d$export$1fc8f52ad1810e52;
27964
+ (function(ItemType) {
27965
+ ItemType["NATIVE"] = "NATIVE";
27966
+ ItemType["ERC20"] = "ERC20";
27967
+ ItemType["ERC721"] = "ERC721";
27968
+ })($4b58188d47aafe8d$export$1fc8f52ad1810e52 || ($4b58188d47aafe8d$export$1fc8f52ad1810e52 = {}));
27969
+ var $4b58188d47aafe8d$export$65c64e46348ee3c1;
27970
+ (function(TransactionOrGasType) {
27971
+ TransactionOrGasType["TRANSACTION"] = "TRANSACTION";
27972
+ TransactionOrGasType["GAS"] = "GAS";
27973
+ })($4b58188d47aafe8d$export$65c64e46348ee3c1 || ($4b58188d47aafe8d$export$65c64e46348ee3c1 = {}));
27974
+ var $4b58188d47aafe8d$export$537fa3efd10ed435;
27975
+ (function(GasTokenType) {
27976
+ GasTokenType["NATIVE"] = "NATIVE";
27977
+ GasTokenType["ERC20"] = "ERC20";
27978
+ })($4b58188d47aafe8d$export$537fa3efd10ed435 || ($4b58188d47aafe8d$export$537fa3efd10ed435 = {}));
27979
+ var $4b58188d47aafe8d$export$5d3b0ad129b9b98e;
27980
+ (function(TransactionRequirementType) {
27981
+ TransactionRequirementType["GAS"] = "GAS";
27982
+ TransactionRequirementType["NATIVE"] = "NATIVE";
27983
+ TransactionRequirementType["ERC20"] = "ERC20";
27984
+ TransactionRequirementType["ERC721"] = "ERC721";
27985
+ })($4b58188d47aafe8d$export$5d3b0ad129b9b98e || ($4b58188d47aafe8d$export$5d3b0ad129b9b98e = {}));
27986
+
27987
+
27693
27988
 
27694
27989
 
27695
27990
  /**
@@ -28024,9 +28319,13 @@ async function $5c763be0b0b81038$var$getMetaMaskProvider() {
28024
28319
  if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR);
28025
28320
  return new (Web3Provider)(provider);
28026
28321
  }
28027
- async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(walletProviderName) {
28322
+ async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(walletProviderName, passport) {
28028
28323
  let provider = null;
28029
28324
  switch(walletProviderName){
28325
+ case ($e768639828688ca3$export$2d7a51a18d87e21d).PASSPORT:
28326
+ if (passport) provider = new (Web3Provider)(passport.connectEvm());
28327
+ else throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Passport not provided", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).DEFAULT_PROVIDER_ERROR);
28328
+ break;
28030
28329
  case ($e768639828688ca3$export$2d7a51a18d87e21d).METAMASK:
28031
28330
  provider = await $5c763be0b0b81038$var$getMetaMaskProvider();
28032
28331
  break;
@@ -28406,20 +28705,19 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
28406
28705
 
28407
28706
  const $c147333b1f360629$export$92589613aaa38e1f = 300000;
28408
28707
  const $c147333b1f360629$export$dea9ce0e9bb2441c = "0x474989C4D25DD41B0B9b1ECb4643B9Fe25f83B19";
28409
- const $c147333b1f360629$export$5baee63457fa7911 = (type, amount, contractAddress)=>{
28708
+ const $c147333b1f360629$export$4249179755829904 = (type, contractAddress, amount)=>{
28410
28709
  switch(type){
28411
- case ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC20:
28412
- case ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC721:
28710
+ case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20:
28413
28711
  return {
28414
28712
  type: type,
28415
28713
  amount: amount,
28416
28714
  contractAddress: contractAddress,
28417
- approvalContractAddress: $c147333b1f360629$export$dea9ce0e9bb2441c
28715
+ spenderAddress: $c147333b1f360629$export$dea9ce0e9bb2441c
28418
28716
  };
28419
- case ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE:
28717
+ case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE:
28420
28718
  default:
28421
28719
  return {
28422
- type: ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE,
28720
+ type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE,
28423
28721
  amount: amount
28424
28722
  };
28425
28723
  }
@@ -28436,19 +28734,15 @@ const $c147333b1f360629$export$7f8e2b98eca5a7f0 = async (config, provider, order
28436
28734
  });
28437
28735
  }
28438
28736
  let amount = (BigNumber$1).from("0");
28439
- let type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE;
28737
+ let type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE;
28440
28738
  let contractAddress = "";
28441
28739
  const buyArray = order.result.buy;
28442
28740
  if (buyArray.length > 0) switch(buyArray[0].item_type){
28443
28741
  case "NATIVE":
28444
- type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE;
28742
+ type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE;
28445
28743
  break;
28446
28744
  case "ERC20":
28447
- type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC20;
28448
- contractAddress = buyArray[0].contract_address;
28449
- break;
28450
- case "ERC721":
28451
- type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC721;
28745
+ type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20;
28452
28746
  contractAddress = buyArray[0].contract_address;
28453
28747
  break;
28454
28748
  default:
@@ -28457,19 +28751,19 @@ const $c147333b1f360629$export$7f8e2b98eca5a7f0 = async (config, provider, order
28457
28751
  });
28458
28752
  }
28459
28753
  buyArray.forEach((item)=>{
28460
- amount = amount.add((BigNumber$1).from(item.start_amount));
28754
+ if (item.item_type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721) amount = amount.add((BigNumber$1).from(item.start_amount));
28461
28755
  });
28462
28756
  const feeArray = order.result.fees;
28463
28757
  feeArray.forEach((item)=>{
28464
28758
  amount = amount.add((BigNumber$1).from(item.amount));
28465
28759
  });
28466
- const requirements = [
28467
- $c147333b1f360629$export$5baee63457fa7911(type, amount, contractAddress)
28760
+ const itemRequirements = [
28761
+ $c147333b1f360629$export$4249179755829904(type, contractAddress, amount)
28468
28762
  ];
28469
28763
  return {
28470
- requirements: requirements,
28471
- gas: {
28472
- type: ($aa144554f9ef124b$export$537fa3efd10ed435).NATIVE,
28764
+ itemRequirements: itemRequirements,
28765
+ gasToken: {
28766
+ type: ($4b58188d47aafe8d$export$537fa3efd10ed435).NATIVE,
28473
28767
  limit: (BigNumber$1).from($c147333b1f360629$export$92589613aaa38e1f)
28474
28768
  }
28475
28769
  };
@@ -28480,6 +28774,45 @@ const $c147333b1f360629$export$7f8e2b98eca5a7f0 = async (config, provider, order
28480
28774
 
28481
28775
 
28482
28776
 
28777
+ const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (provider, itemRequirements, transactionOrGasAmount)=>{
28778
+ // eslint-disable-next-line no-console
28779
+ console.log(provider, itemRequirements, transactionOrGasAmount);
28780
+ return {
28781
+ sufficient: true,
28782
+ transactionRequirements: [
28783
+ {
28784
+ type: ($4b58188d47aafe8d$export$5d3b0ad129b9b98e).GAS,
28785
+ sufficient: true,
28786
+ required: {
28787
+ balance: (BigNumber$1).from(0),
28788
+ formattedBalance: "0",
28789
+ token: {
28790
+ name: "IMX",
28791
+ symbol: "IMX",
28792
+ address: "0x0",
28793
+ decimals: 18
28794
+ }
28795
+ },
28796
+ current: {
28797
+ balance: (BigNumber$1).from(1),
28798
+ formattedBalance: "1",
28799
+ token: {
28800
+ name: "IMX",
28801
+ symbol: "IMX",
28802
+ address: "0x0",
28803
+ decimals: 18
28804
+ }
28805
+ }
28806
+ }
28807
+ ]
28808
+ };
28809
+ };
28810
+
28811
+
28812
+
28813
+
28814
+
28815
+
28483
28816
 
28484
28817
 
28485
28818
  async function $0e0060cb42e136d2$export$339cb2be73677b30(config, existingReadOnlyProviders) {
@@ -28518,7 +28851,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
28518
28851
  * @param {CreateProviderParams} params - The parameters for creating the provider.
28519
28852
  * @returns {Promise<CreateProviderResult>} A promise that resolves to the created provider.
28520
28853
  */ async createProvider(params) {
28521
- return await $5c763be0b0b81038$export$500fbc0cd14cdbaa(params.walletProvider);
28854
+ return await $5c763be0b0b81038$export$500fbc0cd14cdbaa(params.walletProvider, params.passport);
28522
28855
  }
28523
28856
  /**
28524
28857
  * Checks if a wallet is connected to the specified provider.
@@ -28619,12 +28952,23 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
28619
28952
  * Determines the requirements for performing a buy.
28620
28953
  * @param {BuyParams} params - The parameters for the buy.
28621
28954
  */ async buy(params) {
28955
+ if (this.config.isProduction) throw new Error("This endpoint is not currently available.");
28622
28956
  // eslint-disable-next-line no-console
28623
28957
  console.warn("This endpoint is currently under construction.");
28624
28958
  const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
28625
28959
  await $c147333b1f360629$export$7f8e2b98eca5a7f0(this.config, web3Provider, params.orderId);
28626
28960
  }
28627
28961
  /**
28962
+ * Determines the transaction requirements to complete a purchase.
28963
+ * @params {SmartCheckoutParams} params - The parameters for smart checkout.
28964
+ */ async smartCheckout(params) {
28965
+ if (this.config.isProduction) throw new Error("This endpoint is not currently available.");
28966
+ // eslint-disable-next-line no-console
28967
+ console.warn("This endpoint is currently under construction.");
28968
+ const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
28969
+ await $0e7419077c373b24$export$9e073f9ada8c81e6(web3Provider, params.itemRequirements, params.transactionOrGasAmount);
28970
+ }
28971
+ /**
28628
28972
  * Checks if the given object is a Web3 provider.
28629
28973
  * @param {Web3Provider} web3Provider - The object to check.
28630
28974
  * @returns {boolean} - True if the object is a Web3 provider, false otherwise.
@@ -28658,7 +29002,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
28658
29002
  function $parcel$export(e, n, v, s) {
28659
29003
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
28660
29004
  }
28661
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.8.0-alpha";
29005
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.11.0-alpha";
28662
29006
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
28663
29007
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
28664
29008