@nadohq/indexer-client 0.15.0 → 0.18.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
@@ -1,355 +1,289 @@
1
- // src/dataMappers.ts
2
- import {
3
- mapEngineServerPerpProduct,
4
- mapEngineServerSpotProduct
5
- } from "@nadohq/engine-client";
6
- import {
7
- getRecvTimeFromOrderNonce,
8
- mapValues,
9
- ProductEngineType,
10
- removeDecimals,
11
- subaccountFromHex,
12
- toBigNumber,
13
- toIntegerString,
14
- unpackOrderAppendix
15
- } from "@nadohq/shared";
1
+ import { ProductEngineType, getRecvTimeFromOrderNonce, mapValues, removeDecimals, subaccountFromHex, toBigNumber, toIntegerString, unpackOrderAppendix } from "@nadohq/shared";
2
+ import { mapEngineServerPerpProduct, mapEngineServerSpotProduct } from "@nadohq/engine-client";
3
+ //#region src/dataMappers.ts
16
4
  function mapSnapshotsIntervalToServerParams(params) {
17
- return {
18
- count: params.limit,
19
- max_time: params.maxTimeInclusive ? toIntegerString(params.maxTimeInclusive) : void 0,
20
- granularity: params.granularity
21
- };
5
+ return {
6
+ count: params.limit,
7
+ max_time: params.maxTimeInclusive ? toIntegerString(params.maxTimeInclusive) : void 0,
8
+ granularity: params.granularity
9
+ };
22
10
  }
23
11
  function mapIndexerServerProduct(product) {
24
- if ("spot" in product) {
25
- return mapEngineServerSpotProduct(product.spot);
26
- }
27
- return mapEngineServerPerpProduct(product.perp);
12
+ if ("spot" in product) return mapEngineServerSpotProduct(product.spot);
13
+ return mapEngineServerPerpProduct(product.perp);
28
14
  }
29
15
  function mapIndexerServerBalance(balance) {
30
- if ("spot" in balance) {
31
- return {
32
- amount: toBigNumber(balance.spot.balance.amount),
33
- productId: balance.spot.product_id,
34
- type: ProductEngineType.SPOT
35
- };
36
- }
37
- return {
38
- amount: toBigNumber(balance.perp.balance.amount),
39
- productId: balance.perp.product_id,
40
- type: ProductEngineType.PERP,
41
- vQuoteBalance: toBigNumber(balance.perp.balance.v_quote_balance)
42
- };
16
+ if ("spot" in balance) return {
17
+ amount: toBigNumber(balance.spot.balance.amount),
18
+ productId: balance.spot.product_id,
19
+ type: ProductEngineType.SPOT
20
+ };
21
+ return {
22
+ amount: toBigNumber(balance.perp.balance.amount),
23
+ productId: balance.perp.product_id,
24
+ type: ProductEngineType.PERP,
25
+ vQuoteBalance: toBigNumber(balance.perp.balance.v_quote_balance)
26
+ };
43
27
  }
