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

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 -59
  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 +8 -11
  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 +104 -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 +9 -14
  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 +6 -7
  29. package/dist/types/clientTypes.d.ts +6 -7
  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 +14 -17
  49. package/src/IndexerClient.ts +2 -2
  50. package/src/dataMappers.ts +13 -18
  51. package/src/endpoints.ts +2 -2
  52. package/src/types/clientTypes.ts +9 -9
  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
@@ -4,23 +4,21 @@ import {
4
4
  getDefaultRecvTime,
5
5
  getNadoEIP712Values,
6
6
  getSignedTransactionRequest,
7
+ getValidatedHex,
8
+ mapValues,
9
+ nowInSeconds,
10
+ removeDecimals,
7
11
  SignableRequestType,
8
12
  SignableRequestTypeToParams,
9
13
  SignedTx,
10
14
  subaccountFromHex,
11
15
  subaccountToHex,
12
- WalletClientWithAccount,
13
- } from '@nadohq/contracts';
14
- import {
15
- getValidatedHex,
16
- mapValues,
17
- nowInSeconds,
18
- removeDecimals,
19
16
  toBigDecimal,
20
17
  toBigInt,
21
18
  toIntegerString,
19
+ WalletClientWithAccount,
22
20
  WalletNotProvidedError,
23
- } from '@nadohq/utils';
21
+ } from '@nadohq/shared';
24
22
  import axios, { AxiosInstance, AxiosResponse } from 'axios';
