@nadohq/indexer-client 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +2 -0
  2. package/dist/IndexerBaseClient.cjs +608 -0
  3. package/dist/IndexerBaseClient.cjs.map +1 -0
  4. package/dist/IndexerBaseClient.d.cts +183 -0
  5. package/dist/IndexerBaseClient.d.ts +183 -0
  6. package/dist/IndexerBaseClient.js +605 -0
  7. package/dist/IndexerBaseClient.js.map +1 -0
  8. package/dist/IndexerClient.cjs +368 -0
  9. package/dist/IndexerClient.cjs.map +1 -0
  10. package/dist/IndexerClient.d.cts +50 -0
  11. package/dist/IndexerClient.d.ts +50 -0
  12. package/dist/IndexerClient.js +348 -0
  13. package/dist/IndexerClient.js.map +1 -0
  14. package/dist/dataMappers.cjs +324 -0
  15. package/dist/dataMappers.cjs.map +1 -0
  16. package/dist/dataMappers.d.cts +31 -0
  17. package/dist/dataMappers.d.ts +31 -0
  18. package/dist/dataMappers.js +296 -0
  19. package/dist/dataMappers.js.map +1 -0
  20. package/dist/endpoints.cjs +35 -0
  21. package/dist/endpoints.cjs.map +1 -0
  22. package/dist/endpoints.d.cts +5 -0
  23. package/dist/endpoints.d.ts +5 -0
  24. package/dist/endpoints.js +10 -0
  25. package/dist/endpoints.js.map +1 -0
  26. package/dist/index.cjs +31 -0
  27. package/dist/index.cjs.map +1 -0
  28. package/dist/index.d.cts +18 -0
  29. package/dist/index.d.ts +18 -0
  30. package/dist/index.js +6 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/types/CandlestickPeriod.cjs +42 -0
  33. package/dist/types/CandlestickPeriod.cjs.map +1 -0
  34. package/dist/types/CandlestickPeriod.d.cts +13 -0
  35. package/dist/types/CandlestickPeriod.d.ts +13 -0
  36. package/dist/types/CandlestickPeriod.js +17 -0
  37. package/dist/types/CandlestickPeriod.js.map +1 -0
  38. package/dist/types/IndexerEventType.cjs +19 -0
  39. package/dist/types/IndexerEventType.cjs.map +1 -0
  40. package/dist/types/IndexerEventType.d.cts +3 -0
  41. package/dist/types/IndexerEventType.d.ts +3 -0
  42. package/dist/types/IndexerEventType.js +1 -0
  43. package/dist/types/IndexerEventType.js.map +1 -0
  44. package/dist/types/IndexerLeaderboardType.cjs +19 -0
  45. package/dist/types/IndexerLeaderboardType.cjs.map +1 -0
  46. package/dist/types/IndexerLeaderboardType.d.cts +3 -0
  47. package/dist/types/IndexerLeaderboardType.d.ts +3 -0
  48. package/dist/types/IndexerLeaderboardType.js +1 -0
  49. package/dist/types/IndexerLeaderboardType.js.map +1 -0
  50. package/dist/types/NadoTx.cjs +19 -0
  51. package/dist/types/NadoTx.cjs.map +1 -0
  52. package/dist/types/NadoTx.d.cts +49 -0
  53. package/dist/types/NadoTx.d.ts +49 -0
  54. package/dist/types/NadoTx.js +1 -0
  55. package/dist/types/NadoTx.js.map +1 -0
  56. package/dist/types/clientTypes.cjs +19 -0
  57. package/dist/types/clientTypes.cjs.map +1 -0
  58. package/dist/types/clientTypes.d.cts +467 -0
  59. package/dist/types/clientTypes.d.ts +467 -0
  60. package/dist/types/clientTypes.js +1 -0
  61. package/dist/types/clientTypes.js.map +1 -0
  62. package/dist/types/collateralEventType.cjs +19 -0
  63. package/dist/types/collateralEventType.cjs.map +1 -0
  64. package/dist/types/collateralEventType.d.cts +3 -0
  65. package/dist/types/collateralEventType.d.ts +3 -0
  66. package/dist/types/collateralEventType.js +1 -0
  67. package/dist/types/collateralEventType.js.map +1 -0
  68. package/dist/types/index.cjs +41 -0
  69. package/dist/types/index.cjs.map +1 -0
  70. package/dist/types/index.d.cts +13 -0
  71. package/dist/types/index.d.ts +13 -0
  72. package/dist/types/index.js +11 -0
  73. package/dist/types/index.js.map +1 -0
  74. package/dist/types/paginatedEventsTypes.cjs +19 -0
  75. package/dist/types/paginatedEventsTypes.cjs.map +1 -0
  76. package/dist/types/paginatedEventsTypes.d.cts +115 -0
  77. package/dist/types/paginatedEventsTypes.d.ts +115 -0
  78. package/dist/types/paginatedEventsTypes.js +1 -0
  79. package/dist/types/paginatedEventsTypes.js.map +1 -0
  80. package/dist/types/serverModelTypes.cjs +19 -0
  81. package/dist/types/serverModelTypes.cjs.map +1 -0
  82. package/dist/types/serverModelTypes.d.cts +224 -0
  83. package/dist/types/serverModelTypes.d.ts +224 -0
  84. package/dist/types/serverModelTypes.js +1 -0
  85. package/dist/types/serverModelTypes.js.map +1 -0
  86. package/dist/types/serverTypes.cjs +19 -0
  87. package/dist/types/serverTypes.cjs.map +1 -0
  88. package/dist/types/serverTypes.d.cts +304 -0
  89. package/dist/types/serverTypes.d.ts +304 -0
  90. package/dist/types/serverTypes.js +1 -0
  91. package/dist/types/serverTypes.js.map +1 -0
  92. package/dist/utils/index.cjs +25 -0
  93. package/dist/utils/index.cjs.map +1 -0
  94. package/dist/utils/index.d.cts +12 -0
  95. package/dist/utils/index.d.ts +12 -0
  96. package/dist/utils/index.js +3 -0
  97. package/dist/utils/index.js.map +1 -0
  98. package/dist/utils/indexerBalanceValue.cjs +43 -0
  99. package/dist/utils/indexerBalanceValue.cjs.map +1 -0
  100. package/dist/utils/indexerBalanceValue.d.cts +39 -0
  101. package/dist/utils/indexerBalanceValue.d.ts +39 -0
  102. package/dist/utils/indexerBalanceValue.js +16 -0
  103. package/dist/utils/indexerBalanceValue.js.map +1 -0
  104. package/package.json +53 -0
  105. package/src/IndexerBaseClient.ts +851 -0
  106. package/src/IndexerClient.ts +468 -0
  107. package/src/dataMappers.ts +362 -0
  108. package/src/endpoints.ts +7 -0
  109. package/src/index.ts +4 -0
  110. package/src/types/CandlestickPeriod.ts +11 -0
  111. package/src/types/IndexerEventType.ts +9 -0
  112. package/src/types/IndexerLeaderboardType.ts +2 -0
  113. package/src/types/NadoTx.ts +63 -0
  114. package/src/types/clientTypes.ts +679 -0
  115. package/src/types/collateralEventType.ts +4 -0
  116. package/src/types/index.ts +9 -0
  117. package/src/types/paginatedEventsTypes.ts +194 -0
  118. package/src/types/serverModelTypes.ts +271 -0
  119. package/src/types/serverTypes.ts +427 -0
  120. package/src/utils/index.ts +1 -0
  121. package/src/utils/indexerBalanceValue.ts +46 -0