44
28
  function mapIndexerOrder(order) {
45
- const appendix = unpackOrderAppendix(order.appendix);
46
- return {
47
- amount: toBigNumber(order.amount),
48
- digest: order.digest,
49
- expiration: Number(order.expiration),
50
- appendix,
51
- nonce: toBigNumber(order.nonce),
52
- isolated: order.isolated,
53
- recvTimeSeconds: getRecvTimeFromOrderNonce(order.nonce) / 1e3,
54
- price: removeDecimals(order.price_x18),
55
- productId: order.product_id,
56
- subaccount: order.subaccount,
57
- submissionIndex: order.submission_idx,
58
- lastFillSubmissionIndex: order.last_fill_submission_idx,
59
- baseFilled: toBigNumber(order.base_filled),
60
- quoteFilled: toBigNumber(order.quote_filled),
61
- totalFee: toBigNumber(order.fee),
62
- builderFee: toBigNumber(order.builder_fee),
63
- realizedPnl: toBigNumber(order.realized_pnl),
64
- closedAmount: toBigNumber(order.closed_amount),
65
- closedNetEntry: toBigNumber(order.closed_net_entry),
66
- preCloseMargin: order.closed_margin ? toBigNumber(order.closed_margin) : null,
67
- firstFillTimestamp: toBigNumber(order.first_fill_timestamp),
68
- lastFillTimestamp: toBigNumber(order.last_fill_timestamp),
69
- preBalances: mapIndexerMatchEventBalances(order.pre_balance),
70
- postBalances: mapIndexerMatchEventBalances(order.post_balance)
71
- };
29
+ const appendix = unpackOrderAppendix(order.appendix);
30
+ return {
31
+ amount: toBigNumber(order.amount),
32
+ digest: order.digest,
33
+ expiration: Number(order.expiration),
34
+ appendix,
35
+ nonce: toBigNumber(order.nonce),
36
+ isolated: order.isolated,
37
+ recvTimeSeconds: getRecvTimeFromOrderNonce(order.nonce) / 1e3,
38
+ price: removeDecimals(order.price_x18),
39
+ productId: order.product_id,
40
+ subaccount: order.subaccount,
41
+ submissionIndex: order.submission_idx,
42
+ lastFillSubmissionIndex: order.last_fill_submission_idx,
43
+ baseFilled: toBigNumber(order.base_filled),
44
+ quoteFilled: toBigNumber(order.quote_filled),
45
+ totalFee: toBigNumber(order.fee),
46
+ builderFee: toBigNumber(order.builder_fee),
47
+ realizedPnl: toBigNumber(order.realized_pnl),
48
+ closedAmount: toBigNumber(order.closed_amount),
49
+ closedNetEntry: toBigNumber(order.closed_net_entry),
50
+ preCloseMargin: order.closed_margin ? toBigNumber(order.closed_margin) : null,
51
+ firstFillTimestamp: toBigNumber(order.first_fill_timestamp),
52
+ lastFillTimestamp: toBigNumber(order.last_fill_timestamp),
53
+ preBalances: mapIndexerMatchEventBalances(order.pre_balance),
54
+ postBalances: mapIndexerMatchEventBalances(order.post_balance)
55
+ };
72
56
  }
73
57
  function mapIndexerEvent(event) {
74
- const eventState = (() => {
75
- if ("spot" in event.pre_balance) {
76
- return {
77
- type: ProductEngineType.SPOT,
78
- market: mapIndexerServerProduct(event.product),
79
- preBalance: mapIndexerServerBalance(
80
- event.pre_balance
81
- ),
82
- postBalance: mapIndexerServerBalance(
83
- event.post_balance
84
- )
85
- };
86
- }
87
- return {
88
- type: ProductEngineType.PERP,
89
- market: mapIndexerServerProduct(event.product),
90
- preBalance: mapIndexerServerBalance(
91
- event.pre_balance
92
- ),
93
- postBalance: mapIndexerServerBalance(
94
- event.post_balance
95
- )
96
- };
97
- })();
98
- return {
99
- eventType: event.event_type,
100
- productId: event.product_id,
101
- isolated: event.isolated,
102
- isolatedProductId: event.isolated_product_id,
103
- state: eventState,
104
- subaccount: event.subaccount,
105
- submissionIndex: event.submission_idx,
106
- trackedVars: {
107
- netEntryCumulative: toBigNumber(event.net_entry_cumulative),
108
- netEntryUnrealized: toBigNumber(event.net_entry_unrealized),
109
- netFundingCumulative: toBigNumber(event.net_funding_cumulative),
110
- netFundingUnrealized: toBigNumber(event.net_funding_unrealized),
111
- netInterestCumulative: toBigNumber(event.net_interest_cumulative),
112
- netInterestUnrealized: toBigNumber(event.net_interest_unrealized),
113
- quoteVolumeCumulative: toBigNumber(event.quote_volume_cumulative)
114
- }
115
- };
58
+ const eventState = (() => {
59
+ if ("spot" in event.pre_balance) return {
60
+ type: ProductEngineType.SPOT,
61
+ market: mapIndexerServerProduct(event.product),
62
+ preBalance: mapIndexerServerBalance(event.pre_balance),
63
+ postBalance: mapIndexerServerBalance(event.post_balance)
64
+ };
65
+ return {
66
+ type: ProductEngineType.PERP,
67
+ market: mapIndexerServerProduct(event.product),
68
+ preBalance: mapIndexerServerBalance(event.pre_balance),
69
+ postBalance: mapIndexerServerBalance(event.post_balance)
70
+ };
71
+ })();
72
+ return {
73
+ eventType: event.event_type,
74
+ productId: event.product_id,
75
+ isolated: event.isolated,
76
+ isolatedProductId: event.isolated_product_id,
77
+ state: eventState,
78
+ subaccount: event.subaccount,
79
+ submissionIndex: event.submission_idx,
80
+ trackedVars: {
81
+ netEntryCumulative: toBigNumber(event.net_entry_cumulative),
82
+ netEntryUnrealized: toBigNumber(event.net_entry_unrealized),
83
+ netFundingCumulative: toBigNumber(event.net_funding_cumulative),
84
+ netFundingUnrealized: toBigNumber(event.net_funding_unrealized),
85
+ netInterestCumulative: toBigNumber(event.net_interest_cumulative),
86
+ netInterestUnrealized: toBigNumber(event.net_interest_unrealized),
87
+ quoteVolumeCumulative: toBigNumber(event.quote_volume_cumulative)
88
+ }
89
+ };
116
90
  }
