@nadohq/indexer-client 0.14.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CandlestickPeriod-1DtcEiOb.d.ts +15 -0
- package/dist/CandlestickPeriod-1DtcEiOb.d.ts.map +1 -0
- package/dist/CandlestickPeriod-D3_IoSev.d.cts +15 -0
- package/dist/CandlestickPeriod-D3_IoSev.d.cts.map +1 -0
- package/dist/IndexerBaseClient-3KfzA2ph.cjs +639 -0
- package/dist/IndexerBaseClient-3KfzA2ph.cjs.map +1 -0
- package/dist/IndexerBaseClient.cjs +3 -788
- package/dist/IndexerBaseClient.d.cts +223 -229
- package/dist/IndexerBaseClient.d.cts.map +1 -0
- package/dist/IndexerBaseClient.d.ts +223 -229
- package/dist/IndexerBaseClient.d.ts.map +1 -0
- package/dist/IndexerBaseClient.js +601 -783
- package/dist/IndexerBaseClient.js.map +1 -1
- package/dist/IndexerClient.cjs +275 -381
- package/dist/IndexerClient.cjs.map +1 -1
- package/dist/IndexerClient.d.cts +32 -43
- package/dist/IndexerClient.d.cts.map +1 -0
- package/dist/IndexerClient.d.ts +32 -43
- package/dist/IndexerClient.d.ts.map +1 -0
- package/dist/IndexerClient.js +273 -362
- package/dist/IndexerClient.js.map +1 -1
- package/dist/IndexerEventType-B-uXsf-a.d.cts +5 -0
- package/dist/IndexerEventType-B-uXsf-a.d.cts.map +1 -0
- package/dist/IndexerEventType-DCLkSlgR.d.ts +5 -0
- package/dist/IndexerEventType-DCLkSlgR.d.ts.map +1 -0
- package/dist/IndexerLeaderboardType-Ck12QVWR.d.cts +13 -0
- package/dist/IndexerLeaderboardType-Ck12QVWR.d.cts.map +1 -0
- package/dist/IndexerLeaderboardType-DAKw2tfI.d.ts +13 -0
- package/dist/IndexerLeaderboardType-DAKw2tfI.d.ts.map +1 -0
- package/dist/NadoTx-CWCklgY4.d.ts +50 -0
- package/dist/NadoTx-CWCklgY4.d.ts.map +1 -0
- package/dist/NadoTx-MYNIlXyq.d.cts +50 -0
- package/dist/NadoTx-MYNIlXyq.d.cts.map +1 -0
- package/dist/clientTypes-BpxOUu1q.d.ts +709 -0
- package/dist/clientTypes-BpxOUu1q.d.ts.map +1 -0
- package/dist/clientTypes-BsJ2yIC4.d.cts +709 -0
- package/dist/clientTypes-BsJ2yIC4.d.cts.map +1 -0
- package/dist/collateralEventType-CzH_2iTV.d.ts +5 -0
- package/dist/collateralEventType-CzH_2iTV.d.ts.map +1 -0
- package/dist/collateralEventType-DIm6Te7F.d.cts +5 -0
- package/dist/collateralEventType-DIm6Te7F.d.cts.map +1 -0
- package/dist/dataMappers.cjs +269 -346
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.d.cts +7 -12
- package/dist/dataMappers.d.cts.map +1 -0
- package/dist/dataMappers.d.ts +7 -12
- package/dist/dataMappers.d.ts.map +1 -0
- package/dist/dataMappers.js +248 -314
- package/dist/dataMappers.js.map +1 -1
- package/dist/endpoints.cjs +8 -32
- package/dist/endpoints.cjs.map +1 -1
- package/dist/endpoints.d.cts +4 -2
- package/dist/endpoints.d.cts.map +1 -0
- package/dist/endpoints.d.ts +4 -2
- package/dist/endpoints.d.ts.map +1 -0
- package/dist/endpoints.js +8 -8
- package/dist/endpoints.js.map +1 -1
- package/dist/index-D6CnpA_r.d.cts +1 -0
- package/dist/index-DhI2LvVQ.d.ts +1 -0
- package/dist/index.cjs +15 -33
- package/dist/index.d.cts +14 -18
- package/dist/index.d.ts +14 -18
- package/dist/index.js +8 -7
- package/dist/indexerBalanceValue-4AuNuTAc.d.cts +32 -0
- package/dist/indexerBalanceValue-4AuNuTAc.d.cts.map +1 -0
- package/dist/indexerBalanceValue-B0OggI67.d.ts +32 -0
- package/dist/indexerBalanceValue-B0OggI67.d.ts.map +1 -0
- package/dist/paginatedEventsTypes-DtGDU-kI.d.cts +110 -0
- package/dist/paginatedEventsTypes-DtGDU-kI.d.cts.map +1 -0
- package/dist/paginatedEventsTypes-RwXoQrEa.d.ts +110 -0
- package/dist/paginatedEventsTypes-RwXoQrEa.d.ts.map +1 -0
- package/dist/serverModelTypes-CM2g040o.d.cts +262 -0
- package/dist/serverModelTypes-CM2g040o.d.cts.map +1 -0
- package/dist/serverModelTypes-DPHMUSZe.d.ts +262 -0
- package/dist/serverModelTypes-DPHMUSZe.d.ts.map +1 -0
- package/dist/serverTypes-BMSNh2GK.d.cts +452 -0
- package/dist/serverTypes-BMSNh2GK.d.cts.map +1 -0
- package/dist/serverTypes-c8IABU73.d.ts +452 -0
- package/dist/serverTypes-c8IABU73.d.ts.map +1 -0
- package/dist/types/CandlestickPeriod.cjs +16 -40
- package/dist/types/CandlestickPeriod.cjs.map +1 -1
- package/dist/types/CandlestickPeriod.d.cts +2 -13
- package/dist/types/CandlestickPeriod.d.ts +2 -13
- package/dist/types/CandlestickPeriod.js +16 -16
- package/dist/types/CandlestickPeriod.js.map +1 -1
- package/dist/types/IndexerEventType.cjs +0 -19
- package/dist/types/IndexerEventType.d.cts +2 -3
- package/dist/types/IndexerEventType.d.ts +2 -3
- package/dist/types/IndexerEventType.js +1 -1
- package/dist/types/IndexerLeaderboardType.cjs +0 -19
- package/dist/types/IndexerLeaderboardType.d.cts +2 -11
- package/dist/types/IndexerLeaderboardType.d.ts +2 -11
- package/dist/types/IndexerLeaderboardType.js +1 -1
- package/dist/types/NadoTx.cjs +0 -19
- package/dist/types/NadoTx.d.cts +2 -48
- package/dist/types/NadoTx.d.ts +2 -48
- package/dist/types/NadoTx.js +1 -1
- package/dist/types/clientTypes.cjs +0 -19
- package/dist/types/clientTypes.d.cts +2 -709
- package/dist/types/clientTypes.d.ts +2 -709
- package/dist/types/clientTypes.js +1 -1
- package/dist/types/collateralEventType.cjs +0 -19
- package/dist/types/collateralEventType.d.cts +2 -3
- package/dist/types/collateralEventType.d.ts +2 -3
- package/dist/types/collateralEventType.js +1 -1
- package/dist/types/index.cjs +3 -41
- package/dist/types/index.d.cts +10 -13
- package/dist/types/index.d.ts +10 -13
- package/dist/types/index.js +2 -11
- package/dist/types/paginatedEventsTypes.cjs +0 -19
- package/dist/types/paginatedEventsTypes.d.cts +2 -115
- package/dist/types/paginatedEventsTypes.d.ts +2 -115
- package/dist/types/paginatedEventsTypes.js +1 -1
- package/dist/types/serverModelTypes.cjs +0 -19
- package/dist/types/serverModelTypes.d.cts +2 -260
- package/dist/types/serverModelTypes.d.ts +2 -260
- package/dist/types/serverModelTypes.js +1 -1
- package/dist/types/serverTypes.cjs +0 -19
- package/dist/types/serverTypes.d.cts +2 -451
- package/dist/types/serverTypes.d.ts +2 -451
- package/dist/types/serverTypes.js +1 -1
- package/dist/utils/index.cjs +5 -25
- package/dist/utils/index.d.cts +2 -12
- package/dist/utils/index.d.ts +2 -12
- package/dist/utils/index.js +2 -3
- package/dist/utils/indexerBalanceValue.cjs +32 -36
- package/dist/utils/indexerBalanceValue.cjs.map +1 -1
- package/dist/utils/indexerBalanceValue.d.cts +2 -39
- package/dist/utils/indexerBalanceValue.d.ts +2 -39
- package/dist/utils/indexerBalanceValue.js +29 -9
- package/dist/utils/indexerBalanceValue.js.map +1 -1
- package/package.json +10 -10
- package/dist/IndexerBaseClient.cjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types/IndexerEventType.cjs.map +0 -1
- package/dist/types/IndexerEventType.js.map +0 -1
- package/dist/types/IndexerLeaderboardType.cjs.map +0 -1
- package/dist/types/IndexerLeaderboardType.js.map +0 -1
- package/dist/types/NadoTx.cjs.map +0 -1
- package/dist/types/NadoTx.js.map +0 -1
- package/dist/types/clientTypes.cjs.map +0 -1
- package/dist/types/clientTypes.js.map +0 -1
- package/dist/types/collateralEventType.cjs.map +0 -1
- package/dist/types/collateralEventType.js.map +0 -1
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/paginatedEventsTypes.cjs.map +0 -1
- package/dist/types/paginatedEventsTypes.js.map +0 -1
- package/dist/types/serverModelTypes.cjs.map +0 -1
- package/dist/types/serverModelTypes.js.map +0 -1
- package/dist/types/serverTypes.cjs.map +0 -1
- package/dist/types/serverTypes.js.map +0 -1
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.js.map +0 -1
package/dist/dataMappers.js
CHANGED
|
@@ -1,355 +1,289 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
25
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
92
|
+
return {
|
|
93
|
+
timestamp: toBigNumber(tx.timestamp),
|
|
94
|
+
tx: tx.tx,
|
|
95
|
+
...mapIndexerEvent(event)
|
|
96
|
+
};
|
|
123
97
|
}
|
|
124
98
|
function mapIndexerMatchEventBalances(eventBalances) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
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
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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
|
-
|
|
334
|
-
|
|
335
|
-
|
|
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
|