@nadohq/indexer-client 0.1.0-alpha.2 → 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 +71 -55
  2. package/dist/IndexerBaseClient.cjs.map +1 -1
  3. package/dist/IndexerBaseClient.d.cts +7 -3
  4. package/dist/IndexerBaseClient.d.ts +7 -3
  5. package/dist/IndexerBaseClient.js +22 -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 +3 -4
  26. package/dist/index.d.ts +3 -4
  27. package/dist/types/clientTypes.cjs.map +1 -1
  28. package/dist/types/clientTypes.d.cts +8 -7
  29. package/dist/types/clientTypes.d.ts +8 -7
  30. package/dist/types/index.d.cts +3 -4
  31. package/dist/types/index.d.ts +3 -4
  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 +10 -2
  40. package/dist/types/serverTypes.d.ts +10 -2
  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 +32 -11
  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 +12 -8
  53. package/src/types/paginatedEventsTypes.ts +1 -2
  54. package/src/types/serverModelTypes.ts +2 -1
  55. package/src/types/serverTypes.ts +11 -1
  56. package/src/utils/indexerBalanceValue.ts +1 -1
@@ -39,13 +39,13 @@ __export(dataMappers_exports, {
39
39
  mapSnapshotsIntervalToServerParams: () => mapSnapshotsIntervalToServerParams
40
40
  });
41
41
  module.exports = __toCommonJS(dataMappers_exports);
42
- var import_contracts = require("@nadohq/contracts");
42
+ var import_shared = require("@nadohq/shared");
43
43
  var import_engine_client = require("@nadohq/engine-client");
44
- var import_utils = require("@nadohq/utils");
44
+ var import_shared2 = require("@nadohq/shared");
45
45
  function mapSnapshotsIntervalToServerParams(params) {
46
46
  return {
47
47
  count: params.limit,
48
- max_time: params.maxTimeInclusive ? (0, import_utils.toIntegerString)(params.maxTimeInclusive) : void 0,
48
+ max_time: params.maxTimeInclusive ? (0, import_shared2.toIntegerString)(params.maxTimeInclusive) : void 0,
49
49
  granularity: params.granularity
50
50
  };
51
51
  }