117
91
  function mapIndexerEventWithTx(event, tx) {
118
- return {
119
- timestamp: toBigNumber(tx.timestamp),
120
- tx: tx.tx,
121
- ...mapIndexerEvent(event)
122
- };
92
+ return {
93
+ timestamp: toBigNumber(tx.timestamp),
94
+ tx: tx.tx,
95
+ ...mapIndexerEvent(event)
96
+ };
123
97
  }
124
98
  function mapIndexerMatchEventBalances(eventBalances) {
125
- return {
126
- base: mapIndexerServerBalance(eventBalances.base),
127
- quote: eventBalances.quote ? mapIndexerServerBalance(eventBalances.quote) : void 0
128
- };
99
+ return {
100
+ base: mapIndexerServerBalance(eventBalances.base),
101
+ quote: eventBalances.quote ? mapIndexerServerBalance(eventBalances.quote) : void 0
102
+ };
129
103
  }
130
104
  function mapIndexerProductPayment(payment) {
131
- return {
132
- submissionIndex: payment.idx,
133
- timestamp: toBigNumber(payment.timestamp),
134
- paymentAmount: toBigNumber(payment.amount),
135
- balanceAmount: toBigNumber(payment.balance_amount),
136
- annualPaymentRate: removeDecimals(payment.rate_x18),
137
- oraclePrice: removeDecimals(payment.oracle_price_x18),
138
- isolated: payment.isolated,
139
- productId: payment.product_id,
140
- isolatedProductId: payment.isolated_product_id
141
- };
105
+ return {
106
+ submissionIndex: payment.idx,
107
+ timestamp: toBigNumber(payment.timestamp),
108
+ paymentAmount: toBigNumber(payment.amount),
109
+ balanceAmount: toBigNumber(payment.balance_amount),
110
+ annualPaymentRate: removeDecimals(payment.rate_x18),
111
+ oraclePrice: removeDecimals(payment.oracle_price_x18),
112
+ isolated: payment.isolated,
113
+ productId: payment.product_id,
114
+ isolatedProductId: payment.isolated_product_id
115
+ };
142
116
  }
143
117
  function mapIndexerPerpPrices(perpPrices) {
144
- return {
145
- indexPrice: removeDecimals(perpPrices.index_price_x18),
146
- markPrice: removeDecimals(perpPrices.mark_price_x18),
147
- updateTime: toBigNumber(perpPrices.update_time),
148
- productId: perpPrices.product_id
149
- };
118
+ return {
119
+ indexPrice: removeDecimals(perpPrices.index_price_x18),
120
+ markPrice: removeDecimals(perpPrices.mark_price_x18),
121
+ updateTime: toBigNumber(perpPrices.update_time),
122
+ productId: perpPrices.product_id
123
+ };
150
124
  }
151
125
  function mapIndexerFundingRate(fundingRate) {
152
- return {
153
- fundingRate: removeDecimals(fundingRate.funding_rate_x18),
154
- updateTime: toBigNumber(fundingRate.update_time),
155
- productId: fundingRate.product_id
156
- };
126
+ return {
127
+ fundingRate: removeDecimals(fundingRate.funding_rate_x18),
128
+ updateTime: toBigNumber(fundingRate.update_time),
129
+ productId: fundingRate.product_id
130
+ };
157
131
  }