@@ -0,0 +1,304 @@
1
+ import { SignedTx, EIP712LeaderboardAuthenticationValues } from '@nadohq/contracts';
2
+ import { IndexerEventType } from './IndexerEventType.js';
3
+ import { IndexerLeaderboardRankType } from './IndexerLeaderboardType.js';
4
+ import { NadoWithdrawCollateralTx } from './NadoTx.js';
5
+ import { IndexerServerMarketSnapshotInterval, IndexerServerSnapshotsInterval, IndexerServerEvent, IndexerServerCandlestick, IndexerServerMarketSnapshot, IndexerServerTx, IndexerServerProductPayment, IndexerServerLeaderboardPosition, IndexerServerLeaderboardContest, IndexerServerLeaderboardRegistration, IndexerServerMaker, IndexerServerMatchEvent, IndexerServerOraclePrice, IndexerServerOrder, IndexerServerProductSnapshot, IndexerServerVlpSnapshot } from './serverModelTypes.js';
6
+ import '@nadohq/engine-client';
7
+
8
+ /**
9
+ * Params
10
+ */
11
+ interface IndexerServerListSubaccountsParams {
12
+ start?: number;
13
+ limit?: number;
14
+ address?: string;
15
+ }
16
+ interface IndexerServerMultiSubaccountSnapshotsParams {
17
+ subaccounts: string[];
18
+ timestamps: number[];
19
+ isolated?: boolean;
20
+ }
21
+ interface IndexerServerReferralCodeParams {
22
+ subaccount: string;
23
+ }
24
+ interface IndexerServerFundingRateParams {
25
+ product_id: number;
26
+ }
27
+ interface IndexerServerFundingRatesParams {
28
+ product_ids: number[];
29
+ }
30
+ interface IndexerServerPriceParams {
31
+ product_id: number;
32
+ }
33
+ interface IndexerServerPerpPricesParams {
34
+ product_ids: number[];
35
+ }
36
+ interface IndexerServerOraclePricesParams {
37
+ product_ids: number[];
38
+ }
39
+ interface IndexerServerCandlesticksParams {
40
+ product_id: number;
41
+ granularity: number;
42
+ max_time?: number;
43
+ limit: number;
44
+ }
45
+ type IndexerEdgeServerCandlesticksParams = IndexerServerCandlesticksParams;
46
+ interface IndexerServerProductsParams {
47
+ product_id: number;
48
+ max_time?: number;
49
+ limit: number;
50
+ idx?: string;
51
+ }
52
+ interface IndexerServerMultiProductsParams {
53
+ product_ids: number[];
54
+ max_time: number[];
55
+ }
56
+ interface IndexerServerEventsParams {
57
+ subaccount?: string;
58
+ product_ids?: number[];
59
+ isolated?: boolean;
60
+ event_types?: IndexerEventType[];
61
+ desc?: boolean;
62
+ idx?: string;
63
+ max_time?: number;
64
+ limit?: {
65
+ raw: number;
66
+ } | {
67
+ txs: number;
68
+ };
69
+ }
70
+ interface IndexerServerOrdersParams {
71
+ subaccount?: string;
72
+ product_ids?: number[];
73
+ digests?: string[];
74
+ max_time?: number;
75
+ limit?: number;
76
+ isolated?: boolean;
77
+ idx?: string;
78
+ }
79
+ interface IndexerServerMatchEventsParams {
80
+ subaccount?: string;
81
+ product_ids?: number[];
82
+ isolated?: boolean;
83
+ max_time?: number;
84
+ limit: number;
85
+ idx?: string;
86
+ }
87
+ interface IndexerServerLinkedSignerParams {
88
+ subaccount: string;
89
+ }
90
+ interface IndexerServerMarketSnapshotsParams {
91
+ interval: IndexerServerMarketSnapshotInterval;
92
+ product_ids?: number[];
93
+ }
94
+ interface IndexerEdgeServerMarketSnapshotsParams {
95
+ interval: IndexerServerMarketSnapshotInterval;
96
+ }
97
+ interface IndexerServerInterestFundingParams {
98
+ subaccount: string;
99
+ product_ids: number[];
100
+ max_idx?: string;
101
+ max_time?: number;
102
+ limit: number;
103
+ }
104
+ interface IndexerServerMakerStatisticsParams {
105
+ product_id: number;
106
+ epoch: number;
107
+ interval: number;
108
+ }
109
+ interface IndexerServerLeaderboardParams {
110
+ contest_id: number;
111
+ rank_type: IndexerLeaderboardRankType;
112
+ start?: number | string;
113
+ limit?: number | string;
114
+ }
115
+ interface IndexerServerLeaderboardRankParams {
116
+ subaccount: string;
117
+ contest_ids: number[];
118
+ }
119
+ interface IndexerServerLeaderboardContestsParams {
120
+ contest_ids: number[];
121
+ }
122
+ interface IndexerServerLeaderboardRegistrationParams {
123
+ subaccount: string;
124
+ contest_id: number;
125
+ update_registration: SignedTx<EIP712LeaderboardAuthenticationValues> | null;
126
+ }
127
+ interface IndexerServerFastWithdrawalSignatureParams {
128
+ /**
129
+ * The submission index of the WithdrawCollateral tx to be used for fast withdraw.
130
+ */
131
+ idx: number | string;
132
+ }
133
+ interface IndexerServerVlpSnapshotsParams {
134
+ interval: IndexerServerSnapshotsInterval;
135
+ }
136
+ interface IndexerServerQueryRequestByType {
137
+ account_snapshots: IndexerServerMultiSubaccountSnapshotsParams;
138
+ backlog: Record<string, never>;
139
+ candlesticks: IndexerServerCandlesticksParams;
140
+ edge_candlesticks: IndexerEdgeServerCandlesticksParams;
141
+ edge_market_snapshots: IndexerEdgeServerMarketSnapshotsParams;
142
+ events: IndexerServerEventsParams;
143
+ fast_withdrawal_signature: IndexerServerFastWithdrawalSignatureParams;
144
+ funding_rate: IndexerServerFundingRateParams;
145
+ funding_rates: IndexerServerFundingRatesParams;
146
+ interest_and_funding: IndexerServerInterestFundingParams;
147
+ leaderboard: IndexerServerLeaderboardParams;
148
+ leaderboard_contests: IndexerServerLeaderboardContestsParams;
149
+ leaderboard_rank: IndexerServerLeaderboardRankParams;
150
+ leaderboard_registration: IndexerServerLeaderboardRegistrationParams;
151
+ linked_signer_rate_limit: IndexerServerLinkedSignerParams;
152
+ maker_statistics: IndexerServerMakerStatisticsParams;
153
+ market_snapshots: IndexerServerMarketSnapshotsParams;
154
+ matches: IndexerServerMatchEventsParams;
155
+ oracle_price: IndexerServerOraclePricesParams;
156
+ orders: IndexerServerOrdersParams;
157
+ perp_prices: IndexerServerPerpPricesParams;
158
+ price: IndexerServerPriceParams;
159
+ product_snapshots: IndexerServerMultiProductsParams;
160
+ products: IndexerServerProductsParams;
161
+ referral_code: IndexerServerReferralCodeParams;
162
+ subaccounts: IndexerServerListSubaccountsParams;
163
+ usdc_price: Record<string, never>;
164
+ vlp_snapshots: IndexerServerVlpSnapshotsParams;
165
+ }
166
+ type IndexerServerQueryRequestType = keyof IndexerServerQueryRequestByType;
167
+ /**
168
+ * Responses
169
+ */
170
+ interface IndexerServerListSubaccountsResponse {
171
+ subaccounts: {
172
+ id: string;
173
+ subaccount: string;
174
+ }[];
175
+ }
176
+ interface IndexerServerMultiSubaccountSnapshotsResponse {
177
+ snapshots: Record<string, Record<string, IndexerServerEvent[]>>;
178
+ }
179
+ interface IndexerServerReferralCodeResponse {
180
+ referral_code: string | null;
181
+ }
182
+ interface IndexerServerFundingRate {
183
+ product_id: number;
184
+ funding_rate_x18: string;
185
+ update_time: number;
186
+ }
187
+ type IndexerServerFundingRateResponse = IndexerServerFundingRate;
188
+ type IndexerServerFundingRatesResponse = Record<string, IndexerServerFundingRate>;
189
+ interface IndexerServerPerpPrices {
190
+ product_id: number;
191
+ index_price_x18: string;
192
+ mark_price_x18: string;
193
+ update_time: number;
194
+ }
195
+ type IndexerServerPriceResponse = IndexerServerPerpPrices;
196
+ type IndexerServerPerpPricesResponse = Record<string, IndexerServerPerpPrices>;
197
+ interface IndexerServerOraclePricesResponse {
198
+ prices: IndexerServerOraclePrice[];
199
+ }
200
+ interface IndexerServerCandlesticksResponse {
201
+ candlesticks: IndexerServerCandlestick[];
202
+ }
203
+ type IndexerEdgeServerCandlesticksResponse = IndexerServerCandlesticksResponse;
204
+ interface IndexerServerProductsResponse {
205
+ products: IndexerServerProductSnapshot[];
206
+ txs: IndexerServerTx[];
207
+ }
208
+ type IndexerServerMultiProductsResponse = Record<string, Record<string, IndexerServerProductSnapshot>>;
209
+ interface IndexerServerEventsResponse {
210
+ events: IndexerServerEvent[];
211
+ txs: IndexerServerTx[];
212
+ }
213
+ interface IndexerServerOrdersResponse {
214
+ orders: IndexerServerOrder[];
215
+ }
216
+ interface IndexerServerMatchEventsResponse {
217
+ matches: IndexerServerMatchEvent[];
218
+ txs: IndexerServerTx[];
219
+ }
220
+ interface IndexerServerUsdcPriceResponse {
221
+ price_x18: string;
222
+ }
223
+ interface IndexerServerLinkedSignerResponse {
224
+ total_tx_limit: string;
225
+ remaining_tx: string;
226
+ wait_time: string;
227
+ signer: string;
228
+ }
229
+ interface IndexerServerMarketSnapshotsResponse {
230
+ snapshots: IndexerServerMarketSnapshot[];
231
+ }
232
+ interface IndexerEdgeServerMarketSnapshotsResponse {
233
+ snapshots: Record<number, IndexerServerMarketSnapshot[]>;
234
+ }
235
+ interface IndexerServerInterestFundingResponse {
236
+ interest_payments: IndexerServerProductPayment[];
237
+ funding_payments: IndexerServerProductPayment[];
238
+ next_idx: string;
239
+ }
240
+ interface IndexerServerMakerStatisticsResponse {
241
+ reward_coefficient: string;
242
+ makers: IndexerServerMaker[];
243
+ }
244
+ interface IndexerServerLeaderboardResponse {
245
+ positions: IndexerServerLeaderboardPosition[];
246
+ }
247
+ interface IndexerServerLeaderboardRegistrationResponse {
248
+ registration: IndexerServerLeaderboardRegistration | null;
249
+ }
250
+ interface IndexerServerLeaderboardRankResponse {
251
+ positions: Record<string, IndexerServerLeaderboardPosition>;
252
+ }
253
+ interface IndexerServerLeaderboardContestsResponse {
254
+ contests: IndexerServerLeaderboardContest[];
255
+ }
256
+ interface IndexerServerFastWithdrawalSignatureResponse {
257
+ idx: string;
258
+ tx: NadoWithdrawCollateralTx['withdraw_collateral'];
259
+ tx_bytes: string;
260
+ signatures: string[];
261
+ }
262
+ interface IndexerServerVlpSnapshotsResponse {
263
+ snapshots: IndexerServerVlpSnapshot[];
264
+ }
265
+ interface IndexerServerBacklogResponse {
266
+ total_txs: string;
267
+ total_submissions: string;
268
+ backlog_size: string;
269
+ updated_at: string;
270
+ backlog_eta_in_seconds: string | null;
271
+ txs_per_second: string | null;
272
+ }
273
+ interface IndexerServerQueryResponseByType {
274
+ account_snapshots: IndexerServerMultiSubaccountSnapshotsResponse;
275
+ backlog: IndexerServerBacklogResponse;
276
+ candlesticks: IndexerServerCandlesticksResponse;
277
+ edge_candlesticks: IndexerEdgeServerCandlesticksResponse;
278
+ edge_market_snapshots: IndexerEdgeServerMarketSnapshotsResponse;
279
+ events: IndexerServerEventsResponse;
280
+ fast_withdrawal_signature: IndexerServerFastWithdrawalSignatureResponse;
281
+ funding_rate: IndexerServerFundingRateResponse;
282
+ funding_rates: IndexerServerFundingRatesResponse;
283
+ interest_and_funding: IndexerServerInterestFundingResponse;
284
+ leaderboard: IndexerServerLeaderboardResponse;
285
+ leaderboard_contests: IndexerServerLeaderboardContestsResponse;
286
+ leaderboard_rank: IndexerServerLeaderboardRankResponse;
287
+ leaderboard_registration: IndexerServerLeaderboardRegistrationResponse;
288
+ linked_signer_rate_limit: IndexerServerLinkedSignerResponse;
289
+ maker_statistics: IndexerServerMakerStatisticsResponse;
290
+ market_snapshots: IndexerServerMarketSnapshotsResponse;
291
+ matches: IndexerServerMatchEventsResponse;
292
+ oracle_price: IndexerServerOraclePricesResponse;
293
+ orders: IndexerServerOrdersResponse;
294
+ perp_prices: IndexerServerPerpPricesResponse;
295
+ price: IndexerServerPriceResponse;
296
+ product_snapshots: IndexerServerMultiProductsResponse;
297
+ products: IndexerServerProductsResponse;
298
+ referral_code: IndexerServerReferralCodeResponse;
299
+ subaccounts: IndexerServerListSubaccountsResponse;
300
+ usdc_price: IndexerServerUsdcPriceResponse;
301
+ vlp_snapshots: IndexerServerVlpSnapshotsResponse;
302
+ }
303
+
304
+ export type { IndexerEdgeServerCandlesticksParams, IndexerEdgeServerCandlesticksResponse, IndexerEdgeServerMarketSnapshotsParams, IndexerEdgeServerMarketSnapshotsResponse, IndexerServerBacklogResponse, IndexerServerCandlesticksParams, IndexerServerCandlesticksResponse, IndexerServerEventsParams, IndexerServerEventsResponse, IndexerServerFastWithdrawalSignatureParams, IndexerServerFastWithdrawalSignatureResponse, IndexerServerFundingRate, IndexerServerFundingRateParams, IndexerServerFundingRateResponse, IndexerServerFundingRatesParams, IndexerServerFundingRatesResponse, IndexerServerInterestFundingParams, IndexerServerInterestFundingResponse, IndexerServerLeaderboardContestsParams, IndexerServerLeaderboardContestsResponse, IndexerServerLeaderboardParams, IndexerServerLeaderboardRankParams, IndexerServerLeaderboardRankResponse, IndexerServerLeaderboardRegistrationParams, IndexerServerLeaderboardRegistrationResponse, IndexerServerLeaderboardResponse, IndexerServerLinkedSignerParams, IndexerServerLinkedSignerResponse, IndexerServerListSubaccountsParams, IndexerServerListSubaccountsResponse, IndexerServerMakerStatisticsParams, IndexerServerMakerStatisticsResponse, IndexerServerMarketSnapshotsParams, IndexerServerMarketSnapshotsResponse, IndexerServerMatchEventsParams, IndexerServerMatchEventsResponse, IndexerServerMultiProductsParams, IndexerServerMultiProductsResponse, IndexerServerMultiSubaccountSnapshotsParams, IndexerServerMultiSubaccountSnapshotsResponse, IndexerServerOraclePricesParams, IndexerServerOraclePricesResponse, IndexerServerOrdersParams, IndexerServerOrdersResponse, IndexerServerPerpPrices, IndexerServerPerpPricesParams, IndexerServerPerpPricesResponse, IndexerServerPriceParams, IndexerServerPriceResponse, IndexerServerProductsParams, IndexerServerProductsResponse, IndexerServerQueryRequestByType, IndexerServerQueryRequestType, IndexerServerQueryResponseByType, IndexerServerReferralCodeParams, IndexerServerReferralCodeResponse, IndexerServerUsdcPriceResponse, IndexerServerVlpSnapshotsParams, IndexerServerVlpSnapshotsResponse };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=serverTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+
17
+ // src/utils/index.ts
18
+ var utils_exports = {};
19
+ module.exports = __toCommonJS(utils_exports);
20
+ __reExport(utils_exports, require("./indexerBalanceValue.cjs"), module.exports);
21
+ // Annotate the CommonJS export names for ESM import in node:
22
+ 0 && (module.exports = {
23
+ ...require("./indexerBalanceValue.cjs")
24
+ });
25
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './indexerBalanceValue';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,sCAAd;","names":[]}
@@ -0,0 +1,12 @@
1
+ export { calcIndexerPerpBalanceNotionalValue, calcIndexerPerpBalanceValue, calcIndexerSpotBalanceValue } from './indexerBalanceValue.cjs';
2
+ import '@nadohq/utils';
3
+ import '../types/clientTypes.cjs';
4
+ import '@nadohq/contracts';
5
+ import 'viem';
6
+ import '../types/CandlestickPeriod.cjs';
7
+ import '../types/IndexerEventType.cjs';
8
+ import '../types/IndexerLeaderboardType.cjs';
9
+ import '../types/serverTypes.cjs';
10
+ import '../types/NadoTx.cjs';
11
+ import '../types/serverModelTypes.cjs';
12
+ import '@nadohq/engine-client';
@@ -0,0 +1,12 @@
1
+ export { calcIndexerPerpBalanceNotionalValue, calcIndexerPerpBalanceValue, calcIndexerSpotBalanceValue } from './indexerBalanceValue.js';
2
+ import '@nadohq/utils';
3
+ import '../types/clientTypes.js';
4
+ import '@nadohq/contracts';
5
+ import 'viem';
6
+ import '../types/CandlestickPeriod.js';
7
+ import '../types/IndexerEventType.js';
8
+ import '../types/IndexerLeaderboardType.js';
9
+ import '../types/serverTypes.js';
10
+ import '../types/NadoTx.js';
11
+ import '../types/serverModelTypes.js';
12
+ import '@nadohq/engine-client';
@@ -0,0 +1,3 @@
1
+ // src/utils/index.ts
2
+ export * from "./indexerBalanceValue.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './indexerBalanceValue';\n"],"mappings":";AAAA,cAAc;","names":[]}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/indexerBalanceValue.ts
21
+ var indexerBalanceValue_exports = {};
22
+ __export(indexerBalanceValue_exports, {
23
+ calcIndexerPerpBalanceNotionalValue: () => calcIndexerPerpBalanceNotionalValue,
24
+ calcIndexerPerpBalanceValue: () => calcIndexerPerpBalanceValue,
25
+ calcIndexerSpotBalanceValue: () => calcIndexerSpotBalanceValue
26
+ });
27
+ module.exports = __toCommonJS(indexerBalanceValue_exports);
28
+ function calcIndexerSpotBalanceValue(balance, oraclePrice) {
29
+ return balance.amount.multipliedBy(oraclePrice);
30
+ }
31
+ function calcIndexerPerpBalanceNotionalValue(balance, oraclePrice) {
32
+ return balance.amount.multipliedBy(oraclePrice).abs();
33
+ }
34
+ function calcIndexerPerpBalanceValue(balance, oraclePrice) {
35
+ return balance.amount.multipliedBy(oraclePrice).plus(balance.vQuoteBalance);
36
+ }
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ calcIndexerPerpBalanceNotionalValue,
40
+ calcIndexerPerpBalanceValue,
41
+ calcIndexerSpotBalanceValue
42
+ });
43
+ //# sourceMappingURL=indexerBalanceValue.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/indexerBalanceValue.ts"],"sourcesContent":["import { BigDecimal } from '@nadohq/utils';\nimport { IndexerPerpBalance, IndexerSpotBalance } from '../types';\n\n/**\n * Most of these calculations take oraclePrice as a separate parameter. This allows us to not rely on the Snapshot\n * interfaces to give clients the optionality to pass either the pre or post balance\n */\n\n/**\n * Calculates the quote value of an indexer spot balance\n *\n * @param balance\n * @param oraclePrice\n */\nexport function calcIndexerSpotBalanceValue(\n balance: IndexerSpotBalance,\n oraclePrice: BigDecimal,\n): BigDecimal {\n return balance.amount.multipliedBy(oraclePrice);\n}\n\n/**\n * Calculates the notional value of an indexer perp balance\n *\n * @param balance\n * @param oraclePrice\n */\nexport function calcIndexerPerpBalanceNotionalValue(\n balance: IndexerPerpBalance,\n oraclePrice: BigDecimal,\n): BigDecimal {\n return balance.amount.multipliedBy(oraclePrice).abs();\n}\n\n/**\n * Calculates the true quote value of a indexer perp balance, which is the same as its unrealized pnl / unsettled quote\n *\n * @param balance\n * @param oraclePrice\n */\nexport function calcIndexerPerpBalanceValue(\n balance: IndexerPerpBalance,\n oraclePrice: BigDecimal,\n): BigDecimal {\n return balance.amount.multipliedBy(oraclePrice).plus(balance.vQuoteBalance);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,SAAS,4BACd,SACA,aACY;AACZ,SAAO,QAAQ,OAAO,aAAa,WAAW;AAChD;AAQO,SAAS,oCACd,SACA,aACY;AACZ,SAAO,QAAQ,OAAO,aAAa,WAAW,EAAE,IAAI;AACtD;AAQO,SAAS,4BACd,SACA,aACY;AACZ,SAAO,QAAQ,OAAO,aAAa,WAAW,EAAE,KAAK,QAAQ,aAAa;AAC5E;","names":[]}
@@ -0,0 +1,39 @@
1
+ import { BigDecimal } from '@nadohq/utils';
2
+ import { IndexerSpotBalance, IndexerPerpBalance } from '../types/clientTypes.cjs';
3
+ import '@nadohq/contracts';
4
+ import 'viem';
5
+ import '../types/CandlestickPeriod.cjs';
6
+ import '../types/IndexerEventType.cjs';
7
+ import '../types/IndexerLeaderboardType.cjs';
8
+ import '../types/serverTypes.cjs';
9
+ import '../types/NadoTx.cjs';
10
+ import '../types/serverModelTypes.cjs';
11
+ import '@nadohq/engine-client';
12
+
13
+ /**
14
+ * Most of these calculations take oraclePrice as a separate parameter. This allows us to not rely on the Snapshot
15
+ * interfaces to give clients the optionality to pass either the pre or post balance
16
+ */
17
+ /**
18
+ * Calculates the quote value of an indexer spot balance
19
+ *
20
+ * @param balance
21
+ * @param oraclePrice
22
+ */
23
+ declare function calcIndexerSpotBalanceValue(balance: IndexerSpotBalance, oraclePrice: BigDecimal): BigDecimal;
24
+ /**
25
+ * Calculates the notional value of an indexer perp balance
26
+ *
27
+ * @param balance
28
+ * @param oraclePrice
29
+ */
30
+ declare function calcIndexerPerpBalanceNotionalValue(balance: IndexerPerpBalance, oraclePrice: BigDecimal): BigDecimal;
31
+ /**
32
+ * Calculates the true quote value of a indexer perp balance, which is the same as its unrealized pnl / unsettled quote
33
+ *
34
+ * @param balance
35
+ * @param oraclePrice
36
+ */
37
+ declare function calcIndexerPerpBalanceValue(balance: IndexerPerpBalance, oraclePrice: BigDecimal): BigDecimal;
38
+
39
+ export { calcIndexerPerpBalanceNotionalValue, calcIndexerPerpBalanceValue, calcIndexerSpotBalanceValue };
@@ -0,0 +1,39 @@
1
+ import { BigDecimal } from '@nadohq/utils';
2
+ import { IndexerSpotBalance, IndexerPerpBalance } from '../types/clientTypes.js';
3
+ import '@nadohq/contracts';
4
+ import 'viem';
5
+ import '../types/CandlestickPeriod.js';
6
+ import '../types/IndexerEventType.js';
7
+ import '../types/IndexerLeaderboardType.js';
8
+ import '../types/serverTypes.js';
9
+ import '../types/NadoTx.js';
10
+ import '../types/serverModelTypes.js';
11
+ import '@nadohq/engine-client';
12
+
13
+ /**
14
+ * Most of these calculations take oraclePrice as a separate parameter. This allows us to not rely on the Snapshot
15
+ * interfaces to give clients the optionality to pass either the pre or post balance
16
+ */
17
+ /**
18
+ * Calculates the quote value of an indexer spot balance
19
+ *
20
+ * @param balance
21
+ * @param oraclePrice
22
+ */
23
+ declare function calcIndexerSpotBalanceValue(balance: IndexerSpotBalance, oraclePrice: BigDecimal): BigDecimal;
24
+ /**
25
+ * Calculates the notional value of an indexer perp balance
26
+ *
27
+ * @param balance
28
+ * @param oraclePrice
29
+ */
30
+ declare function calcIndexerPerpBalanceNotionalValue(balance: IndexerPerpBalance, oraclePrice: BigDecimal): BigDecimal;
31
+ /**
32
+ * Calculates the true quote value of a indexer perp balance, which is the same as its unrealized pnl / unsettled quote
33
+ *
34
+ * @param balance
35
+ * @param oraclePrice
36
+ */
37
+ declare function calcIndexerPerpBalanceValue(balance: IndexerPerpBalance, oraclePrice: BigDecimal): BigDecimal;
38
+
39
+ export { calcIndexerPerpBalanceNotionalValue, calcIndexerPerpBalanceValue, calcIndexerSpotBalanceValue };
@@ -0,0 +1,16 @@
1
+ // src/utils/indexerBalanceValue.ts
2
+ function calcIndexerSpotBalanceValue(balance, oraclePrice) {
3
+ return balance.amount.multipliedBy(oraclePrice);
4
+ }
5
+ function calcIndexerPerpBalanceNotionalValue(balance, oraclePrice) {
6
+ return balance.amount.multipliedBy(oraclePrice).abs();
7
+ }
8
+ function calcIndexerPerpBalanceValue(balance, oraclePrice) {
9
+ return balance.amount.multipliedBy(oraclePrice).plus(balance.vQuoteBalance);
10
+ }
11
+ export {
12
+ calcIndexerPerpBalanceNotionalValue,
13
+ calcIndexerPerpBalanceValue,
14
+ calcIndexerSpotBalanceValue
15
+ };
16
+ //# sourceMappingURL=indexerBalanceValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/indexerBalanceValue.ts"],"sourcesContent":["import { BigDecimal } from '@nadohq/utils';\nimport { IndexerPerpBalance, IndexerSpotBalance } from '../types';\n\n/**\n * Most of these calculations take oraclePrice as a separate parameter. This allows us to not rely on the Snapshot\n * interfaces to give clients the optionality to pass either the pre or post balance\n */\n\n/**\n * Calculates the quote value of an indexer spot balance\n *\n * @param balance\n * @param oraclePrice\n */\nexport function calcIndexerSpotBalanceValue(\n balance: IndexerSpotBalance,\n oraclePrice: BigDecimal,\n): BigDecimal {\n return balance.amount.multipliedBy(oraclePrice);\n}\n\n/**\n * Calculates the notional value of an indexer perp balance\n *\n * @param balance\n * @param oraclePrice\n */\nexport function calcIndexerPerpBalanceNotionalValue(\n balance: IndexerPerpBalance,\n oraclePrice: BigDecimal,\n): BigDecimal {\n return balance.amount.multipliedBy(oraclePrice).abs();\n}\n\n/**\n * Calculates the true quote value of a indexer perp balance, which is the same as its unrealized pnl / unsettled quote\n *\n * @param balance\n * @param oraclePrice\n */\nexport function calcIndexerPerpBalanceValue(\n balance: IndexerPerpBalance,\n oraclePrice: BigDecimal,\n): BigDecimal {\n return balance.amount.multipliedBy(oraclePrice).plus(balance.vQuoteBalance);\n}\n"],"mappings":";AAcO,SAAS,4BACd,SACA,aACY;AACZ,SAAO,QAAQ,OAAO,aAAa,WAAW;AAChD;AAQO,SAAS,oCACd,SACA,aACY;AACZ,SAAO,QAAQ,OAAO,aAAa,WAAW,EAAE,IAAI;AACtD;AAQO,SAAS,4BACd,SACA,aACY;AACZ,SAAO,QAAQ,OAAO,aAAa,WAAW,EAAE,KAAK,QAAQ,aAAa;AAC5E;","names":[]}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@nadohq/indexer-client",
3
+ "version": "0.1.0-alpha.1",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "description": "> TODO: description",
7
+ "author": "Frank Jia <frank@inkfnd.com>",
8
+ "homepage": "",
9
+ "license": "ISC",
10
+ "source": "./src/index.ts",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "repository": "https://github.com/nadohq/nado-typescript-sdk",
15
+ "scripts": {
16
+ "clean": "rm -rf dist && rm -f tsconfig.tsbuildinfo",
17
+ "build": "tsup",
18
+ "dev": "tsc -w",
19
+ "lint": "eslint --cache './**/*.{ts,tsx}'",
20
+ "lint:fix": "eslint --cache --fix './**/*.{ts,tsx}'",
21
+ "typecheck": "tsc --noEmit"
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "src"
26
+ ],
27
+ "exports": {
28
+ ".": {
29
+ "import": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ },
33
+ "require": {
34
+ "types": "./dist/index.d.cts",
35
+ "default": "./dist/index.cjs"
36
+ }
37
+ }
38
+ },
39
+ "dependencies": {
40
+ "@nadohq/contracts": "^0.1.0-alpha.1",
41
+ "@nadohq/engine-client": "^0.1.0-alpha.1",
42
+ "@nadohq/utils": "^0.1.0-alpha.1",
43
+ "axios": "*",
44
+ "ts-mixer": "*"
45
+ },
46
+ "peerDependencies": {
47
+ "viem": "*"
48
+ },
49
+ "devDependencies": {
50
+ "viem": "*"
51
+ },
52
+ "gitHead": "80100d38c43806d1bb57c9139d9577329467d5db"
53
+ }