@nadohq/indexer-client 0.1.0-alpha.1
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/README.md +2 -0
- package/dist/IndexerBaseClient.cjs +608 -0
- package/dist/IndexerBaseClient.cjs.map +1 -0
- package/dist/IndexerBaseClient.d.cts +183 -0
- package/dist/IndexerBaseClient.d.ts +183 -0
- package/dist/IndexerBaseClient.js +605 -0
- package/dist/IndexerBaseClient.js.map +1 -0
- package/dist/IndexerClient.cjs +368 -0
- package/dist/IndexerClient.cjs.map +1 -0
- package/dist/IndexerClient.d.cts +50 -0
- package/dist/IndexerClient.d.ts +50 -0
- package/dist/IndexerClient.js +348 -0
- package/dist/IndexerClient.js.map +1 -0
- package/dist/dataMappers.cjs +324 -0
- package/dist/dataMappers.cjs.map +1 -0
- package/dist/dataMappers.d.cts +31 -0
- package/dist/dataMappers.d.ts +31 -0
- package/dist/dataMappers.js +296 -0
- package/dist/dataMappers.js.map +1 -0
- package/dist/endpoints.cjs +35 -0
- package/dist/endpoints.cjs.map +1 -0
- package/dist/endpoints.d.cts +5 -0
- package/dist/endpoints.d.ts +5 -0
- package/dist/endpoints.js +10 -0
- package/dist/endpoints.js.map +1 -0
- package/dist/index.cjs +31 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/types/CandlestickPeriod.cjs +42 -0
- package/dist/types/CandlestickPeriod.cjs.map +1 -0
- package/dist/types/CandlestickPeriod.d.cts +13 -0
- package/dist/types/CandlestickPeriod.d.ts +13 -0
- package/dist/types/CandlestickPeriod.js +17 -0
- package/dist/types/CandlestickPeriod.js.map +1 -0
- package/dist/types/IndexerEventType.cjs +19 -0
- package/dist/types/IndexerEventType.cjs.map +1 -0
- package/dist/types/IndexerEventType.d.cts +3 -0
- package/dist/types/IndexerEventType.d.ts +3 -0
- package/dist/types/IndexerEventType.js +1 -0
- package/dist/types/IndexerEventType.js.map +1 -0
- package/dist/types/IndexerLeaderboardType.cjs +19 -0
- package/dist/types/IndexerLeaderboardType.cjs.map +1 -0
- package/dist/types/IndexerLeaderboardType.d.cts +3 -0
- package/dist/types/IndexerLeaderboardType.d.ts +3 -0
- package/dist/types/IndexerLeaderboardType.js +1 -0
- package/dist/types/IndexerLeaderboardType.js.map +1 -0
- package/dist/types/NadoTx.cjs +19 -0
- package/dist/types/NadoTx.cjs.map +1 -0
- package/dist/types/NadoTx.d.cts +49 -0
- package/dist/types/NadoTx.d.ts +49 -0
- package/dist/types/NadoTx.js +1 -0
- package/dist/types/NadoTx.js.map +1 -0
- package/dist/types/clientTypes.cjs +19 -0
- package/dist/types/clientTypes.cjs.map +1 -0
- package/dist/types/clientTypes.d.cts +467 -0
- package/dist/types/clientTypes.d.ts +467 -0
- package/dist/types/clientTypes.js +1 -0
- package/dist/types/clientTypes.js.map +1 -0
- package/dist/types/collateralEventType.cjs +19 -0
- package/dist/types/collateralEventType.cjs.map +1 -0
- package/dist/types/collateralEventType.d.cts +3 -0
- package/dist/types/collateralEventType.d.ts +3 -0
- package/dist/types/collateralEventType.js +1 -0
- package/dist/types/collateralEventType.js.map +1 -0
- package/dist/types/index.cjs +41 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +13 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/paginatedEventsTypes.cjs +19 -0
- package/dist/types/paginatedEventsTypes.cjs.map +1 -0
- package/dist/types/paginatedEventsTypes.d.cts +115 -0
- package/dist/types/paginatedEventsTypes.d.ts +115 -0
- package/dist/types/paginatedEventsTypes.js +1 -0
- package/dist/types/paginatedEventsTypes.js.map +1 -0
- package/dist/types/serverModelTypes.cjs +19 -0
- package/dist/types/serverModelTypes.cjs.map +1 -0
- package/dist/types/serverModelTypes.d.cts +224 -0
- package/dist/types/serverModelTypes.d.ts +224 -0
- package/dist/types/serverModelTypes.js +1 -0
- package/dist/types/serverModelTypes.js.map +1 -0
- package/dist/types/serverTypes.cjs +19 -0
- package/dist/types/serverTypes.cjs.map +1 -0
- package/dist/types/serverTypes.d.cts +304 -0
- package/dist/types/serverTypes.d.ts +304 -0
- package/dist/types/serverTypes.js +1 -0
- package/dist/types/serverTypes.js.map +1 -0
- package/dist/utils/index.cjs +25 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +12 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/indexerBalanceValue.cjs +43 -0
- package/dist/utils/indexerBalanceValue.cjs.map +1 -0
- package/dist/utils/indexerBalanceValue.d.cts +39 -0
- package/dist/utils/indexerBalanceValue.d.ts +39 -0
- package/dist/utils/indexerBalanceValue.js +16 -0
- package/dist/utils/indexerBalanceValue.js.map +1 -0
- package/package.json +53 -0
- package/src/IndexerBaseClient.ts +851 -0
- package/src/IndexerClient.ts +468 -0
- package/src/dataMappers.ts +362 -0
- package/src/endpoints.ts +7 -0
- package/src/index.ts +4 -0
- package/src/types/CandlestickPeriod.ts +11 -0
- package/src/types/IndexerEventType.ts +9 -0
- package/src/types/IndexerLeaderboardType.ts +2 -0
- package/src/types/NadoTx.ts +63 -0
- package/src/types/clientTypes.ts +679 -0
- package/src/types/collateralEventType.ts +4 -0
- package/src/types/index.ts +9 -0
- package/src/types/paginatedEventsTypes.ts +194 -0
- package/src/types/serverModelTypes.ts +271 -0
- package/src/types/serverTypes.ts +427 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/indexerBalanceValue.ts +46 -0
|
@@ -0,0 +1,679 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EIP712OrderValues,
|
|
3
|
+
Market,
|
|
4
|
+
OrderExpirationType,
|
|
5
|
+
PerpBalance,
|
|
6
|
+
PerpMarket,
|
|
7
|
+
ProductEngineType,
|
|
8
|
+
SpotBalance,
|
|
9
|
+
SpotMarket,
|
|
10
|
+
Subaccount,
|
|
11
|
+
} from '@nadohq/contracts';
|
|
12
|
+
import { BigDecimal } from '@nadohq/utils';
|
|
13
|
+
import { Hex } from 'viem';
|
|
14
|
+
import { CandlestickPeriod } from './CandlestickPeriod';
|
|
15
|
+
import { IndexerEventType } from './IndexerEventType';
|
|
16
|
+
import { IndexerLeaderboardRankType } from './IndexerLeaderboardType';
|
|
17
|
+
import {
|
|
18
|
+
IndexerServerFastWithdrawalSignatureParams,
|
|
19
|
+
IndexerServerListSubaccountsParams,
|
|
20
|
+
} from './serverTypes';
|
|
21
|
+
import { NadoTx, NadoWithdrawCollateralTx } from './NadoTx';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Base types
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export type IndexerSpotBalance = Omit<SpotBalance, 'healthContributions'>;
|
|
28
|
+
|
|
29
|
+
export type IndexerPerpBalance = Omit<PerpBalance, 'healthContributions'>;
|
|
30
|
+
|
|
31
|
+
export interface IndexerEventSpotStateSnapshot {
|
|
32
|
+
type: ProductEngineType.SPOT;
|
|
33
|
+
preBalance: IndexerSpotBalance;
|
|
34
|
+
postBalance: IndexerSpotBalance;
|
|
35
|
+
market: SpotMarket;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface IndexerEventPerpStateSnapshot {
|
|
39
|
+
type: ProductEngineType.PERP;
|
|
40
|
+
preBalance: IndexerPerpBalance;
|
|
41
|
+
postBalance: IndexerPerpBalance;
|
|
42
|
+
market: PerpMarket;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type IndexerEventBalanceStateSnapshot =
|
|
46
|
+
| IndexerEventSpotStateSnapshot
|
|
47
|
+
| IndexerEventPerpStateSnapshot;
|
|
48
|
+
|
|
49
|
+
export interface IndexerBalanceTrackedVars {
|
|
50
|
+
netInterestUnrealized: BigDecimal;
|
|
51
|
+
netInterestCumulative: BigDecimal;
|
|
52
|
+
netFundingUnrealized: BigDecimal;
|
|
53
|
+
netFundingCumulative: BigDecimal;
|
|
54
|
+
netEntryUnrealized: BigDecimal;
|
|
55
|
+
netEntryCumulative: BigDecimal;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface IndexerEvent<
|
|
59
|
+
TStateType extends
|
|
60
|
+
IndexerEventBalanceStateSnapshot = IndexerEventBalanceStateSnapshot,
|
|
61
|
+
> {
|
|
62
|
+
subaccount: string;
|
|
63
|
+
isolated: boolean;
|
|
64
|
+
// The product ID associated with the isolated perp market. This is only used when productId === QUOTE_PRODUCT_ID and isolated === true
|
|
65
|
+
isolatedProductId: number | null;
|
|
66
|
+
productId: number;
|
|
67
|
+
submissionIndex: string;
|
|
68
|
+
eventType: IndexerEventType;
|
|
69
|
+
state: TStateType;
|
|
70
|
+
trackedVars: IndexerBalanceTrackedVars;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface IndexerEventWithTx<
|
|
74
|
+
TStateType extends
|
|
75
|
+
IndexerEventBalanceStateSnapshot = IndexerEventBalanceStateSnapshot,
|
|
76
|
+
> extends IndexerEvent<TStateType> {
|
|
77
|
+
timestamp: BigDecimal;
|
|
78
|
+
tx: NadoTx;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* List subaccounts
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
export type ListIndexerSubaccountsParams = IndexerServerListSubaccountsParams;
|
|
86
|
+
|
|
87
|
+
export type ListIndexerSubaccountsResponse = ({
|
|
88
|
+
hexId: string;
|
|
89
|
+
} & Subaccount)[];
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Subaccount snapshots
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
export interface GetIndexerMultiSubaccountSnapshotsParams {
|
|
96
|
+
subaccounts: Subaccount[];
|
|
97
|
+
// A series of timestamps for which to return a summary of each subaccount
|
|
98
|
+
timestamps: number[];
|
|
99
|
+
// If not given, will return both isolated & non-iso balances
|
|
100
|
+
isolated?: boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export type IndexerSnapshotBalance<
|
|
104
|
+
TStateType extends
|
|
105
|
+
IndexerEventBalanceStateSnapshot = IndexerEventBalanceStateSnapshot,
|
|
106
|
+
> = IndexerEvent<TStateType>;
|
|
107
|
+
|
|
108
|
+
export interface IndexerSubaccountSnapshot {
|
|
109
|
+
timestamp: BigDecimal;
|
|
110
|
+
balances: IndexerSnapshotBalance[];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface GetIndexerMultiSubaccountSnapshotsResponse {
|
|
114
|
+
// Utility for retrieving a subaccount's hex ID, in the same order as the request params
|
|
115
|
+
subaccountHexIds: string[];
|
|
116
|
+
// Map of subaccount hex -> timestamp requested -> summary for that time
|
|
117
|
+
snapshots: Record<string, Record<string, IndexerSubaccountSnapshot>>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Perp prices
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
export interface GetIndexerPerpPricesParams {
|
|
125
|
+
productId: number;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface IndexerPerpPrices {
|
|
129
|
+
productId: number;
|
|
130
|
+
indexPrice: BigDecimal;
|
|
131
|
+
markPrice: BigDecimal;
|
|
132
|
+
// Seconds
|
|
133
|
+
updateTime: BigDecimal;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export type GetIndexerPerpPricesResponse = IndexerPerpPrices;
|
|
137
|
+
|
|
138
|
+
export interface GetIndexerMultiProductPerpPricesParams {
|
|
139
|
+
productIds: number[];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Map of productId -> IndexerPerpPrices
|
|
143
|
+
export type GetIndexerMultiProductPerpPricesResponse = Record<
|
|
144
|
+
number,
|
|
145
|
+
IndexerPerpPrices
|
|
146
|
+
>;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Oracle prices
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
export interface GetIndexerOraclePricesParams {
|
|
153
|
+
productIds: number[];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface IndexerOraclePrice {
|
|
157
|
+
productId: number;
|
|
158
|
+
oraclePrice: BigDecimal;
|
|
159
|
+
// Seconds
|
|
160
|
+
updateTime: BigDecimal;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export type GetIndexerOraclePricesResponse = IndexerOraclePrice[];
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Funding rates
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
export interface GetIndexerFundingRateParams {
|
|
170
|
+
productId: number;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface IndexerFundingRate {
|
|
174
|
+
productId: number;
|
|
175
|
+
fundingRate: BigDecimal;
|
|
176
|
+
// Seconds
|
|
177
|
+
updateTime: BigDecimal;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export type GetIndexerFundingRateResponse = IndexerFundingRate;
|
|
181
|
+
|
|
182
|
+
export interface GetIndexerMultiProductFundingRatesParams {
|
|
183
|
+
productIds: number[];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Map of productId -> IndexerFundingRate
|
|
187
|
+
export type GetIndexerMultiProductFundingRatesResponse = Record<
|
|
188
|
+
number,
|
|
189
|
+
IndexerFundingRate
|
|
190
|
+
>;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Candlesticks
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
export interface GetIndexerCandlesticksParams {
|
|
197
|
+
productId: number;
|
|
198
|
+
period: CandlestickPeriod;
|
|
199
|
+
// Seconds
|
|
200
|
+
maxTimeInclusive?: number;
|
|
201
|
+
limit: number;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Semi-Tradingview compatible bars
|
|
205
|
+
export interface Candlestick {
|
|
206
|
+
// In SECONDS, for TV compat, this needs to be in millis
|
|
207
|
+
time: BigDecimal;
|
|
208
|
+
open: BigDecimal;
|
|
209
|
+
high: BigDecimal;
|
|
210
|
+
low: BigDecimal;
|
|
211
|
+
close: BigDecimal;
|
|
212
|
+
volume: BigDecimal;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export type GetIndexerCandlesticksResponse = Candlestick[];
|
|
216
|
+
|
|
217
|
+
export type GetIndexerEdgeCandlesticksResponse = GetIndexerCandlesticksResponse;
|
|
218
|
+
|
|
219
|
+
export type GetIndexerEdgeCandlesticksParams = GetIndexerCandlesticksParams;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Product snapshots
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
export interface GetIndexerProductSnapshotsParams {
|
|
226
|
+
// Max submission index, inclusive
|
|
227
|
+
startCursor?: string;
|
|
228
|
+
productId: number;
|
|
229
|
+
maxTimestampInclusive?: number;
|
|
230
|
+
limit: number;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface IndexerProductSnapshot extends Market {
|
|
234
|
+
submissionIndex: string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export type GetIndexerProductSnapshotsResponse = IndexerProductSnapshot[];
|
|
238
|
+
|
|
239
|
+
export interface GetIndexerMultiProductSnapshotsParams {
|
|
240
|
+
productIds: number[];
|
|
241
|
+
maxTimestampInclusive?: number[];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Map of timestamp -> (productId -> IndexerProductSnapshot)
|
|
245
|
+
export type GetIndexerMultiProductSnapshotsResponse = Record<
|
|
246
|
+
string,
|
|
247
|
+
Record<number, IndexerProductSnapshot>
|
|
248
|
+
>;
|
|
249
|
+
|
|
250
|
+
export interface IndexerSnapshotsIntervalParams {
|
|
251
|
+
/** Currently accepts all integers, in seconds */
|
|
252
|
+
granularity: number;
|
|
253
|
+
/**
|
|
254
|
+
* Optional upper bound for snapshot timestamps (in seconds).
|
|
255
|
+
* Without this, snapshots will default to align with last UTC midnight,
|
|
256
|
+
* which can make "Last 24h" metrics inaccurate.
|
|
257
|
+
*/
|
|
258
|
+
maxTimeInclusive?: number;
|
|
259
|
+
limit: number;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Market snapshots
|
|
264
|
+
*/
|
|
265
|
+
|
|
266
|
+
export interface GetIndexerMarketSnapshotsParams
|
|
267
|
+
extends IndexerSnapshotsIntervalParams {
|
|
268
|
+
// Defaults to all
|
|
269
|
+
productIds?: number[];
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface IndexerMarketSnapshot {
|
|
273
|
+
timestamp: BigDecimal;
|
|
274
|
+
cumulativeUsers: BigDecimal;
|
|
275
|
+
dailyActiveUsers: BigDecimal;
|
|
276
|
+
tvl: BigDecimal;
|
|
277
|
+
cumulativeVolumes: Record<number, BigDecimal>;
|
|
278
|
+
cumulativeTakerFees: Record<number, BigDecimal>;
|
|
279
|
+
cumulativeSequencerFees: Record<number, BigDecimal>;
|
|
280
|
+
cumulativeMakerFees: Record<number, BigDecimal>;
|
|
281
|
+
cumulativeTrades: Record<number, BigDecimal>;
|
|
282
|
+
cumulativeLiquidationAmounts: Record<number, BigDecimal>;
|
|
283
|
+
openInterestsQuote: Record<number, BigDecimal>;
|
|
284
|
+
totalDeposits: Record<number, BigDecimal>;
|
|
285
|
+
totalBorrows: Record<number, BigDecimal>;
|
|
286
|
+
fundingRates: Record<number, BigDecimal>;
|
|
287
|
+
depositRates: Record<number, BigDecimal>;
|
|
288
|
+
borrowRates: Record<number, BigDecimal>;
|
|
289
|
+
cumulativeTradeSizes: Record<number, BigDecimal>;
|
|
290
|
+
cumulativeInflows: Record<number, BigDecimal>;
|
|
291
|
+
cumulativeOutflows: Record<number, BigDecimal>;
|
|
292
|
+
oraclePrices: Record<number, BigDecimal>;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export type GetIndexerMarketSnapshotsResponse = IndexerMarketSnapshot[];
|
|
296
|
+
|
|
297
|
+
export type GetIndexerEdgeMarketSnapshotsParams =
|
|
298
|
+
IndexerSnapshotsIntervalParams;
|
|
299
|
+
|
|
300
|
+
// Map of chain id -> IndexerMarketSnapshot[]
|
|
301
|
+
export type GetIndexerEdgeMarketSnapshotResponse = Record<
|
|
302
|
+
number,
|
|
303
|
+
IndexerMarketSnapshot[]
|
|
304
|
+
>;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Events
|
|
308
|
+
*/
|
|
309
|
+
|
|
310
|
+
// There can be multiple events per tx, this allows a limit depending on usecase
|
|
311
|
+
export type GetIndexerEventsLimitType = 'events' | 'txs';
|
|
312
|
+
|
|
313
|
+
export interface GetIndexerEventsParams {
|
|
314
|
+
// Max submission index, inclusive
|
|
315
|
+
startCursor?: string;
|
|
316
|
+
subaccount?: Subaccount;
|
|
317
|
+
productIds?: number[];
|
|
318
|
+
// If not given, will return both isolated & non-iso events
|
|
319
|
+
isolated?: boolean;
|
|
320
|
+
eventTypes?: IndexerEventType[];
|
|
321
|
+
maxTimestampInclusive?: number;
|
|
322
|
+
// Descending order for idx (time), defaults to true
|
|
323
|
+
desc?: boolean;
|
|
324
|
+
limit?: {
|
|
325
|
+
type: GetIndexerEventsLimitType;
|
|
326
|
+
value: number;
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export type GetIndexerEventsResponse = IndexerEventWithTx[];
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Historical orders
|
|
334
|
+
*/
|
|
335
|
+
|
|
336
|
+
export interface GetIndexerOrdersParams {
|
|
337
|
+
// Max submission index, inclusive
|
|
338
|
+
startCursor?: string;
|
|
339
|
+
subaccount?: Subaccount;
|
|
340
|
+
minTimestampInclusive?: number;
|
|
341
|
+
maxTimestampInclusive?: number;
|
|
342
|
+
limit?: number;
|
|
343
|
+
productIds?: number[];
|
|
344
|
+
// If not given, will return both isolated & non-iso orders
|
|
345
|
+
isolated?: boolean;
|
|
346
|
+
digests?: string[];
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export interface IndexerOrder {
|
|
350
|
+
digest: string;
|
|
351
|
+
subaccount: string;
|
|
352
|
+
isolated: boolean;
|
|
353
|
+
productId: number;
|
|
354
|
+
submissionIndex: string;
|
|
355
|
+
amount: BigDecimal;
|
|
356
|
+
price: BigDecimal;
|
|
357
|
+
// This includes the order type
|
|
358
|
+
rawExpiration: BigDecimal;
|
|
359
|
+
isReduceOnly: boolean;
|
|
360
|
+
orderType: OrderExpirationType;
|
|
361
|
+
expiration: number;
|
|
362
|
+
nonce: BigDecimal;
|
|
363
|
+
// Derived from the nonce
|
|
364
|
+
recvTimeSeconds: number;
|
|
365
|
+
// Fill amounts
|
|
366
|
+
baseFilled: BigDecimal;
|
|
367
|
+
// Includes fee
|
|
368
|
+
quoteFilled: BigDecimal;
|
|
369
|
+
// Includes sequencer fee
|
|
370
|
+
totalFee: BigDecimal;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export type GetIndexerOrdersResponse = IndexerOrder[];
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Match events
|
|
377
|
+
*/
|
|
378
|
+
|
|
379
|
+
export interface GetIndexerMatchEventsParams {
|
|
380
|
+
// When not given, will return all maker events
|
|
381
|
+
subaccount?: Subaccount;
|
|
382
|
+
productIds?: number[];
|
|
383
|
+
// If not given, will return both isolated & non-iso events
|
|
384
|
+
isolated?: boolean;
|
|
385
|
+
maxTimestampInclusive?: number;
|
|
386
|
+
limit: number;
|
|
387
|
+
// Max submission index, inclusive
|
|
388
|
+
startCursor?: string;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// There are 2 balance states per match event if the match is in a spot market, but only one if the match is in a perp market
|
|
392
|
+
export interface IndexerMatchEventBalances {
|
|
393
|
+
base: IndexerSpotBalance | IndexerPerpBalance;
|
|
394
|
+
quote?: IndexerSpotBalance;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export interface IndexerMatchEvent extends Subaccount {
|
|
398
|
+
productId: number;
|
|
399
|
+
digest: string;
|
|
400
|
+
isolated: boolean;
|
|
401
|
+
order: EIP712OrderValues;
|
|
402
|
+
baseFilled: BigDecimal;
|
|
403
|
+
quoteFilled: BigDecimal;
|
|
404
|
+
// Includes sequencer fee
|
|
405
|
+
totalFee: BigDecimal;
|
|
406
|
+
sequencerFee: BigDecimal;
|
|
407
|
+
cumulativeBaseFilled: BigDecimal;
|
|
408
|
+
cumulativeQuoteFilled: BigDecimal;
|
|
409
|
+
cumulativeFee: BigDecimal;
|
|
410
|
+
submissionIndex: string;
|
|
411
|
+
timestamp: BigDecimal;
|
|
412
|
+
// Tracked vars for the balance BEFORE this match event occurred
|
|
413
|
+
preEventTrackedVars: Pick<
|
|
414
|
+
IndexerBalanceTrackedVars,
|
|
415
|
+
'netEntryCumulative' | 'netEntryUnrealized'
|
|
416
|
+
>;
|
|
417
|
+
preBalances: IndexerMatchEventBalances;
|
|
418
|
+
postBalances: IndexerMatchEventBalances;
|
|
419
|
+
tx: NadoTx;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export type GetIndexerMatchEventsResponse = IndexerMatchEvent[];
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Quote price
|
|
426
|
+
*/
|
|
427
|
+
|
|
428
|
+
export interface GetIndexerQuotePriceResponse {
|
|
429
|
+
price: BigDecimal;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Linked Signer
|
|
434
|
+
*/
|
|
435
|
+
|
|
436
|
+
export interface GetIndexerLinkedSignerParams {
|
|
437
|
+
subaccount: Subaccount;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
export interface GetIndexerLinkedSignerResponse {
|
|
441
|
+
totalTxLimit: BigDecimal;
|
|
442
|
+
remainingTxs: BigDecimal;
|
|
443
|
+
// If remainingTxs is 0, this is the time until the next link signer tx can be sent
|
|
444
|
+
waitTimeUntilNextTx: BigDecimal;
|
|
445
|
+
// If zero address, none is configured
|
|
446
|
+
signer: string;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Interest / funding payments
|
|
451
|
+
*/
|
|
452
|
+
|
|
453
|
+
export interface GetIndexerInterestFundingPaymentsParams {
|
|
454
|
+
subaccount: Subaccount;
|
|
455
|
+
productIds: number[];
|
|
456
|
+
maxTimestampInclusive?: number;
|
|
457
|
+
limit: number;
|
|
458
|
+
// Max submission index, inclusive
|
|
459
|
+
startCursor?: string;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
export interface IndexerProductPayment {
|
|
463
|
+
productId: number;
|
|
464
|
+
submissionIndex: string;
|
|
465
|
+
timestamp: BigDecimal;
|
|
466
|
+
paymentAmount: BigDecimal;
|
|
467
|
+
// For spots: previous spot balance at the moment of payment (exclusive of `paymentAmount`).
|
|
468
|
+
// For perps: previous perp balance at the moment of payment + amount of perps locked in LPs (exclusive of `paymentAmount`).
|
|
469
|
+
balanceAmount: BigDecimal;
|
|
470
|
+
// Represents the annually interest rate for spots and annually funding rate for perps.
|
|
471
|
+
annualPaymentRate: BigDecimal;
|
|
472
|
+
oraclePrice: BigDecimal;
|
|
473
|
+
isolated: boolean;
|
|
474
|
+
// The product ID associated with the isolated perp market. This is only used when product_id === QUOTE_PRODUCT_ID and isolated === true
|
|
475
|
+
isolatedProductId: number | null;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
export interface GetIndexerInterestFundingPaymentsResponse {
|
|
479
|
+
interestPayments: IndexerProductPayment[];
|
|
480
|
+
fundingPayments: IndexerProductPayment[];
|
|
481
|
+
nextCursor: string | null;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Referral code
|
|
486
|
+
*/
|
|
487
|
+
|
|
488
|
+
export interface GetIndexerReferralCodeParams {
|
|
489
|
+
subaccount: Subaccount;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
export interface GetIndexerReferralCodeResponse {
|
|
493
|
+
referralCode: string | null;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Maker stats
|
|
498
|
+
*/
|
|
499
|
+
|
|
500
|
+
export interface GetIndexerMakerStatisticsParams {
|
|
501
|
+
productId: number;
|
|
502
|
+
epoch: number;
|
|
503
|
+
interval: number;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export interface IndexerMakerSnapshot {
|
|
507
|
+
timestamp: BigDecimal;
|
|
508
|
+
makerFee: BigDecimal;
|
|
509
|
+
uptime: BigDecimal;
|
|
510
|
+
sumQMin: BigDecimal;
|
|
511
|
+
qScore: BigDecimal;
|
|
512
|
+
makerShare: BigDecimal;
|
|
513
|
+
expectedMakerReward: BigDecimal;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export interface IndexerMaker {
|
|
517
|
+
address: string;
|
|
518
|
+
snapshots: IndexerMakerSnapshot[];
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
export interface GetIndexerMakerStatisticsResponse {
|
|
522
|
+
rewardCoefficient: BigDecimal;
|
|
523
|
+
makers: IndexerMaker[];
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Leaderboards
|
|
528
|
+
*/
|
|
529
|
+
|
|
530
|
+
export interface GetIndexerLeaderboardParams {
|
|
531
|
+
contestId: number;
|
|
532
|
+
rankType: IndexerLeaderboardRankType;
|
|
533
|
+
// Min rank inclusive
|
|
534
|
+
startCursor?: string;
|
|
535
|
+
limit?: number;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export interface IndexerLeaderboardParticipant {
|
|
539
|
+
subaccount: Subaccount;
|
|
540
|
+
contestId: number;
|
|
541
|
+
pnl: BigDecimal;
|
|
542
|
+
pnlRank: BigDecimal;
|
|
543
|
+
percentRoi: BigDecimal;
|
|
544
|
+
roiRank: BigDecimal;
|
|
545
|
+
// Float indicating the ending account value at the time the snapshot was taken i.e: at updateTime
|
|
546
|
+
accountValue: BigDecimal;
|
|
547
|
+
// Float indicating the trading volume at the time the snapshot was taken i.e: at updateTime.
|
|
548
|
+
// Null for contests that have no volume requirement.
|
|
549
|
+
volume?: BigDecimal;
|
|
550
|
+
// Seconds
|
|
551
|
+
updateTime: BigDecimal;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
export interface GetIndexerLeaderboardResponse {
|
|
555
|
+
participants: IndexerLeaderboardParticipant[];
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export interface GetIndexerLeaderboardParticipantParams {
|
|
559
|
+
contestIds: number[];
|
|
560
|
+
subaccount: Subaccount;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
export interface GetIndexerLeaderboardParticipantResponse {
|
|
564
|
+
// If the subaccount is not eligible for a given contest, it would not be included in the response.
|
|
565
|
+
// contestId -> IndexerLeaderboardParticipant
|
|
566
|
+
participant: Record<string, IndexerLeaderboardParticipant>;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
interface LeaderboardSignatureParams {
|
|
570
|
+
// endpoint address
|
|
571
|
+
verifyingAddr: string;
|
|
572
|
+
chainId: number;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
export interface GetIndexerLeaderboardRegistrationParams extends Subaccount {
|
|
576
|
+
contestId: number;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
export interface UpdateIndexerLeaderboardRegistrationParams
|
|
580
|
+
extends GetIndexerLeaderboardRegistrationParams {
|
|
581
|
+
updateRegistration: LeaderboardSignatureParams;
|
|
582
|
+
// In millis, defaults to 90s in the future
|
|
583
|
+
recvTime?: BigDecimal;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
export interface IndexerLeaderboardRegistration {
|
|
587
|
+
subaccount: Subaccount;
|
|
588
|
+
contestId: number;
|
|
589
|
+
// Seconds
|
|
590
|
+
updateTime: BigDecimal;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
export interface GetIndexerLeaderboardRegistrationResponse {
|
|
594
|
+
// For non-tiered contests, null if the user is not registered for the provided contestId.
|
|
595
|
+
// For tiered contests (i.e., related contests), null if the user is not registered for any of the contests in the tier group.
|
|
596
|
+
registration: IndexerLeaderboardRegistration | null;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
export type UpdateIndexerLeaderboardRegistrationResponse =
|
|
600
|
+
GetIndexerLeaderboardRegistrationResponse;
|
|
601
|
+
|
|
602
|
+
export interface GetIndexerLeaderboardContestsParams {
|
|
603
|
+
contestIds: number[];
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
export interface IndexerLeaderboardContest {
|
|
607
|
+
contestId: number;
|
|
608
|
+
// NOTE: Start / End times are ignored when `period` is non-zero.
|
|
609
|
+
// Start time in seconds
|
|
610
|
+
startTime: BigDecimal;
|
|
611
|
+
// End time in seconds
|
|
612
|
+
endTime: BigDecimal;
|
|
613
|
+
// Contest duration in seconds; when set to 0, contest duration is [startTime,endTime];
|
|
614
|
+
// Otherwise, contest runs indefinitely in the interval [lastUpdated - period, lastUpdated] if active;
|
|
615
|
+
period: BigDecimal;
|
|
616
|
+
// Last updated time in Seconds
|
|
617
|
+
lastUpdated: BigDecimal;
|
|
618
|
+
totalParticipants: BigDecimal;
|
|
619
|
+
// Float indicating the min account value required to be eligible for this contest e.g: 250.0
|
|
620
|
+
minRequiredAccountValue: BigDecimal;
|
|
621
|
+
// Float indicating the min trading volume required to be eligible for this contest e.g: 1000.0
|
|
622
|
+
minRequiredVolume: BigDecimal;
|
|
623
|
+
// For market-specific contests, only the volume from these products will be counted.
|
|
624
|
+
requiredProductIds: number[];
|
|
625
|
+
active: boolean;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
export interface GetIndexerLeaderboardContestsResponse {
|
|
629
|
+
contests: IndexerLeaderboardContest[];
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
export type GetIndexerFastWithdrawalSignatureParams =
|
|
633
|
+
IndexerServerFastWithdrawalSignatureParams;
|
|
634
|
+
|
|
635
|
+
export interface GetIndexerFastWithdrawalSignatureResponse {
|
|
636
|
+
idx: bigint;
|
|
637
|
+
tx: NadoWithdrawCollateralTx['withdraw_collateral'];
|
|
638
|
+
txBytes: Hex;
|
|
639
|
+
signatures: Hex[];
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* VLP
|
|
644
|
+
*/
|
|
645
|
+
|
|
646
|
+
export type GetIndexerVlpSnapshotsParams = IndexerSnapshotsIntervalParams;
|
|
647
|
+
|
|
648
|
+
export interface IndexerVlpSnapshot {
|
|
649
|
+
submissionIndex: string;
|
|
650
|
+
timestamp: BigDecimal;
|
|
651
|
+
// Total volume traded by the VLP, in terms of the primary quote
|
|
652
|
+
cumulativeVolume: BigDecimal;
|
|
653
|
+
cumulativeTrades: BigDecimal;
|
|
654
|
+
cumulativeMintAmountUsdc: BigDecimal;
|
|
655
|
+
cumulativeBurnAmountUsdc: BigDecimal;
|
|
656
|
+
cumulativePnl: BigDecimal;
|
|
657
|
+
tvl: BigDecimal;
|
|
658
|
+
oraclePrice: BigDecimal;
|
|
659
|
+
depositors: BigDecimal;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
export interface GetIndexerVlpSnapshotsResponse {
|
|
663
|
+
snapshots: IndexerVlpSnapshot[];
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
export interface GetIndexerBacklogResponse {
|
|
667
|
+
// Total number of transactions stored in the indexer DB
|
|
668
|
+
totalTxs: BigDecimal;
|
|
669
|
+
// Current nSubmissions value from the chain (i.e., number of processed txs)
|
|
670
|
+
totalSubmissions: BigDecimal;
|
|
671
|
+
// Number of unprocessed transactions (totalTxs - totalSubmissions)
|
|
672
|
+
backlogSize: BigDecimal;
|
|
673
|
+
// UNIX timestamp (in seconds) of when the data was last updated
|
|
674
|
+
updatedAt: BigDecimal;
|
|
675
|
+
// Estimated time in seconds (float) to clear the entire backlog (null if unavailable)
|
|
676
|
+
backlogEtaInSeconds: BigDecimal | null;
|
|
677
|
+
// Current submission rate in transactions per second (float) (null if unavailable)
|
|
678
|
+
txsPerSecond: BigDecimal | null;
|
|
679
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './clientTypes';
|
|
2
|
+
export * from './paginatedEventsTypes';
|
|
3
|
+
export * from './serverTypes';
|
|
4
|
+
export * from './serverModelTypes';
|
|
5
|
+
export * from './CandlestickPeriod';
|
|
6
|
+
export * from './IndexerEventType';
|
|
7
|
+
export * from './IndexerLeaderboardType';
|
|
8
|
+
export * from './collateralEventType';
|
|
9
|
+
export * from './NadoTx';
|