158
132
  function mapIndexerMakerStatistics(maker) {
159
- return {
160
- address: maker.address,
161
- snapshots: maker.data.map((makerData) => {
162
- return {
163
- timestamp: toBigNumber(makerData.timestamp),
164
- makerFee: toBigNumber(makerData.maker_fee),
165
- uptime: toBigNumber(makerData.uptime),
166
- sumQMin: toBigNumber(makerData.sum_q_min),
167
- qScore: toBigNumber(makerData.q_score),
168
- makerShare: toBigNumber(makerData.maker_share),
169
- expectedMakerReward: toBigNumber(makerData.expected_maker_reward)
170
- };
171
- })
172
- };
133
+ return {
134
+ address: maker.address,
135
+ snapshots: maker.data.map((makerData) => {
136
+ return {
137
+ timestamp: toBigNumber(makerData.timestamp),
138
+ makerFee: toBigNumber(makerData.maker_fee),
139
+ uptime: toBigNumber(makerData.uptime),
140
+ sumQMin: toBigNumber(makerData.sum_q_min),
141
+ qScore: toBigNumber(makerData.q_score),
142
+ makerShare: toBigNumber(makerData.maker_share),
143
+ expectedMakerReward: toBigNumber(makerData.expected_maker_reward)
144
+ };
145
+ })
146
+ };
173
147
  }
174
148
  function mapIndexerLeaderboardPosition(position) {
175
- const tracks = mapValues(position.tracks, (trackData) => ({
176
- value: toBigNumber(trackData.value),
177
- rank: toBigNumber(trackData.rank),
178
- qualificationStatus: trackData.qualification_status
179
- }));
180
- return {
181
- subaccount: subaccountFromHex(position.subaccount),
182
- contestId: position.contest_id,
183
- accountValue: toBigNumber(position.account_value),
184
- updateTime: toBigNumber(position.update_time),
185
- tracks,
186
- socialAccounts: position.social_accounts.map((account) => ({
187
- provider: account.provider,
188
- username: account.username,
189
- displayName: account.display_name,
190
- profileImageUrl: account.profile_image_url
191
- }))
192
- };
149
+ const tracks = mapValues(position.tracks, (trackData) => ({
150
+ value: toBigNumber(trackData.value),
151
+ rank: toBigNumber(trackData.rank),
152
+ qualificationStatus: trackData.qualification_status
153
+ }));
154
+ return {
155
+ subaccount: subaccountFromHex(position.subaccount),
156
+ contestId: position.contest_id,
157
+ accountValue: toBigNumber(position.account_value),
158
+ updateTime: toBigNumber(position.update_time),
159
+ tracks,
160
+ socialAccounts: position.social_accounts.map((account) => ({
161
+ provider: account.provider,
162
+ username: account.username,
163
+ displayName: account.display_name,
164
+ profileImageUrl: account.profile_image_url
165
+ }))
166
+ };
193
167
  }
194
168
  function mapIndexerLeaderboardRegistration(registration) {
195
- return {
196
- subaccount: subaccountFromHex(registration.subaccount),
197
- contestId: registration.contest_id,
198
- updateTime: toBigNumber(registration.update_time)
199
- };
169
+ return {
170
+ subaccount: subaccountFromHex(registration.subaccount),
171
+ contestId: registration.contest_id,
172
+ updateTime: toBigNumber(registration.update_time)
173
+ };
200
174
  }
201
175
  function mapIndexerLeaderboardContest(contest) {
202
- const startTime = toBigNumber(contest.start_time);
203
- const endTime = toBigNumber(contest.end_time);
204
- return {
205
- contestId: contest.contest_id,
206
- startTime,
207
- endTime,
208
- totalParticipants: toBigNumber(contest.count),
209
- requiredProductIds: contest.product_ids,
210
- active: contest.active,
211
- lastUpdated: toBigNumber(contest.last_updated),
212
- title: contest.title,
213
- description: contest.description,
214
- tracks: contest.tracks.map((track) => ({
215
- trackId: track.track_id,
216
- rankType: track.rank_type,
217
- sortOrder: track.sort_order,
218
- minRequiredAccountValue: toBigNumber(track.threshold)
219
- }))
220
- };
176
+ const startTime = toBigNumber(contest.start_time);
177
+ const endTime = toBigNumber(contest.end_time);
178
+ return {
179
+ contestId: contest.contest_id,
180
+ startTime,
181
+ endTime,
182
+ totalParticipants: toBigNumber(contest.count),
183
+ requiredProductIds: contest.product_ids,
184
+ active: contest.active,
185
+ lastUpdated: toBigNumber(contest.last_updated),
186
+ title: contest.title,
187
+ description: contest.description,
188
+ tracks: contest.tracks.map((track) => ({
189
+ trackId: track.track_id,
190
+ rankType: track.rank_type,
191
+ sortOrder: track.sort_order,
192
+ minRequiredAccountValue: toBigNumber(track.threshold)
193
+ }))
194
+ };
221
195
  }
