@nadohq/indexer-client 0.14.0 → 0.17.0

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 (155) hide show
  1. package/dist/CandlestickPeriod-1DtcEiOb.d.ts +15 -0
  2. package/dist/CandlestickPeriod-1DtcEiOb.d.ts.map +1 -0
  3. package/dist/CandlestickPeriod-D3_IoSev.d.cts +15 -0
  4. package/dist/CandlestickPeriod-D3_IoSev.d.cts.map +1 -0
  5. package/dist/IndexerBaseClient-3KfzA2ph.cjs +639 -0
  6. package/dist/IndexerBaseClient-3KfzA2ph.cjs.map +1 -0
  7. package/dist/IndexerBaseClient.cjs +3 -788
  8. package/dist/IndexerBaseClient.d.cts +223 -229
  9. package/dist/IndexerBaseClient.d.cts.map +1 -0
  10. package/dist/IndexerBaseClient.d.ts +223 -229
  11. package/dist/IndexerBaseClient.d.ts.map +1 -0
  12. package/dist/IndexerBaseClient.js +601 -783
  13. package/dist/IndexerBaseClient.js.map +1 -1
  14. package/dist/IndexerClient.cjs +275 -381
  15. package/dist/IndexerClient.cjs.map +1 -1
  16. package/dist/IndexerClient.d.cts +32 -43
  17. package/dist/IndexerClient.d.cts.map +1 -0
  18. package/dist/IndexerClient.d.ts +32 -43
  19. package/dist/IndexerClient.d.ts.map +1 -0
  20. package/dist/IndexerClient.js +273 -362
  21. package/dist/IndexerClient.js.map +1 -1
  22. package/dist/IndexerEventType-B-uXsf-a.d.cts +5 -0
  23. package/dist/IndexerEventType-B-uXsf-a.d.cts.map +1 -0
  24. package/dist/IndexerEventType-DCLkSlgR.d.ts +5 -0
  25. package/dist/IndexerEventType-DCLkSlgR.d.ts.map +1 -0
  26. package/dist/IndexerLeaderboardType-Ck12QVWR.d.cts +13 -0
  27. package/dist/IndexerLeaderboardType-Ck12QVWR.d.cts.map +1 -0
  28. package/dist/IndexerLeaderboardType-DAKw2tfI.d.ts +13 -0
  29. package/dist/IndexerLeaderboardType-DAKw2tfI.d.ts.map +1 -0
  30. package/dist/NadoTx-CWCklgY4.d.ts +50 -0
  31. package/dist/NadoTx-CWCklgY4.d.ts.map +1 -0
  32. package/dist/NadoTx-MYNIlXyq.d.cts +50 -0
  33. package/dist/NadoTx-MYNIlXyq.d.cts.map +1 -0
  34. package/dist/clientTypes-BpxOUu1q.d.ts +709 -0
  35. package/dist/clientTypes-BpxOUu1q.d.ts.map +1 -0
  36. package/dist/clientTypes-BsJ2yIC4.d.cts +709 -0
  37. package/dist/clientTypes-BsJ2yIC4.d.cts.map +1 -0
  38. package/dist/collateralEventType-CzH_2iTV.d.ts +5 -0
  39. package/dist/collateralEventType-CzH_2iTV.d.ts.map +1 -0
  40. package/dist/collateralEventType-DIm6Te7F.d.cts +5 -0
  41. package/dist/collateralEventType-DIm6Te7F.d.cts.map +1 -0
  42. package/dist/dataMappers.cjs +269 -346
  43. package/dist/dataMappers.cjs.map +1 -1
  44. package/dist/dataMappers.d.cts +7 -12
  45. package/dist/dataMappers.d.cts.map +1 -0
  46. package/dist/dataMappers.d.ts +7 -12
  47. package/dist/dataMappers.d.ts.map +1 -0
  48. package/dist/dataMappers.js +248 -314
  49. package/dist/dataMappers.js.map +1 -1
  50. package/dist/endpoints.cjs +8 -32
  51. package/dist/endpoints.cjs.map +1 -1
  52. package/dist/endpoints.d.cts +4 -2
  53. package/dist/endpoints.d.cts.map +1 -0
  54. package/dist/endpoints.d.ts +4 -2
  55. package/dist/endpoints.d.ts.map +1 -0
  56. package/dist/endpoints.js +8 -8
  57. package/dist/endpoints.js.map +1 -1
  58. package/dist/index-D6CnpA_r.d.cts +1 -0
  59. package/dist/index-DhI2LvVQ.d.ts +1 -0
  60. package/dist/index.cjs +15 -33
  61. package/dist/index.d.cts +14 -18
  62. package/dist/index.d.ts +14 -18
  63. package/dist/index.js +8 -7
  64. package/dist/indexerBalanceValue-4AuNuTAc.d.cts +32 -0
  65. package/dist/indexerBalanceValue-4AuNuTAc.d.cts.map +1 -0
  66. package/dist/indexerBalanceValue-B0OggI67.d.ts +32 -0
  67. package/dist/indexerBalanceValue-B0OggI67.d.ts.map +1 -0
  68. package/dist/paginatedEventsTypes-DtGDU-kI.d.cts +110 -0
  69. package/dist/paginatedEventsTypes-DtGDU-kI.d.cts.map +1 -0
  70. package/dist/paginatedEventsTypes-RwXoQrEa.d.ts +110 -0
  71. package/dist/paginatedEventsTypes-RwXoQrEa.d.ts.map +1 -0
  72. package/dist/serverModelTypes-CM2g040o.d.cts +262 -0
  73. package/dist/serverModelTypes-CM2g040o.d.cts.map +1 -0
  74. package/dist/serverModelTypes-DPHMUSZe.d.ts +262 -0
  75. package/dist/serverModelTypes-DPHMUSZe.d.ts.map +1 -0
  76. package/dist/serverTypes-BMSNh2GK.d.cts +452 -0
  77. package/dist/serverTypes-BMSNh2GK.d.cts.map +1 -0
  78. package/dist/serverTypes-c8IABU73.d.ts +452 -0
  79. package/dist/serverTypes-c8IABU73.d.ts.map +1 -0
  80. package/dist/types/CandlestickPeriod.cjs +16 -40
  81. package/dist/types/CandlestickPeriod.cjs.map +1 -1
  82. package/dist/types/CandlestickPeriod.d.cts +2 -13
  83. package/dist/types/CandlestickPeriod.d.ts +2 -13
  84. package/dist/types/CandlestickPeriod.js +16 -16
  85. package/dist/types/CandlestickPeriod.js.map +1 -1
  86. package/dist/types/IndexerEventType.cjs +0 -19
  87. package/dist/types/IndexerEventType.d.cts +2 -3
  88. package/dist/types/IndexerEventType.d.ts +2 -3
  89. package/dist/types/IndexerEventType.js +1 -1
  90. package/dist/types/IndexerLeaderboardType.cjs +0 -19
  91. package/dist/types/IndexerLeaderboardType.d.cts +2 -11
  92. package/dist/types/IndexerLeaderboardType.d.ts +2 -11
  93. package/dist/types/IndexerLeaderboardType.js +1 -1
  94. package/dist/types/NadoTx.cjs +0 -19
  95. package/dist/types/NadoTx.d.cts +2 -48
  96. package/dist/types/NadoTx.d.ts +2 -48
  97. package/dist/types/NadoTx.js +1 -1
  98. package/dist/types/clientTypes.cjs +0 -19
  99. package/dist/types/clientTypes.d.cts +2 -709
  100. package/dist/types/clientTypes.d.ts +2 -709
  101. package/dist/types/clientTypes.js +1 -1
  102. package/dist/types/collateralEventType.cjs +0 -19
  103. package/dist/types/collateralEventType.d.cts +2 -3
  104. package/dist/types/collateralEventType.d.ts +2 -3
  105. package/dist/types/collateralEventType.js +1 -1
  106. package/dist/types/index.cjs +3 -41
  107. package/dist/types/index.d.cts +10 -13
  108. package/dist/types/index.d.ts +10 -13
  109. package/dist/types/index.js +2 -11
  110. package/dist/types/paginatedEventsTypes.cjs +0 -19
  111. package/dist/types/paginatedEventsTypes.d.cts +2 -115
  112. package/dist/types/paginatedEventsTypes.d.ts +2 -115
  113. package/dist/types/paginatedEventsTypes.js +1 -1
  114. package/dist/types/serverModelTypes.cjs +0 -19
  115. package/dist/types/serverModelTypes.d.cts +2 -260
  116. package/dist/types/serverModelTypes.d.ts +2 -260
  117. package/dist/types/serverModelTypes.js +1 -1
  118. package/dist/types/serverTypes.cjs +0 -19
  119. package/dist/types/serverTypes.d.cts +2 -451
  120. package/dist/types/serverTypes.d.ts +2 -451
  121. package/dist/types/serverTypes.js +1 -1
  122. package/dist/utils/index.cjs +5 -25
  123. package/dist/utils/index.d.cts +2 -12
  124. package/dist/utils/index.d.ts +2 -12
  125. package/dist/utils/index.js +2 -3
  126. package/dist/utils/indexerBalanceValue.cjs +32 -36
  127. package/dist/utils/indexerBalanceValue.cjs.map +1 -1
  128. package/dist/utils/indexerBalanceValue.d.cts +2 -39
  129. package/dist/utils/indexerBalanceValue.d.ts +2 -39
  130. package/dist/utils/indexerBalanceValue.js +29 -9
  131. package/dist/utils/indexerBalanceValue.js.map +1 -1
  132. package/package.json +10 -10
  133. package/dist/IndexerBaseClient.cjs.map +0 -1
  134. package/dist/index.cjs.map +0 -1
  135. package/dist/index.js.map +0 -1
  136. package/dist/types/IndexerEventType.cjs.map +0 -1
  137. package/dist/types/IndexerEventType.js.map +0 -1
  138. package/dist/types/IndexerLeaderboardType.cjs.map +0 -1
  139. package/dist/types/IndexerLeaderboardType.js.map +0 -1
  140. package/dist/types/NadoTx.cjs.map +0 -1
  141. package/dist/types/NadoTx.js.map +0 -1
  142. package/dist/types/clientTypes.cjs.map +0 -1
  143. package/dist/types/clientTypes.js.map +0 -1
  144. package/dist/types/collateralEventType.cjs.map +0 -1
  145. package/dist/types/collateralEventType.js.map +0 -1
  146. package/dist/types/index.cjs.map +0 -1
  147. package/dist/types/index.js.map +0 -1
  148. package/dist/types/paginatedEventsTypes.cjs.map +0 -1
  149. package/dist/types/paginatedEventsTypes.js.map +0 -1
  150. package/dist/types/serverModelTypes.cjs.map +0 -1
  151. package/dist/types/serverModelTypes.js.map +0 -1
  152. package/dist/types/serverTypes.cjs.map +0 -1
  153. package/dist/types/serverTypes.js.map +0 -1
  154. package/dist/utils/index.cjs.map +0 -1
  155. package/dist/utils/index.js.map +0 -1