@@ -58,45 +58,42 @@ function mapIndexerServerProduct(product) {
58
58
  function mapIndexerServerBalance(balance) {
59
59
  if ("spot" in balance) {
60
60
  return {
61
- amount: (0, import_utils.toBigDecimal)(balance.spot.balance.amount),
61
+ amount: (0, import_shared2.toBigDecimal)(balance.spot.balance.amount),
62
62
  productId: balance.spot.product_id,
63
- type: import_contracts.ProductEngineType.SPOT
63
+ type: import_shared.ProductEngineType.SPOT
64
64
  };
65
65
  }
66
66
  return {
67
- amount: (0, import_utils.toBigDecimal)(balance.perp.balance.amount),
67
+ amount: (0, import_shared2.toBigDecimal)(balance.perp.balance.amount),
68
68
  productId: balance.perp.product_id,
69
- type: import_contracts.ProductEngineType.PERP,
70
- vQuoteBalance: (0, import_utils.toBigDecimal)(balance.perp.balance.v_quote_balance)
69
+ type: import_shared.ProductEngineType.PERP,
70
+ vQuoteBalance: (0, import_shared2.toBigDecimal)(balance.perp.balance.v_quote_balance)
71
71
  };
72
72
  }
73
73
  function mapIndexerOrder(order) {
74
- const expiration = (0, import_utils.toBigDecimal)(order.expiration);
75
- const expirationEncodedData = (0, import_contracts.parseRawExpirationTimestamp)(order.expiration);
74
+ const appendix = (0, import_shared.unpackOrderAppendix)(order.appendix);
76
75
  return {
77
- amount: (0, import_utils.toBigDecimal)(order.amount),
76
+ amount: (0, import_shared2.toBigDecimal)(order.amount),
78
77
  digest: order.digest,
79
78
  isolated: order.isolated,
80
- rawExpiration: expiration,
81
- isReduceOnly: expirationEncodedData.reduceOnly,
82
- expiration: expirationEncodedData.expirationTime,
83
- orderType: expirationEncodedData.type,
84
- nonce: (0, import_utils.toBigDecimal)(order.nonce),
85
- recvTimeSeconds: (0, import_contracts.getRecvTimeFromOrderNonce)(order.nonce) / 1e3,
86
- price: (0, import_utils.removeDecimals)(order.price_x18),
79
+ expiration: Number(order.expiration),
80
+ appendix,
81
+ nonce: (0, import_shared2.toBigDecimal)(order.nonce),
82
+ recvTimeSeconds: (0, import_shared.getRecvTimeFromOrderNonce)(order.nonce) / 1e3,
83
+ price: (0, import_shared2.removeDecimals)(order.price_x18),
87
84
  productId: order.product_id,
88
85
  subaccount: order.subaccount,
89
86
  submissionIndex: order.submission_idx,
90
- baseFilled: (0, import_utils.toBigDecimal)(order.base_filled),
91
- quoteFilled: (0, import_utils.toBigDecimal)(order.quote_filled),
92
- totalFee: (0, import_utils.toBigDecimal)(order.fee)
87
+ baseFilled: (0, import_shared2.toBigDecimal)(order.base_filled),
88
+ quoteFilled: (0, import_shared2.toBigDecimal)(order.quote_filled),
89
+ totalFee: (0, import_shared2.toBigDecimal)(order.fee)
93
90
  };
94
91
  }
95
92
  function mapIndexerEvent(event) {
96
93
  const eventState = (() => {
97
94
  if ("spot" in event.pre_balance) {
98
95
  return {
99
- type: import_contracts.ProductEngineType.SPOT,
96
+ type: import_shared.ProductEngineType.SPOT,
100
97
  market: mapIndexerServerProduct(event.product),
101
98
  preBalance: mapIndexerServerBalance(
102
99
  event.pre_balance
@@ -107,7 +104,7 @@ function mapIndexerEvent(event) {
107
104
  };
108
105
  }
109
106
  return {
110
- type: import_contracts.ProductEngineType.PERP,
107
+ type: import_shared.ProductEngineType.PERP,
111
108
  market: mapIndexerServerProduct(event.product),
112
109
  preBalance: mapIndexerServerBalance(
113
110
  event.pre_balance
@@ -126,18 +123,18 @@ function mapIndexerEvent(event) {
126
123
  subaccount: event.subaccount,
127
124
  submissionIndex: event.submission_idx,
128
125
  trackedVars: {
129
- netEntryCumulative: (0, import_utils.toBigDecimal)(event.net_entry_cumulative),
130
- netEntryUnrealized: (0, import_utils.toBigDecimal)(event.net_entry_unrealized),
131
- netFundingCumulative: (0, import_utils.toBigDecimal)(event.net_funding_cumulative),
132
- netFundingUnrealized: (0, import_utils.toBigDecimal)(event.net_funding_unrealized),
133
- netInterestCumulative: (0, import_utils.toBigDecimal)(event.net_interest_cumulative),
134
- netInterestUnrealized: (0, import_utils.toBigDecimal)(event.net_interest_unrealized)
126
+ netEntryCumulative: (0, import_shared2.toBigDecimal)(event.net_entry_cumulative),
127
+ netEntryUnrealized: (0, import_shared2.toBigDecimal)(event.net_entry_unrealized),
128
+ netFundingCumulative: (0, import_shared2.toBigDecimal)(event.net_funding_cumulative),
129
+ netFundingUnrealized: (0, import_shared2.toBigDecimal)(event.net_funding_unrealized),
130
+ netInterestCumulative: (0, import_shared2.toBigDecimal)(event.net_interest_cumulative),
131
+ netInterestUnrealized: (0, import_shared2.toBigDecimal)(event.net_interest_unrealized)
135
132
  }
136
133
  };
137
134
  }
138
135
  function mapIndexerEventWithTx(event, tx) {
139
136
  return {
140
- timestamp: (0, import_utils.toBigDecimal)(tx.timestamp),
137
+ timestamp: (0, import_shared2.toBigDecimal)(tx.timestamp),
141
138
  tx: tx.tx,
142
139
  ...mapIndexerEvent(event)
143
140
  };
@@ -151,11 +148,11 @@ function mapIndexerMatchEventBalances(eventBalances) {
151
148
  function mapIndexerProductPayment(payment) {
152
149
  return {
153
150
  submissionIndex: payment.idx,
154
- timestamp: (0, import_utils.toBigDecimal)(payment.timestamp),
155
- paymentAmount: (0, import_utils.toBigDecimal)(payment.amount),
156
- balanceAmount: (0, import_utils.toBigDecimal)(payment.balance_amount),
157
- annualPaymentRate: (0, import_utils.removeDecimals)(payment.rate_x18),
158
- oraclePrice: (0, import_utils.removeDecimals)(payment.oracle_price_x18),
151
+ timestamp: (0, import_shared2.toBigDecimal)(payment.timestamp),
152
+ paymentAmount: (0, import_shared2.toBigDecimal)(payment.amount),
153
+ balanceAmount: (0, import_shared2.toBigDecimal)(payment.balance_amount),
154
+ annualPaymentRate: (0, import_shared2.removeDecimals)(payment.rate_x18),
155
+ oraclePrice: (0, import_shared2.removeDecimals)(payment.oracle_price_x18),
159
156
  isolated: payment.isolated,
160
157
  productId: payment.product_id,
161
158
  isolatedProductId: payment.isolated_product_id
@@ -163,16 +160,16 @@ function mapIndexerProductPayment(payment) {
163
160
  }
164
161
  function mapIndexerPerpPrices(perpPrices) {
165
162
  return {
166
- indexPrice: (0, import_utils.removeDecimals)(perpPrices.index_price_x18),
167
- markPrice: (0, import_utils.removeDecimals)(perpPrices.mark_price_x18),
168
- updateTime: (0, import_utils.toBigDecimal)(perpPrices.update_time),
163
+ indexPrice: (0, import_shared2.removeDecimals)(perpPrices.index_price_x18),
164
+ markPrice: (0, import_shared2.removeDecimals)(perpPrices.mark_price_x18),
165
+ updateTime: (0, import_shared2.toBigDecimal)(perpPrices.update_time),
169
166
  productId: perpPrices.product_id
170
167
  };
171
168
  }
172
169
  function mapIndexerFundingRate(fundingRate) {
173
170
  return {
174
- fundingRate: (0, import_utils.removeDecimals)(fundingRate.funding_rate_x18),
175
- updateTime: (0, import_utils.toBigDecimal)(fundingRate.update_time),
171
+ fundingRate: (0, import_shared2.removeDecimals)(fundingRate.funding_rate_x18),
172
+ updateTime: (0, import_shared2.toBigDecimal)(fundingRate.update_time),
176
173
  productId: fundingRate.product_id
177
174
  };
178
175
  }
@@ -181,124 +178,124 @@ function mapIndexerMakerStatistics(maker) {
181
178
  address: maker.address,
182
179
  snapshots: maker.data.map((makerData) => {
183
180
  return {
184
- timestamp: (0, import_utils.toBigDecimal)(makerData.timestamp),
185
- makerFee: (0, import_utils.toBigDecimal)(makerData.maker_fee),
186
- uptime: (0, import_utils.toBigDecimal)(makerData.uptime),
187
- sumQMin: (0, import_utils.toBigDecimal)(makerData.sum_q_min),
188
- qScore: (0, import_utils.toBigDecimal)(makerData.q_score),
189
- makerShare: (0, import_utils.toBigDecimal)(makerData.maker_share),
190
- expectedMakerReward: (0, import_utils.toBigDecimal)(makerData.expected_maker_reward)
181
+ timestamp: (0, import_shared2.toBigDecimal)(makerData.timestamp),
182
+ makerFee: (0, import_shared2.toBigDecimal)(makerData.maker_fee),
183
+ uptime: (0, import_shared2.toBigDecimal)(makerData.uptime),
184
+ sumQMin: (0, import_shared2.toBigDecimal)(makerData.sum_q_min),
185
+ qScore: (0, import_shared2.toBigDecimal)(makerData.q_score),
186
+ makerShare: (0, import_shared2.toBigDecimal)(makerData.maker_share),
187
+ expectedMakerReward: (0, import_shared2.toBigDecimal)(makerData.expected_maker_reward)
191
188
  };
192
189
  })
193
190
  };
194
191
  }
195
192
  function mapIndexerLeaderboardPosition(position) {
196
193
  return {
197
- subaccount: (0, import_contracts.subaccountFromHex)(position.subaccount),
194
+ subaccount: (0, import_shared.subaccountFromHex)(position.subaccount),
198
195
  contestId: position.contest_id,
199
- pnl: (0, import_utils.toBigDecimal)(position.pnl),
200
- pnlRank: (0, import_utils.toBigDecimal)(position.pnl_rank),
201
- percentRoi: (0, import_utils.toBigDecimal)(position.roi),
202
- roiRank: (0, import_utils.toBigDecimal)(position.roi_rank),
203
- accountValue: (0, import_utils.toBigDecimal)(position.account_value),
204
- volume: position.volume ? (0, import_utils.toBigDecimal)(position.volume) : void 0,
205
- updateTime: (0, import_utils.toBigDecimal)(position.update_time)
196
+ pnl: (0, import_shared2.toBigDecimal)(position.pnl),
197
+ pnlRank: (0, import_shared2.toBigDecimal)(position.pnl_rank),
198
+ percentRoi: (0, import_shared2.toBigDecimal)(position.roi),
199
+ roiRank: (0, import_shared2.toBigDecimal)(position.roi_rank),
200
+ accountValue: (0, import_shared2.toBigDecimal)(position.account_value),
201
+ volume: position.volume ? (0, import_shared2.toBigDecimal)(position.volume) : void 0,
202
+ updateTime: (0, import_shared2.toBigDecimal)(position.update_time)
206
203
  };
207
204
  }
208
205
  function mapIndexerLeaderboardRegistration(registration) {
209
206
  return {
210
- subaccount: (0, import_contracts.subaccountFromHex)(registration.subaccount),
207
+ subaccount: (0, import_shared.subaccountFromHex)(registration.subaccount),
211
208
  contestId: registration.contest_id,
212
- updateTime: (0, import_utils.toBigDecimal)(registration.update_time)
209
+ updateTime: (0, import_shared2.toBigDecimal)(registration.update_time)
213
210
  };
214
211
  }
215
212
  function mapIndexerLeaderboardContest(contest) {
216
213
  return {
217
214
  contestId: contest.contest_id,
218
- startTime: (0, import_utils.toBigDecimal)(contest.start_time),
219
- endTime: (0, import_utils.toBigDecimal)(contest.end_time),
220
- period: (0, import_utils.toBigDecimal)(contest.threshold),
221
- totalParticipants: (0, import_utils.toBigDecimal)(contest.count),
222
- minRequiredAccountValue: (0, import_utils.toBigDecimal)(contest.threshold),
223
- minRequiredVolume: (0, import_utils.toBigDecimal)(contest.volume_threshold),
215
+ startTime: (0, import_shared2.toBigDecimal)(contest.start_time),
216
+ endTime: (0, import_shared2.toBigDecimal)(contest.end_time),
217
+ period: (0, import_shared2.toBigDecimal)(contest.threshold),
218
+ totalParticipants: (0, import_shared2.toBigDecimal)(contest.count),
219
+ minRequiredAccountValue: (0, import_shared2.toBigDecimal)(contest.threshold),
220
+ minRequiredVolume: (0, import_shared2.toBigDecimal)(contest.volume_threshold),
224
221
  requiredProductIds: contest.product_ids,
225
222
  active: contest.active,
226
- lastUpdated: (0, import_utils.toBigDecimal)(contest.last_updated)
223
+ lastUpdated: (0, import_shared2.toBigDecimal)(contest.last_updated)
227
224
  };
228
225
  }
229
226
  function mapIndexerCandlesticks(candlestick) {
230
227
  return {
231
- close: (0, import_utils.removeDecimals)(candlestick.close_x18),
232
- high: (0, import_utils.removeDecimals)(candlestick.high_x18),
233
- low: (0, import_utils.removeDecimals)(candlestick.low_x18),
234
- open: (0, import_utils.removeDecimals)(candlestick.open_x18),
235
- time: (0, import_utils.toBigDecimal)(candlestick.timestamp),
236
- volume: (0, import_utils.toBigDecimal)(candlestick.volume)
228
+ close: (0, import_shared2.removeDecimals)(candlestick.close_x18),
229
+ high: (0, import_shared2.removeDecimals)(candlestick.high_x18),
230
+ low: (0, import_shared2.removeDecimals)(candlestick.low_x18),
231
+ open: (0, import_shared2.removeDecimals)(candlestick.open_x18),
232
+ time: (0, import_shared2.toBigDecimal)(candlestick.timestamp),
233
+ volume: (0, import_shared2.toBigDecimal)(candlestick.volume)
237
234
  };
238
235
  }
239
236
  function mapIndexerMarketSnapshot(snapshot) {
240
237
  return {
241
- timestamp: (0, import_utils.toBigDecimal)(snapshot.timestamp),
242
- cumulativeUsers: (0, import_utils.toBigDecimal)(snapshot.cumulative_users),
243
- dailyActiveUsers: (0, import_utils.toBigDecimal)(snapshot.daily_active_users),
244
- tvl: (0, import_utils.toBigDecimal)(snapshot.tvl),
245
- borrowRates: (0, import_utils.mapValues)(
238
+ timestamp: (0, import_shared2.toBigDecimal)(snapshot.timestamp),
239
+ cumulativeUsers: (0, import_shared2.toBigDecimal)(snapshot.cumulative_users),
240
+ dailyActiveUsers: (0, import_shared2.toBigDecimal)(snapshot.daily_active_users),
241
+ tvl: (0, import_shared2.toBigDecimal)(snapshot.tvl),
242
+ borrowRates: (0, import_shared2.mapValues)(
246
243
  snapshot.borrow_rates,
247
- (value) => (0, import_utils.removeDecimals)(value)
244
+ (value) => (0, import_shared2.removeDecimals)(value)
248
245
  ),
249
- cumulativeLiquidationAmounts: (0, import_utils.mapValues)(
246
+ cumulativeLiquidationAmounts: (0, import_shared2.mapValues)(
250
247
  snapshot.cumulative_liquidation_amounts,
251
- import_utils.toBigDecimal
248
+ import_shared2.toBigDecimal
252
249
  ),
253
- cumulativeMakerFees: (0, import_utils.mapValues)(
250
+ cumulativeMakerFees: (0, import_shared2.mapValues)(
254
251
  snapshot.cumulative_maker_fees,
255
- import_utils.toBigDecimal
252
+ import_shared2.toBigDecimal
256
253
  ),
257
- cumulativeSequencerFees: (0, import_utils.mapValues)(
254
+ cumulativeSequencerFees: (0, import_shared2.mapValues)(
258
255
  snapshot.cumulative_sequencer_fees,
259
- import_utils.toBigDecimal
256
+ import_shared2.toBigDecimal
260
257
  ),
261
- cumulativeTakerFees: (0, import_utils.mapValues)(
258
+ cumulativeTakerFees: (0, import_shared2.mapValues)(
262
259
  snapshot.cumulative_taker_fees,
263
- import_utils.toBigDecimal
260
+ import_shared2.toBigDecimal
264
261
  ),
265
- cumulativeTrades: (0, import_utils.mapValues)(snapshot.cumulative_trades, import_utils.toBigDecimal),
266
- cumulativeVolumes: (0, import_utils.mapValues)(snapshot.cumulative_volumes, import_utils.toBigDecimal),
267
- depositRates: (0, import_utils.mapValues)(
262
+ cumulativeTrades: (0, import_shared2.mapValues)(snapshot.cumulative_trades, import_shared2.toBigDecimal),
263
+ cumulativeVolumes: (0, import_shared2.mapValues)(snapshot.cumulative_volumes, import_shared2.toBigDecimal),
264
+ depositRates: (0, import_shared2.mapValues)(
268
265
  snapshot.deposit_rates,
269
- (value) => (0, import_utils.removeDecimals)(value)
266
+ (value) => (0, import_shared2.removeDecimals)(value)
270
267
  ),
271
- fundingRates: (0, import_utils.mapValues)(
268
+ fundingRates: (0, import_shared2.mapValues)(
272
269
  snapshot.funding_rates,
273
- (value) => (0, import_utils.removeDecimals)(value)
270
+ (value) => (0, import_shared2.removeDecimals)(value)
274
271
  ),
275
- openInterestsQuote: (0, import_utils.mapValues)(snapshot.open_interests, import_utils.toBigDecimal),
276
- totalBorrows: (0, import_utils.mapValues)(snapshot.total_borrows, import_utils.toBigDecimal),
277
- totalDeposits: (0, import_utils.mapValues)(snapshot.total_deposits, import_utils.toBigDecimal),
278
- cumulativeTradeSizes: (0, import_utils.mapValues)(
272
+ openInterestsQuote: (0, import_shared2.mapValues)(snapshot.open_interests, import_shared2.toBigDecimal),
273
+ totalBorrows: (0, import_shared2.mapValues)(snapshot.total_borrows, import_shared2.toBigDecimal),
274
+ totalDeposits: (0, import_shared2.mapValues)(snapshot.total_deposits, import_shared2.toBigDecimal),
275
+ cumulativeTradeSizes: (0, import_shared2.mapValues)(
279
276
  snapshot.cumulative_trade_sizes,
280
- import_utils.toBigDecimal
277
+ import_shared2.toBigDecimal
281
278
  ),
282
- cumulativeInflows: (0, import_utils.mapValues)(snapshot.cumulative_inflows, import_utils.toBigDecimal),
283
- cumulativeOutflows: (0, import_utils.mapValues)(snapshot.cumulative_outflows, import_utils.toBigDecimal),
284
- oraclePrices: (0, import_utils.mapValues)(
279
+ cumulativeInflows: (0, import_shared2.mapValues)(snapshot.cumulative_inflows, import_shared2.toBigDecimal),
280
+ cumulativeOutflows: (0, import_shared2.mapValues)(snapshot.cumulative_outflows, import_shared2.toBigDecimal),
281
+ oraclePrices: (0, import_shared2.mapValues)(
285
282
  snapshot.oracle_prices,
286
- (value) => (0, import_utils.removeDecimals)(value)
283
+ (value) => (0, import_shared2.removeDecimals)(value)
287
284
  )
288
285
  };
289
286
  }
290
287
  function mapIndexerNlpSnapshot(snapshot) {
291
288
  return {
292
289
  submissionIndex: snapshot.submission_idx,
293
- timestamp: (0, import_utils.toBigDecimal)(snapshot.timestamp),
294
- cumulativeBurnAmountUsdc: (0, import_utils.toBigDecimal)(snapshot.cumulative_burn_usdc),
295
- cumulativeMintAmountUsdc: (0, import_utils.toBigDecimal)(snapshot.cumulative_mint_usdc),
296
- cumulativePnl: (0, import_utils.toBigDecimal)(snapshot.cumulative_pnl),
297
- cumulativeTrades: (0, import_utils.toBigDecimal)(snapshot.cumulative_trades),
298
- cumulativeVolume: (0, import_utils.toBigDecimal)(snapshot.cumulative_volume),
299
- depositors: (0, import_utils.toBigDecimal)(snapshot.depositors),
300
- oraclePrice: (0, import_utils.removeDecimals)(snapshot.oracle_price_x18),
301
- tvl: (0, import_utils.toBigDecimal)(snapshot.tvl)
290
+ timestamp: (0, import_shared2.toBigDecimal)(snapshot.timestamp),
291
+ cumulativeBurnAmountUsdc: (0, import_shared2.toBigDecimal)(snapshot.cumulative_burn_usdc),
292
+ cumulativeMintAmountUsdc: (0, import_shared2.toBigDecimal)(snapshot.cumulative_mint_usdc),
293
+ cumulativePnl: (0, import_shared2.toBigDecimal)(snapshot.cumulative_pnl),
294
+ cumulativeTrades: (0, import_shared2.toBigDecimal)(snapshot.cumulative_trades),
295
+ cumulativeVolume: (0, import_shared2.toBigDecimal)(snapshot.cumulative_volume),
296
+ depositors: (0, import_shared2.toBigDecimal)(snapshot.depositors),
297
+ oraclePrice: (0, import_shared2.removeDecimals)(snapshot.oracle_price_x18),
298
+ tvl: (0, import_shared2.toBigDecimal)(snapshot.tvl)
302
299
  };
303
300
  }
304
301
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dataMappers.ts"],"sourcesContent":["import {\n getRecvTimeFromOrderNonce,\n Market,\n parseRawExpirationTimestamp,\n PerpMarket,\n ProductEngineType,\n SpotMarket,\n subaccountFromHex,\n} from '@nadohq/contracts';\nimport {\n mapEngineServerPerpProduct,\n mapEngineServerSpotProduct,\n} from '@nadohq/engine-client';\nimport {\n mapValues,\n removeDecimals,\n toBigDecimal,\n toIntegerString,\n} from '@nadohq/utils';\nimport {\n Candlestick,\n IndexerEvent,\n IndexerEventWithTx,\n IndexerFundingRate,\n IndexerLeaderboardContest,\n IndexerLeaderboardParticipant,\n IndexerLeaderboardRegistration,\n IndexerMaker,\n IndexerMarketSnapshot,\n IndexerMatchEventBalances,\n IndexerOrder,\n IndexerPerpBalance,\n IndexerPerpPrices,\n IndexerProductPayment,\n IndexerServerBalance,\n IndexerServerCandlestick,\n IndexerServerEvent,\n IndexerServerFundingRate,\n IndexerServerLeaderboardContest,\n IndexerServerLeaderboardPosition,\n IndexerServerLeaderboardRegistration,\n IndexerServerMaker,\n IndexerServerMarketSnapshot,\n IndexerServerMatchEventBalances,\n IndexerServerOrder,\n IndexerServerPerpPrices,\n IndexerServerProduct,\n IndexerServerProductPayment,\n IndexerServerSnapshotsInterval,\n IndexerServerTx,\n IndexerServerNlpSnapshot,\n IndexerSnapshotsIntervalParams,\n IndexerSpotBalance,\n IndexerNlpSnapshot,\n} from './types';\n\nexport function mapSnapshotsIntervalToServerParams(\n params: IndexerSnapshotsIntervalParams,\n): IndexerServerSnapshotsInterval {\n return {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n };\n}\n\nexport function mapIndexerServerProduct(product: IndexerServerProduct): Market {\n if ('spot' in product) {\n return mapEngineServerSpotProduct(product.spot);\n }\n return mapEngineServerPerpProduct(product.perp);\n}\n\nexport function mapIndexerServerBalance(\n balance: IndexerServerBalance,\n): IndexerSpotBalance | IndexerPerpBalance {\n if ('spot' in balance) {\n return {\n amount: toBigDecimal(balance.spot.balance.amount),\n productId: balance.spot.product_id,\n type: ProductEngineType.SPOT,\n };\n }\n return {\n amount: toBigDecimal(balance.perp.balance.amount),\n productId: balance.perp.product_id,\n type: ProductEngineType.PERP,\n vQuoteBalance: toBigDecimal(balance.perp.balance.v_quote_balance),\n };\n}\n\nexport function mapIndexerOrder(order: IndexerServerOrder): IndexerOrder {\n const expiration = toBigDecimal(order.expiration);\n const expirationEncodedData = parseRawExpirationTimestamp(order.expiration);\n return {\n amount: toBigDecimal(order.amount),\n digest: order.digest,\n isolated: order.isolated,\n rawExpiration: expiration,\n isReduceOnly: expirationEncodedData.reduceOnly,\n expiration: expirationEncodedData.expirationTime,\n orderType: expirationEncodedData.type,\n nonce: toBigDecimal(order.nonce),\n recvTimeSeconds: getRecvTimeFromOrderNonce(order.nonce) / 1000,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccount: order.subaccount,\n submissionIndex: order.submission_idx,\n baseFilled: toBigDecimal(order.base_filled),\n quoteFilled: toBigDecimal(order.quote_filled),\n totalFee: toBigDecimal(order.fee),\n };\n}\n\nexport function mapIndexerEvent(event: IndexerServerEvent): IndexerEvent {\n const eventState: IndexerEvent['state'] = (() => {\n // Assume backend data is consistent\n if ('spot' in event.pre_balance) {\n return {\n type: ProductEngineType.SPOT,\n market: mapIndexerServerProduct(event.product) as SpotMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerSpotBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerSpotBalance,\n };\n }\n return {\n type: ProductEngineType.PERP,\n market: mapIndexerServerProduct(event.product) as PerpMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerPerpBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerPerpBalance,\n };\n })();\n\n return {\n eventType: event.event_type,\n productId: event.product_id,\n isolated: event.isolated,\n isolatedProductId: event.isolated_product_id,\n state: eventState,\n subaccount: event.subaccount,\n submissionIndex: event.submission_idx,\n trackedVars: {\n netEntryCumulative: toBigDecimal(event.net_entry_cumulative),\n netEntryUnrealized: toBigDecimal(event.net_entry_unrealized),\n netFundingCumulative: toBigDecimal(event.net_funding_cumulative),\n netFundingUnrealized: toBigDecimal(event.net_funding_unrealized),\n netInterestCumulative: toBigDecimal(event.net_interest_cumulative),\n netInterestUnrealized: toBigDecimal(event.net_interest_unrealized),\n },\n };\n}\n\nexport function mapIndexerEventWithTx(\n event: IndexerServerEvent,\n tx: IndexerServerTx,\n): IndexerEventWithTx {\n return {\n timestamp: toBigDecimal(tx.timestamp),\n tx: tx.tx,\n ...mapIndexerEvent(event),\n };\n}\n\nexport function mapIndexerMatchEventBalances(\n eventBalances: IndexerServerMatchEventBalances,\n): IndexerMatchEventBalances {\n return {\n base: mapIndexerServerBalance(eventBalances.base),\n quote: eventBalances.quote\n ? (mapIndexerServerBalance(eventBalances.quote) as IndexerSpotBalance)\n : undefined,\n };\n}\n\nexport function mapIndexerProductPayment(\n payment: IndexerServerProductPayment,\n): IndexerProductPayment {\n return {\n submissionIndex: payment.idx,\n timestamp: toBigDecimal(payment.timestamp),\n paymentAmount: toBigDecimal(payment.amount),\n balanceAmount: toBigDecimal(payment.balance_amount),\n annualPaymentRate: removeDecimals(payment.rate_x18),\n oraclePrice: removeDecimals(payment.oracle_price_x18),\n isolated: payment.isolated,\n productId: payment.product_id,\n isolatedProductId: payment.isolated_product_id,\n };\n}\n\nexport function mapIndexerPerpPrices(\n perpPrices: IndexerServerPerpPrices,\n): IndexerPerpPrices {\n return {\n indexPrice: removeDecimals(perpPrices.index_price_x18),\n markPrice: removeDecimals(perpPrices.mark_price_x18),\n updateTime: toBigDecimal(perpPrices.update_time),\n productId: perpPrices.product_id,\n };\n}\n\nexport function mapIndexerFundingRate(\n fundingRate: IndexerServerFundingRate,\n): IndexerFundingRate {\n return {\n fundingRate: removeDecimals(fundingRate.funding_rate_x18),\n updateTime: toBigDecimal(fundingRate.update_time),\n productId: fundingRate.product_id,\n };\n}\n\nexport function mapIndexerMakerStatistics(\n maker: IndexerServerMaker,\n): IndexerMaker {\n return {\n address: maker.address,\n snapshots: maker.data.map((makerData) => {\n return {\n timestamp: toBigDecimal(makerData.timestamp),\n makerFee: toBigDecimal(makerData.maker_fee),\n uptime: toBigDecimal(makerData.uptime),\n sumQMin: toBigDecimal(makerData.sum_q_min),\n qScore: toBigDecimal(makerData.q_score),\n makerShare: toBigDecimal(makerData.maker_share),\n expectedMakerReward: toBigDecimal(makerData.expected_maker_reward),\n };\n }),\n };\n}\n\nexport function mapIndexerLeaderboardPosition(\n position: IndexerServerLeaderboardPosition,\n): IndexerLeaderboardParticipant {\n return {\n subaccount: subaccountFromHex(position.subaccount),\n contestId: position.contest_id,\n pnl: toBigDecimal(position.pnl),\n pnlRank: toBigDecimal(position.pnl_rank),\n percentRoi: toBigDecimal(position.roi),\n roiRank: toBigDecimal(position.roi_rank),\n accountValue: toBigDecimal(position.account_value),\n volume: position.volume ? toBigDecimal(position.volume) : undefined,\n updateTime: toBigDecimal(position.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardRegistration(\n registration: IndexerServerLeaderboardRegistration,\n): IndexerLeaderboardRegistration {\n return {\n subaccount: subaccountFromHex(registration.subaccount),\n contestId: registration.contest_id,\n updateTime: toBigDecimal(registration.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardContest(\n contest: IndexerServerLeaderboardContest,\n): IndexerLeaderboardContest {\n return {\n contestId: contest.contest_id,\n startTime: toBigDecimal(contest.start_time),\n endTime: toBigDecimal(contest.end_time),\n period: toBigDecimal(contest.threshold),\n totalParticipants: toBigDecimal(contest.count),\n minRequiredAccountValue: toBigDecimal(contest.threshold),\n minRequiredVolume: toBigDecimal(contest.volume_threshold),\n requiredProductIds: contest.product_ids,\n active: contest.active,\n lastUpdated: toBigDecimal(contest.last_updated),\n };\n}\n\nexport function mapIndexerCandlesticks(\n candlestick: IndexerServerCandlestick,\n): Candlestick {\n return {\n close: removeDecimals(candlestick.close_x18),\n high: removeDecimals(candlestick.high_x18),\n low: removeDecimals(candlestick.low_x18),\n open: removeDecimals(candlestick.open_x18),\n time: toBigDecimal(candlestick.timestamp),\n volume: toBigDecimal(candlestick.volume),\n };\n}\n\nexport function mapIndexerMarketSnapshot(\n snapshot: IndexerServerMarketSnapshot,\n): IndexerMarketSnapshot {\n return {\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeUsers: toBigDecimal(snapshot.cumulative_users),\n dailyActiveUsers: toBigDecimal(snapshot.daily_active_users),\n tvl: toBigDecimal(snapshot.tvl),\n borrowRates: mapValues(snapshot.borrow_rates, (value) =>\n removeDecimals(value),\n ),\n cumulativeLiquidationAmounts: mapValues(\n snapshot.cumulative_liquidation_amounts,\n toBigDecimal,\n ),\n cumulativeMakerFees: mapValues(\n snapshot.cumulative_maker_fees,\n toBigDecimal,\n ),\n cumulativeSequencerFees: mapValues(\n snapshot.cumulative_sequencer_fees,\n toBigDecimal,\n ),\n cumulativeTakerFees: mapValues(\n snapshot.cumulative_taker_fees,\n toBigDecimal,\n ),\n cumulativeTrades: mapValues(snapshot.cumulative_trades, toBigDecimal),\n cumulativeVolumes: mapValues(snapshot.cumulative_volumes, toBigDecimal),\n depositRates: mapValues(snapshot.deposit_rates, (value) =>\n removeDecimals(value),\n ),\n fundingRates: mapValues(snapshot.funding_rates, (value) =>\n removeDecimals(value),\n ),\n openInterestsQuote: mapValues(snapshot.open_interests, toBigDecimal),\n totalBorrows: mapValues(snapshot.total_borrows, toBigDecimal),\n totalDeposits: mapValues(snapshot.total_deposits, toBigDecimal),\n cumulativeTradeSizes: mapValues(\n snapshot.cumulative_trade_sizes,\n toBigDecimal,\n ),\n cumulativeInflows: mapValues(snapshot.cumulative_inflows, toBigDecimal),\n cumulativeOutflows: mapValues(snapshot.cumulative_outflows, toBigDecimal),\n oraclePrices: mapValues(snapshot.oracle_prices, (value) =>\n removeDecimals(value),\n ),\n };\n}\n\nexport function mapIndexerNlpSnapshot(\n snapshot: IndexerServerNlpSnapshot,\n): IndexerNlpSnapshot {\n return {\n submissionIndex: snapshot.submission_idx,\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeBurnAmountUsdc: toBigDecimal(snapshot.cumulative_burn_usdc),\n cumulativeMintAmountUsdc: toBigDecimal(snapshot.cumulative_mint_usdc),\n cumulativePnl: toBigDecimal(snapshot.cumulative_pnl),\n cumulativeTrades: toBigDecimal(snapshot.cumulative_trades),\n cumulativeVolume: toBigDecimal(snapshot.cumulative_volume),\n depositors: toBigDecimal(snapshot.depositors),\n oraclePrice: removeDecimals(snapshot.oracle_price_x18),\n tvl: toBigDecimal(snapshot.tvl),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAQO;AACP,2BAGO;AACP,mBAKO;AAsCA,SAAS,mCACd,QACgC;AAChC,SAAO;AAAA,IACL,OAAO,OAAO;AAAA,IACd,UAAU,OAAO,uBACb,8BAAgB,OAAO,gBAAgB,IACvC;AAAA,IACJ,aAAa,OAAO;AAAA,EACtB;AACF;AAEO,SAAS,wBAAwB,SAAuC;AAC7E,MAAI,UAAU,SAAS;AACrB,eAAO,iDAA2B,QAAQ,IAAI;AAAA,EAChD;AACA,aAAO,iDAA2B,QAAQ,IAAI;AAChD;AAEO,SAAS,wBACd,SACyC;AACzC,MAAI,UAAU,SAAS;AACrB,WAAO;AAAA,MACL,YAAQ,2BAAa,QAAQ,KAAK,QAAQ,MAAM;AAAA,MAChD,WAAW,QAAQ,KAAK;AAAA,MACxB,MAAM,mCAAkB;AAAA,IAC1B;AAAA,EACF;AACA,SAAO;AAAA,IACL,YAAQ,2BAAa,QAAQ,KAAK,QAAQ,MAAM;AAAA,IAChD,WAAW,QAAQ,KAAK;AAAA,IACxB,MAAM,mCAAkB;AAAA,IACxB,mBAAe,2BAAa,QAAQ,KAAK,QAAQ,eAAe;AAAA,EAClE;AACF;AAEO,SAAS,gBAAgB,OAAyC;AACvE,QAAM,iBAAa,2B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;AAAA,IACtB;AAAA,IACA,kBAAc;AAAA,MAAU,SAAS;AAAA,MAAe,CAAC,cAC/C,6BAAe,KAAK;AAAA,IACtB;AAAA,IACA,wBAAoB,wBAAU,SAAS,gBAAgB,yBAAY;AAAA,IACnE,kBAAc,wBAAU,SAAS,eAAe,yBAAY;AAAA,IAC5D,mBAAe,wBAAU,SAAS,gBAAgB,yBAAY;AAAA,IAC9D,0BAAsB;AAAA,MACpB,SAAS;AAAA,MACT;AAAA,IACF;AAAA,IACA,uBAAmB,wBAAU,SAAS,oBAAoB,yBAAY;AAAA,IACtE,wBAAoB,wBAAU,SAAS,qBAAqB,yBAAY;AAAA,IACxE,kBAAc;AAAA,MAAU,SAAS;AAAA,MAAe,CAAC,cAC/C,6BAAe,KAAK;AAAA,IACtB;AAAA,EACF;AACF;AAEO,SAAS,sBACd,UACoB;AACpB,SAAO;AAAA,IACL,iBAAiB,SAAS;AAAA,IAC1B,eAAW,2BAAa,SAAS,SAAS;AAAA,IAC1C,8BAA0B,2BAAa,SAAS,oBAAoB;AAAA,IACpE,8BAA0B,2BAAa,SAAS,oBAAoB;AAAA,IACpE,mBAAe,2BAAa,SAAS,cAAc;AAAA,IACnD,sBAAkB,2BAAa,SAAS,iBAAiB;AAAA,IACzD,sBAAkB,2BAAa,SAAS,iBAAiB;AAAA,IACzD,gBAAY,2BAAa,SAAS,UAAU;AAAA,IAC5C,iBAAa,6BAAe,SAAS,gBAAgB;AAAA,IACrD,SAAK,2BAAa,SAAS,GAAG;AAAA,EAChC;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/dataMappers.ts"],"sourcesContent":["import {\n getRecvTimeFromOrderNonce,\n Market,\n PerpMarket,\n ProductEngineType,\n SpotMarket,\n subaccountFromHex,\n unpackOrderAppendix,\n} from '@nadohq/shared';\nimport {\n mapEngineServerPerpProduct,\n mapEngineServerSpotProduct,\n} from '@nadohq/engine-client';\nimport {\n mapValues,\n removeDecimals,\n toBigDecimal,\n toIntegerString,\n} from '@nadohq/shared';\nimport {\n Candlestick,\n IndexerEvent,\n IndexerEventWithTx,\n IndexerFundingRate,\n IndexerLeaderboardContest,\n IndexerLeaderboardParticipant,\n IndexerLeaderboardRegistration,\n IndexerMaker,\n IndexerMarketSnapshot,\n IndexerMatchEventBalances,\n IndexerNlpSnapshot,\n IndexerOrder,\n IndexerPerpBalance,\n IndexerPerpPrices,\n IndexerProductPayment,\n IndexerServerBalance,\n IndexerServerCandlestick,\n IndexerServerEvent,\n IndexerServerFundingRate,\n IndexerServerLeaderboardContest,\n IndexerServerLeaderboardPosition,\n IndexerServerLeaderboardRegistration,\n IndexerServerMaker,\n IndexerServerMarketSnapshot,\n IndexerServerMatchEventBalances,\n IndexerServerNlpSnapshot,\n IndexerServerOrder,\n IndexerServerPerpPrices,\n IndexerServerProduct,\n IndexerServerProductPayment,\n IndexerServerSnapshotsInterval,\n IndexerServerTx,\n IndexerSnapshotsIntervalParams,\n IndexerSpotBalance,\n} from './types';\n\nexport function mapSnapshotsIntervalToServerParams(\n params: IndexerSnapshotsIntervalParams,\n): IndexerServerSnapshotsInterval {\n return {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n };\n}\n\nexport function mapIndexerServerProduct(product: IndexerServerProduct): Market {\n if ('spot' in product) {\n return mapEngineServerSpotProduct(product.spot);\n }\n return mapEngineServerPerpProduct(product.perp);\n}\n\nexport function mapIndexerServerBalance(\n balance: IndexerServerBalance,\n): IndexerSpotBalance | IndexerPerpBalance {\n if ('spot' in balance) {\n return {\n amount: toBigDecimal(balance.spot.balance.amount),\n productId: balance.spot.product_id,\n type: ProductEngineType.SPOT,\n };\n }\n return {\n amount: toBigDecimal(balance.perp.balance.amount),\n productId: balance.perp.product_id,\n type: ProductEngineType.PERP,\n vQuoteBalance: toBigDecimal(balance.perp.balance.v_quote_balance),\n };\n}\n\nexport function mapIndexerOrder(order: IndexerServerOrder): IndexerOrder {\n const appendix = unpackOrderAppendix(order.appendix);\n return {\n amount: toBigDecimal(order.amount),\n digest: order.digest,\n isolated: order.isolated,\n expiration: Number(order.expiration),\n appendix,\n nonce: toBigDecimal(order.nonce),\n recvTimeSeconds: getRecvTimeFromOrderNonce(order.nonce) / 1000,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccount: order.subaccount,\n submissionIndex: order.submission_idx,\n baseFilled: toBigDecimal(order.base_filled),\n quoteFilled: toBigDecimal(order.quote_filled),\n totalFee: toBigDecimal(order.fee),\n };\n}\n\nexport function mapIndexerEvent(event: IndexerServerEvent): IndexerEvent {\n const eventState: IndexerEvent['state'] = (() => {\n // Assume backend data is consistent\n if ('spot' in event.pre_balance) {\n return {\n type: ProductEngineType.SPOT,\n market: mapIndexerServerProduct(event.product) as SpotMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerSpotBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerSpotBalance,\n };\n }\n return {\n type: ProductEngineType.PERP,\n market: mapIndexerServerProduct(event.product) as PerpMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerPerpBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerPerpBalance,\n };\n })();\n\n return {\n eventType: event.event_type,\n productId: event.product_id,\n isolated: event.isolated,\n isolatedProductId: event.isolated_product_id,\n state: eventState,\n subaccount: event.subaccount,\n submissionIndex: event.submission_idx,\n trackedVars: {\n netEntryCumulative: toBigDecimal(event.net_entry_cumulative),\n netEntryUnrealized: toBigDecimal(event.net_entry_unrealized),\n netFundingCumulative: toBigDecimal(event.net_funding_cumulative),\n netFundingUnrealized: toBigDecimal(event.net_funding_unrealized),\n netInterestCumulative: toBigDecimal(event.net_interest_cumulative),\n netInterestUnrealized: toBigDecimal(event.net_interest_unrealized),\n },\n };\n}\n\nexport function mapIndexerEventWithTx(\n event: IndexerServerEvent,\n tx: IndexerServerTx,\n): IndexerEventWithTx {\n return {\n timestamp: toBigDecimal(tx.timestamp),\n tx: tx.tx,\n ...mapIndexerEvent(event),\n };\n}\n\nexport function mapIndexerMatchEventBalances(\n eventBalances: IndexerServerMatchEventBalances,\n): IndexerMatchEventBalances {\n return {\n base: mapIndexerServerBalance(eventBalances.base),\n quote: eventBalances.quote\n ? (mapIndexerServerBalance(eventBalances.quote) as IndexerSpotBalance)\n : undefined,\n };\n}\n\nexport function mapIndexerProductPayment(\n payment: IndexerServerProductPayment,\n): IndexerProductPayment {\n return {\n submissionIndex: payment.idx,\n timestamp: toBigDecimal(payment.timestamp),\n paymentAmount: toBigDecimal(payment.amount),\n balanceAmount: toBigDecimal(payment.balance_amount),\n annualPaymentRate: removeDecimals(payment.rate_x18),\n oraclePrice: removeDecimals(payment.oracle_price_x18),\n isolated: payment.isolated,\n productId: payment.product_id,\n isolatedProductId: payment.isolated_product_id,\n };\n}\n\nexport function mapIndexerPerpPrices(\n perpPrices: IndexerServerPerpPrices,\n): IndexerPerpPrices {\n return {\n indexPrice: removeDecimals(perpPrices.index_price_x18),\n markPrice: removeDecimals(perpPrices.mark_price_x18),\n updateTime: toBigDecimal(perpPrices.update_time),\n productId: perpPrices.product_id,\n };\n}\n\nexport function mapIndexerFundingRate(\n fundingRate: IndexerServerFundingRate,\n): IndexerFundingRate {\n return {\n fundingRate: removeDecimals(fundingRate.funding_rate_x18),\n updateTime: toBigDecimal(fundingRate.update_time),\n productId: fundingRate.product_id,\n };\n}\n\nexport function mapIndexerMakerStatistics(\n maker: IndexerServerMaker,\n): IndexerMaker {\n return {\n address: maker.address,\n snapshots: maker.data.map((makerData) => {\n return {\n timestamp: toBigDecimal(makerData.timestamp),\n makerFee: toBigDecimal(makerData.maker_fee),\n uptime: toBigDecimal(makerData.uptime),\n sumQMin: toBigDecimal(makerData.sum_q_min),\n qScore: toBigDecimal(makerData.q_score),\n makerShare: toBigDecimal(makerData.maker_share),\n expectedMakerReward: toBigDecimal(makerData.expected_maker_reward),\n };\n }),\n };\n}\n\nexport function mapIndexerLeaderboardPosition(\n position: IndexerServerLeaderboardPosition,\n): IndexerLeaderboardParticipant {\n return {\n subaccount: subaccountFromHex(position.subaccount),\n contestId: position.contest_id,\n pnl: toBigDecimal(position.pnl),\n pnlRank: toBigDecimal(position.pnl_rank),\n percentRoi: toBigDecimal(position.roi),\n roiRank: toBigDecimal(position.roi_rank),\n accountValue: toBigDecimal(position.account_value),\n volume: position.volume ? toBigDecimal(position.volume) : undefined,\n updateTime: toBigDecimal(position.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardRegistration(\n registration: IndexerServerLeaderboardRegistration,\n): IndexerLeaderboardRegistration {\n return {\n subaccount: subaccountFromHex(registration.subaccount),\n contestId: registration.contest_id,\n updateTime: toBigDecimal(registration.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardContest(\n contest: IndexerServerLeaderboardContest,\n): IndexerLeaderboardContest {\n return {\n contestId: contest.contest_id,\n startTime: toBigDecimal(contest.start_time),\n endTime: toBigDecimal(contest.end_time),\n period: toBigDecimal(contest.threshold),\n totalParticipants: toBigDecimal(contest.count),\n minRequiredAccountValue: toBigDecimal(contest.threshold),\n minRequiredVolume: toBigDecimal(contest.volume_threshold),\n requiredProductIds: contest.product_ids,\n active: contest.active,\n lastUpdated: toBigDecimal(contest.last_updated),\n };\n}\n\nexport function mapIndexerCandlesticks(\n candlestick: IndexerServerCandlestick,\n): Candlestick {\n return {\n close: removeDecimals(candlestick.close_x18),\n high: removeDecimals(candlestick.high_x18),\n low: removeDecimals(candlestick.low_x18),\n open: removeDecimals(candlestick.open_x18),\n time: toBigDecimal(candlestick.timestamp),\n volume: toBigDecimal(candlestick.volume),\n };\n}\n\nexport function mapIndexerMarketSnapshot(\n snapshot: IndexerServerMarketSnapshot,\n): IndexerMarketSnapshot {\n return {\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeUsers: toBigDecimal(snapshot.cumulative_users),\n dailyActiveUsers: toBigDecimal(snapshot.daily_active_users),\n tvl: toBigDecimal(snapshot.tvl),\n borrowRates: mapValues(snapshot.borrow_rates, (value) =>\n removeDecimals(value),\n ),\n cumulativeLiquidationAmounts: mapValues(\n snapshot.cumulative_liquidation_amounts,\n toBigDecimal,\n ),\n cumulativeMakerFees: mapValues(\n snapshot.cumulative_maker_fees,\n toBigDecimal,\n ),\n cumulativeSequencerFees: mapValues(\n snapshot.cumulative_sequencer_fees,\n toBigDecimal,\n ),\n cumulativeTakerFees: mapValues(\n snapshot.cumulative_taker_fees,\n toBigDecimal,\n ),\n cumulativeTrades: mapValues(snapshot.cumulative_trades, toBigDecimal),\n cumulativeVolumes: mapValues(snapshot.cumulative_volumes, toBigDecimal),\n depositRates: mapValues(snapshot.deposit_rates, (value) =>\n removeDecimals(value),\n ),\n fundingRates: mapValues(snapshot.funding_rates, (value) =>\n removeDecimals(value),\n ),\n openInterestsQuote: mapValues(snapshot.open_interests, toBigDecimal),\n totalBorrows: mapValues(snapshot.total_borrows, toBigDecimal),\n totalDeposits: mapValues(snapshot.total_deposits, toBigDecimal),\n cumulativeTradeSizes: mapValues(\n snapshot.cumulative_trade_sizes,\n toBigDecimal,\n ),\n cumulativeInflows: mapValues(snapshot.cumulative_inflows, toBigDecimal),\n cumulativeOutflows: mapValues(snapshot.cumulative_outflows, toBigDecimal),\n oraclePrices: mapValues(snapshot.oracle_prices, (value) =>\n removeDecimals(value),\n ),\n };\n}\n\nexport function mapIndexerNlpSnapshot(\n snapshot: IndexerServerNlpSnapshot,\n): IndexerNlpSnapshot {\n return {\n submissionIndex: snapshot.submission_idx,\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeBurnAmountUsdc: toBigDecimal(snapshot.cumulative_burn_usdc),\n cumulativeMintAmountUsdc: toBigDecimal(snapshot.cumulative_mint_usdc),\n cumulativePnl: toBigDecimal(snapshot.cumulative_pnl),\n cumulativeTrades: toBigDecimal(snapshot.cumulative_trades),\n cumulativeVolume: toBigDecimal(snapshot.cumulative_volume),\n depositors: toBigDecimal(snapshot.depositors),\n o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mB,0BAAU,SAAS,oBAAoB,2BAAY;AAAA,IACtE,wBAAoB,0BAAU,SAAS,qBAAqB,2BAAY;AAAA,IACxE,kBAAc;AAAA,MAAU,SAAS;AAAA,MAAe,CAAC,cAC/C,+BAAe,KAAK;AAAA,IACtB;AAAA,EACF;AACF;AAEO,SAAS,sBACd,UACoB;AACpB,SAAO;AAAA,IACL,iBAAiB,SAAS;AAAA,IAC1B,eAAW,6BAAa,SAAS,SAAS;AAAA,IAC1C,8BAA0B,6BAAa,SAAS,oBAAoB;AAAA,IACpE,8BAA0B,6BAAa,SAAS,oBAAoB;AAAA,IACpE,mBAAe,6BAAa,SAAS,cAAc;AAAA,IACnD,sBAAkB,6BAAa,SAAS,iBAAiB;AAAA,IACzD,sBAAkB,6BAAa,SAAS,iBAAiB;AAAA,IACzD,gBAAY,6BAAa,SAAS,UAAU;AAAA,IAC5C,iBAAa,+BAAe,SAAS,gBAAgB;AAAA,IACrD,SAAK,6BAAa,SAAS,GAAG;AAAA,EAChC;AACF;","names":["import_shared"]}
@@ -1,8 +1,7 @@
1
- import { Market } from '@nadohq/contracts';
1
+ import { Market } from '@nadohq/shared';
2
2
  import { IndexerSnapshotsIntervalParams, IndexerSpotBalance, IndexerPerpBalance, IndexerOrder, IndexerEvent, IndexerEventWithTx, IndexerMatchEventBalances, IndexerProductPayment, IndexerPerpPrices, IndexerFundingRate, IndexerMaker, IndexerLeaderboardParticipant, IndexerLeaderboardRegistration, IndexerLeaderboardContest, Candlestick, IndexerMarketSnapshot, IndexerNlpSnapshot } from './types/clientTypes.cjs';
3
3
  import { IndexerServerPerpPrices, IndexerServerFundingRate } from './types/serverTypes.cjs';
4
4
  import { IndexerServerSnapshotsInterval, IndexerServerProduct, IndexerServerBalance, IndexerServerOrder, IndexerServerEvent, IndexerServerTx, IndexerServerMatchEventBalances, IndexerServerProductPayment, IndexerServerMaker, IndexerServerLeaderboardPosition, IndexerServerLeaderboardRegistration, IndexerServerLeaderboardContest, IndexerServerCandlestick, IndexerServerMarketSnapshot, IndexerServerNlpSnapshot } from './types/serverModelTypes.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 { Market } from '@nadohq/contracts';
1
+ import { Market } from '@nadohq/shared';
2
2
  import { IndexerSnapshotsIntervalParams, IndexerSpotBalance, IndexerPerpBalance, IndexerOrder, IndexerEvent, IndexerEventWithTx, IndexerMatchEventBalances, IndexerProductPayment, IndexerPerpPrices, IndexerFundingRate, IndexerMaker, IndexerLeaderboardParticipant, IndexerLeaderboardRegistration, IndexerLeaderboardContest, Candlestick, IndexerMarketSnapshot, IndexerNlpSnapshot } from './types/clientTypes.js';
3
3
  import { IndexerServerPerpPrices, IndexerServerFundingRate } from './types/serverTypes.js';
4
4
  import { IndexerServerSnapshotsInterval, IndexerServerProduct, IndexerServerBalance, IndexerServerOrder, IndexerServerEvent, IndexerServerTx, IndexerServerMatchEventBalances, IndexerServerProductPayment, IndexerServerMaker, IndexerServerLeaderboardPosition, IndexerServerLeaderboardRegistration, IndexerServerLeaderboardContest, IndexerServerCandlestick, IndexerServerMarketSnapshot, IndexerServerNlpSnapshot } from './types/serverModelTypes.js';
5
- import '@nadohq/utils';
6
5
  import 'viem';
7
6
  import './types/CandlestickPeriod.js';
8
7
  import './types/IndexerEventType.js';
@@ -1,10 +1,10 @@
1
1
  // src/dataMappers.ts
2
2
  import {
3
3
  getRecvTimeFromOrderNonce,
4
- parseRawExpirationTimestamp,
5
4
  ProductEngineType,
6
- subaccountFromHex
7
- } from "@nadohq/contracts";
5
+ subaccountFromHex,
6
+ unpackOrderAppendix
7
+ } from "@nadohq/shared";
8
8
  import {
9
9
  mapEngineServerPerpProduct,
10
10
  mapEngineServerSpotProduct
@@ -14,7 +14,7 @@ import {
14
14
  removeDecimals,
15
15
  toBigDecimal,
16
16
  toIntegerString
17
- } from "@nadohq/utils";
17
+ } from "@nadohq/shared";
18
18
  function mapSnapshotsIntervalToServerParams(params) {
19
19
  return {
20
20
  count: params.limit,
@@ -44,16 +44,13 @@ function mapIndexerServerBalance(balance) {
44
44
  };
45
45
  }
46
46
  function mapIndexerOrder(order) {
47
- const expiration = toBigDecimal(order.expiration);
48
- const expirationEncodedData = parseRawExpirationTimestamp(order.expiration);
47
+ const appendix = unpackOrderAppendix(order.appendix);
49
48
  return {
50
49
  amount: toBigDecimal(order.amount),
51
50
  digest: order.digest,
52
51
  isolated: order.isolated,
53
- rawExpiration: expiration,
54
- isReduceOnly: expirationEncodedData.reduceOnly,
55
- expiration: expirationEncodedData.expirationTime,
56
- orderType: expirationEncodedData.type,
52
+ expiration: Number(order.expiration),
53
+ appendix,
57
54
  nonce: toBigDecimal(order.nonce),
58
55
  recvTimeSeconds: getRecvTimeFromOrderNonce(order.nonce) / 1e3,
59
56
  price: removeDecimals(order.price_x18),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dataMappers.ts"],"sourcesContent":["import {\n getRecvTimeFromOrderNonce,\n Market,\n parseRawExpirationTimestamp,\n PerpMarket,\n ProductEngineType,\n SpotMarket,\n subaccountFromHex,\n} from '@nadohq/contracts';\nimport {\n mapEngineServerPerpProduct,\n mapEngineServerSpotProduct,\n} from '@nadohq/engine-client';\nimport {\n mapValues,\n removeDecimals,\n toBigDecimal,\n toIntegerString,\n} from '@nadohq/utils';\nimport {\n Candlestick,\n IndexerEvent,\n IndexerEventWithTx,\n IndexerFundingRate,\n IndexerLeaderboardContest,\n IndexerLeaderboardParticipant,\n IndexerLeaderboardRegistration,\n IndexerMaker,\n IndexerMarketSnapshot,\n IndexerMatchEventBalances,\n IndexerOrder,\n IndexerPerpBalance,\n IndexerPerpPrices,\n IndexerProductPayment,\n IndexerServerBalance,\n IndexerServerCandlestick,\n IndexerServerEvent,\n IndexerServerFundingRate,\n IndexerServerLeaderboardContest,\n IndexerServerLeaderboardPosition,\n IndexerServerLeaderboardRegistration,\n IndexerServerMaker,\n IndexerServerMarketSnapshot,\n IndexerServerMatchEventBalances,\n IndexerServerOrder,\n IndexerServerPerpPrices,\n IndexerServerProduct,\n IndexerServerProductPayment,\n IndexerServerSnapshotsInterval,\n IndexerServerTx,\n IndexerServerNlpSnapshot,\n IndexerSnapshotsIntervalParams,\n IndexerSpotBalance,\n IndexerNlpSnapshot,\n} from './types';\n\nexport function mapSnapshotsIntervalToServerParams(\n params: IndexerSnapshotsIntervalParams,\n): IndexerServerSnapshotsInterval {\n return {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n };\n}\n\nexport function mapIndexerServerProduct(product: IndexerServerProduct): Market {\n if ('spot' in product) {\n return mapEngineServerSpotProduct(product.spot);\n }\n return mapEngineServerPerpProduct(product.perp);\n}\n\nexport function mapIndexerServerBalance(\n balance: IndexerServerBalance,\n): IndexerSpotBalance | IndexerPerpBalance {\n if ('spot' in balance) {\n return {\n amount: toBigDecimal(balance.spot.balance.amount),\n productId: balance.spot.product_id,\n type: ProductEngineType.SPOT,\n };\n }\n return {\n amount: toBigDecimal(balance.perp.balance.amount),\n productId: balance.perp.product_id,\n type: ProductEngineType.PERP,\n vQuoteBalance: toBigDecimal(balance.perp.balance.v_quote_balance),\n };\n}\n\nexport function mapIndexerOrder(order: IndexerServerOrder): IndexerOrder {\n const expiration = toBigDecimal(order.expiration);\n const expirationEncodedData = parseRawExpirationTimestamp(order.expiration);\n return {\n amount: toBigDecimal(order.amount),\n digest: order.digest,\n isolated: order.isolated,\n rawExpiration: expiration,\n isReduceOnly: expirationEncodedData.reduceOnly,\n expiration: expirationEncodedData.expirationTime,\n orderType: expirationEncodedData.type,\n nonce: toBigDecimal(order.nonce),\n recvTimeSeconds: getRecvTimeFromOrderNonce(order.nonce) / 1000,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccount: order.subaccount,\n submissionIndex: order.submission_idx,\n baseFilled: toBigDecimal(order.base_filled),\n quoteFilled: toBigDecimal(order.quote_filled),\n totalFee: toBigDecimal(order.fee),\n };\n}\n\nexport function mapIndexerEvent(event: IndexerServerEvent): IndexerEvent {\n const eventState: IndexerEvent['state'] = (() => {\n // Assume backend data is consistent\n if ('spot' in event.pre_balance) {\n return {\n type: ProductEngineType.SPOT,\n market: mapIndexerServerProduct(event.product) as SpotMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerSpotBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerSpotBalance,\n };\n }\n return {\n type: ProductEngineType.PERP,\n market: mapIndexerServerProduct(event.product) as PerpMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerPerpBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerPerpBalance,\n };\n })();\n\n return {\n eventType: event.event_type,\n productId: event.product_id,\n isolated: event.isolated,\n isolatedProductId: event.isolated_product_id,\n state: eventState,\n subaccount: event.subaccount,\n submissionIndex: event.submission_idx,\n trackedVars: {\n netEntryCumulative: toBigDecimal(event.net_entry_cumulative),\n netEntryUnrealized: toBigDecimal(event.net_entry_unrealized),\n netFundingCumulative: toBigDecimal(event.net_funding_cumulative),\n netFundingUnrealized: toBigDecimal(event.net_funding_unrealized),\n netInterestCumulative: toBigDecimal(event.net_interest_cumulative),\n netInterestUnrealized: toBigDecimal(event.net_interest_unrealized),\n },\n };\n}\n\nexport function mapIndexerEventWithTx(\n event: IndexerServerEvent,\n tx: IndexerServerTx,\n): IndexerEventWithTx {\n return {\n timestamp: toBigDecimal(tx.timestamp),\n tx: tx.tx,\n ...mapIndexerEvent(event),\n };\n}\n\nexport function mapIndexerMatchEventBalances(\n eventBalances: IndexerServerMatchEventBalances,\n): IndexerMatchEventBalances {\n return {\n base: mapIndexerServerBalance(eventBalances.base),\n quote: eventBalances.quote\n ? (mapIndexerServerBalance(eventBalances.quote) as IndexerSpotBalance)\n : undefined,\n };\n}\n\nexport function mapIndexerProductPayment(\n payment: IndexerServerProductPayment,\n): IndexerProductPayment {\n return {\n submissionIndex: payment.idx,\n timestamp: toBigDecimal(payment.timestamp),\n paymentAmount: toBigDecimal(payment.amount),\n balanceAmount: toBigDecimal(payment.balance_amount),\n annualPaymentRate: removeDecimals(payment.rate_x18),\n oraclePrice: removeDecimals(payment.oracle_price_x18),\n isolated: payment.isolated,\n productId: payment.product_id,\n isolatedProductId: payment.isolated_product_id,\n };\n}\n\nexport function mapIndexerPerpPrices(\n perpPrices: IndexerServerPerpPrices,\n): IndexerPerpPrices {\n return {\n indexPrice: removeDecimals(perpPrices.index_price_x18),\n markPrice: removeDecimals(perpPrices.mark_price_x18),\n updateTime: toBigDecimal(perpPrices.update_time),\n productId: perpPrices.product_id,\n };\n}\n\nexport function mapIndexerFundingRate(\n fundingRate: IndexerServerFundingRate,\n): IndexerFundingRate {\n return {\n fundingRate: removeDecimals(fundingRate.funding_rate_x18),\n updateTime: toBigDecimal(fundingRate.update_time),\n productId: fundingRate.product_id,\n };\n}\n\nexport function mapIndexerMakerStatistics(\n maker: IndexerServerMaker,\n): IndexerMaker {\n return {\n address: maker.address,\n snapshots: maker.data.map((makerData) => {\n return {\n timestamp: toBigDecimal(makerData.timestamp),\n makerFee: toBigDecimal(makerData.maker_fee),\n uptime: toBigDecimal(makerData.uptime),\n sumQMin: toBigDecimal(makerData.sum_q_min),\n qScore: toBigDecimal(makerData.q_score),\n makerShare: toBigDecimal(makerData.maker_share),\n expectedMakerReward: toBigDecimal(makerData.expected_maker_reward),\n };\n }),\n };\n}\n\nexport function mapIndexerLeaderboardPosition(\n position: IndexerServerLeaderboardPosition,\n): IndexerLeaderboardParticipant {\n return {\n subaccount: subaccountFromHex(position.subaccount),\n contestId: position.contest_id,\n pnl: toBigDecimal(position.pnl),\n pnlRank: toBigDecimal(position.pnl_rank),\n percentRoi: toBigDecimal(position.roi),\n roiRank: toBigDecimal(position.roi_rank),\n accountValue: toBigDecimal(position.account_value),\n volume: position.volume ? toBigDecimal(position.volume) : undefined,\n updateTime: toBigDecimal(position.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardRegistration(\n registration: IndexerServerLeaderboardRegistration,\n): IndexerLeaderboardRegistration {\n return {\n subaccount: subaccountFromHex(registration.subaccount),\n contestId: registration.contest_id,\n updateTime: toBigDecimal(registration.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardContest(\n contest: IndexerServerLeaderboardContest,\n): IndexerLeaderboardContest {\n return {\n contestId: contest.contest_id,\n startTime: toBigDecimal(contest.start_time),\n endTime: toBigDecimal(contest.end_time),\n period: toBigDecimal(contest.threshold),\n totalParticipants: toBigDecimal(contest.count),\n minRequiredAccountValue: toBigDecimal(contest.threshold),\n minRequiredVolume: toBigDecimal(contest.volume_threshold),\n requiredProductIds: contest.product_ids,\n active: contest.active,\n lastUpdated: toBigDecimal(contest.last_updated),\n };\n}\n\nexport function mapIndexerCandlesticks(\n candlestick: IndexerServerCandlestick,\n): Candlestick {\n return {\n close: removeDecimals(candlestick.close_x18),\n high: removeDecimals(candlestick.high_x18),\n low: removeDecimals(candlestick.low_x18),\n open: removeDecimals(candlestick.open_x18),\n time: toBigDecimal(candlestick.timestamp),\n volume: toBigDecimal(candlestick.volume),\n };\n}\n\nexport function mapIndexerMarketSnapshot(\n snapshot: IndexerServerMarketSnapshot,\n): IndexerMarketSnapshot {\n return {\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeUsers: toBigDecimal(snapshot.cumulative_users),\n dailyActiveUsers: toBigDecimal(snapshot.daily_active_users),\n tvl: toBigDecimal(snapshot.tvl),\n borrowRates: mapValues(snapshot.borrow_rates, (value) =>\n removeDecimals(value),\n ),\n cumulativeLiquidationAmounts: mapValues(\n snapshot.cumulative_liquidation_amounts,\n toBigDecimal,\n ),\n cumulativeMakerFees: mapValues(\n snapshot.cumulative_maker_fees,\n toBigDecimal,\n ),\n cumulativeSequencerFees: mapValues(\n snapshot.cumulative_sequencer_fees,\n toBigDecimal,\n ),\n cumulativeTakerFees: mapValues(\n snapshot.cumulative_taker_fees,\n toBigDecimal,\n ),\n cumulativeTrades: mapValues(snapshot.cumulative_trades, toBigDecimal),\n cumulativeVolumes: mapValues(snapshot.cumulative_volumes, toBigDecimal),\n depositRates: mapValues(snapshot.deposit_rates, (value) =>\n removeDecimals(value),\n ),\n fundingRates: mapValues(snapshot.funding_rates, (value) =>\n removeDecimals(value),\n ),\n openInterestsQuote: mapValues(snapshot.open_interests, toBigDecimal),\n totalBorrows: mapValues(snapshot.total_borrows, toBigDecimal),\n totalDeposits: mapValues(snapshot.total_deposits, toBigDecimal),\n cumulativeTradeSizes: mapValues(\n snapshot.cumulative_trade_sizes,\n toBigDecimal,\n ),\n cumulativeInflows: mapValues(snapshot.cumulative_inflows, toBigDecimal),\n cumulativeOutflows: mapValues(snapshot.cumulative_outflows, toBigDecimal),\n oraclePrices: mapValues(snapshot.oracle_prices, (value) =>\n removeDecimals(value),\n ),\n };\n}\n\nexport function mapIndexerNlpSnapshot(\n snapshot: IndexerServerNlpSnapshot,\n): IndexerNlpSnapshot {\n return {\n submissionIndex: snapshot.submission_idx,\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeBurnAmountUsdc: toBigDecimal(snapshot.cumulative_burn_usdc),\n cumulativeMintAmountUsdc: toBigDecimal(snapshot.cumulative_mint_usdc),\n cumulativePnl: toBigDecimal(snapshot.cumulative_pnl),\n cumulativeTrades: toBigDecimal(snapshot.cumulative_trades),\n cumulativeVolume: toBigDecimal(snapshot.cumulative_volume),\n depositors: toBigDecimal(snapshot.depositors),\n oraclePrice: removeDecimals(snapshot.oracle_price_x18),\n tvl: toBigDecimal(snapshot.tvl),\n };\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAsCA,SAAS,mCACd,QACgC;AAChC,SAAO;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0B,aAAa,SAAS,oBAAoB;AAAA,IACpE,eAAe,aAAa,SAAS,cAAc;AAAA,IACnD,kBAAkB,aAAa,SAAS,iBAAiB;AAAA,IACzD,kBAAkB,aAAa,SAAS,iBAAiB;AAAA,IACzD,YAAY,aAAa,SAAS,UAAU;AAAA,IAC5C,aAAa,eAAe,SAAS,gBAAgB;AAAA,IACrD,KAAK,aAAa,SAAS,GAAG;AAAA,EAChC;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/dataMappers.ts"],"sourcesContent":["import {\n getRecvTimeFromOrderNonce,\n Market,\n PerpMarket,\n ProductEngineType,\n SpotMarket,\n subaccountFromHex,\n unpackOrderAppendix,\n} from '@nadohq/shared';\nimport {\n mapEngineServerPerpProduct,\n mapEngineServerSpotProduct,\n} from '@nadohq/engine-client';\nimport {\n mapValues,\n removeDecimals,\n toBigDecimal,\n toIntegerString,\n} from '@nadohq/shared';\nimport {\n Candlestick,\n IndexerEvent,\n IndexerEventWithTx,\n IndexerFundingRate,\n IndexerLeaderboardContest,\n IndexerLeaderboardParticipant,\n IndexerLeaderboardRegistration,\n IndexerMaker,\n IndexerMarketSnapshot,\n IndexerMatchEventBalances,\n IndexerNlpSnapshot,\n IndexerOrder,\n IndexerPerpBalance,\n IndexerPerpPrices,\n IndexerProductPayment,\n IndexerServerBalance,\n IndexerServerCandlestick,\n IndexerServerEvent,\n IndexerServerFundingRate,\n IndexerServerLeaderboardContest,\n IndexerServerLeaderboardPosition,\n IndexerServerLeaderboardRegistration,\n IndexerServerMaker,\n IndexerServerMarketSnapshot,\n IndexerServerMatchEventBalances,\n IndexerServerNlpSnapshot,\n IndexerServerOrder,\n IndexerServerPerpPrices,\n IndexerServerProduct,\n IndexerServerProductPayment,\n IndexerServerSnapshotsInterval,\n IndexerServerTx,\n IndexerSnapshotsIntervalParams,\n IndexerSpotBalance,\n} from './types';\n\nexport function mapSnapshotsIntervalToServerParams(\n params: IndexerSnapshotsIntervalParams,\n): IndexerServerSnapshotsInterval {\n return {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n };\n}\n\nexport function mapIndexerServerProduct(product: IndexerServerProduct): Market {\n if ('spot' in product) {\n return mapEngineServerSpotProduct(product.spot);\n }\n return mapEngineServerPerpProduct(product.perp);\n}\n\nexport function mapIndexerServerBalance(\n balance: IndexerServerBalance,\n): IndexerSpotBalance | IndexerPerpBalance {\n if ('spot' in balance) {\n return {\n amount: toBigDecimal(balance.spot.balance.amount),\n productId: balance.spot.product_id,\n type: ProductEngineType.SPOT,\n };\n }\n return {\n amount: toBigDecimal(balance.perp.balance.amount),\n productId: balance.perp.product_id,\n type: ProductEngineType.PERP,\n vQuoteBalance: toBigDecimal(balance.perp.balance.v_quote_balance),\n };\n}\n\nexport function mapIndexerOrder(order: IndexerServerOrder): IndexerOrder {\n const appendix = unpackOrderAppendix(order.appendix);\n return {\n amount: toBigDecimal(order.amount),\n digest: order.digest,\n isolated: order.isolated,\n expiration: Number(order.expiration),\n appendix,\n nonce: toBigDecimal(order.nonce),\n recvTimeSeconds: getRecvTimeFromOrderNonce(order.nonce) / 1000,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccount: order.subaccount,\n submissionIndex: order.submission_idx,\n baseFilled: toBigDecimal(order.base_filled),\n quoteFilled: toBigDecimal(order.quote_filled),\n totalFee: toBigDecimal(order.fee),\n };\n}\n\nexport function mapIndexerEvent(event: IndexerServerEvent): IndexerEvent {\n const eventState: IndexerEvent['state'] = (() => {\n // Assume backend data is consistent\n if ('spot' in event.pre_balance) {\n return {\n type: ProductEngineType.SPOT,\n market: mapIndexerServerProduct(event.product) as SpotMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerSpotBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerSpotBalance,\n };\n }\n return {\n type: ProductEngineType.PERP,\n market: mapIndexerServerProduct(event.product) as PerpMarket,\n preBalance: mapIndexerServerBalance(\n event.pre_balance,\n ) as IndexerPerpBalance,\n postBalance: mapIndexerServerBalance(\n event.post_balance,\n ) as IndexerPerpBalance,\n };\n })();\n\n return {\n eventType: event.event_type,\n productId: event.product_id,\n isolated: event.isolated,\n isolatedProductId: event.isolated_product_id,\n state: eventState,\n subaccount: event.subaccount,\n submissionIndex: event.submission_idx,\n trackedVars: {\n netEntryCumulative: toBigDecimal(event.net_entry_cumulative),\n netEntryUnrealized: toBigDecimal(event.net_entry_unrealized),\n netFundingCumulative: toBigDecimal(event.net_funding_cumulative),\n netFundingUnrealized: toBigDecimal(event.net_funding_unrealized),\n netInterestCumulative: toBigDecimal(event.net_interest_cumulative),\n netInterestUnrealized: toBigDecimal(event.net_interest_unrealized),\n },\n };\n}\n\nexport function mapIndexerEventWithTx(\n event: IndexerServerEvent,\n tx: IndexerServerTx,\n): IndexerEventWithTx {\n return {\n timestamp: toBigDecimal(tx.timestamp),\n tx: tx.tx,\n ...mapIndexerEvent(event),\n };\n}\n\nexport function mapIndexerMatchEventBalances(\n eventBalances: IndexerServerMatchEventBalances,\n): IndexerMatchEventBalances {\n return {\n base: mapIndexerServerBalance(eventBalances.base),\n quote: eventBalances.quote\n ? (mapIndexerServerBalance(eventBalances.quote) as IndexerSpotBalance)\n : undefined,\n };\n}\n\nexport function mapIndexerProductPayment(\n payment: IndexerServerProductPayment,\n): IndexerProductPayment {\n return {\n submissionIndex: payment.idx,\n timestamp: toBigDecimal(payment.timestamp),\n paymentAmount: toBigDecimal(payment.amount),\n balanceAmount: toBigDecimal(payment.balance_amount),\n annualPaymentRate: removeDecimals(payment.rate_x18),\n oraclePrice: removeDecimals(payment.oracle_price_x18),\n isolated: payment.isolated,\n productId: payment.product_id,\n isolatedProductId: payment.isolated_product_id,\n };\n}\n\nexport function mapIndexerPerpPrices(\n perpPrices: IndexerServerPerpPrices,\n): IndexerPerpPrices {\n return {\n indexPrice: removeDecimals(perpPrices.index_price_x18),\n markPrice: removeDecimals(perpPrices.mark_price_x18),\n updateTime: toBigDecimal(perpPrices.update_time),\n productId: perpPrices.product_id,\n };\n}\n\nexport function mapIndexerFundingRate(\n fundingRate: IndexerServerFundingRate,\n): IndexerFundingRate {\n return {\n fundingRate: removeDecimals(fundingRate.funding_rate_x18),\n updateTime: toBigDecimal(fundingRate.update_time),\n productId: fundingRate.product_id,\n };\n}\n\nexport function mapIndexerMakerStatistics(\n maker: IndexerServerMaker,\n): IndexerMaker {\n return {\n address: maker.address,\n snapshots: maker.data.map((makerData) => {\n return {\n timestamp: toBigDecimal(makerData.timestamp),\n makerFee: toBigDecimal(makerData.maker_fee),\n uptime: toBigDecimal(makerData.uptime),\n sumQMin: toBigDecimal(makerData.sum_q_min),\n qScore: toBigDecimal(makerData.q_score),\n makerShare: toBigDecimal(makerData.maker_share),\n expectedMakerReward: toBigDecimal(makerData.expected_maker_reward),\n };\n }),\n };\n}\n\nexport function mapIndexerLeaderboardPosition(\n position: IndexerServerLeaderboardPosition,\n): IndexerLeaderboardParticipant {\n return {\n subaccount: subaccountFromHex(position.subaccount),\n contestId: position.contest_id,\n pnl: toBigDecimal(position.pnl),\n pnlRank: toBigDecimal(position.pnl_rank),\n percentRoi: toBigDecimal(position.roi),\n roiRank: toBigDecimal(position.roi_rank),\n accountValue: toBigDecimal(position.account_value),\n volume: position.volume ? toBigDecimal(position.volume) : undefined,\n updateTime: toBigDecimal(position.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardRegistration(\n registration: IndexerServerLeaderboardRegistration,\n): IndexerLeaderboardRegistration {\n return {\n subaccount: subaccountFromHex(registration.subaccount),\n contestId: registration.contest_id,\n updateTime: toBigDecimal(registration.update_time),\n };\n}\n\nexport function mapIndexerLeaderboardContest(\n contest: IndexerServerLeaderboardContest,\n): IndexerLeaderboardContest {\n return {\n contestId: contest.contest_id,\n startTime: toBigDecimal(contest.start_time),\n endTime: toBigDecimal(contest.end_time),\n period: toBigDecimal(contest.threshold),\n totalParticipants: toBigDecimal(contest.count),\n minRequiredAccountValue: toBigDecimal(contest.threshold),\n minRequiredVolume: toBigDecimal(contest.volume_threshold),\n requiredProductIds: contest.product_ids,\n active: contest.active,\n lastUpdated: toBigDecimal(contest.last_updated),\n };\n}\n\nexport function mapIndexerCandlesticks(\n candlestick: IndexerServerCandlestick,\n): Candlestick {\n return {\n close: removeDecimals(candlestick.close_x18),\n high: removeDecimals(candlestick.high_x18),\n low: removeDecimals(candlestick.low_x18),\n open: removeDecimals(candlestick.open_x18),\n time: toBigDecimal(candlestick.timestamp),\n volume: toBigDecimal(candlestick.volume),\n };\n}\n\nexport function mapIndexerMarketSnapshot(\n snapshot: IndexerServerMarketSnapshot,\n): IndexerMarketSnapshot {\n return {\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeUsers: toBigDecimal(snapshot.cumulative_users),\n dailyActiveUsers: toBigDecimal(snapshot.daily_active_users),\n tvl: toBigDecimal(snapshot.tvl),\n borrowRates: mapValues(snapshot.borrow_rates, (value) =>\n removeDecimals(value),\n ),\n cumulativeLiquidationAmounts: mapValues(\n snapshot.cumulative_liquidation_amounts,\n toBigDecimal,\n ),\n cumulativeMakerFees: mapValues(\n snapshot.cumulative_maker_fees,\n toBigDecimal,\n ),\n cumulativeSequencerFees: mapValues(\n snapshot.cumulative_sequencer_fees,\n toBigDecimal,\n ),\n cumulativeTakerFees: mapValues(\n snapshot.cumulative_taker_fees,\n toBigDecimal,\n ),\n cumulativeTrades: mapValues(snapshot.cumulative_trades, toBigDecimal),\n cumulativeVolumes: mapValues(snapshot.cumulative_volumes, toBigDecimal),\n depositRates: mapValues(snapshot.deposit_rates, (value) =>\n removeDecimals(value),\n ),\n fundingRates: mapValues(snapshot.funding_rates, (value) =>\n removeDecimals(value),\n ),\n openInterestsQuote: mapValues(snapshot.open_interests, toBigDecimal),\n totalBorrows: mapValues(snapshot.total_borrows, toBigDecimal),\n totalDeposits: mapValues(snapshot.total_deposits, toBigDecimal),\n cumulativeTradeSizes: mapValues(\n snapshot.cumulative_trade_sizes,\n toBigDecimal,\n ),\n cumulativeInflows: mapValues(snapshot.cumulative_inflows, toBigDecimal),\n cumulativeOutflows: mapValues(snapshot.cumulative_outflows, toBigDecimal),\n oraclePrices: mapValues(snapshot.oracle_prices, (value) =>\n removeDecimals(value),\n ),\n };\n}\n\nexport function mapIndexerNlpSnapshot(\n snapshot: IndexerServerNlpSnapshot,\n): IndexerNlpSnapshot {\n return {\n submissionIndex: snapshot.submission_idx,\n timestamp: toBigDecimal(snapshot.timestamp),\n cumulativeBurnAmountUsdc: toBigDecimal(snapshot.cumulative_burn_usdc),\n cumulativeMintAmountUsdc: toBigDecimal(snapshot.cumulative_mint_usdc),\n cumulativePnl: toBigDecimal(snapshot.cumulative_pnl),\n cumulativeTrades: toBigDecimal(snapshot.cumulative_trades),\n cumulativeVolume: toBigDecimal(snapshot.cumulative_volume),\n depositors: toBigDecimal(snapshot.depositors),\n oraclePrice: removeDecimals(snapshot.oracle_price_x18),\n tvl: toBigDecimal(snapshot.tvl),\n };\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EAGA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAsCA,SAAS,mCACd,QACgC;AAChC,SAAO;AAAA,IACL,OAAO,OAAO;AAAA,IACd,UAAU,OAAO,mBACb,gBAAgB,OAAO,gBAAgB,IACvC;AAAA,IACJ,aAAa,OAAO;AAAA,EACtB;AACF;AAEO,SAAS,wBAAwB,SAAuC;AAC7E,MAAI,UAAU,SAAS;AACrB,WAAO,2BAA2B,QAAQ,IAAI;AAAA,EAChD;AACA,SAAO,2BAA2B,QAAQ,IAAI;AAChD;AAEO,SAAS,wBACd,SACyC;AACzC,MAAI,UAAU,SAAS;AACrB,WAAO;AAAA,MACL,QAAQ,aAAa,QAAQ,KAAK,QAAQ,MAAM;AAAA,MAChD,WAAW,QAAQ,KAAK;A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UAAU,SAAS,oBAAoB,YAAY;AAAA,IACtE,cAAc;AAAA,MAAU,SAAS;AAAA,MAAe,CAAC,UAC/C,eAAe,KAAK;AAAA,IACtB;AAAA,IACA,cAAc;AAAA,MAAU,SAAS;AAAA,MAAe,CAAC,UAC/C,eAAe,KAAK;AAAA,IACtB;AAAA,IACA,oBAAoB,UAAU,SAAS,gBAAgB,YAAY;AAAA,IACnE,cAAc,UAAU,SAAS,eAAe,YAAY;AAAA,IAC5D,eAAe,UAAU,SAAS,gBAAgB,YAAY;AAAA,IAC9D,sBAAsB;AAAA,MACpB,SAAS;AAAA,MACT;AAAA,IACF;AAAA,IACA,mBAAmB,UAAU,SAAS,oBAAoB,YAAY;AAAA,IACtE,oBAAoB,UAAU,SAAS,qBAAqB,YAAY;AAAA,IACxE,cAAc;AAAA,MAAU,SAAS;AAAA,MAAe,CAAC,UAC/C,eAAe,KAAK;AAAA,IACtB;AAAA,EACF;AACF;AAEO,SAAS,sBACd,UACoB;AACpB,SAAO;AAAA,IACL,iBAAiB,SAAS;AAAA,IAC1B,WAAW,aAAa,SAAS,SAAS;AAAA,IAC1C,0BAA0B,aAAa,SAAS,oBAAoB;AAAA,IACpE,0BAA0B,aAAa,SAAS,oBAAoB;AAAA,IACpE,eAAe,aAAa,SAAS,cAAc;AAAA,IACnD,kBAAkB,aAAa,SAAS,iBAAiB;AAAA,IACzD,kBAAkB,aAAa,SAAS,iBAAiB;AAAA,IACzD,YAAY,aAAa,SAAS,UAAU;AAAA,IAC5C,aAAa,eAAe,SAAS,gBAAgB;AAAA,IACrD,KAAK,aAAa,SAAS,GAAG;AAAA,EAChC;AACF;","names":[]}
@@ -25,8 +25,8 @@ __export(endpoints_exports, {
25
25
  module.exports = __toCommonJS(endpoints_exports);
26
26
  var INDEXER_CLIENT_ENDPOINTS = {
27
27
  local: "http://localhost:8000/indexer",
28
- arbitrumTestnet: "https://archive.sepolia-test.vertexprotocol.com/v1",
29
- arbitrum: "https://archive.prod.vertexprotocol.com/v1"
28
+ arbitrum: "https://archive.prod.vertexprotocol.com/v1",
29
+ inkTestnet: "https://archive.test.nado-backend.xyz/v1"
30
30
  };
31
31
  // Annotate the CommonJS export names for ESM import in node:
32
32
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/endpoints.ts"],"sourcesContent":["import { ChainEnv } from '@nadohq/contracts';\n\nexport const INDEXER_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {\n local: 'http://localhost:8000/indexer',\n arbitrumTestnet: 'https://archive.sepolia-test.vertexprotocol.com/v1',\n arbitrum: 'https://archive.prod.vertexprotocol.com/v1',\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,2BAAqD;AAAA,EAChE,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB,UAAU;AACZ;","names":[]}
1
+ {"version":3,"sources":["../src/endpoints.ts"],"sourcesContent":["import { ChainEnv } from '@nadohq/shared';\n\nexport const INDEXER_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {\n local: 'http://localhost:8000/indexer',\n arbitrum: 'https://archive.prod.vertexprotocol.com/v1',\n inkTestnet: 'https://archive.test.nado-backend.xyz/v1',\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,2BAAqD;AAAA,EAChE,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YAAY;AACd;","names":[]}
@@ -1,4 +1,4 @@
1
- import { ChainEnv } from '@nadohq/contracts';
1
+ import { ChainEnv } from '@nadohq/shared';
2
2
 
3
3
  declare const INDEXER_CLIENT_ENDPOINTS: Record<ChainEnv, string>;
4
4
 
@@ -1,4 +1,4 @@
1
- import { ChainEnv } from '@nadohq/contracts';
1
+ import { ChainEnv } from '@nadohq/shared';
2
2
 
3
3
  declare const INDEXER_CLIENT_ENDPOINTS: Record<ChainEnv, string>;
4
4