222
196
  function mapIndexerCandlesticks(candlestick) {
223
- return {
224
- close: removeDecimals(candlestick.close_x18),
225
- high: removeDecimals(candlestick.high_x18),
226
- low: removeDecimals(candlestick.low_x18),
227
- open: removeDecimals(candlestick.open_x18),
228
- time: toBigNumber(candlestick.timestamp),
229
- volume: toBigNumber(candlestick.volume)
230
- };
197
+ return {
198
+ close: removeDecimals(candlestick.close_x18),
199
+ high: removeDecimals(candlestick.high_x18),
200
+ low: removeDecimals(candlestick.low_x18),
201
+ open: removeDecimals(candlestick.open_x18),
202
+ time: toBigNumber(candlestick.timestamp),
203
+ volume: toBigNumber(candlestick.volume)
204
+ };
231
205
  }
232
206
  function mapIndexerMarketSnapshot(snapshot) {
233
- return {
234
- timestamp: toBigNumber(snapshot.timestamp),
235
- cumulativeUsers: toBigNumber(snapshot.cumulative_users),
236
- dailyActiveUsers: toBigNumber(snapshot.daily_active_users),
237
- tvl: toBigNumber(snapshot.tvl),
238
- borrowRates: mapValues(
239
- snapshot.borrow_rates,
240
- (value) => removeDecimals(value)
241
- ),
242
- cumulativeLiquidationAmounts: mapValues(
243
- snapshot.cumulative_liquidation_amounts,
244
- toBigNumber
245
- ),
246
- cumulativeMakerFees: mapValues(snapshot.cumulative_maker_fees, toBigNumber),
247
- cumulativeSequencerFees: mapValues(
248
- snapshot.cumulative_sequencer_fees,
249
- toBigNumber
250
- ),
251
- cumulativeTakerFees: mapValues(snapshot.cumulative_taker_fees, toBigNumber),
252
- cumulativeTrades: mapValues(snapshot.cumulative_trades, toBigNumber),
253
- cumulativeVolumes: mapValues(snapshot.cumulative_volumes, toBigNumber),
254
- depositRates: mapValues(
255
- snapshot.deposit_rates,
256
- (value) => removeDecimals(value)
257
- ),
258
- fundingRates: mapValues(
259
- snapshot.funding_rates,
260
- (value) => removeDecimals(value)
261
- ),
262
- openInterestsQuote: mapValues(snapshot.open_interests, toBigNumber),
263
- totalBorrows: mapValues(snapshot.total_borrows, toBigNumber),
264
- totalDeposits: mapValues(snapshot.total_deposits, toBigNumber),
265
- cumulativeTradeSizes: mapValues(
266
- snapshot.cumulative_trade_sizes,
267
- toBigNumber
268
- ),
269
- cumulativeInflows: mapValues(snapshot.cumulative_inflows, toBigNumber),
270
- cumulativeOutflows: mapValues(snapshot.cumulative_outflows, toBigNumber),
271
- oraclePrices: mapValues(
272
- snapshot.oracle_prices,
273
- (value) => removeDecimals(value)
274
- )
275
- };
207
+ return {
208
+ timestamp: toBigNumber(snapshot.timestamp),
209
+ cumulativeUsers: toBigNumber(snapshot.cumulative_users),
210
+ dailyActiveUsers: toBigNumber(snapshot.daily_active_users),
211
+ tvl: toBigNumber(snapshot.tvl),
212
+ borrowRates: mapValues(snapshot.borrow_rates, (value) => removeDecimals(value)),
213
+ cumulativeLiquidationAmounts: mapValues(snapshot.cumulative_liquidation_amounts, toBigNumber),
214
+ cumulativeMakerFees: mapValues(snapshot.cumulative_maker_fees, toBigNumber),
215
+ cumulativeSequencerFees: mapValues(snapshot.cumulative_sequencer_fees, toBigNumber),
216
+ cumulativeTakerFees: mapValues(snapshot.cumulative_taker_fees, toBigNumber),
217
+ cumulativeTrades: mapValues(snapshot.cumulative_trades, toBigNumber),
218
+ cumulativeVolumes: mapValues(snapshot.cumulative_volumes, toBigNumber),
219
+ depositRates: mapValues(snapshot.deposit_rates, (value) => removeDecimals(value)),
220
+ fundingRates: mapValues(snapshot.funding_rates, (value) => removeDecimals(value)),
221
+ openInterestsQuote: mapValues(snapshot.open_interests, toBigNumber),
222
+ totalBorrows: mapValues(snapshot.total_borrows, toBigNumber),
223
+ totalDeposits: mapValues(snapshot.total_deposits, toBigNumber),
224
+ cumulativeTradeSizes: mapValues(snapshot.cumulative_trade_sizes, toBigNumber),
225
+ cumulativeInflows: mapValues(snapshot.cumulative_inflows, toBigNumber),
226
+ cumulativeOutflows: mapValues(snapshot.cumulative_outflows, toBigNumber),
227
+ oraclePrices: mapValues(snapshot.oracle_prices, (value) => removeDecimals(value))
228
+ };
276
229
  }
