@nadohq/indexer-client 0.1.0-alpha.4 → 0.1.0-alpha.40
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.
- package/dist/IndexerBaseClient.cjs +38 -19
- package/dist/IndexerBaseClient.cjs.map +1 -1
- package/dist/IndexerBaseClient.d.cts +7 -2
- package/dist/IndexerBaseClient.d.ts +7 -2
- package/dist/IndexerBaseClient.js +40 -19
- package/dist/IndexerBaseClient.js.map +1 -1
- package/dist/IndexerClient.cjs +11 -10
- package/dist/IndexerClient.cjs.map +1 -1
- package/dist/IndexerClient.js +11 -8
- package/dist/IndexerClient.js.map +1 -1
- package/dist/dataMappers.cjs +109 -96
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.d.cts +4 -3
- package/dist/dataMappers.d.ts +4 -3
- package/dist/dataMappers.js +22 -11
- package/dist/dataMappers.js.map +1 -1
- package/dist/endpoints.cjs +2 -2
- package/dist/endpoints.cjs.map +1 -1
- package/dist/endpoints.js +2 -2
- package/dist/endpoints.js.map +1 -1
- package/dist/index.cjs +6 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/types/clientTypes.cjs.map +1 -1
- package/dist/types/clientTypes.d.cts +66 -11
- package/dist/types/clientTypes.d.ts +66 -11
- package/dist/types/index.cjs +11 -11
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +5 -5
- package/dist/types/index.d.ts +5 -5
- package/dist/types/index.js +5 -5
- package/dist/types/index.js.map +1 -1
- package/dist/types/paginatedEventsTypes.cjs.map +1 -1
- package/dist/types/paginatedEventsTypes.d.cts +6 -6
- package/dist/types/paginatedEventsTypes.d.ts +6 -6
- package/dist/types/serverModelTypes.cjs.map +1 -1
- package/dist/types/serverModelTypes.d.cts +8 -4
- package/dist/types/serverModelTypes.d.ts +8 -4
- package/dist/types/serverTypes.cjs.map +1 -1
- package/dist/types/serverTypes.d.cts +32 -7
- package/dist/types/serverTypes.d.ts +32 -7
- package/package.json +8 -4
- package/src/IndexerBaseClient.ts +49 -25
- package/src/IndexerClient.ts +14 -11
- package/src/dataMappers.ts +27 -12
- package/src/endpoints.ts +2 -2
- package/src/index.ts +3 -2
- package/src/types/clientTypes.ts +75 -10
- package/src/types/index.ts +5 -5
- package/src/types/paginatedEventsTypes.ts +1 -1
- package/src/types/serverModelTypes.ts +8 -4
- package/src/types/serverTypes.ts +43 -7
package/dist/dataMappers.cjs
CHANGED
|
@@ -36,16 +36,16 @@ __export(dataMappers_exports, {
|
|
|
36
36
|
mapIndexerProductPayment: () => mapIndexerProductPayment,
|
|
37
37
|
mapIndexerServerBalance: () => mapIndexerServerBalance,
|
|
38
38
|
mapIndexerServerProduct: () => mapIndexerServerProduct,
|
|
39
|
+
mapIndexerV2Ticker: () => mapIndexerV2Ticker,
|
|
39
40
|
mapSnapshotsIntervalToServerParams: () => mapSnapshotsIntervalToServerParams
|
|
40
41
|
});
|
|
41
42
|
module.exports = __toCommonJS(dataMappers_exports);
|
|
42
|
-
var import_shared = require("@nadohq/shared");
|
|
43
43
|
var import_engine_client = require("@nadohq/engine-client");
|
|
44
|
-
var
|
|
44
|
+
var import_shared = require("@nadohq/shared");
|
|
45
45
|
function mapSnapshotsIntervalToServerParams(params) {
|
|
46
46
|
return {
|
|
47
47
|
count: params.limit,
|
|
48
|
-
max_time: params.maxTimeInclusive ? (0,
|
|
48
|
+
max_time: params.maxTimeInclusive ? (0, import_shared.toIntegerString)(params.maxTimeInclusive) : void 0,
|
|
49
49
|
granularity: params.granularity
|
|
50
50
|
};
|
|
51
51
|
}
|
|
@@ -58,35 +58,34 @@ function mapIndexerServerProduct(product) {
|
|
|
58
58
|
function mapIndexerServerBalance(balance) {
|
|
59
59
|
if ("spot" in balance) {
|
|
60
60
|
return {
|
|
61
|
-
amount: (0,
|
|
61
|
+
amount: (0, import_shared.toBigDecimal)(balance.spot.balance.amount),
|
|
62
62
|
productId: balance.spot.product_id,
|
|
63
63
|
type: import_shared.ProductEngineType.SPOT
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
return {
|
|
67
|
-
amount: (0,
|
|
67
|
+
amount: (0, import_shared.toBigDecimal)(balance.perp.balance.amount),
|
|
68
68
|
productId: balance.perp.product_id,
|
|
69
69
|
type: import_shared.ProductEngineType.PERP,
|
|
70
|
-
vQuoteBalance: (0,
|
|
70
|
+
vQuoteBalance: (0, import_shared.toBigDecimal)(balance.perp.balance.v_quote_balance)
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
function mapIndexerOrder(order) {
|
|
74
74
|
const appendix = (0, import_shared.unpackOrderAppendix)(order.appendix);
|
|
75
75
|
return {
|
|
76
|
-
amount: (0,
|
|
76
|
+
amount: (0, import_shared.toBigDecimal)(order.amount),
|
|
77
77
|
digest: order.digest,
|
|
78
|
-
isolated: order.isolated,
|
|
79
78
|
expiration: Number(order.expiration),
|
|
80
79
|
appendix,
|
|
81
|
-
nonce: (0,
|
|
80
|
+
nonce: (0, import_shared.toBigDecimal)(order.nonce),
|
|
82
81
|
recvTimeSeconds: (0, import_shared.getRecvTimeFromOrderNonce)(order.nonce) / 1e3,
|
|
83
|
-
price: (0,
|
|
82
|
+
price: (0, import_shared.removeDecimals)(order.price_x18),
|
|
84
83
|
productId: order.product_id,
|
|
85
84
|
subaccount: order.subaccount,
|
|
86
85
|
submissionIndex: order.submission_idx,
|
|
87
|
-
baseFilled: (0,
|
|
88
|
-
quoteFilled: (0,
|
|
89
|
-
totalFee: (0,
|
|
86
|
+
baseFilled: (0, import_shared.toBigDecimal)(order.base_filled),
|
|
87
|
+
quoteFilled: (0, import_shared.toBigDecimal)(order.quote_filled),
|
|
88
|
+
totalFee: (0, import_shared.toBigDecimal)(order.fee)
|
|
90
89
|
};
|
|
91
90
|
}
|
|
92
91
|
function mapIndexerEvent(event) {
|
|
@@ -123,18 +122,19 @@ function mapIndexerEvent(event) {
|
|
|
123
122
|
subaccount: event.subaccount,
|
|
124
123
|
submissionIndex: event.submission_idx,
|
|
125
124
|
trackedVars: {
|
|
126
|
-
netEntryCumulative: (0,
|
|
127
|
-
netEntryUnrealized: (0,
|
|
128
|
-
netFundingCumulative: (0,
|
|
129
|
-
netFundingUnrealized: (0,
|
|
130
|
-
netInterestCumulative: (0,
|
|
131
|
-
netInterestUnrealized: (0,
|
|
125
|
+
netEntryCumulative: (0, import_shared.toBigDecimal)(event.net_entry_cumulative),
|
|
126
|
+
netEntryUnrealized: (0, import_shared.toBigDecimal)(event.net_entry_unrealized),
|
|
127
|
+
netFundingCumulative: (0, import_shared.toBigDecimal)(event.net_funding_cumulative),
|
|
128
|
+
netFundingUnrealized: (0, import_shared.toBigDecimal)(event.net_funding_unrealized),
|
|
129
|
+
netInterestCumulative: (0, import_shared.toBigDecimal)(event.net_interest_cumulative),
|
|
130
|
+
netInterestUnrealized: (0, import_shared.toBigDecimal)(event.net_interest_unrealized),
|
|
131
|
+
quoteVolumeCumulative: (0, import_shared.toBigDecimal)(event.quote_volume_cumulative)
|
|
132
132
|
}
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
135
|
function mapIndexerEventWithTx(event, tx) {
|
|
136
136
|
return {
|
|
137
|
-
timestamp: (0,
|
|
137
|
+
timestamp: (0, import_shared.toBigDecimal)(tx.timestamp),
|
|
138
138
|
tx: tx.tx,
|
|
139
139
|
...mapIndexerEvent(event)
|
|
140
140
|
};
|
|
@@ -148,11 +148,11 @@ function mapIndexerMatchEventBalances(eventBalances) {
|
|
|
148
148
|
function mapIndexerProductPayment(payment) {
|
|
149
149
|
return {
|
|
150
150
|
submissionIndex: payment.idx,
|
|
151
|
-
timestamp: (0,
|
|
152
|
-
paymentAmount: (0,
|
|
153
|
-
balanceAmount: (0,
|
|
154
|
-
annualPaymentRate: (0,
|
|
155
|
-
oraclePrice: (0,
|
|
151
|
+
timestamp: (0, import_shared.toBigDecimal)(payment.timestamp),
|
|
152
|
+
paymentAmount: (0, import_shared.toBigDecimal)(payment.amount),
|
|
153
|
+
balanceAmount: (0, import_shared.toBigDecimal)(payment.balance_amount),
|
|
154
|
+
annualPaymentRate: (0, import_shared.removeDecimals)(payment.rate_x18),
|
|
155
|
+
oraclePrice: (0, import_shared.removeDecimals)(payment.oracle_price_x18),
|
|
156
156
|
isolated: payment.isolated,
|
|
157
157
|
productId: payment.product_id,
|
|
158
158
|
isolatedProductId: payment.isolated_product_id
|
|
@@ -160,16 +160,16 @@ function mapIndexerProductPayment(payment) {
|
|
|
160
160
|
}
|
|
161
161
|
function mapIndexerPerpPrices(perpPrices) {
|
|
162
162
|
return {
|
|
163
|
-
indexPrice: (0,
|
|
164
|
-
markPrice: (0,
|
|
165
|
-
updateTime: (0,
|
|
163
|
+
indexPrice: (0, import_shared.removeDecimals)(perpPrices.index_price_x18),
|
|
164
|
+
markPrice: (0, import_shared.removeDecimals)(perpPrices.mark_price_x18),
|
|
165
|
+
updateTime: (0, import_shared.toBigDecimal)(perpPrices.update_time),
|
|
166
166
|
productId: perpPrices.product_id
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
function mapIndexerFundingRate(fundingRate) {
|
|
170
170
|
return {
|
|
171
|
-
fundingRate: (0,
|
|
172
|
-
updateTime: (0,
|
|
171
|
+
fundingRate: (0, import_shared.removeDecimals)(fundingRate.funding_rate_x18),
|
|
172
|
+
updateTime: (0, import_shared.toBigDecimal)(fundingRate.update_time),
|
|
173
173
|
productId: fundingRate.product_id
|
|
174
174
|
};
|
|
175
175
|
}
|
|
@@ -178,13 +178,13 @@ function mapIndexerMakerStatistics(maker) {
|
|
|
178
178
|
address: maker.address,
|
|
179
179
|
snapshots: maker.data.map((makerData) => {
|
|
180
180
|
return {
|
|
181
|
-
timestamp: (0,
|
|
182
|
-
makerFee: (0,
|
|
183
|
-
uptime: (0,
|
|
184
|
-
sumQMin: (0,
|
|
185
|
-
qScore: (0,
|
|
186
|
-
makerShare: (0,
|
|
187
|
-
expectedMakerReward: (0,
|
|
181
|
+
timestamp: (0, import_shared.toBigDecimal)(makerData.timestamp),
|
|
182
|
+
makerFee: (0, import_shared.toBigDecimal)(makerData.maker_fee),
|
|
183
|
+
uptime: (0, import_shared.toBigDecimal)(makerData.uptime),
|
|
184
|
+
sumQMin: (0, import_shared.toBigDecimal)(makerData.sum_q_min),
|
|
185
|
+
qScore: (0, import_shared.toBigDecimal)(makerData.q_score),
|
|
186
|
+
makerShare: (0, import_shared.toBigDecimal)(makerData.maker_share),
|
|
187
|
+
expectedMakerReward: (0, import_shared.toBigDecimal)(makerData.expected_maker_reward)
|
|
188
188
|
};
|
|
189
189
|
})
|
|
190
190
|
};
|
|
@@ -193,109 +193,121 @@ function mapIndexerLeaderboardPosition(position) {
|
|
|
193
193
|
return {
|
|
194
194
|
subaccount: (0, import_shared.subaccountFromHex)(position.subaccount),
|
|
195
195
|
contestId: position.contest_id,
|
|
196
|
-
pnl: (0,
|
|
197
|
-
pnlRank: (0,
|
|
198
|
-
percentRoi: (0,
|
|
199
|
-
roiRank: (0,
|
|
200
|
-
accountValue: (0,
|
|
201
|
-
volume: position.volume ? (0,
|
|
202
|
-
updateTime: (0,
|
|
196
|
+
pnl: (0, import_shared.toBigDecimal)(position.pnl),
|
|
197
|
+
pnlRank: (0, import_shared.toBigDecimal)(position.pnl_rank),
|
|
198
|
+
percentRoi: (0, import_shared.toBigDecimal)(position.roi),
|
|
199
|
+
roiRank: (0, import_shared.toBigDecimal)(position.roi_rank),
|
|
200
|
+
accountValue: (0, import_shared.toBigDecimal)(position.account_value),
|
|
201
|
+
volume: position.volume ? (0, import_shared.toBigDecimal)(position.volume) : void 0,
|
|
202
|
+
updateTime: (0, import_shared.toBigDecimal)(position.update_time)
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
205
|
function mapIndexerLeaderboardRegistration(registration) {
|
|
206
206
|
return {
|
|
207
207
|
subaccount: (0, import_shared.subaccountFromHex)(registration.subaccount),
|
|
208
208
|
contestId: registration.contest_id,
|
|
209
|
-
updateTime: (0,
|
|
209
|
+
updateTime: (0, import_shared.toBigDecimal)(registration.update_time)
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
212
|
function mapIndexerLeaderboardContest(contest) {
|
|
213
213
|
return {
|
|
214
214
|
contestId: contest.contest_id,
|
|
215
|
-
startTime: (0,
|
|
216
|
-
endTime: (0,
|
|
217
|
-
period: (0,
|
|
218
|
-
totalParticipants: (0,
|
|
219
|
-
minRequiredAccountValue: (0,
|
|
220
|
-
minRequiredVolume: (0,
|
|
215
|
+
startTime: (0, import_shared.toBigDecimal)(contest.start_time),
|
|
216
|
+
endTime: (0, import_shared.toBigDecimal)(contest.end_time),
|
|
217
|
+
period: (0, import_shared.toBigDecimal)(contest.threshold),
|
|
218
|
+
totalParticipants: (0, import_shared.toBigDecimal)(contest.count),
|
|
219
|
+
minRequiredAccountValue: (0, import_shared.toBigDecimal)(contest.threshold),
|
|
220
|
+
minRequiredVolume: (0, import_shared.toBigDecimal)(contest.volume_threshold),
|
|
221
221
|
requiredProductIds: contest.product_ids,
|
|
222
222
|
active: contest.active,
|
|
223
|
-
lastUpdated: (0,
|
|
223
|
+
lastUpdated: (0, import_shared.toBigDecimal)(contest.last_updated)
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
function mapIndexerCandlesticks(candlestick) {
|
|
227
227
|
return {
|
|
228
|
-
close: (0,
|
|
229
|
-
high: (0,
|
|
230
|
-
low: (0,
|
|
231
|
-
open: (0,
|
|
232
|
-
time: (0,
|
|
233
|
-
volume: (0,
|
|
228
|
+
close: (0, import_shared.removeDecimals)(candlestick.close_x18),
|
|
229
|
+
high: (0, import_shared.removeDecimals)(candlestick.high_x18),
|
|
230
|
+
low: (0, import_shared.removeDecimals)(candlestick.low_x18),
|
|
231
|
+
open: (0, import_shared.removeDecimals)(candlestick.open_x18),
|
|
232
|
+
time: (0, import_shared.toBigDecimal)(candlestick.timestamp),
|
|
233
|
+
volume: (0, import_shared.toBigDecimal)(candlestick.volume)
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
236
|
function mapIndexerMarketSnapshot(snapshot) {
|
|
237
237
|
return {
|
|
238
|
-
timestamp: (0,
|
|
239
|
-
cumulativeUsers: (0,
|
|
240
|
-
dailyActiveUsers: (0,
|
|
241
|
-
tvl: (0,
|
|
242
|
-
borrowRates: (0,
|
|
238
|
+
timestamp: (0, import_shared.toBigDecimal)(snapshot.timestamp),
|
|
239
|
+
cumulativeUsers: (0, import_shared.toBigDecimal)(snapshot.cumulative_users),
|
|
240
|
+
dailyActiveUsers: (0, import_shared.toBigDecimal)(snapshot.daily_active_users),
|
|
241
|
+
tvl: (0, import_shared.toBigDecimal)(snapshot.tvl),
|
|
242
|
+
borrowRates: (0, import_shared.mapValues)(
|
|
243
243
|
snapshot.borrow_rates,
|
|
244
|
-
(value) => (0,
|
|
244
|
+
(value) => (0, import_shared.removeDecimals)(value)
|
|
245
245
|
),
|
|
246
|
-
cumulativeLiquidationAmounts: (0,
|
|
246
|
+
cumulativeLiquidationAmounts: (0, import_shared.mapValues)(
|
|
247
247
|
snapshot.cumulative_liquidation_amounts,
|
|
248
|
-
|
|
248
|
+
import_shared.toBigDecimal
|
|
249
249
|
),
|
|
250
|
-
cumulativeMakerFees: (0,
|
|
250
|
+
cumulativeMakerFees: (0, import_shared.mapValues)(
|
|
251
251
|
snapshot.cumulative_maker_fees,
|
|
252
|
-
|
|
252
|
+
import_shared.toBigDecimal
|
|
253
253
|
),
|
|
254
|
-
cumulativeSequencerFees: (0,
|
|
254
|
+
cumulativeSequencerFees: (0, import_shared.mapValues)(
|
|
255
255
|
snapshot.cumulative_sequencer_fees,
|
|
256
|
-
|
|
256
|
+
import_shared.toBigDecimal
|
|
257
257
|
),
|
|
258
|
-
cumulativeTakerFees: (0,
|
|
258
|
+
cumulativeTakerFees: (0, import_shared.mapValues)(
|
|
259
259
|
snapshot.cumulative_taker_fees,
|
|
260
|
-
|
|
260
|
+
import_shared.toBigDecimal
|
|
261
261
|
),
|
|
262
|
-
cumulativeTrades: (0,
|
|
263
|
-
cumulativeVolumes: (0,
|
|
264
|
-
depositRates: (0,
|
|
262
|
+
cumulativeTrades: (0, import_shared.mapValues)(snapshot.cumulative_trades, import_shared.toBigDecimal),
|
|
263
|
+
cumulativeVolumes: (0, import_shared.mapValues)(snapshot.cumulative_volumes, import_shared.toBigDecimal),
|
|
264
|
+
depositRates: (0, import_shared.mapValues)(
|
|
265
265
|
snapshot.deposit_rates,
|
|
266
|
-
(value) => (0,
|
|
266
|
+
(value) => (0, import_shared.removeDecimals)(value)
|
|
267
267
|
),
|
|
268
|
-
fundingRates: (0,
|
|
268
|
+
fundingRates: (0, import_shared.mapValues)(
|
|
269
269
|
snapshot.funding_rates,
|
|
270
|
-
(value) => (0,
|
|
270
|
+
(value) => (0, import_shared.removeDecimals)(value)
|
|
271
271
|
),
|
|
272
|
-
openInterestsQuote: (0,
|
|
273
|
-
totalBorrows: (0,
|
|
274
|
-
totalDeposits: (0,
|
|
275
|
-
cumulativeTradeSizes: (0,
|
|
272
|
+
openInterestsQuote: (0, import_shared.mapValues)(snapshot.open_interests, import_shared.toBigDecimal),
|
|
273
|
+
totalBorrows: (0, import_shared.mapValues)(snapshot.total_borrows, import_shared.toBigDecimal),
|
|
274
|
+
totalDeposits: (0, import_shared.mapValues)(snapshot.total_deposits, import_shared.toBigDecimal),
|
|
275
|
+
cumulativeTradeSizes: (0, import_shared.mapValues)(
|
|
276
276
|
snapshot.cumulative_trade_sizes,
|
|
277
|
-
|
|
277
|
+
import_shared.toBigDecimal
|
|
278
278
|
),
|
|
279
|
-
cumulativeInflows: (0,
|
|
280
|
-
cumulativeOutflows: (0,
|
|
281
|
-
oraclePrices: (0,
|
|
279
|
+
cumulativeInflows: (0, import_shared.mapValues)(snapshot.cumulative_inflows, import_shared.toBigDecimal),
|
|
280
|
+
cumulativeOutflows: (0, import_shared.mapValues)(snapshot.cumulative_outflows, import_shared.toBigDecimal),
|
|
281
|
+
oraclePrices: (0, import_shared.mapValues)(
|
|
282
282
|
snapshot.oracle_prices,
|
|
283
|
-
(value) => (0,
|
|
283
|
+
(value) => (0, import_shared.removeDecimals)(value)
|
|
284
284
|
)
|
|
285
285
|
};
|
|
286
286
|
}
|
|
287
287
|
function mapIndexerNlpSnapshot(snapshot) {
|
|
288
288
|
return {
|
|
289
289
|
submissionIndex: snapshot.submission_idx,
|
|
290
|
-
timestamp: (0,
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
cumulativePnl: (0,
|
|
294
|
-
cumulativeTrades: (0,
|
|
295
|
-
cumulativeVolume: (0,
|
|
296
|
-
depositors: (0,
|
|
297
|
-
oraclePrice: (0,
|
|
298
|
-
tvl: (0,
|
|
290
|
+
timestamp: (0, import_shared.toBigDecimal)(snapshot.timestamp),
|
|
291
|
+
cumulativeBurnAmountQuote: (0, import_shared.toBigDecimal)(snapshot.cumulative_burn_quote),
|
|
292
|
+
cumulativeMintAmountQuote: (0, import_shared.toBigDecimal)(snapshot.cumulative_mint_quote),
|
|
293
|
+
cumulativePnl: (0, import_shared.toBigDecimal)(snapshot.cumulative_pnl),
|
|
294
|
+
cumulativeTrades: (0, import_shared.toBigDecimal)(snapshot.cumulative_trades),
|
|
295
|
+
cumulativeVolume: (0, import_shared.toBigDecimal)(snapshot.cumulative_volume),
|
|
296
|
+
depositors: (0, import_shared.toBigDecimal)(snapshot.depositors),
|
|
297
|
+
oraclePrice: (0, import_shared.removeDecimals)(snapshot.oracle_price_x18),
|
|
298
|
+
tvl: (0, import_shared.toBigDecimal)(snapshot.tvl)
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
function mapIndexerV2Ticker(ticker) {
|
|
302
|
+
return {
|
|
303
|
+
productId: ticker.product_id,
|
|
304
|
+
tickerId: ticker.ticker_id,
|
|
305
|
+
baseCurrency: ticker.base_currency,
|
|
306
|
+
quoteCurrency: ticker.quote_currency,
|
|
307
|
+
lastPrice: ticker.last_price,
|
|
308
|
+
baseVolume: ticker.base_volume,
|
|
309
|
+
quoteVolume: ticker.quote_volume,
|
|
310
|
+
priceChangePercent24h: ticker.price_change_percent_24h
|
|
299
311
|
};
|
|
300
312
|
}
|
|
301
313
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -316,6 +328,7 @@ function mapIndexerNlpSnapshot(snapshot) {
|
|
|
316
328
|
mapIndexerProductPayment,
|
|
317
329
|
mapIndexerServerBalance,
|
|
318
330
|
mapIndexerServerProduct,
|
|
331
|
+
mapIndexerV2Ticker,
|
|
319
332
|
mapSnapshotsIntervalToServerParams
|
|
320
333
|
});
|
|
321
334
|
//# sourceMappingURL=dataMappers.cjs.map
|
package/dist/dataMappers.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAQO;AACP,2BAGO;AACP,IAAAA,iBAKO;AAsCA,SAAS,mCACd,QACgC;AAChC,SAAO;AAAA,IACL,OAAO,OAAO;AAAA,IACd,UAAU,OAAO,uBACb,gCAAgB,OAAO,gBAAgB,IACvC;AAAA,IACJ,aAAa,OAAO;AAAA,EACtB;AACF;AAEO,SAAS,wBAAwB,SAAuC;AAC7E,MAAI,UAAU,SAAS;AACrB,eAA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AAA,IACzD,gBAAY,6BAAa,SAAS,UAAU;AAAA,IAC5C,iBAAa,+BAAe,SAAS,gBAAgB;AAAA,IACrD,SAAK,6BAAa,SAAS,GAAG;AAAA,EAChC;AACF;","names":["import_shared"]}
|
|
1
|
+
{"version":3,"sources":["../src/dataMappers.ts"],"sourcesContent":["import {\n mapEngineServerPerpProduct,\n mapEngineServerSpotProduct,\n} from '@nadohq/engine-client';\nimport {\n getRecvTimeFromOrderNonce,\n mapValues,\n Market,\n PerpMarket,\n ProductEngineType,\n removeDecimals,\n SpotMarket,\n subaccountFromHex,\n toBigDecimal,\n toIntegerString,\n unpackOrderAppendix,\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 IndexerServerV2TickerResponse,\n IndexerSnapshotsIntervalParams,\n IndexerSpotBalance,\n IndexerV2TickerResponse,\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 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 quoteVolumeCumulative: toBigDecimal(event.quote_volume_cumulative),\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 cumulativeBurnAmountQuote: toBigDecimal(snapshot.cumulative_burn_quote),\n cumulativeMintAmountQuote: toBigDecimal(snapshot.cumulative_mint_quote),\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\nexport function mapIndexerV2Ticker(\n ticker: IndexerServerV2TickerResponse,\n): IndexerV2TickerResponse {\n return {\n productId: ticker.product_id,\n tickerId: ticker.ticker_id,\n baseCurrency: ticker.base_currency,\n quoteCurrency: ticker.quote_currency,\n lastPrice: ticker.last_price,\n baseVolume: ticker.base_volume,\n quoteVolume: ticker.quote_volume,\n priceChangePercent24h: ticker.price_change_percent_24h,\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;AAAA,2BAGO;AACP,oBAYO;AAwCA,SAAS,mCACd,QACgC;AAChC,SAAO;AAAA,IACL,OAAO,OAAO;AAAA,IACd,UAAU,OAAO,uBACb,+BAAgB,OAAO,gBAAgB,IACvC;AAAA,IACJ,aAAa,OAAO;AAAA,EACtB;AACF;AAEO,SAAS,wBAAwB,SAAuC;AAC7E,MAAI,UAAU,SAAS;AACrB,eAAO,iDAA2B,QAAQ,IAAI;A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zD,gBAAY,4BAAa,SAAS,UAAU;AAAA,IAC5C,iBAAa,8BAAe,SAAS,gBAAgB;AAAA,IACrD,SAAK,4BAAa,SAAS,GAAG;AAAA,EAChC;AACF;AAEO,SAAS,mBACd,QACyB;AACzB,SAAO;AAAA,IACL,WAAW,OAAO;AAAA,IAClB,UAAU,OAAO;AAAA,IACjB,cAAc,OAAO;AAAA,IACrB,eAAe,OAAO;AAAA,IACtB,WAAW,OAAO;AAAA,IAClB,YAAY,OAAO;AAAA,IACnB,aAAa,OAAO;AAAA,IACpB,uBAAuB,OAAO;AAAA,EAChC;AACF;","names":[]}
|
package/dist/dataMappers.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Market } from '@nadohq/shared';
|
|
2
|
-
import { IndexerSnapshotsIntervalParams, IndexerSpotBalance, IndexerPerpBalance, IndexerOrder, IndexerEvent, IndexerEventWithTx, IndexerMatchEventBalances, IndexerProductPayment, IndexerPerpPrices, IndexerFundingRate, IndexerMaker, IndexerLeaderboardParticipant, IndexerLeaderboardRegistration, IndexerLeaderboardContest, Candlestick, IndexerMarketSnapshot, IndexerNlpSnapshot } from './types/clientTypes.cjs';
|
|
3
|
-
import { IndexerServerPerpPrices, IndexerServerFundingRate } from './types/serverTypes.cjs';
|
|
2
|
+
import { IndexerSnapshotsIntervalParams, IndexerSpotBalance, IndexerPerpBalance, IndexerOrder, IndexerEvent, IndexerEventWithTx, IndexerMatchEventBalances, IndexerProductPayment, IndexerPerpPrices, IndexerFundingRate, IndexerMaker, IndexerLeaderboardParticipant, IndexerLeaderboardRegistration, IndexerLeaderboardContest, Candlestick, IndexerMarketSnapshot, IndexerNlpSnapshot, IndexerV2TickerResponse } from './types/clientTypes.cjs';
|
|
4
3
|
import { IndexerServerSnapshotsInterval, IndexerServerProduct, IndexerServerBalance, IndexerServerOrder, IndexerServerEvent, IndexerServerTx, IndexerServerMatchEventBalances, IndexerServerProductPayment, IndexerServerMaker, IndexerServerLeaderboardPosition, IndexerServerLeaderboardRegistration, IndexerServerLeaderboardContest, IndexerServerCandlestick, IndexerServerMarketSnapshot, IndexerServerNlpSnapshot } from './types/serverModelTypes.cjs';
|
|
4
|
+
import { IndexerServerPerpPrices, IndexerServerFundingRate, IndexerServerV2TickerResponse } from './types/serverTypes.cjs';
|
|
5
5
|
import 'viem';
|
|
6
6
|
import './types/CandlestickPeriod.cjs';
|
|
7
7
|
import './types/IndexerEventType.cjs';
|
|
@@ -26,5 +26,6 @@ declare function mapIndexerLeaderboardContest(contest: IndexerServerLeaderboardC
|
|
|
26
26
|
declare function mapIndexerCandlesticks(candlestick: IndexerServerCandlestick): Candlestick;
|
|
27
27
|
declare function mapIndexerMarketSnapshot(snapshot: IndexerServerMarketSnapshot): IndexerMarketSnapshot;
|
|
28
28
|
declare function mapIndexerNlpSnapshot(snapshot: IndexerServerNlpSnapshot): IndexerNlpSnapshot;
|
|
29
|
+
declare function mapIndexerV2Ticker(ticker: IndexerServerV2TickerResponse): IndexerV2TickerResponse;
|
|
29
30
|
|
|
30
|
-
export { mapIndexerCandlesticks, mapIndexerEvent, mapIndexerEventWithTx, mapIndexerFundingRate, mapIndexerLeaderboardContest, mapIndexerLeaderboardPosition, mapIndexerLeaderboardRegistration, mapIndexerMakerStatistics, mapIndexerMarketSnapshot, mapIndexerMatchEventBalances, mapIndexerNlpSnapshot, mapIndexerOrder, mapIndexerPerpPrices, mapIndexerProductPayment, mapIndexerServerBalance, mapIndexerServerProduct, mapSnapshotsIntervalToServerParams };
|
|
31
|
+
export { mapIndexerCandlesticks, mapIndexerEvent, mapIndexerEventWithTx, mapIndexerFundingRate, mapIndexerLeaderboardContest, mapIndexerLeaderboardPosition, mapIndexerLeaderboardRegistration, mapIndexerMakerStatistics, mapIndexerMarketSnapshot, mapIndexerMatchEventBalances, mapIndexerNlpSnapshot, mapIndexerOrder, mapIndexerPerpPrices, mapIndexerProductPayment, mapIndexerServerBalance, mapIndexerServerProduct, mapIndexerV2Ticker, mapSnapshotsIntervalToServerParams };
|
package/dist/dataMappers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Market } from '@nadohq/shared';
|
|
2
|
-
import { IndexerSnapshotsIntervalParams, IndexerSpotBalance, IndexerPerpBalance, IndexerOrder, IndexerEvent, IndexerEventWithTx, IndexerMatchEventBalances, IndexerProductPayment, IndexerPerpPrices, IndexerFundingRate, IndexerMaker, IndexerLeaderboardParticipant, IndexerLeaderboardRegistration, IndexerLeaderboardContest, Candlestick, IndexerMarketSnapshot, IndexerNlpSnapshot } from './types/clientTypes.js';
|
|
3
|
-
import { IndexerServerPerpPrices, IndexerServerFundingRate } from './types/serverTypes.js';
|
|
2
|
+
import { IndexerSnapshotsIntervalParams, IndexerSpotBalance, IndexerPerpBalance, IndexerOrder, IndexerEvent, IndexerEventWithTx, IndexerMatchEventBalances, IndexerProductPayment, IndexerPerpPrices, IndexerFundingRate, IndexerMaker, IndexerLeaderboardParticipant, IndexerLeaderboardRegistration, IndexerLeaderboardContest, Candlestick, IndexerMarketSnapshot, IndexerNlpSnapshot, IndexerV2TickerResponse } from './types/clientTypes.js';
|
|
4
3
|
import { IndexerServerSnapshotsInterval, IndexerServerProduct, IndexerServerBalance, IndexerServerOrder, IndexerServerEvent, IndexerServerTx, IndexerServerMatchEventBalances, IndexerServerProductPayment, IndexerServerMaker, IndexerServerLeaderboardPosition, IndexerServerLeaderboardRegistration, IndexerServerLeaderboardContest, IndexerServerCandlestick, IndexerServerMarketSnapshot, IndexerServerNlpSnapshot } from './types/serverModelTypes.js';
|
|
4
|
+
import { IndexerServerPerpPrices, IndexerServerFundingRate, IndexerServerV2TickerResponse } from './types/serverTypes.js';
|
|
5
5
|
import 'viem';
|
|
6
6
|
import './types/CandlestickPeriod.js';
|
|
7
7
|
import './types/IndexerEventType.js';
|
|
@@ -26,5 +26,6 @@ declare function mapIndexerLeaderboardContest(contest: IndexerServerLeaderboardC
|
|
|
26
26
|
declare function mapIndexerCandlesticks(candlestick: IndexerServerCandlestick): Candlestick;
|
|
27
27
|
declare function mapIndexerMarketSnapshot(snapshot: IndexerServerMarketSnapshot): IndexerMarketSnapshot;
|
|
28
28
|
declare function mapIndexerNlpSnapshot(snapshot: IndexerServerNlpSnapshot): IndexerNlpSnapshot;
|
|
29
|
+
declare function mapIndexerV2Ticker(ticker: IndexerServerV2TickerResponse): IndexerV2TickerResponse;
|
|
29
30
|
|
|
30
|
-
export { mapIndexerCandlesticks, mapIndexerEvent, mapIndexerEventWithTx, mapIndexerFundingRate, mapIndexerLeaderboardContest, mapIndexerLeaderboardPosition, mapIndexerLeaderboardRegistration, mapIndexerMakerStatistics, mapIndexerMarketSnapshot, mapIndexerMatchEventBalances, mapIndexerNlpSnapshot, mapIndexerOrder, mapIndexerPerpPrices, mapIndexerProductPayment, mapIndexerServerBalance, mapIndexerServerProduct, mapSnapshotsIntervalToServerParams };
|
|
31
|
+
export { mapIndexerCandlesticks, mapIndexerEvent, mapIndexerEventWithTx, mapIndexerFundingRate, mapIndexerLeaderboardContest, mapIndexerLeaderboardPosition, mapIndexerLeaderboardRegistration, mapIndexerMakerStatistics, mapIndexerMarketSnapshot, mapIndexerMatchEventBalances, mapIndexerNlpSnapshot, mapIndexerOrder, mapIndexerPerpPrices, mapIndexerProductPayment, mapIndexerServerBalance, mapIndexerServerProduct, mapIndexerV2Ticker, mapSnapshotsIntervalToServerParams };
|
package/dist/dataMappers.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
// src/dataMappers.ts
|
|
2
|
-
import {
|
|
3
|
-
getRecvTimeFromOrderNonce,
|
|
4
|
-
ProductEngineType,
|
|
5
|
-
subaccountFromHex,
|
|
6
|
-
unpackOrderAppendix
|
|
7
|
-
} from "@nadohq/shared";
|
|
8
2
|
import {
|
|
9
3
|
mapEngineServerPerpProduct,
|
|
10
4
|
mapEngineServerSpotProduct
|
|
11
5
|
} from "@nadohq/engine-client";
|
|
12
6
|
import {
|
|
7
|
+
getRecvTimeFromOrderNonce,
|
|
13
8
|
mapValues,
|
|
9
|
+
ProductEngineType,
|
|
14
10
|
removeDecimals,
|
|
11
|
+
subaccountFromHex,
|
|
15
12
|
toBigDecimal,
|
|
16
|
-
toIntegerString
|
|
13
|
+
toIntegerString,
|
|
14
|
+
unpackOrderAppendix
|
|
17
15
|
} from "@nadohq/shared";
|
|
18
16
|
function mapSnapshotsIntervalToServerParams(params) {
|
|
19
17
|
return {
|
|
@@ -48,7 +46,6 @@ function mapIndexerOrder(order) {
|
|
|
48
46
|
return {
|
|
49
47
|
amount: toBigDecimal(order.amount),
|
|
50
48
|
digest: order.digest,
|
|
51
|
-
isolated: order.isolated,
|
|
52
49
|
expiration: Number(order.expiration),
|
|
53
50
|
appendix,
|
|
54
51
|
nonce: toBigDecimal(order.nonce),
|
|
@@ -101,7 +98,8 @@ function mapIndexerEvent(event) {
|
|
|
101
98
|
netFundingCumulative: toBigDecimal(event.net_funding_cumulative),
|
|
102
99
|
netFundingUnrealized: toBigDecimal(event.net_funding_unrealized),
|
|
103
100
|
netInterestCumulative: toBigDecimal(event.net_interest_cumulative),
|
|
104
|
-
netInterestUnrealized: toBigDecimal(event.net_interest_unrealized)
|
|
101
|
+
netInterestUnrealized: toBigDecimal(event.net_interest_unrealized),
|
|
102
|
+
quoteVolumeCumulative: toBigDecimal(event.quote_volume_cumulative)
|
|
105
103
|
}
|
|
106
104
|
};
|
|
107
105
|
}
|
|
@@ -261,8 +259,8 @@ function mapIndexerNlpSnapshot(snapshot) {
|
|
|
261
259
|
return {
|
|
262
260
|
submissionIndex: snapshot.submission_idx,
|
|
263
261
|
timestamp: toBigDecimal(snapshot.timestamp),
|
|
264
|
-
|
|
265
|
-
|
|
262
|
+
cumulativeBurnAmountQuote: toBigDecimal(snapshot.cumulative_burn_quote),
|
|
263
|
+
cumulativeMintAmountQuote: toBigDecimal(snapshot.cumulative_mint_quote),
|
|
266
264
|
cumulativePnl: toBigDecimal(snapshot.cumulative_pnl),
|
|
267
265
|
cumulativeTrades: toBigDecimal(snapshot.cumulative_trades),
|
|
268
266
|
cumulativeVolume: toBigDecimal(snapshot.cumulative_volume),
|
|
@@ -271,6 +269,18 @@ function mapIndexerNlpSnapshot(snapshot) {
|
|
|
271
269
|
tvl: toBigDecimal(snapshot.tvl)
|
|
272
270
|
};
|
|
273
271
|
}
|
|
272
|
+
function mapIndexerV2Ticker(ticker) {
|
|
273
|
+
return {
|
|
274
|
+
productId: ticker.product_id,
|
|
275
|
+
tickerId: ticker.ticker_id,
|
|
276
|
+
baseCurrency: ticker.base_currency,
|
|
277
|
+
quoteCurrency: ticker.quote_currency,
|
|
278
|
+
lastPrice: ticker.last_price,
|
|
279
|
+
baseVolume: ticker.base_volume,
|
|
280
|
+
quoteVolume: ticker.quote_volume,
|
|
281
|
+
priceChangePercent24h: ticker.price_change_percent_24h
|
|
282
|
+
};
|
|
283
|
+
}
|
|
274
284
|
export {
|
|
275
285
|
mapIndexerCandlesticks,
|
|
276
286
|
mapIndexerEvent,
|
|
@@ -288,6 +298,7 @@ export {
|
|
|
288
298
|
mapIndexerProductPayment,
|
|
289
299
|
mapIndexerServerBalance,
|
|
290
300
|
mapIndexerServerProduct,
|
|
301
|
+
mapIndexerV2Ticker,
|
|
291
302
|
mapSnapshotsIntervalToServerParams
|
|
292
303
|
};
|
|
293
304
|
//# sourceMappingURL=dataMappers.js.map
|