@@ -0,0 +1,15 @@
1
+ //#region src/types/CandlestickPeriod.d.ts
2
+ declare enum CandlestickPeriod {
3
+ MIN = 60,
4
+ FIVE_MIN = 300,
5
+ FIFTEEN_MIN = 900,
6
+ HOUR = 3600,
7
+ TWO_HOUR = 7200,
8
+ FOUR_HOUR = 14400,
9
+ DAY = 86400,
10
+ WEEK = 604800,
11
+ MONTH = 2419200
12
+ }
13
+ //#endregion
14
+ export { CandlestickPeriod as t };
15
+ //# sourceMappingURL=CandlestickPeriod-1DtcEiOb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CandlestickPeriod-1DtcEiOb.d.ts","names":[],"sources":["../src/types/src/types/CandlestickPeriod.ts"],"mappings":";aAAY,iBAAA;EACV,GAAA;EACA,QAAA;EACA,WAAA;EACA,IAAA;EACA,QAAA;EACA,SAAA;EACA,GAAA;EACA,IAAA;EACA,KAAA;AAAA"}
@@ -0,0 +1,15 @@
1
+ //#region src/types/CandlestickPeriod.d.ts
2
+ declare enum CandlestickPeriod {
3
+ MIN = 60,
4
+ FIVE_MIN = 300,
5
+ FIFTEEN_MIN = 900,
6
+ HOUR = 3600,
7
+ TWO_HOUR = 7200,
8
+ FOUR_HOUR = 14400,
9
+ DAY = 86400,
10
+ WEEK = 604800,
11
+ MONTH = 2419200
12
+ }
13
+ //#endregion
14
+ export { CandlestickPeriod as t };
15
+ //# sourceMappingURL=CandlestickPeriod-D3_IoSev.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CandlestickPeriod-D3_IoSev.d.cts","names":[],"sources":["../src/types/src/types/CandlestickPeriod.ts"],"mappings":";aAAY,iBAAA;EACV,GAAA;EACA,QAAA;EACA,WAAA;EACA,IAAA;EACA,QAAA;EACA,SAAA;EACA,GAAA;EACA,IAAA;EACA,KAAA;AAAA"}
@@ -0,0 +1,639 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ const require_dataMappers = require("./dataMappers.cjs");
24
+ let _nadohq_shared = require("@nadohq/shared");
25
+ let axios = require("axios");
26
+ axios = __toESM(axios, 1);
27
+ //#region src/IndexerBaseClient.ts
28
+ /**
29
+ * Base client for all indexer requests
30
+ */
31
+ var IndexerBaseClient = class {
32
+ constructor(opts) {
33
+ this.opts = opts;
34
+ this.axiosInstance = axios.default.create({
35
+ withCredentials: true,
36
+ validateStatus: () => true
37
+ });
38
+ this.v2Url = opts.v2Url ? opts.v2Url : opts.url.replace("v1", "v2");
39
+ }
40
+ /**
41
+ * Sets the linked signer for execute requests
42
+ *
43
+ * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer
44
+ */
45
+ setLinkedSigner(linkedSignerWalletClient) {
46
+ this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? void 0;
47
+ }
48
+ /**
49
+ * List all subaccounts
50
+ *
51
+ * @param params
52
+ */
53
+ async listSubaccounts(params) {
54
+ return (await this.query("subaccounts", params)).subaccounts.map((item) => {
55
+ const subaccount = (0, _nadohq_shared.subaccountFromHex)(item.subaccount);
56
+ return {
57
+ hexId: item.subaccount,
58
+ createdAt: Number(item.created_at),
59
+ isolated: item.isolated,
60
+ ...subaccount
61
+ };
62
+ });
63
+ }
64
+ /**
65
+ * Retrieve snapshots of multiple subaccounts at multiple points in time.
66
+ * Each snapshot is a view of the subaccount's balances at this point in time, with tracked variables for interest, funding, etc.
67
+ *
68
+ * @param params
69
+ */
70
+ async getMultiSubaccountSnapshots(params) {
71
+ const subaccountHexIds = params.subaccounts.map(({ subaccountOwner, subaccountName }) => (0, _nadohq_shared.subaccountToHex)({
72
+ subaccountOwner,
73
+ subaccountName
74
+ }));
75
+ return {
76
+ subaccountHexIds,
77
+ snapshots: (0, _nadohq_shared.mapValues)((await this.query("account_snapshots", {
78
+ subaccounts: subaccountHexIds,
79
+ timestamps: params.timestamps,
80
+ isolated: params.isolated
81
+ })).snapshots, (balanceSnapshots) => {
82
+ const snapshotByTimestamp = {};
83
+ Object.entries(balanceSnapshots).forEach(([timestamp, events]) => {
84
+ const balances = events.map(require_dataMappers.mapIndexerEvent);
85
+ snapshotByTimestamp[timestamp] = {
86
+ timestamp: (0, _nadohq_shared.toBigNumber)(timestamp),
87
+ balances
88
+ };
89
+ });
90
+ return snapshotByTimestamp;
91
+ })
92
+ };
93
+ }
94
+ /**
95
+ * Retrieves referral code for an address
96
+ *
97
+ * @param params
98
+ */
99
+ async getReferralCode(params) {
100
+ return { referralCode: (await this.query("referral_code", { subaccount: (0, _nadohq_shared.subaccountToHex)({
101
+ subaccountOwner: params.subaccount.subaccountOwner,
102
+ subaccountName: params.subaccount.subaccountName
103
+ }) })).referral_code };
104
+ }
105
+ /**
106
+ * Retrieves funding rate for a product, where 1 = 100%
107
+ * @param params
108
+ */
109
+ async getFundingRate(params) {
110
+ return require_dataMappers.mapIndexerFundingRate(await this.query("funding_rate", { product_id: params.productId }));
111
+ }
112
+ /**
113
+ * Retrieves funding rate for multiple products, where 1 = 100%
114
+ * @param params
115
+ */
116
+ async getMultiProductFundingRates(params) {
117
+ return (0, _nadohq_shared.mapValues)(await this.query("funding_rates", { product_ids: params.productIds }), require_dataMappers.mapIndexerFundingRate);
118
+ }
119
+ /**
120
+ * Retrieves latest mark/index price for a perp product
121
+ * @param params
122
+ */
123
+ async getPerpPrices(params) {
124
+ return require_dataMappers.mapIndexerPerpPrices(await this.query("price", { product_id: params.productId }));
125
+ }
126
+ /**
127
+ * Retrieves latest mark/index price for multiple perp products
128
+ * @param params
129
+ */
130
+ async getMultiProductPerpPrices(params) {
131
+ return (0, _nadohq_shared.mapValues)(await this.query("perp_prices", { product_ids: params.productIds }), require_dataMappers.mapIndexerPerpPrices);
132
+ }
133
+ /**
134
+ * Retrieves latest oracle prices for provided products
135
+ * @param params
136
+ */
137
+ async getOraclePrices(params) {
138
+ return (await this.query("oracle_price", { product_ids: params.productIds })).prices.map((price) => {
139
+ return {
140
+ oraclePrice: (0, _nadohq_shared.removeDecimals)(price.oracle_price_x18),
141
+ updateTime: (0, _nadohq_shared.toBigNumber)(price.update_time),
142
+ productId: price.product_id
143
+ };
144
+ });
145
+ }
146
+ /**
147
+ * Retrieves candlesticks for a product
148
+ * @param params
149
+ */
150
+ async getCandlesticks(params) {
151
+ return (await this.query("candlesticks", {
152
+ product_id: params.productId,
153
+ max_time: params.maxTimeInclusive,
154
+ limit: params.limit,
155
+ granularity: params.period
156
+ })).candlesticks.map(require_dataMappers.mapIndexerCandlesticks);
157
+ }
158
+ /**
159
+ * Retrieves candlesticks for a product from Edge
160
+ * @param params
161
+ */
162
+ async getEdgeCandlesticks(params) {
163
+ return (await this.query("edge_candlesticks", {
164
+ product_id: params.productId,
165
+ max_time: params.maxTimeInclusive,
166
+ limit: params.limit,
167
+ granularity: params.period
168
+ })).candlesticks.map(require_dataMappers.mapIndexerCandlesticks);
169
+ }
170
+ /**
171
+ * Retrieves historical snapshots for a product
172
+ * @param params
173
+ */
174
+ async getProductSnapshots(params) {
175
+ return (await this.query("products", {
176
+ product_id: params.productId,
177
+ max_time: params.maxTimestampInclusive,
178
+ limit: params.limit,
179
+ idx: params.startCursor
180
+ })).products.map((product) => {
181
+ return {
182
+ ...require_dataMappers.mapIndexerServerProduct(product.product),
183
+ submissionIndex: product.submission_idx
184
+ };
185
+ });
186
+ }
187
+ /**
188
+ * Retrieves historical snapshots for multiple products
189
+ * @param params
190
+ */
191
+ async getMultiProductSnapshots(params) {
192
+ return (0, _nadohq_shared.mapValues)(await this.query("product_snapshots", {
193
+ product_ids: params.productIds,
194
+ max_time: params.maxTimestampInclusive ?? [(0, _nadohq_shared.nowInSeconds)()]
195
+ }), (productIdToProduct) => {
196
+ return (0, _nadohq_shared.mapValues)(productIdToProduct, (indexerProduct) => {
197
+ return {
198
+ ...require_dataMappers.mapIndexerServerProduct(indexerProduct.product),
199
+ submissionIndex: indexerProduct.submission_idx
200
+ };
201
+ });
202
+ });
203
+ }
204
+ /**
205
+ * Retrieves historical events
206
+ *
207
+ * @param params
208
+ */
209
+ async getEvents(params) {
210
+ const serverLimit = (() => {
211
+ if (!params.limit) return;
212
+ if (params.limit.type === "events") return { raw: params.limit.value };
213
+ return { txs: params.limit.value };
214
+ })();
215
+ const baseResponse = await this.query("events", {
216
+ subaccounts: params.subaccounts?.map((subaccount) => (0, _nadohq_shared.subaccountToHex)({
217
+ subaccountOwner: subaccount.subaccountOwner,
218
+ subaccountName: subaccount.subaccountName
219
+ })),
220
+ product_ids: params.productIds,
221
+ isolated: params.isolated,
222
+ event_types: params.eventTypes,
223
+ max_time: params.maxTimestampInclusive,
224
+ desc: params.desc,
225
+ limit: serverLimit,
226
+ idx: params.startCursor
227
+ });
228
+ let lastTxIdx = 0;
229
+ return baseResponse.events.map((event) => {
230
+ if (baseResponse.txs[lastTxIdx].submission_idx !== event.submission_idx) lastTxIdx += 1;
231
+ const tx = baseResponse.txs[lastTxIdx];
232
+ return require_dataMappers.mapIndexerEventWithTx(event, tx);
233
+ });
234
+ }
235
+ /**
236
+ * Retrieves historical orders
237
+ * @param params
238
+ */
239
+ async getOrders(params) {
240
+ return (await this.query("orders", {
241
+ subaccounts: params?.subaccounts?.map((subaccount) => (0, _nadohq_shared.subaccountToHex)({
242
+ subaccountOwner: subaccount.subaccountOwner,
243
+ subaccountName: subaccount.subaccountName
244
+ })),
245
+ product_ids: params.productIds,
246
+ trigger_types: params.triggerTypes,
247
+ isolated: params.isolated,
248
+ digests: params.digests,
249
+ max_time: params.maxTimestampInclusive,
250
+ limit: params.limit,
251
+ idx: params.startCursor
252
+ })).orders.map(require_dataMappers.mapIndexerOrder);
253
+ }
254
+ /**
255
+ * Gets match order events, this will return the same events as the events query, but with additional information
256
+ * to identify the order that was matched
257
+ *
258
+ * @param params
259
+ */
260
+ async getMatchEvents(params) {
261
+ const baseResponse = await this.query("matches", {
262
+ subaccounts: params?.subaccounts?.map((subaccount) => (0, _nadohq_shared.subaccountToHex)({
263
+ subaccountOwner: subaccount.subaccountOwner,
264
+ subaccountName: subaccount.subaccountName
265
+ })),
266
+ product_ids: params.productIds,
267
+ isolated: params.isolated,
268
+ max_time: params.maxTimestampInclusive,
269
+ limit: params.limit,
270
+ idx: params.startCursor
271
+ });
272
+ let lastTxIdx = 0;
273
+ return baseResponse.matches.map((matchEvent) => {
274
+ if (baseResponse.txs[lastTxIdx].submission_idx !== matchEvent.submission_idx) lastTxIdx += 1;
275
+ const { tx, timestamp } = baseResponse.txs[lastTxIdx];
276
+ const postBalances = require_dataMappers.mapIndexerMatchEventBalances(matchEvent.post_balance);
277
+ return {
278
+ productId: postBalances.base.productId,
279
+ isolated: matchEvent.isolated,
280
+ totalFee: (0, _nadohq_shared.toBigNumber)(matchEvent.fee),
281
+ sequencerFee: (0, _nadohq_shared.toBigNumber)(matchEvent.sequencer_fee),
282
+ builderFee: (0, _nadohq_shared.toBigNumber)(matchEvent.builder_fee),
283
+ baseFilled: (0, _nadohq_shared.toBigNumber)(matchEvent.base_filled),
284
+ quoteFilled: (0, _nadohq_shared.toBigNumber)(matchEvent.quote_filled),
285
+ cumulativeFee: (0, _nadohq_shared.toBigNumber)(matchEvent.cumulative_fee),
286
+ cumulativeBaseFilled: (0, _nadohq_shared.toBigNumber)(matchEvent.cumulative_base_filled),
287
+ cumulativeQuoteFilled: (0, _nadohq_shared.toBigNumber)(matchEvent.cumulative_quote_filled),
288
+ digest: matchEvent.digest,
289
+ order: matchEvent.order,
290
+ submissionIndex: matchEvent.submission_idx,
291
+ timestamp: (0, _nadohq_shared.toBigNumber)(timestamp),
292
+ preEventTrackedVars: {
293
+ netEntryUnrealized: (0, _nadohq_shared.toBigNumber)(matchEvent.net_entry_unrealized),
294
+ netEntryCumulative: (0, _nadohq_shared.toBigNumber)(matchEvent.net_entry_cumulative)
295
+ },
296
+ preBalances: require_dataMappers.mapIndexerMatchEventBalances(matchEvent.pre_balance),
297
+ postBalances,
298
+ tx,
299
+ isTaker: matchEvent.is_taker,
300
+ realizedPnl: (0, _nadohq_shared.toBigNumber)(matchEvent.realized_pnl),
301
+ closedAmount: (0, _nadohq_shared.toBigNumber)(matchEvent.closed_amount),
302
+ closedNetEntry: (0, _nadohq_shared.toBigNumber)(matchEvent.closed_net_entry),
303
+ margin: matchEvent.margin ? (0, _nadohq_shared.toBigNumber)(matchEvent.margin) : null,
304
+ ...(0, _nadohq_shared.subaccountFromHex)(matchEvent.order.sender)
305
+ };
306
+ });
307
+ }
308
+ /**
309
+ * Retrieves historical funding & interest payments.
310
+ * NOTE: `limit` is an upperbound. If a user changes position size such that his position is 0 during each funding/interest tick,
311
+ * then the indexer will return fewer than `limit` results per page. However, more events can be present. This means that
312
+ * 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.
313
+ *
314
+ * @param params
315
+ */
316
+ async getInterestFundingPayments(params) {
317
+ const baseResponse = await this.query("interest_and_funding", {
318
+ subaccount: (0, _nadohq_shared.subaccountToHex)({
319
+ subaccountOwner: params.subaccount.subaccountOwner,
320
+ subaccountName: params.subaccount.subaccountName
321
+ }),
322
+ product_ids: params.productIds,
323
+ max_time: params.maxTimestampInclusive,
324
+ limit: params.limit,
325
+ max_idx: params.startCursor
326
+ });
327
+ return {
328
+ fundingPayments: baseResponse.funding_payments.map(require_dataMappers.mapIndexerProductPayment),
329
+ interestPayments: baseResponse.interest_payments.map(require_dataMappers.mapIndexerProductPayment),
330
+ nextCursor: baseResponse.next_idx
331
+ };
332
+ }
333
+ /**
334
+ * Gets quote (USDT) price in terms of USD
335
+ */
336
+ async getQuotePrice() {
337
+ return { price: (0, _nadohq_shared.removeDecimals)((await this.query("quote_price", {})).price_x18) };
338
+ }
339
+ /**
340
+ * Fetches currently registered linked signer with the remaining txs allowed for the subaccount
341
+ */
342
+ async getLinkedSignerWithRateLimit(params) {
343
+ const baseResponse = await this.query("linked_signer_rate_limit", { subaccount: (0, _nadohq_shared.subaccountToHex)(params.subaccount) });
344
+ return {
345
+ totalTxLimit: (0, _nadohq_shared.toBigNumber)(baseResponse.total_tx_limit),
346
+ remainingTxs: (0, _nadohq_shared.toBigNumber)(baseResponse.remaining_tx),
347
+ signer: baseResponse.signer,
348
+ waitTimeUntilNextTx: (0, _nadohq_shared.toBigNumber)(baseResponse.wait_time)
349
+ };
350
+ }
351
+ /**
352
+ * Retrieve historical market snapshots
353
+ * @param params
354
+ */
355
+ async getMarketSnapshots(params) {
356
+ return (await this.query("market_snapshots", {
357
+ interval: require_dataMappers.mapSnapshotsIntervalToServerParams(params),
358
+ product_ids: params.productIds
359
+ })).snapshots.map(require_dataMappers.mapIndexerMarketSnapshot);
360
+ }
361
+ /**
362
+ * Retrieve historical market snapshots from Edge
363
+ * @param params
364
+ */
365
+ async getEdgeMarketSnapshots(params) {
366
+ return (0, _nadohq_shared.mapValues)((await this.query("edge_market_snapshots", { interval: require_dataMappers.mapSnapshotsIntervalToServerParams(params) })).snapshots, (snapshots) => snapshots.map(require_dataMappers.mapIndexerMarketSnapshot));
367
+ }
368
+ /**
369
+ * Retrieve maker statistics for a given epoch
370
+ *
371
+ * @param params
372
+ */
373
+ async getMakerStatistics(params) {
374
+ const baseResponse = await this.query("maker_statistics", {
375
+ product_id: params.productId,
376
+ epoch: params.epoch,
377
+ interval: params.interval
378
+ });
379
+ return {
380
+ rewardCoefficient: (0, _nadohq_shared.toBigNumber)(baseResponse.reward_coefficient),
381
+ makers: baseResponse.makers.map(require_dataMappers.mapIndexerMakerStatistics)
382
+ };
383
+ }
384
+ /**
385
+ * Retrieve leaderboard stats for a given contest
386
+ *
387
+ * @param params
388
+ */
389
+ async getLeaderboard(params) {
390
+ return { participants: (await this.query("leaderboard", {
391
+ contest_id: params.contestId,
392
+ rank_type: params.rankType,
393
+ start: params.startCursor,
394
+ limit: params.limit,
395
+ order: params.order
396
+ })).positions.map(require_dataMappers.mapIndexerLeaderboardPosition) };
397
+ }
398
+ /**
399
+ * Retrieve leaderboard ranking of a subaccount on a given contest
400
+ *
401
+ * @param params
402
+ */
403
+ async getLeaderboardParticipant(params) {
404
+ return { participant: (0, _nadohq_shared.mapValues)((await this.query("leaderboard_rank", {
405
+ subaccount: (0, _nadohq_shared.subaccountToHex)(params.subaccount),
406
+ contest_ids: params.contestIds
407
+ })).positions, (position) => require_dataMappers.mapIndexerLeaderboardPosition(position)) };
408
+ }
409
+ /**
410
+ * Registers a subaccount for one or more contests. Requires EIP-712 signing.
411
+ *
412
+ * @param params - Registration parameters including contest IDs and signing config.
413
+ */
414
+ async registerLeaderboard(params) {
415
+ const signatureParams = {
416
+ expiration: (0, _nadohq_shared.toIntegerString)(params.recvTime ?? (0, _nadohq_shared.getDefaultRecvTime)()),
417
+ subaccountName: params.subaccountName,
418
+ subaccountOwner: params.subaccountOwner,
419
+ contestIds: params.contestIds
420
+ };
421
+ const updateRegistrationTx = {
422
+ tx: (0, _nadohq_shared.getNadoEIP712Values)("leaderboard_authentication", signatureParams),
423
+ signature: await this.sign("leaderboard_authentication", params.verifyingAddr, params.chainId, signatureParams)
424
+ };
425
+ return { registrations: (await this.query("leaderboard_register", { update_registration: updateRegistrationTx })).registrations.map(require_dataMappers.mapIndexerLeaderboardRegistration) };
426
+ }
427
+ /**
428
+ * Retrieves contest registrations for a subaccount. Supports batch lookup
429
+ * across multiple contests with an optional active filter.
430
+ *
431
+ * @param params - Query parameters including subaccount and contest IDs.
432
+ */
433
+ async getLeaderboardRegistrations(params) {
434
+ return { registrations: (await this.query("leaderboard_registrations", {
435
+ subaccount: (0, _nadohq_shared.subaccountToHex)(params.subaccount),
436
+ contest_ids: params.contestIds,
437
+ active: params.active
438
+ })).registrations.map(require_dataMappers.mapIndexerLeaderboardRegistration) };
439
+ }
440
+ /**
441
+ * Retrieve metadata of provided leaderboard contests
442
+ *
443
+ * @param params
444
+ */
445
+ async getLeaderboardContests(params) {
446
+ return { contests: (await this.query("leaderboard_contests", {
447
+ contest_ids: params.contestIds,
448
+ active: params.active
449
+ })).contests.map(require_dataMappers.mapIndexerLeaderboardContest) };
450
+ }
451
+ /**
452
+ * Retrieve signature and tx to submit a fast withdrawal
453
+ *
454
+ * @param params
455
+ */
456
+ async getFastWithdrawalSignature(params) {
457
+ const baseResponse = await this.query("fast_withdrawal_signature", params);
458
+ return {
459
+ idx: (0, _nadohq_shared.toBigInt)(baseResponse.idx),
460
+ tx: baseResponse.tx,
461
+ txBytes: (0, _nadohq_shared.getValidatedHex)(baseResponse.tx_bytes),
462
+ signatures: baseResponse.signatures.map(_nadohq_shared.getValidatedHex)
463
+ };
464
+ }
465
+ async getNlpSnapshots(params) {
466
+ return { snapshots: (await this.query("nlp_snapshots", { interval: {
467
+ count: params.limit,
468
+ max_time: params.maxTimeInclusive ? (0, _nadohq_shared.toIntegerString)(params.maxTimeInclusive) : void 0,
469
+ granularity: params.granularity
470
+ } })).snapshots.map(require_dataMappers.mapIndexerNlpSnapshot) };
471
+ }
472
+ /**
473
+ * Retrieves the subaccount's DDA (Direct Deposit Address)
474
+ * @param params
475
+ */
476
+ async getSubaccountDDA(params) {
477
+ return { address: (0, _nadohq_shared.getValidatedAddress)((await this.query("direct_deposit_address", { subaccount: (0, _nadohq_shared.subaccountToHex)(params.subaccount) })).v1_address) };
478
+ }
479
+ async getSequencerBacklog() {
480
+ const baseResponse = await this.query("backlog", {});
481
+ return {
482
+ totalTxs: (0, _nadohq_shared.toBigNumber)(baseResponse.total_txs),
483
+ totalSubmissions: (0, _nadohq_shared.toBigNumber)(baseResponse.total_submissions),
484
+ backlogSize: (0, _nadohq_shared.toBigNumber)(baseResponse.backlog_size),
485
+ updatedAt: (0, _nadohq_shared.toBigNumber)(baseResponse.updated_at),
486
+ backlogEtaInSeconds: baseResponse.backlog_eta_in_seconds ? (0, _nadohq_shared.toBigNumber)(baseResponse.backlog_eta_in_seconds) : null,
487
+ txsPerSecond: baseResponse.txs_per_second ? (0, _nadohq_shared.toBigNumber)(baseResponse.txs_per_second) : null
488
+ };
489
+ }
490
+ /**
491
+ * Retrieves private alpha choice information for a given address
492
+ * @param params
493
+ */
494
+ async getPrivateAlphaChoice(params) {
495
+ const baseResponse = await this.query("private_alpha_choice", { address: params.address });
496
+ return {
497
+ points: (0, _nadohq_shared.toBigNumber)(baseResponse.points),
498
+ feeRefund: (0, _nadohq_shared.toBigNumber)(baseResponse.fee_refund),
499
+ nftEligibility: baseResponse.nft_eligibility
500
+ };
501
+ }
502
+ /**
503
+ * Retrieves points information for a given address, including points per epoch and all-time points
504
+ * @param params
505
+ */
506
+ async getPoints(params) {
507
+ const baseResponse = await this.query("nado_points", { address: params.address });
508
+ return {
509
+ pointsPerEpoch: baseResponse.points_per_epoch.map((epoch) => ({
510
+ epoch: epoch.epoch,
511
+ description: epoch.description,
512
+ startTime: (0, _nadohq_shared.toBigNumber)(epoch.start_time),
513
+ endTime: (0, _nadohq_shared.toBigNumber)(epoch.end_time),
514
+ totalPoints: (0, _nadohq_shared.toBigNumber)(epoch.total_points),
515
+ points: (0, _nadohq_shared.toBigNumber)(epoch.points),
516
+ rank: epoch.rank,
517
+ tier: epoch.tier
518
+ })),
519
+ allTimePoints: {
520
+ points: (0, _nadohq_shared.toBigNumber)(baseResponse.all_time_points.points),
521
+ rank: baseResponse.all_time_points.rank,
522
+ tier: baseResponse.all_time_points.tier
523
+ }
524
+ };
525
+ }
526
+ /**
527
+ * Initiates a social account connection flow. Returns a URL the user must visit to complete the OAuth flow.
528
+ * Requires EIP-712 signing.
529
+ *
530
+ * @param params - Connection parameters including provider and signing config.
531
+ */
532
+ async connectSocialAccount(params) {
533
+ const signatureParams = {
534
+ expiration: (0, _nadohq_shared.toIntegerString)(params.recvTime ?? (0, _nadohq_shared.getDefaultRecvTime)()),
535
+ subaccountName: params.subaccountName,
536
+ subaccountOwner: params.subaccountOwner,
537
+ provider: params.provider
538
+ };
539
+ const tx = (0, _nadohq_shared.getNadoEIP712Values)("social_authentication", signatureParams);
540
+ const signature = await this.sign("social_authentication", params.verifyingAddr, params.chainId, signatureParams);
541
+ return { url: (await this.query("social_connect", { update_social_account: {
542
+ tx,
543
+ signature
544
+ } })).url };
545
+ }
546
+ /**
547
+ * Lists linked social accounts for a given address.
548
+ *
549
+ * @param params - Query parameters including the wallet address.
550
+ */
551
+ async listSocialAccounts(params) {
552
+ return { accounts: (await this.query("list_social_accounts", { address: params.address })).accounts.map((a) => ({
553
+ provider: a.provider,
554
+ username: a.username,
555
+ displayName: a.display_name,
556
+ profileImageUrl: a.profile_image_url
557
+ })) };
558
+ }
559
+ /**
560
+ * Revokes a linked social account. Requires EIP-712 signing.
561
+ *
562
+ * @param params - Revocation parameters including provider and signing config.
563
+ */
564
+ async revokeSocialAccount(params) {
565
+ const signatureParams = {
566
+ expiration: (0, _nadohq_shared.toIntegerString)(params.recvTime ?? (0, _nadohq_shared.getDefaultRecvTime)()),
567
+ subaccountName: params.subaccountName,
568
+ subaccountOwner: params.subaccountOwner,
569
+ provider: params.provider
570
+ };
571
+ const tx = (0, _nadohq_shared.getNadoEIP712Values)("social_authentication", signatureParams);
572
+ const signature = await this.sign("social_authentication", params.verifyingAddr, params.chainId, signatureParams);
573
+ return { accounts: (await this.query("revoke_social_account", { update_social_account: {
574
+ tx,
575
+ signature
576
+ } })).accounts.map((a) => ({
577
+ provider: a.provider,
578
+ username: a.username,
579
+ displayName: a.display_name,
580
+ profileImageUrl: a.profile_image_url
581
+ })) };
582
+ }
583
+ /**
584
+ * Get tickers from the v2 indexer endpoint
585
+ * @param params
586
+ */
587
+ async getV2Tickers(params) {
588
+ const response = await this.axiosInstance.get(`${this.v2Url}/tickers`, { params });
589
+ this.checkResponseStatus(response);
590
+ return (0, _nadohq_shared.mapValues)(response.data, require_dataMappers.mapIndexerV2Ticker);
591
+ }
592
+ /**
593
+ * Get symbols with market hours from the v2 indexer endpoint
594
+ * @param params
595
+ */
596
+ async getV2Symbols(params) {
597
+ const response = await this.axiosInstance.get(`${this.v2Url}/symbols`, { params: {
598
+ product_type: params?.productType,
599
+ product_ids: params?.productIds
600
+ } });
601
+ this.checkResponseStatus(response);
602
+ return (0, _nadohq_shared.mapValues)(response.data, require_dataMappers.mapIndexerV2Symbols);
603
+ }
604
+ async query(requestType, params) {
605
+ const reqBody = { [requestType]: params };
606
+ const response = await this.axiosInstance.post(this.opts.url, reqBody);
607
+ this.checkResponseStatus(response);
608
+ return response.data;
609
+ }
610
+ async sign(requestType, verifyingContract, chainId, params) {
611
+ const walletClient = this.opts.linkedSignerWalletClient ?? this.opts.walletClient;
612
+ if (!walletClient) throw new _nadohq_shared.WalletNotProvidedError();
613
+ return (0, _nadohq_shared.getSignedTransactionRequest)({
614
+ chainId,
615
+ requestParams: params,
616
+ requestType,
617
+ walletClient,
618
+ verifyingContract
619
+ });
620
+ }
621
+ checkResponseStatus(response) {
622
+ if (response.status !== 200 || !response.data) throw Error(`Unexpected response from server: ${response.status} ${response.statusText}`);
623
+ }
624
+ };
625
+ //#endregion
626
+ Object.defineProperty(exports, "IndexerBaseClient", {
627
+ enumerable: true,
628
+ get: function() {
629
+ return IndexerBaseClient;
630
+ }
631
+ });
632
+ Object.defineProperty(exports, "__toESM", {
633
+ enumerable: true,
634
+ get: function() {
635
+ return __toESM;
636
+ }
637
+ });
638
+
639
+ //# sourceMappingURL=IndexerBaseClient-3KfzA2ph.cjs.map