277
230
  function mapIndexerNlpSnapshot(snapshot) {
278
- return {
279
- submissionIndex: snapshot.submission_idx,
280
- timestamp: toBigNumber(snapshot.timestamp),
281
- cumulativeBurnAmountQuote: toBigNumber(snapshot.cumulative_burn_quote),
282
- cumulativeMintAmountQuote: toBigNumber(snapshot.cumulative_mint_quote),
283
- cumulativePnl: toBigNumber(snapshot.cumulative_pnl),
284
- cumulativeTrades: toBigNumber(snapshot.cumulative_trades),
285
- cumulativeVolume: toBigNumber(snapshot.cumulative_volume),
286
- depositors: toBigNumber(snapshot.depositors),
287
- oraclePrice: removeDecimals(snapshot.oracle_price_x18),
288
- tvl: toBigNumber(snapshot.tvl)
289
- };
231
+ return {
232
+ submissionIndex: snapshot.submission_idx,
233
+ timestamp: toBigNumber(snapshot.timestamp),
234
+ cumulativeBurnAmountQuote: toBigNumber(snapshot.cumulative_burn_quote),
235
+ cumulativeMintAmountQuote: toBigNumber(snapshot.cumulative_mint_quote),
236
+ cumulativePnl: toBigNumber(snapshot.cumulative_pnl),
237
+ cumulativeTrades: toBigNumber(snapshot.cumulative_trades),
238
+ cumulativeVolume: toBigNumber(snapshot.cumulative_volume),
239
+ depositors: toBigNumber(snapshot.depositors),
240
+ oraclePrice: removeDecimals(snapshot.oracle_price_x18),
241
+ tvl: toBigNumber(snapshot.tvl)
242
+ };
290
243
  }
291
244
  function mapIndexerV2Ticker(ticker) {
292
- return {
293
- productId: ticker.product_id,
294
- tickerId: ticker.ticker_id,
295
- baseCurrency: ticker.base_currency,
296
- quoteCurrency: ticker.quote_currency,
297
- lastPrice: ticker.last_price,
298
- baseVolume: ticker.base_volume,
299
- quoteVolume: ticker.quote_volume,
300
- priceChangePercent24h: ticker.price_change_percent_24h
301
- };
245
+ return {
246
+ productId: ticker.product_id,
247
+ tickerId: ticker.ticker_id,
248
+ baseCurrency: ticker.base_currency,
249
+ quoteCurrency: ticker.quote_currency,
250
+ lastPrice: ticker.last_price,
251
+ baseVolume: ticker.base_volume,
252
+ quoteVolume: ticker.quote_volume,
253
+ priceChangePercent24h: ticker.price_change_percent_24h
254
+ };
302
255
  }
303
256
  function mapIndexerV2MarketHours(hours) {
304
- return {
305
- isOpen: hours.is_open,
306
- reason: hours.reason,
307
- nextClose: hours.next_close,
308
- nextOpen: hours.next_open
309
- };
257
+ return {
258
+ isOpen: hours.is_open,
259
+ reason: hours.reason,
260
+ nextClose: hours.next_close,
261
+ nextOpen: hours.next_open
262
+ };
310
263
  }
