@nadohq/indexer-client 0.1.0-alpha.3 → 0.1.0-alpha.4

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.
Files changed (56) hide show
  1. package/dist/IndexerBaseClient.cjs +57 -56
  2. package/dist/IndexerBaseClient.cjs.map +1 -1
  3. package/dist/IndexerBaseClient.d.cts +1 -2
  4. package/dist/IndexerBaseClient.d.ts +1 -2
  5. package/dist/IndexerBaseClient.js +7 -7
  6. package/dist/IndexerBaseClient.js.map +1 -1
  7. package/dist/IndexerClient.cjs +16 -16
  8. package/dist/IndexerClient.cjs.map +1 -1
  9. package/dist/IndexerClient.d.cts +2 -3
  10. package/dist/IndexerClient.d.ts +2 -3
  11. package/dist/IndexerClient.js +2 -2
  12. package/dist/IndexerClient.js.map +1 -1
  13. package/dist/dataMappers.cjs +105 -108
  14. package/dist/dataMappers.cjs.map +1 -1
  15. package/dist/dataMappers.d.cts +1 -2
  16. package/dist/dataMappers.d.ts +1 -2
  17. package/dist/dataMappers.js +7 -10
  18. package/dist/dataMappers.js.map +1 -1
  19. package/dist/endpoints.cjs +2 -2
  20. package/dist/endpoints.cjs.map +1 -1
  21. package/dist/endpoints.d.cts +1 -1
  22. package/dist/endpoints.d.ts +1 -1
  23. package/dist/endpoints.js +2 -2
  24. package/dist/endpoints.js.map +1 -1
  25. package/dist/index.d.cts +1 -2
  26. package/dist/index.d.ts +1 -2
  27. package/dist/types/clientTypes.cjs.map +1 -1
  28. package/dist/types/clientTypes.d.cts +3 -6
  29. package/dist/types/clientTypes.d.ts +3 -6
  30. package/dist/types/index.d.cts +1 -2
  31. package/dist/types/index.d.ts +1 -2
  32. package/dist/types/paginatedEventsTypes.cjs.map +1 -1
  33. package/dist/types/paginatedEventsTypes.d.cts +1 -2
  34. package/dist/types/paginatedEventsTypes.d.ts +1 -2
  35. package/dist/types/serverModelTypes.cjs.map +1 -1
  36. package/dist/types/serverModelTypes.d.cts +2 -1
  37. package/dist/types/serverModelTypes.d.ts +2 -1
  38. package/dist/types/serverTypes.cjs.map +1 -1
  39. package/dist/types/serverTypes.d.cts +1 -1
  40. package/dist/types/serverTypes.d.ts +1 -1
  41. package/dist/utils/index.d.cts +2 -3
  42. package/dist/utils/index.d.ts +2 -3
  43. package/dist/utils/indexerBalanceValue.cjs.map +1 -1
  44. package/dist/utils/indexerBalanceValue.d.cts +2 -3
  45. package/dist/utils/indexerBalanceValue.d.ts +2 -3
  46. package/dist/utils/indexerBalanceValue.js.map +1 -1
  47. package/package.json +4 -5
  48. package/src/IndexerBaseClient.ts +13 -13
  49. package/src/IndexerClient.ts +2 -2
  50. package/src/dataMappers.ts +8 -11
  51. package/src/endpoints.ts +2 -2
  52. package/src/types/clientTypes.ts +6 -8
  53. package/src/types/paginatedEventsTypes.ts +1 -2
  54. package/src/types/serverModelTypes.ts +2 -1
  55. package/src/types/serverTypes.ts +1 -1
  56. package/src/utils/indexerBalanceValue.ts +1 -1
@@ -33,15 +33,16 @@ __export(IndexerBaseClient_exports, {
33
33
  IndexerBaseClient: () => IndexerBaseClient
34
34
  });
35
35
  module.exports = __toCommonJS(IndexerBaseClient_exports);
36
- var import_contracts = require("@nadohq/contracts");
37
- var import_utils = require("@nadohq/utils");
36
+ var import_shared = require("@nadohq/shared");
38
37
  var import_axios = __toESM(require("axios"), 1);
39
38
  var import_dataMappers = require("./dataMappers.cjs");