25
23
  import {
26
24
  mapIndexerCandlesticks,
@@ -33,11 +31,11 @@ import {
33
31
  mapIndexerMakerStatistics,
34
32
  mapIndexerMarketSnapshot,
35
33
  mapIndexerMatchEventBalances,
34
+ mapIndexerNlpSnapshot,
36
35
  mapIndexerOrder,
37
36
  mapIndexerPerpPrices,
38
37
  mapIndexerProductPayment,
39
38
  mapIndexerServerProduct,
40
- mapIndexerNlpSnapshot,
41
39
  mapSnapshotsIntervalToServerParams,
42
40
  } from './dataMappers';
43
41
  import {
@@ -80,6 +78,8 @@ import {
80
78
  GetIndexerMultiProductSnapshotsResponse,
81
79
  GetIndexerMultiSubaccountSnapshotsParams,
82
80
  GetIndexerMultiSubaccountSnapshotsResponse,
81
+ GetIndexerNlpSnapshotsParams,
82
+ GetIndexerNlpSnapshotsResponse,
83
83
  GetIndexerOraclePricesParams,
84
84
  GetIndexerOraclePricesResponse,
85
85
  GetIndexerOrdersParams,
@@ -91,8 +91,8 @@ import {
91
91
  GetIndexerQuotePriceResponse,
92
92
  GetIndexerReferralCodeParams,
93
93
  GetIndexerReferralCodeResponse,
94
- GetIndexerNlpSnapshotsParams,
95
- GetIndexerNlpSnapshotsResponse,
94
+ GetIndexerSubaccountDDAParams,
95
+ GetIndexerSubaccountDDAResponse,
96
96
  IndexerEventWithTx,
97
97
  IndexerMatchEvent,
98
98
  IndexerOraclePrice,
@@ -104,10 +104,8 @@ import {
104
104
  IndexerSubaccountSnapshot,
105
105
  ListIndexerSubaccountsParams,
106
106
  ListIndexerSubaccountsResponse,
107
- GetIndexerSubaccountDDAParams,
108
107
  UpdateIndexerLeaderboardRegistrationParams,
109
108
  UpdateIndexerLeaderboardRegistrationResponse,
110
- GetIndexerSubaccountDDAResponse,
111
109
  } from './types';
112
110
 
113
111
  export interface IndexerClientOpts {
@@ -132,6 +130,8 @@ export class IndexerBaseClient {
132
130
  this.opts = opts;
133
131
  this.axiosInstance = axios.create({
134
132
  withCredentials: true,
133
+ // We have custom logic to validate response status and create an appropriate error
134
+ validateStatus: () => true,
135
135
  });
136
136
  this.v2Url = opts.v2Url ? opts.v2Url : opts.url.replace('v1', 'v2');
137
137
  }
@@ -797,10 +797,7 @@ export class IndexerBaseClient {
797
797
  params: GetIndexerSubaccountDDAParams,
798
798
  ): Promise<GetIndexerSubaccountDDAResponse> {
799
799
  const baseResponse = await this.query('direct_deposit_address', {
800
- subaccount: subaccountToHex({
801
- subaccountOwner: params.subaccountOwner,
802
- subaccountName: params.subaccountName,
803
- }),
800
+ subaccount: subaccountToHex(params.subaccount),
804
801
  });
805
802
 
806
803
  return {
@@ -3,8 +3,8 @@ import {
3
3
  QUOTE_PRODUCT_ID,
4
4
  subaccountFromHex,
5
5
  NLP_PRODUCT_ID,
6
- } from '@nadohq/contracts';
7
- import { toBigDecimal, toIntegerString } from '@nadohq/utils';
6
+ } from '@nadohq/shared';
7
+ import { toBigDecimal, toIntegerString } from '@nadohq/shared';
8
8
 
9
9
  import { IndexerBaseClient } from './IndexerBaseClient';
10
10
  import {
@@ -1,22 +1,20 @@
1
- import {
2
- getRecvTimeFromOrderNonce,
3
- Market,
4
- parseRawExpirationTimestamp,
5
- PerpMarket,
6
- ProductEngineType,
7
- SpotMarket,
8
- subaccountFromHex,
9
- } from '@nadohq/contracts';
10
1
  import {
11
2
  mapEngineServerPerpProduct,
12
3
  mapEngineServerSpotProduct,
13
4
  } from '@nadohq/engine-client';
14
5
  import {
6
+ getRecvTimeFromOrderNonce,
15
7
  mapValues,
8
+ Market,
9
+ PerpMarket,
10
+ ProductEngineType,
16
11
  removeDecimals,
12
+ SpotMarket,
13
+ subaccountFromHex,
17
14
  toBigDecimal,
18
15
  toIntegerString,
19
- } from '@nadohq/utils';
16
+ unpackOrderAppendix,
17
+ } from '@nadohq/shared';
20
18
  import {
21
19
  Candlestick,
22
20
  IndexerEvent,
@@ -28,6 +26,7 @@ import {
28
26
  IndexerMaker,
29
27
  IndexerMarketSnapshot,
30
28
  IndexerMatchEventBalances,
29
+ IndexerNlpSnapshot,
31
30
  IndexerOrder,
32
31
  IndexerPerpBalance,
33
32
  IndexerPerpPrices,
@@ -42,16 +41,15 @@ import {
42
41
  IndexerServerMaker,
43
42
  IndexerServerMarketSnapshot,
44
43
  IndexerServerMatchEventBalances,
44
+ IndexerServerNlpSnapshot,
45
45
  IndexerServerOrder,
46
46
  IndexerServerPerpPrices,
47
47
  IndexerServerProduct,
48
48
  IndexerServerProductPayment,
49
49
  IndexerServerSnapshotsInterval,
50
50
  IndexerServerTx,
51
- IndexerServerNlpSnapshot,
52
51
  IndexerSnapshotsIntervalParams,
53
52
  IndexerSpotBalance,
54
- IndexerNlpSnapshot,
55
53
  } from './types';
56
54
 
57
55
  export function mapSnapshotsIntervalToServerParams(
@@ -92,16 +90,13 @@ export function mapIndexerServerBalance(
92
90
  }
93
91
 
94
92
  export function mapIndexerOrder(order: IndexerServerOrder): IndexerOrder {
95
- const expiration = toBigDecimal(order.expiration);
96
- const expirationEncodedData = parseRawExpirationTimestamp(order.expiration);
93
+ const appendix = unpackOrderAppendix(order.appendix);
97
94
  return {
98
95
  amount: toBigDecimal(order.amount),
99
96
  digest: order.digest,
100
97
  isolated: order.isolated,
101
- rawExpiration: expiration,
102
- isReduceOnly: expirationEncodedData.reduceOnly,
103
- expiration: expirationEncodedData.expirationTime,
104
- orderType: expirationEncodedData.type,
98
+ expiration: Number(order.expiration),
99
+ appendix,
105
100
  nonce: toBigDecimal(order.nonce),
106
101
  recvTimeSeconds: getRecvTimeFromOrderNonce(order.nonce) / 1000,
107
102
  price: removeDecimals(order.price_x18),
package/src/endpoints.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ChainEnv } from '@nadohq/contracts';
1
+ import { ChainEnv } from '@nadohq/shared';
2
2
 
3
3
  export const INDEXER_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {
4
4
  local: 'http://localhost:8000/indexer',
5
- arbitrumTestnet: 'https://archive.sepolia-test.vertexprotocol.com/v1',
6
5
  arbitrum: 'https://archive.prod.vertexprotocol.com/v1',
6
+ inkTestnet: 'https://archive.test.nado-backend.xyz/v1',
7
7
  };
@@ -1,24 +1,24 @@
1
1
  import {
2
+ BigDecimal,
2
3
  EIP712OrderValues,
3
4
  Market,
4
- OrderExpirationType,
5
+ OrderAppendix,
5
6
  PerpBalance,
6
7
  PerpMarket,
7
8
  ProductEngineType,
8
9
  SpotBalance,
9
10
  SpotMarket,
10
11
  Subaccount,
11
- } from '@nadohq/contracts';
12
- import { BigDecimal } from '@nadohq/utils';
12
+ } from '@nadohq/shared';
13
13
  import { Hex } from 'viem';
14
14
  import { CandlestickPeriod } from './CandlestickPeriod';
15
15
  import { IndexerEventType } from './IndexerEventType';
16
16
  import { IndexerLeaderboardRankType } from './IndexerLeaderboardType';
17
+ import { NadoTx, NadoWithdrawCollateralTx } from './NadoTx';
17
18
  import {
18
19
  IndexerServerFastWithdrawalSignatureParams,
19
20
  IndexerServerListSubaccountsParams,
20
21
  } from './serverTypes';
21
- import { NadoTx, NadoWithdrawCollateralTx } from './NadoTx';
22
22
 
23
23
  /**
24
24
  * Base types
@@ -354,11 +354,9 @@ export interface IndexerOrder {
354
354
  submissionIndex: string;
355
355
  amount: BigDecimal;
356
356
  price: BigDecimal;
357
- // This includes the order type
358
- rawExpiration: BigDecimal;
359
- isReduceOnly: boolean;
360
- orderType: OrderExpirationType;
361
357
  expiration: number;
358
+ // Order metadata from appendix
359
+ appendix: OrderAppendix;
362
360
  nonce: BigDecimal;
363
361
  // Derived from the nonce
364
362
  recvTimeSeconds: number;
@@ -678,7 +676,9 @@ export interface GetIndexerBacklogResponse {
678
676
  txsPerSecond: BigDecimal | null;
679
677
  }
680
678
 
681
- export type GetIndexerSubaccountDDAParams = Subaccount;
679
+ export interface GetIndexerSubaccountDDAParams {
680
+ subaccount: Subaccount;
681
+ }
682
682
 
683
683
  export interface GetIndexerSubaccountDDAResponse {
684
684
  address: string;
@@ -1,5 +1,4 @@
1
- import { Subaccount } from '@nadohq/contracts';
2
- import { BigDecimal } from '@nadohq/utils';
1
+ import { BigDecimal, Subaccount } from '@nadohq/shared';
3
2
  import {
4
3
  GetIndexerInterestFundingPaymentsParams,
5
4
  GetIndexerInterestFundingPaymentsResponse,
@@ -1,4 +1,4 @@
1
- import { EIP712OrderValues } from '@nadohq/contracts';
1
+ import { EIP712OrderValues } from '@nadohq/shared';
2
2
  import {
3
3
  EngineServerPerpBalance,
4
4
  EngineServerPerpProduct,
@@ -99,6 +99,7 @@ export interface IndexerServerOrder {
99
99
  amount: string;
100
100
  price_x18: string;
101
101
  expiration: string;
102
+ appendix: string;
102
103
  nonce: string;
103
104
  base_filled: string;
104
105
  // Includes fee
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  EIP712LeaderboardAuthenticationValues,
3
3
  SignedTx,
4
- } from '@nadohq/contracts';
4
+ } from '@nadohq/shared';
5
5
  import { IndexerEventType } from './IndexerEventType';
6
6
  import { IndexerLeaderboardRankType } from './IndexerLeaderboardType';
7
7
  import { NadoWithdrawCollateralTx } from './NadoTx';
@@ -1,4 +1,4 @@
1
- import { BigDecimal } from '@nadohq/utils';
1
+ import { BigDecimal } from '@nadohq/shared';
2
2
  import { IndexerPerpBalance, IndexerSpotBalance } from '../types';
3
3
 
4
4
  /**