311
264
  function mapIndexerV2Symbols(symbol) {
312
- return {
313
- type: symbol.type,
314
- productId: symbol.product_id,
315
- symbol: symbol.symbol,
316
- priceIncrement: removeDecimals(symbol.price_increment_x18),
317
- sizeIncrement: symbol.size_increment,
318
- minSize: symbol.min_size,
319
- makerFeeRate: removeDecimals(symbol.maker_fee_rate_x18),
320
- takerFeeRate: removeDecimals(symbol.taker_fee_rate_x18),
321
- longWeightInitial: removeDecimals(symbol.long_weight_initial_x18),
322
- longWeightMaintenance: removeDecimals(symbol.long_weight_maintenance_x18),
323
- maxOpenInterest: symbol.max_open_interest_x18 ? removeDecimals(symbol.max_open_interest_x18) : null,
324
- exchangeRate: symbol.exchange_rate_x18 ? removeDecimals(symbol.exchange_rate_x18) : null,
325
- tradingStatus: symbol.trading_status,
326
- isolatedOnly: symbol.isolated_only,
327
- marketHours: symbol.market_hours ? mapIndexerV2MarketHours(symbol.market_hours) : null,
328
- boostType: symbol.boost_type ?? null,
329
- takerMultiplier: symbol.taker_multiplier ?? null,
330
- makerMultiplier: symbol.maker_multiplier ?? null
331
- };
265
+ return {
266
+ type: symbol.type,
267
+ productId: symbol.product_id,
268
+ symbol: symbol.symbol,
269
+ priceIncrement: removeDecimals(symbol.price_increment_x18),
270
+ sizeIncrement: symbol.size_increment,
271
+ minSize: symbol.min_size,
272
+ makerFeeRate: removeDecimals(symbol.maker_fee_rate_x18),
273
+ takerFeeRate: removeDecimals(symbol.taker_fee_rate_x18),
274
+ longWeightInitial: removeDecimals(symbol.long_weight_initial_x18),
275
+ longWeightMaintenance: removeDecimals(symbol.long_weight_maintenance_x18),
276
+ maxOpenInterest: symbol.max_open_interest_x18 ? removeDecimals(symbol.max_open_interest_x18) : null,
277
+ exchangeRate: symbol.exchange_rate_x18 ? removeDecimals(symbol.exchange_rate_x18) : null,
278
+ tradingStatus: symbol.trading_status,
279
+ isolatedOnly: symbol.isolated_only,
280
+ marketHours: symbol.market_hours ? mapIndexerV2MarketHours(symbol.market_hours) : null,
281
+ boostType: symbol.boost_type ?? null,
282
+ takerMultiplier: symbol.taker_multiplier ?? null,
283
+ makerMultiplier: symbol.maker_multiplier ?? null
284
+ };
332
285
  }
333
- export {
334
- mapIndexerCandlesticks,
335
- mapIndexerEvent,
336
- mapIndexerEventWithTx,
337
- mapIndexerFundingRate,
338
- mapIndexerLeaderboardContest,
339
- mapIndexerLeaderboardPosition,
340
- mapIndexerLeaderboardRegistration,
341
- mapIndexerMakerStatistics,
342
- mapIndexerMarketSnapshot,
343
- mapIndexerMatchEventBalances,
344
- mapIndexerNlpSnapshot,
345
- mapIndexerOrder,
346
- mapIndexerPerpPrices,
347
- mapIndexerProductPayment,
348
- mapIndexerServerBalance,
349
- mapIndexerServerProduct,
350
- mapIndexerV2MarketHours,
351
- mapIndexerV2Symbols,
352
- mapIndexerV2Ticker,
353
- mapSnapshotsIntervalToServerParams
354
- };
286
+ //#endregion
287
+ export { mapIndexerCandlesticks, mapIndexerEvent, mapIndexerEventWithTx, mapIndexerFundingRate, mapIndexerLeaderboardContest, mapIndexerLeaderboardPosition, mapIndexerLeaderboardRegistration, mapIndexerMakerStatistics, mapIndexerMarketSnapshot, mapIndexerMatchEventBalances, mapIndexerNlpSnapshot, mapIndexerOrder, mapIndexerPerpPrices, mapIndexerProductPayment, mapIndexerServerBalance, mapIndexerServerProduct, mapIndexerV2MarketHours, mapIndexerV2Symbols, mapIndexerV2Ticker, mapSnapshotsIntervalToServerParams };
288
+
355
289
  //# sourceMappingURL=dataMappers.js.map