40
39
  var IndexerBaseClient = class {
41
40
  constructor(opts) {
42
41
  this.opts = opts;
43
42
  this.axiosInstance = import_axios.default.create({
44
- withCredentials: true
43
+ withCredentials: true,
44
+ // We have custom logic to validate response status and create an appropriate error
45
+ validateStatus: () => true
45
46
  });
46
47
  this.v2Url = opts.v2Url ? opts.v2Url : opts.url.replace("v1", "v2");
47
48
  }
@@ -53,7 +54,7 @@ var IndexerBaseClient = class {
53
54
  async listSubaccounts(params) {
54
55
  const baseResponse = await this.query("subaccounts", params);
55
56
  return baseResponse.subaccounts.map((item) => {
56
- const subaccount = (0, import_contracts.subaccountFromHex)(item.subaccount);
57
+ const subaccount = (0, import_shared.subaccountFromHex)(item.subaccount);
57
58
  return {
58
59
  hexId: item.subaccount,
59
60
  ...subaccount
@@ -68,7 +69,7 @@ var IndexerBaseClient = class {
68
69
  */
69
70
  async getMultiSubaccountSnapshots(params) {
70
71
  const subaccountHexIds = params.subaccounts.map(
71
- ({ subaccountOwner, subaccountName }) => (0, import_contracts.subaccountToHex)({
72
+ ({ subaccountOwner, subaccountName }) => (0, import_shared.subaccountToHex)({
72
73
  subaccountOwner,
73
74
  subaccountName
74
75
  })
@@ -78,14 +79,14 @@ var IndexerBaseClient = class {
78
79
  timestamps: params.timestamps,
79
80
  isolated: params.isolated
80
81
  });
81
- const snapshotsBySubaccount = (0, import_utils.mapValues)(
82
+ const snapshotsBySubaccount = (0, import_shared.mapValues)(
82
83
  baseResponse.snapshots,
83
84
  (balanceSnapshots) => {
84
85
  const snapshotByTimestamp = {};
85
86
  Object.entries(balanceSnapshots).forEach(([timestamp, events]) => {
86
87
  const balances = events.map(import_dataMappers.mapIndexerEvent);
87
88
  snapshotByTimestamp[timestamp] = {
88
- timestamp: (0, import_utils.toBigDecimal)(timestamp),
89
+ timestamp: (0, import_shared.toBigDecimal)(timestamp),
89
90
  balances
90
91
  };
91
92
  });
@@ -104,7 +105,7 @@ var IndexerBaseClient = class {
104
105
  */
105
106
  async getReferralCode(params) {
106
107
  const baseResponse = await this.query("referral_code", {
107
- subaccount: (0, import_contracts.subaccountToHex)({
108
+ subaccount: (0, import_shared.subaccountToHex)({
108
109
  subaccountOwner: params.subaccount.subaccountOwner,
109
110
  subaccountName: params.subaccount.subaccountName
110
111
  })
@@ -131,7 +132,7 @@ var IndexerBaseClient = class {
131
132
  const baseResponse = await this.query("funding_rates", {
132
133
  product_ids: params.productIds
133
134
  });
134
- return (0, import_utils.mapValues)(baseResponse, import_dataMappers.mapIndexerFundingRate);
135
+ return (0, import_shared.mapValues)(baseResponse, import_dataMappers.mapIndexerFundingRate);
135
136
  }
136
137
  /**
137
138
  * Retrieves latest mark/index price for a perp product
@@ -151,7 +152,7 @@ var IndexerBaseClient = class {
151
152
  const baseResponse = await this.query("perp_prices", {
152
153
  product_ids: params.productIds
153
154
  });
154
- return (0, import_utils.mapValues)(baseResponse, import_dataMappers.mapIndexerPerpPrices);
155
+ return (0, import_shared.mapValues)(baseResponse, import_dataMappers.mapIndexerPerpPrices);
155
156
  }
156
157
  /**
157
158
  * Retrieves latest oracle prices for provided products
@@ -163,8 +164,8 @@ var IndexerBaseClient = class {
163
164
  });
164
165
  return baseResponse.prices.map((price) => {
165
166
  return {
166
- oraclePrice: (0, import_utils.removeDecimals)(price.oracle_price_x18),
167
- updateTime: (0, import_utils.toBigDecimal)(price.update_time),
167
+ oraclePrice: (0, import_shared.removeDecimals)(price.oracle_price_x18),
168
+ updateTime: (0, import_shared.toBigDecimal)(price.update_time),
168
169
  productId: price.product_id
169
170
  };
170
171
  });
@@ -220,10 +221,10 @@ var IndexerBaseClient = class {
220
221
  async getMultiProductSnapshots(params) {
221
222
  const timestampToProductsMap = await this.query("product_snapshots", {
222
223
  product_ids: params.productIds,
223
- max_time: params.maxTimestampInclusive ?? [(0, import_utils.nowInSeconds)()]
224
+ max_time: params.maxTimestampInclusive ?? [(0, import_shared.nowInSeconds)()]
224
225
  });
225
- return (0, import_utils.mapValues)(timestampToProductsMap, (productIdToProduct) => {
226
- return (0, import_utils.mapValues)(productIdToProduct, (indexerProduct) => {
226
+ return (0, import_shared.mapValues)(timestampToProductsMap, (productIdToProduct) => {
227
+ return (0, import_shared.mapValues)(productIdToProduct, (indexerProduct) => {
227
228
  return {
228
229
  ...(0, import_dataMappers.mapIndexerServerProduct)(indexerProduct.product),
229
230
  submissionIndex: indexerProduct.submission_idx
@@ -251,7 +252,7 @@ var IndexerBaseClient = class {
251
252
  };
252
253
  })();
253
254
  const baseResponse = await this.query("events", {
254
- subaccount: params.subaccount ? (0, import_contracts.subaccountToHex)({
255
+ subaccount: params.subaccount ? (0, import_shared.subaccountToHex)({
255
256
  subaccountOwner: params.subaccount.subaccountOwner,
256
257
  subaccountName: params.subaccount.subaccountName
257
258
  }) : void 0,
@@ -278,7 +279,7 @@ var IndexerBaseClient = class {
278
279
  */
279
280
  async getOrders(params) {
280
281
  const baseResponse = await this.query("orders", {
281
- subaccount: params.subaccount ? (0, import_contracts.subaccountToHex)({
282
+ subaccount: params.subaccount ? (0, import_shared.subaccountToHex)({
282
283
  subaccountOwner: params.subaccount.subaccountOwner,
283
284
  subaccountName: params.subaccount.subaccountName
284
285
  }) : void 0,
@@ -299,7 +300,7 @@ var IndexerBaseClient = class {
299
300
  */
300
301
  async getMatchEvents(params) {
301
302
  const baseResponse = await this.query("matches", {
302
- subaccount: params.subaccount ? (0, import_contracts.subaccountToHex)({
303
+ subaccount: params.subaccount ? (0, import_shared.subaccountToHex)({
303
304
  subaccountOwner: params.subaccount.subaccountOwner,
304
305
  subaccountName: params.subaccount.subaccountName
305
306
  }) : void 0,
@@ -321,25 +322,25 @@ var IndexerBaseClient = class {
321
322
  return {
322
323
  productId: postBalances.base.productId,
323
324
  isolated: matchEvent.isolated,
324
- totalFee: (0, import_utils.toBigDecimal)(matchEvent.fee),
325
- sequencerFee: (0, import_utils.toBigDecimal)(matchEvent.sequencer_fee),
326
- baseFilled: (0, import_utils.toBigDecimal)(matchEvent.base_filled),
327
- quoteFilled: (0, import_utils.toBigDecimal)(matchEvent.quote_filled),
328
- cumulativeFee: (0, import_utils.toBigDecimal)(matchEvent.cumulative_fee),
329
- cumulativeBaseFilled: (0, import_utils.toBigDecimal)(matchEvent.cumulative_base_filled),
330
- cumulativeQuoteFilled: (0, import_utils.toBigDecimal)(matchEvent.cumulative_quote_filled),
325
+ totalFee: (0, import_shared.toBigDecimal)(matchEvent.fee),
326
+ sequencerFee: (0, import_shared.toBigDecimal)(matchEvent.sequencer_fee),
327
+ baseFilled: (0, import_shared.toBigDecimal)(matchEvent.base_filled),
328
+ quoteFilled: (0, import_shared.toBigDecimal)(matchEvent.quote_filled),
329
+ cumulativeFee: (0, import_shared.toBigDecimal)(matchEvent.cumulative_fee),
330
+ cumulativeBaseFilled: (0, import_shared.toBigDecimal)(matchEvent.cumulative_base_filled),
331
+ cumulativeQuoteFilled: (0, import_shared.toBigDecimal)(matchEvent.cumulative_quote_filled),
331
332
  digest: matchEvent.digest,
332
333
  order: matchEvent.order,
333
334
  submissionIndex: matchEvent.submission_idx,
334
- timestamp: (0, import_utils.toBigDecimal)(timestamp),
335
+ timestamp: (0, import_shared.toBigDecimal)(timestamp),
335
336
  preEventTrackedVars: {
336
- netEntryUnrealized: (0, import_utils.toBigDecimal)(matchEvent.net_entry_unrealized),
337
- netEntryCumulative: (0, import_utils.toBigDecimal)(matchEvent.net_entry_cumulative)
337
+ netEntryUnrealized: (0, import_shared.toBigDecimal)(matchEvent.net_entry_unrealized),
338
+ netEntryCumulative: (0, import_shared.toBigDecimal)(matchEvent.net_entry_cumulative)
338
339
  },
339
340
  preBalances: (0, import_dataMappers.mapIndexerMatchEventBalances)(matchEvent.pre_balance),
340
341
  postBalances,
341
342
  tx,
342
- ...(0, import_contracts.subaccountFromHex)(matchEvent.order.sender)
343
+ ...(0, import_shared.subaccountFromHex)(matchEvent.order.sender)
343
344
  };
344
345
  });
345
346
  }
@@ -353,7 +354,7 @@ var IndexerBaseClient = class {
353
354
  */
354
355
  async getInterestFundingPayments(params) {
355
356
  const baseResponse = await this.query("interest_and_funding", {
356
- subaccount: (0, import_contracts.subaccountToHex)({
357
+ subaccount: (0, import_shared.subaccountToHex)({
357
358
  subaccountOwner: params.subaccount.subaccountOwner,
358
359
  subaccountName: params.subaccount.subaccountName
359
360
  }),
@@ -378,7 +379,7 @@ var IndexerBaseClient = class {
378
379
  async getQuotePrice() {
379
380
  const baseResponse = await this.query("usdc_price", {});
380
381
  return {
381
- price: (0, import_utils.removeDecimals)(baseResponse.price_x18)
382
+ price: (0, import_shared.removeDecimals)(baseResponse.price_x18)
382
383
  };
383
384
  }
384
385
  /**
@@ -386,13 +387,13 @@ var IndexerBaseClient = class {
386
387
  */
387
388
  async getLinkedSignerWithRateLimit(params) {
388
389
  const baseResponse = await this.query("linked_signer_rate_limit", {
389
- subaccount: (0, import_contracts.subaccountToHex)(params.subaccount)
390
+ subaccount: (0, import_shared.subaccountToHex)(params.subaccount)
390
391
  });
391
392
  return {
392
- totalTxLimit: (0, import_utils.toBigDecimal)(baseResponse.total_tx_limit),
393
- remainingTxs: (0, import_utils.toBigDecimal)(baseResponse.remaining_tx),
393
+ totalTxLimit: (0, import_shared.toBigDecimal)(baseResponse.total_tx_limit),
394
+ remainingTxs: (0, import_shared.toBigDecimal)(baseResponse.remaining_tx),
394
395
  signer: baseResponse.signer,
395
- waitTimeUntilNextTx: (0, import_utils.toBigDecimal)(baseResponse.wait_time)
396
+ waitTimeUntilNextTx: (0, import_shared.toBigDecimal)(baseResponse.wait_time)
396
397
  };
397
398
  }
398
399
  /**
@@ -414,7 +415,7 @@ var IndexerBaseClient = class {
414
415
  const baseResponse = await this.query("edge_market_snapshots", {
415
416
  interval: (0, import_dataMappers.mapSnapshotsIntervalToServerParams)(params)
416
417
  });
417
- return (0, import_utils.mapValues)(
418
+ return (0, import_shared.mapValues)(
418
419
  baseResponse.snapshots,
419
420
  (snapshots) => snapshots.map(import_dataMappers.mapIndexerMarketSnapshot)
420
421
  );
@@ -431,7 +432,7 @@ var IndexerBaseClient = class {
431
432
  interval: params.interval
432
433
  });
433
434
  return {
434
- rewardCoefficient: (0, import_utils.toBigDecimal)(baseResponse.reward_coefficient),
435
+ rewardCoefficient: (0, import_shared.toBigDecimal)(baseResponse.reward_coefficient),
435
436
  makers: baseResponse.makers.map(import_dataMappers.mapIndexerMakerStatistics)
436
437
  };
437
438
  }
@@ -458,11 +459,11 @@ var IndexerBaseClient = class {
458
459
  */
459
460
  async getLeaderboardParticipant(params) {
460
461
  const baseResponse = await this.query("leaderboard_rank", {
461
- subaccount: (0, import_contracts.subaccountToHex)(params.subaccount),
462
+ subaccount: (0, import_shared.subaccountToHex)(params.subaccount),
462
463
  contest_ids: params.contestIds
463
464
  });
464
465
  return {
465
- participant: (0, import_utils.mapValues)(
466
+ participant: (0, import_shared.mapValues)(
466
467
  baseResponse.positions,
467
468
  (position) => (0, import_dataMappers.mapIndexerLeaderboardPosition)(position)
468
469
  )
@@ -475,11 +476,11 @@ var IndexerBaseClient = class {
475
476
  async updateLeaderboardRegistration(params) {
476
477
  const signatureParams = {
477
478
  // Default to 90 seconds from now if no recvTime is provided
478
- expiration: (0, import_utils.toIntegerString)(params.recvTime ?? (0, import_contracts.getDefaultRecvTime)()),
479
+ expiration: (0, import_shared.toIntegerString)(params.recvTime ?? (0, import_shared.getDefaultRecvTime)()),
479
480
  subaccountName: params.subaccountName,
480
481
  subaccountOwner: params.subaccountOwner
481
482
  };
482
- const tx = (0, import_contracts.getNadoEIP712Values)(
483
+ const tx = (0, import_shared.getNadoEIP712Values)(
483
484
  "leaderboard_authentication",
484
485
  signatureParams
485
486
  );
@@ -494,7 +495,7 @@ var IndexerBaseClient = class {
494
495
  signature
495
496
  };
496
497
  const baseResponse = await this.query("leaderboard_registration", {
497
- subaccount: (0, import_contracts.subaccountToHex)({
498
+ subaccount: (0, import_shared.subaccountToHex)({
498
499
  subaccountOwner: params.subaccountOwner,
499
500
  subaccountName: params.subaccountName
500
501
  }),
@@ -511,7 +512,7 @@ var IndexerBaseClient = class {
511
512
  */
512
513
  async getLeaderboardRegistration(params) {
513
514
  const baseResponse = await this.query("leaderboard_registration", {
514
- subaccount: (0, import_contracts.subaccountToHex)({
515
+ subaccount: (0, import_shared.subaccountToHex)({
515
516
  subaccountOwner: params.subaccountOwner,
516
517
  subaccountName: params.subaccountName
517
518
  }),
@@ -543,17 +544,17 @@ var IndexerBaseClient = class {
543
544
  async getFastWithdrawalSignature(params) {
544
545
  const baseResponse = await this.query("fast_withdrawal_signature", params);
545
546
  return {
546
- idx: (0, import_utils.toBigInt)(baseResponse.idx),
547
+ idx: (0, import_shared.toBigInt)(baseResponse.idx),
547
548
  tx: baseResponse.tx,
548
- txBytes: (0, import_utils.getValidatedHex)(baseResponse.tx_bytes),
549
- signatures: baseResponse.signatures.map(import_utils.getValidatedHex)
549
+ txBytes: (0, import_shared.getValidatedHex)(baseResponse.tx_bytes),
550
+ signatures: baseResponse.signatures.map(import_shared.getValidatedHex)
550
551
  };
551
552
  }
552
553
  async getNlpSnapshots(params) {
553
554
  const baseResponse = await this.query("nlp_snapshots", {
554
555
  interval: {
555
556
  count: params.limit,
556
- max_time: params.maxTimeInclusive ? (0, import_utils.toIntegerString)(params.maxTimeInclusive) : void 0,
557
+ max_time: params.maxTimeInclusive ? (0, import_shared.toIntegerString)(params.maxTimeInclusive) : void 0,
557
558
  granularity: params.granularity
558
559
  }
559
560
  });
@@ -567,7 +568,7 @@ var IndexerBaseClient = class {
567
568
  */
568
569
  async getSubaccountDDA(params) {
569
570
  const baseResponse = await this.query("direct_deposit_address", {
570
- subaccount: (0, import_contracts.subaccountToHex)({
571
+ subaccount: (0, import_shared.subaccountToHex)({
571
572
  subaccountOwner: params.subaccountOwner,
572
573
  subaccountName: params.subaccountName
573
574
  })
@@ -579,12 +580,12 @@ var IndexerBaseClient = class {
579
580
  async getSequencerBacklog() {
580
581
  const baseResponse = await this.query("backlog", {});
581
582
  return {
582
- totalTxs: (0, import_utils.toBigDecimal)(baseResponse.total_txs),
583
- totalSubmissions: (0, import_utils.toBigDecimal)(baseResponse.total_submissions),
584
- backlogSize: (0, import_utils.toBigDecimal)(baseResponse.backlog_size),
585
- updatedAt: (0, import_utils.toBigDecimal)(baseResponse.updated_at),
586
- backlogEtaInSeconds: baseResponse.backlog_eta_in_seconds ? (0, import_utils.toBigDecimal)(baseResponse.backlog_eta_in_seconds) : null,
587
- txsPerSecond: baseResponse.txs_per_second ? (0, import_utils.toBigDecimal)(baseResponse.txs_per_second) : null
583
+ totalTxs: (0, import_shared.toBigDecimal)(baseResponse.total_txs),
584
+ totalSubmissions: (0, import_shared.toBigDecimal)(baseResponse.total_submissions),
585
+ backlogSize: (0, import_shared.toBigDecimal)(baseResponse.backlog_size),
586
+ updatedAt: (0, import_shared.toBigDecimal)(baseResponse.updated_at),
587
+ backlogEtaInSeconds: baseResponse.backlog_eta_in_seconds ? (0, import_shared.toBigDecimal)(baseResponse.backlog_eta_in_seconds) : null,
588
+ txsPerSecond: baseResponse.txs_per_second ? (0, import_shared.toBigDecimal)(baseResponse.txs_per_second) : null
588
589
  };
589
590
  }
590
591
  async query(requestType, params) {
@@ -598,9 +599,9 @@ var IndexerBaseClient = class {
598
599
  async sign(requestType, verifyingContract, chainId, params) {
599
600
  const walletClient = this.opts.walletClient;
600
601
  if (!walletClient) {
601
- throw new import_utils.WalletNotProvidedError();
602
+ throw new import_shared.WalletNotProvidedError();
602
603
  }
603
- return (0, import_contracts.getSignedTransactionRequest)({
604
+ return (0, import_shared.getSignedTransactionRequest)({
604
605
  chainId,
605
606
  requestParams: params,
606
607
  requestType,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/IndexerBaseClient.ts"],"sourcesContent":["import {\n EIP712LeaderboardAuthenticationParams,\n EIP712LeaderboardAuthenticationValues,\n getDefaultRecvTime,\n getNadoEIP712Values,\n getSignedTransactionRequest,\n SignableRequestType,\n SignableRequestTypeToParams,\n SignedTx,\n subaccountFromHex,\n subaccountToHex,\n WalletClientWithAccount,\n} from '@nadohq/contracts';\nimport {\n getValidatedHex,\n mapValues,\n nowInSeconds,\n removeDecimals,\n toBigDecimal,\n toBigInt,\n toIntegerString,\n WalletNotProvidedError,\n} from '@nadohq/utils';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n mapIndexerCandlesticks,\n mapIndexerEvent,\n mapIndexerEventWithTx,\n mapIndexerFundingRate,\n mapIndexerLeaderboardContest,\n mapIndexerLeaderboardPosition,\n mapIndexerLeaderboardRegistration,\n mapIndexerMakerStatistics,\n mapIndexerMarketSnapshot,\n mapIndexerMatchEventBalances,\n mapIndexerOrder,\n mapIndexerPerpPrices,\n mapIndexerProductPayment,\n mapIndexerServerProduct,\n mapIndexerNlpSnapshot,\n mapSnapshotsIntervalToServerParams,\n} from './dataMappers';\nimport {\n GetIndexerBacklogResponse,\n GetIndexerCandlesticksParams,\n GetIndexerCandlesticksResponse,\n GetIndexerEdgeCandlesticksParams,\n GetIndexerEdgeCandlesticksResponse,\n GetIndexerEdgeMarketSnapshotResponse,\n GetIndexerEdgeMarketSnapshotsParams,\n GetIndexerEventsParams,\n GetIndexerEventsResponse,\n GetIndexerFastWithdrawalSignatureParams,\n GetIndexerFastWithdrawalSignatureResponse,\n GetIndexerFundingRateParams,\n GetIndexerFundingRateResponse,\n GetIndexerInterestFundingPaymentsParams,\n GetIndexerInterestFundingPaymentsResponse,\n GetIndexerLeaderboardContestsParams,\n GetIndexerLeaderboardContestsResponse,\n GetIndexerLeaderboardParams,\n GetIndexerLeaderboardParticipantParams,\n GetIndexerLeaderboardParticipantResponse,\n GetIndexerLeaderboardRegistrationParams,\n GetIndexerLeaderboardRegistrationResponse,\n GetIndexerLeaderboardResponse,\n GetIndexerLinkedSignerParams,\n GetIndexerLinkedSignerResponse,\n GetIndexerMakerStatisticsParams,\n GetIndexerMakerStatisticsResponse,\n GetIndexerMarketSnapshotsParams,\n GetIndexerMarketSnapshotsResponse,\n GetIndexerMatchEventsParams,\n GetIndexerMatchEventsResponse,\n GetIndexerMultiProductFundingRatesParams,\n GetIndexerMultiProductFundingRatesResponse,\n GetIndexerMultiProductPerpPricesParams,\n GetIndexerMultiProductPerpPricesResponse,\n GetIndexerMultiProductSnapshotsParams,\n GetIndexerMultiProductSnapshotsResponse,\n GetIndexerMultiSubaccountSnapshotsParams,\n GetIndexerMultiSubaccountSnapshotsResponse,\n GetIndexerOraclePricesParams,\n GetIndexerOraclePricesResponse,\n GetIndexerOrdersParams,\n GetIndexerOrdersResponse,\n GetIndexerPerpPricesParams,\n GetIndexerPerpPricesResponse,\n GetIndexerProductSnapshotsParams,\n GetIndexerProductSnapshotsResponse,\n GetIndexerQuotePriceResponse,\n GetIndexerReferralCodeParams,\n GetIndexerReferralCodeResponse,\n GetIndexerNlpSnapshotsParams,\n GetIndexerNlpSnapshotsResponse,\n IndexerEventWithTx,\n IndexerMatchEvent,\n IndexerOraclePrice,\n IndexerServerEventsParams,\n IndexerServerQueryRequestByType,\n IndexerServerQueryRequestType,\n IndexerServerQueryResponseByType,\n IndexerSnapshotBalance,\n IndexerSubaccountSnapshot,\n ListIndexerSubaccountsParams,\n ListIndexerSubaccountsResponse,\n GetIndexerSubaccountDDAParams,\n UpdateIndexerLeaderboardRegistrationParams,\n UpdateIndexerLeaderboardRegistrationResponse,\n GetIndexerSubaccountDDAResponse,\n} from './types';\n\nexport interface IndexerClientOpts {\n // Server URLs\n url: string;\n v2Url?: string;\n // Wallet Client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n}\n\ntype IndexerQueryRequestBody = Partial<IndexerServerQueryRequestByType>;\n\n/**\n * Base client for all indexer requests\n */\nexport class IndexerBaseClient {\n readonly opts: IndexerClientOpts;\n readonly v2Url: string;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: IndexerClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n });\n this.v2Url = opts.v2Url ? opts.v2Url : opts.url.replace('v1', 'v2');\n }\n\n /**\n * List all subaccounts\n *\n * @param params\n */\n async listSubaccounts(\n params: ListIndexerSubaccountsParams,\n ): Promise<ListIndexerSubaccountsResponse> {\n const baseResponse = await this.query('subaccounts', params);\n\n return baseResponse.subaccounts.map((item) => {\n const subaccount = subaccountFromHex(item.subaccount);\n return {\n hexId: item.subaccount,\n ...subaccount,\n };\n });\n }\n\n /**\n * Retrieve snapshots of multiple subaccounts at multiple points in time.\n * Each snapshot is a view of the subaccount's balances at this point in time, with tracked variables for interest, funding, etc.\n *\n * @param params\n */\n async getMultiSubaccountSnapshots(\n params: GetIndexerMultiSubaccountSnapshotsParams,\n ): Promise<GetIndexerMultiSubaccountSnapshotsResponse> {\n const subaccountHexIds = params.subaccounts.map(\n ({ subaccountOwner, subaccountName }) =>\n subaccountToHex({\n subaccountOwner,\n subaccountName,\n }),\n );\n\n const baseResponse = await this.query('account_snapshots', {\n subaccounts: subaccountHexIds,\n timestamps: params.timestamps,\n isolated: params.isolated,\n });\n\n const snapshotsBySubaccount = mapValues(\n baseResponse.snapshots,\n (balanceSnapshots) => {\n const snapshotByTimestamp: Record<string, IndexerSubaccountSnapshot> =\n {};\n\n Object.entries(balanceSnapshots).forEach(([timestamp, events]) => {\n const balances: IndexerSnapshotBalance[] =\n events.map(mapIndexerEvent);\n\n snapshotByTimestamp[timestamp] = {\n timestamp: toBigDecimal(timestamp),\n balances,\n };\n });\n\n return snapshotByTimestamp;\n },\n );\n\n return {\n subaccountHexIds,\n snapshots: snapshotsBySubaccount,\n };\n }\n\n /**\n * Retrieves referral code for an address\n *\n * @param params\n */\n async getReferralCode(\n params: GetIndexerReferralCodeParams,\n ): Promise<GetIndexerReferralCodeResponse> {\n const baseResponse = await this.query('referral_code', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n });\n\n return {\n referralCode: baseResponse.referral_code,\n };\n }\n\n /**\n * Retrieves funding rate for a product, where 1 = 100%\n * @param params\n */\n async getFundingRate(\n params: GetIndexerFundingRateParams,\n ): Promise<GetIndexerFundingRateResponse> {\n const baseResponse = await this.query('funding_rate', {\n product_id: params.productId,\n });\n\n return mapIndexerFundingRate(baseResponse);\n }\n\n /**\n * Retrieves funding rate for multiple products, where 1 = 100%\n * @param params\n */\n async getMultiProductFundingRates(\n params: GetIndexerMultiProductFundingRatesParams,\n ): Promise<GetIndexerMultiProductFundingRatesResponse> {\n const baseResponse = await this.query('funding_rates', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerFundingRate);\n }\n\n /**\n * Retrieves latest mark/index price for a perp product\n * @param params\n */\n async getPerpPrices(\n params: GetIndexerPerpPricesParams,\n ): Promise<GetIndexerPerpPricesResponse> {\n const baseResponse = await this.query('price', {\n product_id: params.productId,\n });\n\n return mapIndexerPerpPrices(baseResponse);\n }\n\n /**\n * Retrieves latest mark/index price for multiple perp products\n * @param params\n */\n async getMultiProductPerpPrices(\n params: GetIndexerMultiProductPerpPricesParams,\n ): Promise<GetIndexerMultiProductPerpPricesResponse> {\n const baseResponse = await this.query('perp_prices', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerPerpPrices);\n }\n\n /**\n * Retrieves latest oracle prices for provided products\n * @param params\n */\n async getOraclePrices(\n params: GetIndexerOraclePricesParams,\n ): Promise<GetIndexerOraclePricesResponse> {\n const baseResponse = await this.query('oracle_price', {\n product_ids: params.productIds,\n });\n\n return baseResponse.prices.map((price): IndexerOraclePrice => {\n return {\n oraclePrice: removeDecimals(price.oracle_price_x18),\n updateTime: toBigDecimal(price.update_time),\n productId: price.product_id,\n };\n });\n }\n\n /**\n * Retrieves candlesticks for a product\n * @param params\n */\n async getCandlesticks(\n params: GetIndexerCandlesticksParams,\n ): Promise<GetIndexerCandlesticksResponse> {\n const baseResponse = await this.query('candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves candlesticks for a product from Edge\n * @param params\n */\n async getEdgeCandlesticks(\n params: GetIndexerEdgeCandlesticksParams,\n ): Promise<GetIndexerEdgeCandlesticksResponse> {\n const baseResponse = await this.query('edge_candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves historical snapshots for a product\n * @param params\n */\n async getProductSnapshots(\n params: GetIndexerProductSnapshotsParams,\n ): Promise<GetIndexerProductSnapshotsResponse> {\n const baseResponse = await this.query('products', {\n product_id: params.productId,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.products.map((product) => {\n return {\n ...mapIndexerServerProduct(product.product),\n submissionIndex: product.submission_idx,\n };\n });\n }\n\n /**\n * Retrieves historical snapshots for multiple products\n * @param params\n */\n async getMultiProductSnapshots(\n params: GetIndexerMultiProductSnapshotsParams,\n ): Promise<GetIndexerMultiProductSnapshotsResponse> {\n const timestampToProductsMap = await this.query('product_snapshots', {\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive ?? [nowInSeconds()],\n });\n\n return mapValues(timestampToProductsMap, (productIdToProduct) => {\n return mapValues(productIdToProduct, (indexerProduct) => {\n return {\n ...mapIndexerServerProduct(indexerProduct.product),\n submissionIndex: indexerProduct.submission_idx,\n };\n });\n });\n }\n\n /**\n * Retrieves historical events\n *\n * @param params\n */\n async getEvents(\n params: GetIndexerEventsParams,\n ): Promise<GetIndexerEventsResponse> {\n const serverLimit = ((): IndexerServerEventsParams['limit'] | undefined => {\n if (!params.limit) {\n return;\n }\n\n if (params.limit.type === 'events') {\n return {\n raw: params.limit.value,\n };\n }\n return {\n txs: params.limit.value,\n };\n })();\n\n const baseResponse = await this.query('events', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n event_types: params.eventTypes,\n max_time: params.maxTimestampInclusive,\n desc: params.desc,\n limit: serverLimit,\n idx: params.startCursor,\n });\n\n // Keep track of the last tx index, and go to the next one if the submission_idx for the currently processed event does not match\n // txs are ordered the same as events, so this should be correct\n let lastTxIdx = 0;\n return baseResponse.events.map((event): IndexerEventWithTx => {\n if (baseResponse.txs[lastTxIdx].submission_idx !== event.submission_idx) {\n lastTxIdx += 1;\n }\n const tx = baseResponse.txs[lastTxIdx];\n return mapIndexerEventWithTx(event, tx);\n });\n }\n\n /**\n * Retrieves historical orders\n * @param params\n */\n async getOrders(\n params: GetIndexerOrdersParams,\n ): Promise<GetIndexerOrdersResponse> {\n const baseResponse = await this.query('orders', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n digests: params.digests,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.orders.map(mapIndexerOrder);\n }\n\n /**\n * Gets match order events, this will return the same events as the events query, but with additional information\n * to identify the order that was matched\n *\n * @param params\n */\n async getMatchEvents(\n params: GetIndexerMatchEventsParams,\n ): Promise<GetIndexerMatchEventsResponse> {\n const baseResponse = await this.query('matches', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n // Same as logic in `getEvents`\n let lastTxIdx = 0;\n return baseResponse.matches.map((matchEvent): IndexerMatchEvent => {\n if (\n baseResponse.txs[lastTxIdx].submission_idx !== matchEvent.submission_idx\n ) {\n lastTxIdx += 1;\n }\n const { tx, timestamp } = baseResponse.txs[lastTxIdx];\n\n // We use this to derive the product ID for the match\n const postBalances = mapIndexerMatchEventBalances(\n matchEvent.post_balance,\n );\n\n return {\n productId: postBalances.base.productId,\n isolated: matchEvent.isolated,\n totalFee: toBigDecimal(matchEvent.fee),\n sequencerFee: toBigDecimal(matchEvent.sequencer_fee),\n baseFilled: toBigDecimal(matchEvent.base_filled),\n quoteFilled: toBigDecimal(matchEvent.quote_filled),\n cumulativeFee: toBigDecimal(matchEvent.cumulative_fee),\n cumulativeBaseFilled: toBigDecimal(matchEvent.cumulative_base_filled),\n cumulativeQuoteFilled: toBigDecimal(matchEvent.cumulative_quote_filled),\n digest: matchEvent.digest,\n order: matchEvent.order,\n submissionIndex: matchEvent.submission_idx,\n timestamp: toBigDecimal(timestamp),\n preEventTrackedVars: {\n netEntryUnrealized: toBigDecimal(matchEvent.net_entry_unrealized),\n netEntryCumulative: toBigDecimal(matchEvent.net_entry_cumulative),\n },\n preBalances: mapIndexerMatchEventBalances(matchEvent.pre_balance),\n postBalances,\n tx,\n ...subaccountFromHex(matchEvent.order.sender),\n };\n });\n }\n\n /**\n * Retrieves historical funding & interest payments.\n * NOTE: `limit` is an upperbound. If a user changes position size such that his position is 0 during each funding/interest tick,\n * then the indexer will return fewer than `limit` results per page. However, more events can be present. This means that\n * there isn't a reliable way to determine whether there is a next page. We just need to keep paginating until the next cursor is null.\n *\n * @param params\n */\n async getInterestFundingPayments(\n params: GetIndexerInterestFundingPaymentsParams,\n ): Promise<GetIndexerInterestFundingPaymentsResponse> {\n const baseResponse = await this.query('interest_and_funding', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n max_idx: params.startCursor,\n });\n\n return {\n fundingPayments: baseResponse.funding_payments.map(\n mapIndexerProductPayment,\n ),\n interestPayments: baseResponse.interest_payments.map(\n mapIndexerProductPayment,\n ),\n nextCursor: baseResponse.next_idx,\n };\n }\n\n /**\n * Gets quote (USDC) price in terms of USD\n */\n async getQuotePrice(): Promise<GetIndexerQuotePriceResponse> {\n const baseResponse = await this.query('usdc_price', {});\n return {\n price: removeDecimals(baseResponse.price_x18),\n };\n }\n\n /**\n * Fetches currently registered linked signer with the remaining txs allowed for the subaccount\n */\n async getLinkedSignerWithRateLimit(\n params: GetIndexerLinkedSignerParams,\n ): Promise<GetIndexerLinkedSignerResponse> {\n const baseResponse = await this.query('linked_signer_rate_limit', {\n subaccount: subaccountToHex(params.subaccount),\n });\n return {\n totalTxLimit: toBigDecimal(baseResponse.total_tx_limit),\n remainingTxs: toBigDecimal(baseResponse.remaining_tx),\n signer: baseResponse.signer,\n waitTimeUntilNextTx: toBigDecimal(baseResponse.wait_time),\n };\n }\n\n /**\n * Retrieve historical market snapshots\n * @param params\n */\n async getMarketSnapshots(\n params: GetIndexerMarketSnapshotsParams,\n ): Promise<GetIndexerMarketSnapshotsResponse> {\n const baseResponse = await this.query('market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n product_ids: params.productIds,\n });\n\n return baseResponse.snapshots.map(mapIndexerMarketSnapshot);\n }\n\n /**\n * Retrieve historical market snapshots from Edge\n * @param params\n */\n async getEdgeMarketSnapshots(\n params: GetIndexerEdgeMarketSnapshotsParams,\n ): Promise<GetIndexerEdgeMarketSnapshotResponse> {\n const baseResponse = await this.query('edge_market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n });\n\n return mapValues(baseResponse.snapshots, (snapshots) =>\n snapshots.map(mapIndexerMarketSnapshot),\n );\n }\n\n /**\n * Retrieve maker statistics for a given epoch\n *\n * @param params\n */\n async getMakerStatistics(\n params: GetIndexerMakerStatisticsParams,\n ): Promise<GetIndexerMakerStatisticsResponse> {\n const baseResponse = await this.query('maker_statistics', {\n product_id: params.productId,\n epoch: params.epoch,\n interval: params.interval,\n });\n\n return {\n rewardCoefficient: toBigDecimal(baseResponse.reward_coefficient),\n makers: baseResponse.makers.map(mapIndexerMakerStatistics),\n };\n }\n\n /**\n * Retrieve leaderboard stats for a given contest\n *\n * @param params\n */\n async getLeaderboard(\n params: GetIndexerLeaderboardParams,\n ): Promise<GetIndexerLeaderboardResponse> {\n const baseResponse = await this.query('leaderboard', {\n contest_id: params.contestId,\n rank_type: params.rankType,\n start: params.startCursor,\n limit: params.limit,\n });\n\n return {\n participants: baseResponse.positions.map(mapIndexerLeaderboardPosition),\n };\n }\n\n /**\n * Retrieve leaderboard ranking of a subaccount on a given contest\n *\n * @param params\n */\n async getLeaderboardParticipant(\n params: GetIndexerLeaderboardParticipantParams,\n ): Promise<GetIndexerLeaderboardParticipantResponse> {\n const baseResponse = await this.query('leaderboard_rank', {\n subaccount: subaccountToHex(params.subaccount),\n contest_ids: params.contestIds,\n });\n\n return {\n participant: mapValues(baseResponse.positions, (position) =>\n mapIndexerLeaderboardPosition(position),\n ),\n };\n }\n\n /**\n * Attempts to update a user's registration to the provided `contestId`. This requires signing.\n * @param params\n */\n async updateLeaderboardRegistration(\n params: UpdateIndexerLeaderboardRegistrationParams,\n ): Promise<UpdateIndexerLeaderboardRegistrationResponse> {\n const signatureParams: EIP712LeaderboardAuthenticationParams = {\n // Default to 90 seconds from now if no recvTime is provided\n expiration: toIntegerString(params.recvTime ?? getDefaultRecvTime()),\n subaccountName: params.subaccountName,\n subaccountOwner: params.subaccountOwner,\n };\n\n const tx = getNadoEIP712Values(\n 'leaderboard_authentication',\n signatureParams,\n );\n const signature = await this.sign(\n 'leaderboard_authentication',\n params.updateRegistration.verifyingAddr,\n params.updateRegistration.chainId,\n signatureParams,\n );\n\n const updateRegistrationTx: SignedTx<EIP712LeaderboardAuthenticationValues> =\n {\n tx,\n signature,\n };\n\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: updateRegistrationTx,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieves the registration status for a leaderboard participant for provided `contestId`.\n * @param params\n */\n async getLeaderboardRegistration(\n params: GetIndexerLeaderboardRegistrationParams,\n ): Promise<GetIndexerLeaderboardRegistrationResponse> {\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: null,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieve metadata of provided leaderboard contests\n *\n * @param params\n */\n async getLeaderboardContests(\n params: GetIndexerLeaderboardContestsParams,\n ): Promise<GetIndexerLeaderboardContestsResponse> {\n const baseResponse = await this.query('leaderboard_contests', {\n contest_ids: params.contestIds,\n });\n\n return {\n contests: baseResponse.contests.map(mapIndexerLeaderboardContest),\n };\n }\n\n /**\n * Retrieve signature and tx to submit a fast withdrawal\n *\n * @param params\n */\n async getFastWithdrawalSignature(\n params: GetIndexerFastWithdrawalSignatureParams,\n ): Promise<GetIndexerFastWithdrawalSignatureResponse> {\n const baseResponse = await this.query('fast_withdrawal_signature', params);\n return {\n idx: toBigInt(baseResponse.idx),\n tx: baseResponse.tx,\n txBytes: getValidatedHex(baseResponse.tx_bytes),\n signatures: baseResponse.signatures.map(getValidatedHex),\n };\n }\n\n async getNlpSnapshots(\n params: GetIndexerNlpSnapshotsParams,\n ): Promise<GetIndexerNlpSnapshotsResponse> {\n const baseResponse = await this.query('nlp_snapshots', {\n interval: {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n },\n });\n\n return {\n snapshots: baseResponse.snapshots.map(mapIndexerNlpSnapshot),\n };\n }\n\n /**\n * Retrieves the subaccount's DDA (Direct Deposit Address)\n * @param params\n */\n async getSubaccountDDA(\n params: GetIndexerSubaccountDDAParams,\n ): Promise<GetIndexerSubaccountDDAResponse> {\n const baseResponse = await this.query('direct_deposit_address', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n });\n\n return {\n address: baseResponse.v1_address,\n };\n }\n\n async getSequencerBacklog(): Promise<GetIndexerBacklogResponse> {\n const baseResponse = await this.query('backlog', {});\n\n return {\n totalTxs: toBigDecimal(baseResponse.total_txs),\n totalSubmissions: toBigDecimal(baseResponse.total_submissions),\n backlogSize: toBigDecimal(baseResponse.backlog_size),\n updatedAt: toBigDecimal(baseResponse.updated_at),\n backlogEtaInSeconds: baseResponse.backlog_eta_in_seconds\n ? toBigDecimal(baseResponse.backlog_eta_in_seconds)\n : null,\n txsPerSecond: baseResponse.txs_per_second\n ? toBigDecimal(baseResponse.txs_per_second)\n : null,\n };\n }\n\n protected async query<TRequestType extends IndexerServerQueryRequestType>(\n requestType: TRequestType,\n params: IndexerServerQueryRequestByType[TRequestType],\n ): Promise<IndexerServerQueryResponseByType[TRequestType]> {\n const reqBody: IndexerQueryRequestBody = {\n [requestType]: params,\n };\n const response = await this.axiosInstance.post<\n IndexerServerQueryResponseByType[TRequestType]\n >(this.opts.url, reqBody);\n\n this.checkResponseStatus(response);\n\n return response.data;\n }\n\n protected async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n const walletClient = this.opts.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}`,\n );\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAYO;AACP,mBASO;AACP,mBAAoD;AACpD,yBAiBO;AAoFA,IAAM,oBAAN,MAAwB;AAAA,EAK7B,YAAY,MAAyB;AACnC,SAAK,OAAO;AACZ,SAAK,gBAAgB,aAAAA,QAAM,OAAO;AAAA,MAChC,iBAAiB;AAAA,IACnB,CAAC;AACD,SAAK,QAAQ,KAAK,QAAQ,KAAK,QAAQ,KAAK,IAAI,QAAQ,MAAM,IAAI;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,gBACJ,QACyC;AACzC,UAAM,eAAe,MAAM,KAAK,MAAM,eAAe,MAAM;AAE3D,WAAO,aAAa,YAAY,IAAI,CAAC,SAAS;AAC5C,Y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AAAA,MACJ,cAAc,aAAa,qBACvB,2BAAa,aAAa,cAAc,IACxC;AAAA,IACN;AAAA,EACF;AAAA,EAEA,MAAgB,MACd,aACA,QACyD;AACzD,UAAM,UAAmC;AAAA,MACvC,CAAC,WAAW,GAAG;AAAA,IACjB;AACA,UAAM,WAAW,MAAM,KAAK,cAAc,KAExC,KAAK,KAAK,KAAK,OAAO;AAExB,SAAK,oBAAoB,QAAQ;AAEjC,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAgB,KACd,aACA,mBACA,SACA,QACA;AACA,UAAM,eAAe,KAAK,KAAK;AAE/B,QAAI,CAAC,cAAc;AACjB,YAAM,IAAI,oCAAuB;AAAA,IACnC;AAEA,eAAO,8CAA4B;AAAA,MACjC;AAAA,MACA,eAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,oBAAoB,UAAyB;AACnD,QAAI,SAAS,WAAW,OAAO,CAAC,SAAS,MAAM;AAC7C,YAAM;AAAA,QACJ,oCAAoC,SAAS,MAAM,IAAI,SAAS,UAAU;AAAA,MAC5E;AAAA,IACF;AAAA,EACF;AACF;","names":["axios"]}
1
+ {"version":3,"sources":["../src/IndexerBaseClient.ts"],"sourcesContent":["import {\n EIP712LeaderboardAuthenticationParams,\n EIP712LeaderboardAuthenticationValues,\n getDefaultRecvTime,\n getNadoEIP712Values,\n getSignedTransactionRequest,\n getValidatedHex,\n mapValues,\n nowInSeconds,\n removeDecimals,\n SignableRequestType,\n SignableRequestTypeToParams,\n SignedTx,\n subaccountFromHex,\n subaccountToHex,\n toBigDecimal,\n toBigInt,\n toIntegerString,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n mapIndexerCandlesticks,\n mapIndexerEvent,\n mapIndexerEventWithTx,\n mapIndexerFundingRate,\n mapIndexerLeaderboardContest,\n mapIndexerLeaderboardPosition,\n mapIndexerLeaderboardRegistration,\n mapIndexerMakerStatistics,\n mapIndexerMarketSnapshot,\n mapIndexerMatchEventBalances,\n mapIndexerNlpSnapshot,\n mapIndexerOrder,\n mapIndexerPerpPrices,\n mapIndexerProductPayment,\n mapIndexerServerProduct,\n mapSnapshotsIntervalToServerParams,\n} from './dataMappers';\nimport {\n GetIndexerBacklogResponse,\n GetIndexerCandlesticksParams,\n GetIndexerCandlesticksResponse,\n GetIndexerEdgeCandlesticksParams,\n GetIndexerEdgeCandlesticksResponse,\n GetIndexerEdgeMarketSnapshotResponse,\n GetIndexerEdgeMarketSnapshotsParams,\n GetIndexerEventsParams,\n GetIndexerEventsResponse,\n GetIndexerFastWithdrawalSignatureParams,\n GetIndexerFastWithdrawalSignatureResponse,\n GetIndexerFundingRateParams,\n GetIndexerFundingRateResponse,\n GetIndexerInterestFundingPaymentsParams,\n GetIndexerInterestFundingPaymentsResponse,\n GetIndexerLeaderboardContestsParams,\n GetIndexerLeaderboardContestsResponse,\n GetIndexerLeaderboardParams,\n GetIndexerLeaderboardParticipantParams,\n GetIndexerLeaderboardParticipantResponse,\n GetIndexerLeaderboardRegistrationParams,\n GetIndexerLeaderboardRegistrationResponse,\n GetIndexerLeaderboardResponse,\n GetIndexerLinkedSignerParams,\n GetIndexerLinkedSignerResponse,\n GetIndexerMakerStatisticsParams,\n GetIndexerMakerStatisticsResponse,\n GetIndexerMarketSnapshotsParams,\n GetIndexerMarketSnapshotsResponse,\n GetIndexerMatchEventsParams,\n GetIndexerMatchEventsResponse,\n GetIndexerMultiProductFundingRatesParams,\n GetIndexerMultiProductFundingRatesResponse,\n GetIndexerMultiProductPerpPricesParams,\n GetIndexerMultiProductPerpPricesResponse,\n GetIndexerMultiProductSnapshotsParams,\n GetIndexerMultiProductSnapshotsResponse,\n GetIndexerMultiSubaccountSnapshotsParams,\n GetIndexerMultiSubaccountSnapshotsResponse,\n GetIndexerNlpSnapshotsParams,\n GetIndexerNlpSnapshotsResponse,\n GetIndexerOraclePricesParams,\n GetIndexerOraclePricesResponse,\n GetIndexerOrdersParams,\n GetIndexerOrdersResponse,\n GetIndexerPerpPricesParams,\n GetIndexerPerpPricesResponse,\n GetIndexerProductSnapshotsParams,\n GetIndexerProductSnapshotsResponse,\n GetIndexerQuotePriceResponse,\n GetIndexerReferralCodeParams,\n GetIndexerReferralCodeResponse,\n GetIndexerSubaccountDDAParams,\n GetIndexerSubaccountDDAResponse,\n IndexerEventWithTx,\n IndexerMatchEvent,\n IndexerOraclePrice,\n IndexerServerEventsParams,\n IndexerServerQueryRequestByType,\n IndexerServerQueryRequestType,\n IndexerServerQueryResponseByType,\n IndexerSnapshotBalance,\n IndexerSubaccountSnapshot,\n ListIndexerSubaccountsParams,\n ListIndexerSubaccountsResponse,\n UpdateIndexerLeaderboardRegistrationParams,\n UpdateIndexerLeaderboardRegistrationResponse,\n} from './types';\n\nexport interface IndexerClientOpts {\n // Server URLs\n url: string;\n v2Url?: string;\n // Wallet Client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n}\n\ntype IndexerQueryRequestBody = Partial<IndexerServerQueryRequestByType>;\n\n/**\n * Base client for all indexer requests\n */\nexport class IndexerBaseClient {\n readonly opts: IndexerClientOpts;\n readonly v2Url: string;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: IndexerClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n });\n this.v2Url = opts.v2Url ? opts.v2Url : opts.url.replace('v1', 'v2');\n }\n\n /**\n * List all subaccounts\n *\n * @param params\n */\n async listSubaccounts(\n params: ListIndexerSubaccountsParams,\n ): Promise<ListIndexerSubaccountsResponse> {\n const baseResponse = await this.query('subaccounts', params);\n\n return baseResponse.subaccounts.map((item) => {\n const subaccount = subaccountFromHex(item.subaccount);\n return {\n hexId: item.subaccount,\n ...subaccount,\n };\n });\n }\n\n /**\n * Retrieve snapshots of multiple subaccounts at multiple points in time.\n * Each snapshot is a view of the subaccount's balances at this point in time, with tracked variables for interest, funding, etc.\n *\n * @param params\n */\n async getMultiSubaccountSnapshots(\n params: GetIndexerMultiSubaccountSnapshotsParams,\n ): Promise<GetIndexerMultiSubaccountSnapshotsResponse> {\n const subaccountHexIds = params.subaccounts.map(\n ({ subaccountOwner, subaccountName }) =>\n subaccountToHex({\n subaccountOwner,\n subaccountName,\n }),\n );\n\n const baseResponse = await this.query('account_snapshots', {\n subaccounts: subaccountHexIds,\n timestamps: params.timestamps,\n isolated: params.isolated,\n });\n\n const snapshotsBySubaccount = mapValues(\n baseResponse.snapshots,\n (balanceSnapshots) => {\n const snapshotByTimestamp: Record<string, IndexerSubaccountSnapshot> =\n {};\n\n Object.entries(balanceSnapshots).forEach(([timestamp, events]) => {\n const balances: IndexerSnapshotBalance[] =\n events.map(mapIndexerEvent);\n\n snapshotByTimestamp[timestamp] = {\n timestamp: toBigDecimal(timestamp),\n balances,\n };\n });\n\n return snapshotByTimestamp;\n },\n );\n\n return {\n subaccountHexIds,\n snapshots: snapshotsBySubaccount,\n };\n }\n\n /**\n * Retrieves referral code for an address\n *\n * @param params\n */\n async getReferralCode(\n params: GetIndexerReferralCodeParams,\n ): Promise<GetIndexerReferralCodeResponse> {\n const baseResponse = await this.query('referral_code', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n });\n\n return {\n referralCode: baseResponse.referral_code,\n };\n }\n\n /**\n * Retrieves funding rate for a product, where 1 = 100%\n * @param params\n */\n async getFundingRate(\n params: GetIndexerFundingRateParams,\n ): Promise<GetIndexerFundingRateResponse> {\n const baseResponse = await this.query('funding_rate', {\n product_id: params.productId,\n });\n\n return mapIndexerFundingRate(baseResponse);\n }\n\n /**\n * Retrieves funding rate for multiple products, where 1 = 100%\n * @param params\n */\n async getMultiProductFundingRates(\n params: GetIndexerMultiProductFundingRatesParams,\n ): Promise<GetIndexerMultiProductFundingRatesResponse> {\n const baseResponse = await this.query('funding_rates', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerFundingRate);\n }\n\n /**\n * Retrieves latest mark/index price for a perp product\n * @param params\n */\n async getPerpPrices(\n params: GetIndexerPerpPricesParams,\n ): Promise<GetIndexerPerpPricesResponse> {\n const baseResponse = await this.query('price', {\n product_id: params.productId,\n });\n\n return mapIndexerPerpPrices(baseResponse);\n }\n\n /**\n * Retrieves latest mark/index price for multiple perp products\n * @param params\n */\n async getMultiProductPerpPrices(\n params: GetIndexerMultiProductPerpPricesParams,\n ): Promise<GetIndexerMultiProductPerpPricesResponse> {\n const baseResponse = await this.query('perp_prices', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerPerpPrices);\n }\n\n /**\n * Retrieves latest oracle prices for provided products\n * @param params\n */\n async getOraclePrices(\n params: GetIndexerOraclePricesParams,\n ): Promise<GetIndexerOraclePricesResponse> {\n const baseResponse = await this.query('oracle_price', {\n product_ids: params.productIds,\n });\n\n return baseResponse.prices.map((price): IndexerOraclePrice => {\n return {\n oraclePrice: removeDecimals(price.oracle_price_x18),\n updateTime: toBigDecimal(price.update_time),\n productId: price.product_id,\n };\n });\n }\n\n /**\n * Retrieves candlesticks for a product\n * @param params\n */\n async getCandlesticks(\n params: GetIndexerCandlesticksParams,\n ): Promise<GetIndexerCandlesticksResponse> {\n const baseResponse = await this.query('candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves candlesticks for a product from Edge\n * @param params\n */\n async getEdgeCandlesticks(\n params: GetIndexerEdgeCandlesticksParams,\n ): Promise<GetIndexerEdgeCandlesticksResponse> {\n const baseResponse = await this.query('edge_candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves historical snapshots for a product\n * @param params\n */\n async getProductSnapshots(\n params: GetIndexerProductSnapshotsParams,\n ): Promise<GetIndexerProductSnapshotsResponse> {\n const baseResponse = await this.query('products', {\n product_id: params.productId,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.products.map((product) => {\n return {\n ...mapIndexerServerProduct(product.product),\n submissionIndex: product.submission_idx,\n };\n });\n }\n\n /**\n * Retrieves historical snapshots for multiple products\n * @param params\n */\n async getMultiProductSnapshots(\n params: GetIndexerMultiProductSnapshotsParams,\n ): Promise<GetIndexerMultiProductSnapshotsResponse> {\n const timestampToProductsMap = await this.query('product_snapshots', {\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive ?? [nowInSeconds()],\n });\n\n return mapValues(timestampToProductsMap, (productIdToProduct) => {\n return mapValues(productIdToProduct, (indexerProduct) => {\n return {\n ...mapIndexerServerProduct(indexerProduct.product),\n submissionIndex: indexerProduct.submission_idx,\n };\n });\n });\n }\n\n /**\n * Retrieves historical events\n *\n * @param params\n */\n async getEvents(\n params: GetIndexerEventsParams,\n ): Promise<GetIndexerEventsResponse> {\n const serverLimit = ((): IndexerServerEventsParams['limit'] | undefined => {\n if (!params.limit) {\n return;\n }\n\n if (params.limit.type === 'events') {\n return {\n raw: params.limit.value,\n };\n }\n return {\n txs: params.limit.value,\n };\n })();\n\n const baseResponse = await this.query('events', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n event_types: params.eventTypes,\n max_time: params.maxTimestampInclusive,\n desc: params.desc,\n limit: serverLimit,\n idx: params.startCursor,\n });\n\n // Keep track of the last tx index, and go to the next one if the submission_idx for the currently processed event does not match\n // txs are ordered the same as events, so this should be correct\n let lastTxIdx = 0;\n return baseResponse.events.map((event): IndexerEventWithTx => {\n if (baseResponse.txs[lastTxIdx].submission_idx !== event.submission_idx) {\n lastTxIdx += 1;\n }\n const tx = baseResponse.txs[lastTxIdx];\n return mapIndexerEventWithTx(event, tx);\n });\n }\n\n /**\n * Retrieves historical orders\n * @param params\n */\n async getOrders(\n params: GetIndexerOrdersParams,\n ): Promise<GetIndexerOrdersResponse> {\n const baseResponse = await this.query('orders', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n digests: params.digests,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.orders.map(mapIndexerOrder);\n }\n\n /**\n * Gets match order events, this will return the same events as the events query, but with additional information\n * to identify the order that was matched\n *\n * @param params\n */\n async getMatchEvents(\n params: GetIndexerMatchEventsParams,\n ): Promise<GetIndexerMatchEventsResponse> {\n const baseResponse = await this.query('matches', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n // Same as logic in `getEvents`\n let lastTxIdx = 0;\n return baseResponse.matches.map((matchEvent): IndexerMatchEvent => {\n if (\n baseResponse.txs[lastTxIdx].submission_idx !== matchEvent.submission_idx\n ) {\n lastTxIdx += 1;\n }\n const { tx, timestamp } = baseResponse.txs[lastTxIdx];\n\n // We use this to derive the product ID for the match\n const postBalances = mapIndexerMatchEventBalances(\n matchEvent.post_balance,\n );\n\n return {\n productId: postBalances.base.productId,\n isolated: matchEvent.isolated,\n totalFee: toBigDecimal(matchEvent.fee),\n sequencerFee: toBigDecimal(matchEvent.sequencer_fee),\n baseFilled: toBigDecimal(matchEvent.base_filled),\n quoteFilled: toBigDecimal(matchEvent.quote_filled),\n cumulativeFee: toBigDecimal(matchEvent.cumulative_fee),\n cumulativeBaseFilled: toBigDecimal(matchEvent.cumulative_base_filled),\n cumulativeQuoteFilled: toBigDecimal(matchEvent.cumulative_quote_filled),\n digest: matchEvent.digest,\n order: matchEvent.order,\n submissionIndex: matchEvent.submission_idx,\n timestamp: toBigDecimal(timestamp),\n preEventTrackedVars: {\n netEntryUnrealized: toBigDecimal(matchEvent.net_entry_unrealized),\n netEntryCumulative: toBigDecimal(matchEvent.net_entry_cumulative),\n },\n preBalances: mapIndexerMatchEventBalances(matchEvent.pre_balance),\n postBalances,\n tx,\n ...subaccountFromHex(matchEvent.order.sender),\n };\n });\n }\n\n /**\n * Retrieves historical funding & interest payments.\n * NOTE: `limit` is an upperbound. If a user changes position size such that his position is 0 during each funding/interest tick,\n * then the indexer will return fewer than `limit` results per page. However, more events can be present. This means that\n * there isn't a reliable way to determine whether there is a next page. We just need to keep paginating until the next cursor is null.\n *\n * @param params\n */\n async getInterestFundingPayments(\n params: GetIndexerInterestFundingPaymentsParams,\n ): Promise<GetIndexerInterestFundingPaymentsResponse> {\n const baseResponse = await this.query('interest_and_funding', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n max_idx: params.startCursor,\n });\n\n return {\n fundingPayments: baseResponse.funding_payments.map(\n mapIndexerProductPayment,\n ),\n interestPayments: baseResponse.interest_payments.map(\n mapIndexerProductPayment,\n ),\n nextCursor: baseResponse.next_idx,\n };\n }\n\n /**\n * Gets quote (USDC) price in terms of USD\n */\n async getQuotePrice(): Promise<GetIndexerQuotePriceResponse> {\n const baseResponse = await this.query('usdc_price', {});\n return {\n price: removeDecimals(baseResponse.price_x18),\n };\n }\n\n /**\n * Fetches currently registered linked signer with the remaining txs allowed for the subaccount\n */\n async getLinkedSignerWithRateLimit(\n params: GetIndexerLinkedSignerParams,\n ): Promise<GetIndexerLinkedSignerResponse> {\n const baseResponse = await this.query('linked_signer_rate_limit', {\n subaccount: subaccountToHex(params.subaccount),\n });\n return {\n totalTxLimit: toBigDecimal(baseResponse.total_tx_limit),\n remainingTxs: toBigDecimal(baseResponse.remaining_tx),\n signer: baseResponse.signer,\n waitTimeUntilNextTx: toBigDecimal(baseResponse.wait_time),\n };\n }\n\n /**\n * Retrieve historical market snapshots\n * @param params\n */\n async getMarketSnapshots(\n params: GetIndexerMarketSnapshotsParams,\n ): Promise<GetIndexerMarketSnapshotsResponse> {\n const baseResponse = await this.query('market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n product_ids: params.productIds,\n });\n\n return baseResponse.snapshots.map(mapIndexerMarketSnapshot);\n }\n\n /**\n * Retrieve historical market snapshots from Edge\n * @param params\n */\n async getEdgeMarketSnapshots(\n params: GetIndexerEdgeMarketSnapshotsParams,\n ): Promise<GetIndexerEdgeMarketSnapshotResponse> {\n const baseResponse = await this.query('edge_market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n });\n\n return mapValues(baseResponse.snapshots, (snapshots) =>\n snapshots.map(mapIndexerMarketSnapshot),\n );\n }\n\n /**\n * Retrieve maker statistics for a given epoch\n *\n * @param params\n */\n async getMakerStatistics(\n params: GetIndexerMakerStatisticsParams,\n ): Promise<GetIndexerMakerStatisticsResponse> {\n const baseResponse = await this.query('maker_statistics', {\n product_id: params.productId,\n epoch: params.epoch,\n interval: params.interval,\n });\n\n return {\n rewardCoefficient: toBigDecimal(baseResponse.reward_coefficient),\n makers: baseResponse.makers.map(mapIndexerMakerStatistics),\n };\n }\n\n /**\n * Retrieve leaderboard stats for a given contest\n *\n * @param params\n */\n async getLeaderboard(\n params: GetIndexerLeaderboardParams,\n ): Promise<GetIndexerLeaderboardResponse> {\n const baseResponse = await this.query('leaderboard', {\n contest_id: params.contestId,\n rank_type: params.rankType,\n start: params.startCursor,\n limit: params.limit,\n });\n\n return {\n participants: baseResponse.positions.map(mapIndexerLeaderboardPosition),\n };\n }\n\n /**\n * Retrieve leaderboard ranking of a subaccount on a given contest\n *\n * @param params\n */\n async getLeaderboardParticipant(\n params: GetIndexerLeaderboardParticipantParams,\n ): Promise<GetIndexerLeaderboardParticipantResponse> {\n const baseResponse = await this.query('leaderboard_rank', {\n subaccount: subaccountToHex(params.subaccount),\n contest_ids: params.contestIds,\n });\n\n return {\n participant: mapValues(baseResponse.positions, (position) =>\n mapIndexerLeaderboardPosition(position),\n ),\n };\n }\n\n /**\n * Attempts to update a user's registration to the provided `contestId`. This requires signing.\n * @param params\n */\n async updateLeaderboardRegistration(\n params: UpdateIndexerLeaderboardRegistrationParams,\n ): Promise<UpdateIndexerLeaderboardRegistrationResponse> {\n const signatureParams: EIP712LeaderboardAuthenticationParams = {\n // Default to 90 seconds from now if no recvTime is provided\n expiration: toIntegerString(params.recvTime ?? getDefaultRecvTime()),\n subaccountName: params.subaccountName,\n subaccountOwner: params.subaccountOwner,\n };\n\n const tx = getNadoEIP712Values(\n 'leaderboard_authentication',\n signatureParams,\n );\n const signature = await this.sign(\n 'leaderboard_authentication',\n params.updateRegistration.verifyingAddr,\n params.updateRegistration.chainId,\n signatureParams,\n );\n\n const updateRegistrationTx: SignedTx<EIP712LeaderboardAuthenticationValues> =\n {\n tx,\n signature,\n };\n\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: updateRegistrationTx,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieves the registration status for a leaderboard participant for provided `contestId`.\n * @param params\n */\n async getLeaderboardRegistration(\n params: GetIndexerLeaderboardRegistrationParams,\n ): Promise<GetIndexerLeaderboardRegistrationResponse> {\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: null,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieve metadata of provided leaderboard contests\n *\n * @param params\n */\n async getLeaderboardContests(\n params: GetIndexerLeaderboardContestsParams,\n ): Promise<GetIndexerLeaderboardContestsResponse> {\n const baseResponse = await this.query('leaderboard_contests', {\n contest_ids: params.contestIds,\n });\n\n return {\n contests: baseResponse.contests.map(mapIndexerLeaderboardContest),\n };\n }\n\n /**\n * Retrieve signature and tx to submit a fast withdrawal\n *\n * @param params\n */\n async getFastWithdrawalSignature(\n params: GetIndexerFastWithdrawalSignatureParams,\n ): Promise<GetIndexerFastWithdrawalSignatureResponse> {\n const baseResponse = await this.query('fast_withdrawal_signature', params);\n return {\n idx: toBigInt(baseResponse.idx),\n tx: baseResponse.tx,\n txBytes: getValidatedHex(baseResponse.tx_bytes),\n signatures: baseResponse.signatures.map(getValidatedHex),\n };\n }\n\n async getNlpSnapshots(\n params: GetIndexerNlpSnapshotsParams,\n ): Promise<GetIndexerNlpSnapshotsResponse> {\n const baseResponse = await this.query('nlp_snapshots', {\n interval: {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n },\n });\n\n return {\n snapshots: baseResponse.snapshots.map(mapIndexerNlpSnapshot),\n };\n }\n\n /**\n * Retrieves the subaccount's DDA (Direct Deposit Address)\n * @param params\n */\n async getSubaccountDDA(\n params: GetIndexerSubaccountDDAParams,\n ): Promise<GetIndexerSubaccountDDAResponse> {\n const baseResponse = await this.query('direct_deposit_address', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n });\n\n return {\n address: baseResponse.v1_address,\n };\n }\n\n async getSequencerBacklog(): Promise<GetIndexerBacklogResponse> {\n const baseResponse = await this.query('backlog', {});\n\n return {\n totalTxs: toBigDecimal(baseResponse.total_txs),\n totalSubmissions: toBigDecimal(baseResponse.total_submissions),\n backlogSize: toBigDecimal(baseResponse.backlog_size),\n updatedAt: toBigDecimal(baseResponse.updated_at),\n backlogEtaInSeconds: baseResponse.backlog_eta_in_seconds\n ? toBigDecimal(baseResponse.backlog_eta_in_seconds)\n : null,\n txsPerSecond: baseResponse.txs_per_second\n ? toBigDecimal(baseResponse.txs_per_second)\n : null,\n };\n }\n\n protected async query<TRequestType extends IndexerServerQueryRequestType>(\n requestType: TRequestType,\n params: IndexerServerQueryRequestByType[TRequestType],\n ): Promise<IndexerServerQueryResponseByType[TRequestType]> {\n const reqBody: IndexerQueryRequestBody = {\n [requestType]: params,\n };\n const response = await this.axiosInstance.post<\n IndexerServerQueryResponseByType[TRequestType]\n >(this.opts.url, reqBody);\n\n this.checkResponseStatus(response);\n\n return response.data;\n }\n\n protected async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n const walletClient = this.opts.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}`,\n );\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAoBO;AACP,mBAAoD;AACpD,yBAiBO;AAoFA,IAAM,oBAAN,MAAwB;AAAA,EAK7B,YAAY,MAAyB;AACnC,SAAK,OAAO;AACZ,SAAK,gBAAgB,aAAAA,QAAM,OAAO;AAAA,MAChC,iBAAiB;AAAA;AAAA,MAEjB,gBAAgB,MAAM;AAAA,IACxB,CAAC;AACD,SAAK,QAAQ,KAAK,QAAQ,KAAK,QAAQ,KAAK,IAAI,QAAQ,MAAM,IAAI;AAAA,E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kB,4BAAa,aAAa,iBAAiB;AAAA,MAC7D,iBAAa,4BAAa,aAAa,YAAY;AAAA,MACnD,eAAW,4BAAa,aAAa,UAAU;AAAA,MAC/C,qBAAqB,aAAa,6BAC9B,4BAAa,aAAa,sBAAsB,IAChD;AAAA,MACJ,cAAc,aAAa,qBACvB,4BAAa,aAAa,cAAc,IACxC;AAAA,IACN;AAAA,EACF;AAAA,EAEA,MAAgB,MACd,aACA,QACyD;AACzD,UAAM,UAAmC;AAAA,MACvC,CAAC,WAAW,GAAG;AAAA,IACjB;AACA,UAAM,WAAW,MAAM,KAAK,cAAc,KAExC,KAAK,KAAK,KAAK,OAAO;AAExB,SAAK,oBAAoB,QAAQ;AAEjC,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAgB,KACd,aACA,mBACA,SACA,QACA;AACA,UAAM,eAAe,KAAK,KAAK;AAE/B,QAAI,CAAC,cAAc;AACjB,YAAM,IAAI,qCAAuB;AAAA,IACnC;AAEA,eAAO,2CAA4B;AAAA,MACjC;AAAA,MACA,eAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,oBAAoB,UAAyB;AACnD,QAAI,SAAS,WAAW,OAAO,CAAC,SAAS,MAAM;AAC7C,YAAM;AAAA,QACJ,oCAAoC,SAAS,MAAM,IAAI,SAAS,UAAU;AAAA,MAC5E;AAAA,IACF;AAAA,EACF;AACF;","names":["axios"]}
@@ -1,8 +1,7 @@
1
- import { WalletClientWithAccount, SignableRequestType, SignableRequestTypeToParams } from '@nadohq/contracts';
1
+ import { WalletClientWithAccount, SignableRequestType, SignableRequestTypeToParams } from '@nadohq/shared';
2
2
  import { AxiosInstance } from 'axios';
3
3
  import { ListIndexerSubaccountsParams, ListIndexerSubaccountsResponse, GetIndexerMultiSubaccountSnapshotsParams, GetIndexerMultiSubaccountSnapshotsResponse, GetIndexerReferralCodeParams, GetIndexerReferralCodeResponse, GetIndexerFundingRateParams, GetIndexerFundingRateResponse, GetIndexerMultiProductFundingRatesParams, GetIndexerMultiProductFundingRatesResponse, GetIndexerPerpPricesParams, GetIndexerPerpPricesResponse, GetIndexerMultiProductPerpPricesParams, GetIndexerMultiProductPerpPricesResponse, GetIndexerOraclePricesParams, GetIndexerOraclePricesResponse, GetIndexerCandlesticksParams, GetIndexerCandlesticksResponse, GetIndexerEdgeCandlesticksParams, GetIndexerEdgeCandlesticksResponse, GetIndexerProductSnapshotsParams, GetIndexerProductSnapshotsResponse, GetIndexerMultiProductSnapshotsParams, GetIndexerMultiProductSnapshotsResponse, GetIndexerEventsParams, GetIndexerEventsResponse, GetIndexerOrdersParams, GetIndexerOrdersResponse, GetIndexerMatchEventsParams, GetIndexerMatchEventsResponse, GetIndexerInterestFundingPaymentsParams, GetIndexerInterestFundingPaymentsResponse, GetIndexerQuotePriceResponse, GetIndexerLinkedSignerParams, GetIndexerLinkedSignerResponse, GetIndexerMarketSnapshotsParams, GetIndexerMarketSnapshotsResponse, GetIndexerEdgeMarketSnapshotsParams, GetIndexerEdgeMarketSnapshotResponse, GetIndexerMakerStatisticsParams, GetIndexerMakerStatisticsResponse, GetIndexerLeaderboardParams, GetIndexerLeaderboardResponse, GetIndexerLeaderboardParticipantParams, GetIndexerLeaderboardParticipantResponse, UpdateIndexerLeaderboardRegistrationParams, UpdateIndexerLeaderboardRegistrationResponse, GetIndexerLeaderboardRegistrationParams, GetIndexerLeaderboardRegistrationResponse, GetIndexerLeaderboardContestsParams, GetIndexerLeaderboardContestsResponse, GetIndexerFastWithdrawalSignatureParams, GetIndexerFastWithdrawalSignatureResponse, GetIndexerNlpSnapshotsParams, GetIndexerNlpSnapshotsResponse, GetIndexerSubaccountDDAParams, GetIndexerSubaccountDDAResponse, GetIndexerBacklogResponse } from './types/clientTypes.cjs';
4
4
  import { IndexerServerQueryRequestType, IndexerServerQueryRequestByType, IndexerServerQueryResponseByType } from './types/serverTypes.cjs';
5
- import '@nadohq/utils';
6
5
  import 'viem';
7
6
  import './types/CandlestickPeriod.cjs';
8
7
  import './types/IndexerEventType.cjs';
@@ -1,8 +1,7 @@
1
- import { WalletClientWithAccount, SignableRequestType, SignableRequestTypeToParams } from '@nadohq/contracts';
1
+ import { WalletClientWithAccount, SignableRequestType, SignableRequestTypeToParams } from '@nadohq/shared';
2
2
  import { AxiosInstance } from 'axios';
3
3
  import { ListIndexerSubaccountsParams, ListIndexerSubaccountsResponse, GetIndexerMultiSubaccountSnapshotsParams, GetIndexerMultiSubaccountSnapshotsResponse, GetIndexerReferralCodeParams, GetIndexerReferralCodeResponse, GetIndexerFundingRateParams, GetIndexerFundingRateResponse, GetIndexerMultiProductFundingRatesParams, GetIndexerMultiProductFundingRatesResponse, GetIndexerPerpPricesParams, GetIndexerPerpPricesResponse, GetIndexerMultiProductPerpPricesParams, GetIndexerMultiProductPerpPricesResponse, GetIndexerOraclePricesParams, GetIndexerOraclePricesResponse, GetIndexerCandlesticksParams, GetIndexerCandlesticksResponse, GetIndexerEdgeCandlesticksParams, GetIndexerEdgeCandlesticksResponse, GetIndexerProductSnapshotsParams, GetIndexerProductSnapshotsResponse, GetIndexerMultiProductSnapshotsParams, GetIndexerMultiProductSnapshotsResponse, GetIndexerEventsParams, GetIndexerEventsResponse, GetIndexerOrdersParams, GetIndexerOrdersResponse, GetIndexerMatchEventsParams, GetIndexerMatchEventsResponse, GetIndexerInterestFundingPaymentsParams, GetIndexerInterestFundingPaymentsResponse, GetIndexerQuotePriceResponse, GetIndexerLinkedSignerParams, GetIndexerLinkedSignerResponse, GetIndexerMarketSnapshotsParams, GetIndexerMarketSnapshotsResponse, GetIndexerEdgeMarketSnapshotsParams, GetIndexerEdgeMarketSnapshotResponse, GetIndexerMakerStatisticsParams, GetIndexerMakerStatisticsResponse, GetIndexerLeaderboardParams, GetIndexerLeaderboardResponse, GetIndexerLeaderboardParticipantParams, GetIndexerLeaderboardParticipantResponse, UpdateIndexerLeaderboardRegistrationParams, UpdateIndexerLeaderboardRegistrationResponse, GetIndexerLeaderboardRegistrationParams, GetIndexerLeaderboardRegistrationResponse, GetIndexerLeaderboardContestsParams, GetIndexerLeaderboardContestsResponse, GetIndexerFastWithdrawalSignatureParams, GetIndexerFastWithdrawalSignatureResponse, GetIndexerNlpSnapshotsParams, GetIndexerNlpSnapshotsResponse, GetIndexerSubaccountDDAParams, GetIndexerSubaccountDDAResponse, GetIndexerBacklogResponse } from './types/clientTypes.js';
4
4
  import { IndexerServerQueryRequestType, IndexerServerQueryRequestByType, IndexerServerQueryResponseByType } from './types/serverTypes.js';
5
- import '@nadohq/utils';
6
5
  import 'viem';
7
6
  import './types/CandlestickPeriod.js';
8
7
  import './types/IndexerEventType.js';
@@ -3,19 +3,17 @@ import {
3
3
  getDefaultRecvTime,
4
4
  getNadoEIP712Values,
5
5
  getSignedTransactionRequest,
6
- subaccountFromHex,
7
- subaccountToHex
8
- } from "@nadohq/contracts";
9
- import {
10
6
  getValidatedHex,
11
7
  mapValues,
12
8
  nowInSeconds,
13
9
  removeDecimals,
10
+ subaccountFromHex,
11
+ subaccountToHex,
14
12
  toBigDecimal,
15
13
  toBigInt,
16
14
  toIntegerString,
17
15
  WalletNotProvidedError
18
- } from "@nadohq/utils";
16
+ } from "@nadohq/shared";
19
17
  import axios from "axios";
20
18
  import {
21
19
  mapIndexerCandlesticks,
@@ -28,18 +26,20 @@ import {
28
26
  mapIndexerMakerStatistics,
29
27
  mapIndexerMarketSnapshot,
30
28
  mapIndexerMatchEventBalances,
29
+ mapIndexerNlpSnapshot,
31
30
  mapIndexerOrder,
32
31
  mapIndexerPerpPrices,
33
32
  mapIndexerProductPayment,
34
33
  mapIndexerServerProduct,
35
- mapIndexerNlpSnapshot,
36
34
  mapSnapshotsIntervalToServerParams
37
35
  } from "./dataMappers.js";
38
36
  var IndexerBaseClient = class {
39
37
  constructor(opts) {
40
38
  this.opts = opts;
41
39
  this.axiosInstance = axios.create({
42
- withCredentials: true
40
+ withCredentials: true,
41
+ // We have custom logic to validate response status and create an appropriate error
42
+ validateStatus: () => true
43
43
  });
44
44
  this.v2Url = opts.v2Url ? opts.v2Url : opts.url.replace("v1", "v2");
45
45
  }