@nadohq/indexer-client 0.1.0-alpha.1 → 0.1.0-alpha.11
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 +71 -58
- package/dist/IndexerBaseClient.cjs.map +1 -1
- package/dist/IndexerBaseClient.d.cts +8 -4
- package/dist/IndexerBaseClient.d.ts +8 -4
- package/dist/IndexerBaseClient.js +23 -10
- package/dist/IndexerBaseClient.js.map +1 -1
- package/dist/IndexerClient.cjs +20 -20
- package/dist/IndexerClient.cjs.map +1 -1
- package/dist/IndexerClient.d.cts +4 -5
- package/dist/IndexerClient.d.ts +4 -5
- package/dist/IndexerClient.js +9 -9
- package/dist/IndexerClient.js.map +1 -1
- package/dist/dataMappers.cjs +107 -112
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.d.cts +5 -6
- package/dist/dataMappers.d.ts +5 -6
- package/dist/dataMappers.js +11 -17
- package/dist/dataMappers.js.map +1 -1
- package/dist/endpoints.cjs +2 -2
- package/dist/endpoints.cjs.map +1 -1
- package/dist/endpoints.d.cts +1 -1
- package/dist/endpoints.d.ts +1 -1
- package/dist/endpoints.js +2 -2
- package/dist/endpoints.js.map +1 -1
- package/dist/index.d.cts +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/types/IndexerEventType.cjs.map +1 -1
- package/dist/types/IndexerEventType.d.cts +1 -1
- package/dist/types/IndexerEventType.d.ts +1 -1
- package/dist/types/NadoTx.cjs.map +1 -1
- package/dist/types/clientTypes.cjs.map +1 -1
- package/dist/types/clientTypes.d.cts +16 -14
- package/dist/types/clientTypes.d.ts +16 -14
- package/dist/types/index.d.cts +5 -6
- package/dist/types/index.d.ts +5 -6
- package/dist/types/paginatedEventsTypes.cjs.map +1 -1
- package/dist/types/paginatedEventsTypes.d.cts +7 -8
- package/dist/types/paginatedEventsTypes.d.ts +7 -8
- package/dist/types/serverModelTypes.cjs.map +1 -1
- package/dist/types/serverModelTypes.d.cts +5 -5
- package/dist/types/serverModelTypes.d.ts +5 -5
- package/dist/types/serverTypes.cjs.map +1 -1
- package/dist/types/serverTypes.d.cts +16 -8
- package/dist/types/serverTypes.d.ts +16 -8
- package/dist/utils/index.d.cts +2 -3
- package/dist/utils/index.d.ts +2 -3
- package/dist/utils/indexerBalanceValue.cjs.map +1 -1
- package/dist/utils/indexerBalanceValue.d.cts +2 -3
- package/dist/utils/indexerBalanceValue.d.ts +2 -3
- package/dist/utils/indexerBalanceValue.js.map +1 -1
- package/package.json +4 -5
- package/src/IndexerBaseClient.ts +35 -16
- package/src/IndexerClient.ts +17 -17
- package/src/dataMappers.ts +16 -22
- package/src/endpoints.ts +2 -2
- package/src/types/IndexerEventType.ts +2 -2
- package/src/types/NadoTx.ts +1 -1
- package/src/types/clientTypes.ts +21 -16
- package/src/types/paginatedEventsTypes.ts +7 -8
- package/src/types/serverModelTypes.ts +4 -4
- package/src/types/serverTypes.ts +17 -7
- package/src/utils/indexerBalanceValue.ts +1 -1
|
@@ -33,15 +33,16 @@ __export(IndexerBaseClient_exports, {
|
|
|
33
33
|
IndexerBaseClient: () => IndexerBaseClient
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(IndexerBaseClient_exports);
|
|
36
|
-
var
|
|
37
|
-
var import_utils = require("@nadohq/utils");
|
|
36
|
+
var import_shared = require("@nadohq/shared");
|
|
38
37
|
var import_axios = __toESM(require("axios"), 1);
|
|
39
38
|
var import_dataMappers = require("./dataMappers.cjs");
|
|
40
39
|
var IndexerBaseClient = class {
|
|
41
40
|
constructor(opts) {
|
|
42
41
|
this.opts = opts;
|
|
43
42
|
this.axiosInstance = import_axios.default.create({
|
|
44
|
-
withCredentials: true
|
|
43
|
+
withCredentials: true,
|
|
44
|
+
// We have custom logic to validate response status and create an appropriate error
|
|
45
|
+
validateStatus: () => true
|
|
45
46
|
});
|
|
46
47
|
this.v2Url = opts.v2Url ? opts.v2Url : opts.url.replace("v1", "v2");
|
|
47
48
|
}
|
|
@@ -53,7 +54,7 @@ var IndexerBaseClient = class {
|
|
|
53
54
|
async listSubaccounts(params) {
|
|
54
55
|
const baseResponse = await this.query("subaccounts", params);
|
|
55
56
|
return baseResponse.subaccounts.map((item) => {
|
|
56
|
-
const subaccount = (0,
|
|
57
|
+
const subaccount = (0, import_shared.subaccountFromHex)(item.subaccount);
|
|
57
58
|
return {
|
|
58
59
|
hexId: item.subaccount,
|
|
59
60
|
...subaccount
|
|
@@ -68,7 +69,7 @@ var IndexerBaseClient = class {
|
|
|
68
69
|
*/
|
|
69
70
|
async getMultiSubaccountSnapshots(params) {
|
|
70
71
|
const subaccountHexIds = params.subaccounts.map(
|
|
71
|
-
({ subaccountOwner, subaccountName }) => (0,
|
|
72
|
+
({ subaccountOwner, subaccountName }) => (0, import_shared.subaccountToHex)({
|
|
72
73
|
subaccountOwner,
|
|
73
74
|
subaccountName
|
|
74
75
|
})
|
|
@@ -78,14 +79,14 @@ var IndexerBaseClient = class {
|
|
|
78
79
|
timestamps: params.timestamps,
|
|
79
80
|
isolated: params.isolated
|
|
80
81
|
});
|
|
81
|
-
const snapshotsBySubaccount = (0,
|
|
82
|
+
const snapshotsBySubaccount = (0, import_shared.mapValues)(
|
|
82
83
|
baseResponse.snapshots,
|
|
83
84
|
(balanceSnapshots) => {
|
|
84
85
|
const snapshotByTimestamp = {};
|
|
85
86
|
Object.entries(balanceSnapshots).forEach(([timestamp, events]) => {
|
|
86
87
|
const balances = events.map(import_dataMappers.mapIndexerEvent);
|
|
87
88
|
snapshotByTimestamp[timestamp] = {
|
|
88
|
-
timestamp: (0,
|
|
89
|
+
timestamp: (0, import_shared.toBigDecimal)(timestamp),
|
|
89
90
|
balances
|
|
90
91
|
};
|
|
91
92
|
});
|
|
@@ -104,7 +105,7 @@ var IndexerBaseClient = class {
|
|
|
104
105
|
*/
|
|
105
106
|
async getReferralCode(params) {
|
|
106
107
|
const baseResponse = await this.query("referral_code", {
|
|
107
|
-
subaccount: (0,
|
|
108
|
+
subaccount: (0, import_shared.subaccountToHex)({
|
|
108
109
|
subaccountOwner: params.subaccount.subaccountOwner,
|
|
109
110
|
subaccountName: params.subaccount.subaccountName
|
|
110
111
|
})
|
|
@@ -131,7 +132,7 @@ var IndexerBaseClient = class {
|
|
|
131
132
|
const baseResponse = await this.query("funding_rates", {
|
|
132
133
|
product_ids: params.productIds
|
|
133
134
|
});
|
|
134
|
-
return (0,
|
|
135
|
+
return (0, import_shared.mapValues)(baseResponse, import_dataMappers.mapIndexerFundingRate);
|
|
135
136
|
}
|
|
136
137
|
/**
|
|
137
138
|
* Retrieves latest mark/index price for a perp product
|
|
@@ -151,7 +152,7 @@ var IndexerBaseClient = class {
|
|
|
151
152
|
const baseResponse = await this.query("perp_prices", {
|
|
152
153
|
product_ids: params.productIds
|
|
153
154
|
});
|
|
154
|
-
return (0,
|
|
155
|
+
return (0, import_shared.mapValues)(baseResponse, import_dataMappers.mapIndexerPerpPrices);
|
|
155
156
|
}
|
|
156
157
|
/**
|
|
157
158
|
* Retrieves latest oracle prices for provided products
|
|
@@ -163,8 +164,8 @@ var IndexerBaseClient = class {
|
|
|
163
164
|
});
|
|
164
165
|
return baseResponse.prices.map((price) => {
|
|
165
166
|
return {
|
|
166
|
-
oraclePrice: (0,
|
|
167
|
-
updateTime: (0,
|
|
167
|
+
oraclePrice: (0, import_shared.removeDecimals)(price.oracle_price_x18),
|
|
168
|
+
updateTime: (0, import_shared.toBigDecimal)(price.update_time),
|
|
168
169
|
productId: price.product_id
|
|
169
170
|
};
|
|
170
171
|
});
|
|
@@ -220,10 +221,10 @@ var IndexerBaseClient = class {
|
|
|
220
221
|
async getMultiProductSnapshots(params) {
|
|
221
222
|
const timestampToProductsMap = await this.query("product_snapshots", {
|
|
222
223
|
product_ids: params.productIds,
|
|
223
|
-
max_time: params.maxTimestampInclusive ?? [(0,
|
|
224
|
+
max_time: params.maxTimestampInclusive ?? [(0, import_shared.nowInSeconds)()]
|
|
224
225
|
});
|
|
225
|
-
return (0,
|
|
226
|
-
return (0,
|
|
226
|
+
return (0, import_shared.mapValues)(timestampToProductsMap, (productIdToProduct) => {
|
|
227
|
+
return (0, import_shared.mapValues)(productIdToProduct, (indexerProduct) => {
|
|
227
228
|
return {
|
|
228
229
|
...(0, import_dataMappers.mapIndexerServerProduct)(indexerProduct.product),
|
|
229
230
|
submissionIndex: indexerProduct.submission_idx
|
|
@@ -251,7 +252,7 @@ var IndexerBaseClient = class {
|
|
|
251
252
|
};
|
|
252
253
|
})();
|
|
253
254
|
const baseResponse = await this.query("events", {
|
|
254
|
-
subaccount: params.subaccount ? (0,
|
|
255
|
+
subaccount: params.subaccount ? (0, import_shared.subaccountToHex)({
|
|
255
256
|
subaccountOwner: params.subaccount.subaccountOwner,
|
|
256
257
|
subaccountName: params.subaccount.subaccountName
|
|
257
258
|
}) : void 0,
|
|
@@ -278,7 +279,7 @@ var IndexerBaseClient = class {
|
|
|
278
279
|
*/
|
|
279
280
|
async getOrders(params) {
|
|
280
281
|
const baseResponse = await this.query("orders", {
|
|
281
|
-
subaccount: params.subaccount ? (0,
|
|
282
|
+
subaccount: params.subaccount ? (0, import_shared.subaccountToHex)({
|
|
282
283
|
subaccountOwner: params.subaccount.subaccountOwner,
|
|
283
284
|
subaccountName: params.subaccount.subaccountName
|
|
284
285
|
}) : void 0,
|
|
@@ -299,7 +300,7 @@ var IndexerBaseClient = class {
|
|
|
299
300
|
*/
|
|
300
301
|
async getMatchEvents(params) {
|
|
301
302
|
const baseResponse = await this.query("matches", {
|
|
302
|
-
subaccount: params.subaccount ? (0,
|
|
303
|
+
subaccount: params.subaccount ? (0, import_shared.subaccountToHex)({
|
|
303
304
|
subaccountOwner: params.subaccount.subaccountOwner,
|
|
304
305
|
subaccountName: params.subaccount.subaccountName
|
|
305
306
|
}) : void 0,
|
|
@@ -321,25 +322,25 @@ var IndexerBaseClient = class {
|
|
|
321
322
|
return {
|
|
322
323
|
productId: postBalances.base.productId,
|
|
323
324
|
isolated: matchEvent.isolated,
|
|
324
|
-
totalFee: (0,
|
|
325
|
-
sequencerFee: (0,
|
|
326
|
-
baseFilled: (0,
|
|
327
|
-
quoteFilled: (0,
|
|
328
|
-
cumulativeFee: (0,
|
|
329
|
-
cumulativeBaseFilled: (0,
|
|
330
|
-
cumulativeQuoteFilled: (0,
|
|
325
|
+
totalFee: (0, import_shared.toBigDecimal)(matchEvent.fee),
|
|
326
|
+
sequencerFee: (0, import_shared.toBigDecimal)(matchEvent.sequencer_fee),
|
|
327
|
+
baseFilled: (0, import_shared.toBigDecimal)(matchEvent.base_filled),
|
|
328
|
+
quoteFilled: (0, import_shared.toBigDecimal)(matchEvent.quote_filled),
|
|
329
|
+
cumulativeFee: (0, import_shared.toBigDecimal)(matchEvent.cumulative_fee),
|
|
330
|
+
cumulativeBaseFilled: (0, import_shared.toBigDecimal)(matchEvent.cumulative_base_filled),
|
|
331
|
+
cumulativeQuoteFilled: (0, import_shared.toBigDecimal)(matchEvent.cumulative_quote_filled),
|
|
331
332
|
digest: matchEvent.digest,
|
|
332
333
|
order: matchEvent.order,
|
|
333
334
|
submissionIndex: matchEvent.submission_idx,
|
|
334
|
-
timestamp: (0,
|
|
335
|
+
timestamp: (0, import_shared.toBigDecimal)(timestamp),
|
|
335
336
|
preEventTrackedVars: {
|
|
336
|
-
netEntryUnrealized: (0,
|
|
337
|
-
netEntryCumulative: (0,
|
|
337
|
+
netEntryUnrealized: (0, import_shared.toBigDecimal)(matchEvent.net_entry_unrealized),
|
|
338
|
+
netEntryCumulative: (0, import_shared.toBigDecimal)(matchEvent.net_entry_cumulative)
|
|
338
339
|
},
|
|
339
340
|
preBalances: (0, import_dataMappers.mapIndexerMatchEventBalances)(matchEvent.pre_balance),
|
|
340
341
|
postBalances,
|
|
341
342
|
tx,
|
|
342
|
-
...(0,
|
|
343
|
+
...(0, import_shared.subaccountFromHex)(matchEvent.order.sender)
|
|
343
344
|
};
|
|
344
345
|
});
|
|
345
346
|
}
|
|
@@ -353,7 +354,7 @@ var IndexerBaseClient = class {
|
|
|
353
354
|
*/
|
|
354
355
|
async getInterestFundingPayments(params) {
|
|
355
356
|
const baseResponse = await this.query("interest_and_funding", {
|
|
356
|
-
subaccount: (0,
|
|
357
|
+
subaccount: (0, import_shared.subaccountToHex)({
|
|
357
358
|
subaccountOwner: params.subaccount.subaccountOwner,
|
|
358
359
|
subaccountName: params.subaccount.subaccountName
|
|
359
360
|
}),
|
|
@@ -378,7 +379,7 @@ var IndexerBaseClient = class {
|
|
|
378
379
|
async getQuotePrice() {
|
|
379
380
|
const baseResponse = await this.query("usdc_price", {});
|
|
380
381
|
return {
|
|
381
|
-
price: (0,
|
|
382
|
+
price: (0, import_shared.removeDecimals)(baseResponse.price_x18)
|
|
382
383
|
};
|
|
383
384
|
}
|
|
384
385
|
/**
|
|
@@ -386,13 +387,13 @@ var IndexerBaseClient = class {
|
|
|
386
387
|
*/
|
|
387
388
|
async getLinkedSignerWithRateLimit(params) {
|
|
388
389
|
const baseResponse = await this.query("linked_signer_rate_limit", {
|
|
389
|
-
subaccount: (0,
|
|
390
|
+
subaccount: (0, import_shared.subaccountToHex)(params.subaccount)
|
|
390
391
|
});
|
|
391
392
|
return {
|
|
392
|
-
totalTxLimit: (0,
|
|
393
|
-
remainingTxs: (0,
|
|
393
|
+
totalTxLimit: (0, import_shared.toBigDecimal)(baseResponse.total_tx_limit),
|
|
394
|
+
remainingTxs: (0, import_shared.toBigDecimal)(baseResponse.remaining_tx),
|
|
394
395
|
signer: baseResponse.signer,
|
|
395
|
-
waitTimeUntilNextTx: (0,
|
|
396
|
+
waitTimeUntilNextTx: (0, import_shared.toBigDecimal)(baseResponse.wait_time)
|
|
396
397
|
};
|
|
397
398
|
}
|
|
398
399
|
/**
|
|
@@ -414,7 +415,7 @@ var IndexerBaseClient = class {
|
|
|
414
415
|
const baseResponse = await this.query("edge_market_snapshots", {
|
|
415
416
|
interval: (0, import_dataMappers.mapSnapshotsIntervalToServerParams)(params)
|
|
416
417
|
});
|
|
417
|
-
return (0,
|
|
418
|
+
return (0, import_shared.mapValues)(
|
|
418
419
|
baseResponse.snapshots,
|
|
419
420
|
(snapshots) => snapshots.map(import_dataMappers.mapIndexerMarketSnapshot)
|
|
420
421
|
);
|
|
@@ -431,7 +432,7 @@ var IndexerBaseClient = class {
|
|
|
431
432
|
interval: params.interval
|
|
432
433
|
});
|
|
433
434
|
return {
|
|
434
|
-
rewardCoefficient: (0,
|
|
435
|
+
rewardCoefficient: (0, import_shared.toBigDecimal)(baseResponse.reward_coefficient),
|
|
435
436
|
makers: baseResponse.makers.map(import_dataMappers.mapIndexerMakerStatistics)
|
|
436
437
|
};
|
|
437
438
|
}
|
|
@@ -458,11 +459,11 @@ var IndexerBaseClient = class {
|
|
|
458
459
|
*/
|
|
459
460
|
async getLeaderboardParticipant(params) {
|
|
460
461
|
const baseResponse = await this.query("leaderboard_rank", {
|
|
461
|
-
subaccount: (0,
|
|
462
|
+
subaccount: (0, import_shared.subaccountToHex)(params.subaccount),
|
|
462
463
|
contest_ids: params.contestIds
|
|
463
464
|
});
|
|
464
465
|
return {
|
|
465
|
-
participant: (0,
|
|
466
|
+
participant: (0, import_shared.mapValues)(
|
|
466
467
|
baseResponse.positions,
|
|
467
468
|
(position) => (0, import_dataMappers.mapIndexerLeaderboardPosition)(position)
|
|
468
469
|
)
|
|
@@ -475,11 +476,11 @@ var IndexerBaseClient = class {
|
|
|
475
476
|
async updateLeaderboardRegistration(params) {
|
|
476
477
|
const signatureParams = {
|
|
477
478
|
// Default to 90 seconds from now if no recvTime is provided
|
|
478
|
-
expiration: (0,
|
|
479
|
+
expiration: (0, import_shared.toIntegerString)(params.recvTime ?? (0, import_shared.getDefaultRecvTime)()),
|
|
479
480
|
subaccountName: params.subaccountName,
|
|
480
481
|
subaccountOwner: params.subaccountOwner
|
|
481
482
|
};
|
|
482
|
-
const tx = (0,
|
|
483
|
+
const tx = (0, import_shared.getNadoEIP712Values)(
|
|
483
484
|
"leaderboard_authentication",
|
|
484
485
|
signatureParams
|
|
485
486
|
);
|
|
@@ -494,7 +495,7 @@ var IndexerBaseClient = class {
|
|
|
494
495
|
signature
|
|
495
496
|
};
|
|
496
497
|
const baseResponse = await this.query("leaderboard_registration", {
|
|
497
|
-
subaccount: (0,
|
|
498
|
+
subaccount: (0, import_shared.subaccountToHex)({
|
|
498
499
|
subaccountOwner: params.subaccountOwner,
|
|
499
500
|
subaccountName: params.subaccountName
|
|
500
501
|
}),
|
|
@@ -511,7 +512,7 @@ var IndexerBaseClient = class {
|
|
|
511
512
|
*/
|
|
512
513
|
async getLeaderboardRegistration(params) {
|
|
513
514
|
const baseResponse = await this.query("leaderboard_registration", {
|
|
514
|
-
subaccount: (0,
|
|
515
|
+
subaccount: (0, import_shared.subaccountToHex)({
|
|
515
516
|
subaccountOwner: params.subaccountOwner,
|
|
516
517
|
subaccountName: params.subaccountName
|
|
517
518
|
}),
|
|
@@ -543,33 +544,45 @@ var IndexerBaseClient = class {
|
|
|
543
544
|
async getFastWithdrawalSignature(params) {
|
|
544
545
|
const baseResponse = await this.query("fast_withdrawal_signature", params);
|
|
545
546
|
return {
|
|
546
|
-
idx: (0,
|
|
547
|
+
idx: (0, import_shared.toBigInt)(baseResponse.idx),
|
|
547
548
|
tx: baseResponse.tx,
|
|
548
|
-
txBytes: (0,
|
|
549
|
-
signatures: baseResponse.signatures.map(
|
|
549
|
+
txBytes: (0, import_shared.getValidatedHex)(baseResponse.tx_bytes),
|
|
550
|
+
signatures: baseResponse.signatures.map(import_shared.getValidatedHex)
|
|
550
551
|
};
|
|
551
552
|
}
|
|
552
|
-
async
|
|
553
|
-
const baseResponse = await this.query("
|
|
553
|
+
async getNlpSnapshots(params) {
|
|
554
|
+
const baseResponse = await this.query("nlp_snapshots", {
|
|
554
555
|
interval: {
|
|
555
556
|
count: params.limit,
|
|
556
|
-
max_time: params.maxTimeInclusive ? (0,
|
|
557
|
+
max_time: params.maxTimeInclusive ? (0, import_shared.toIntegerString)(params.maxTimeInclusive) : void 0,
|
|
557
558
|
granularity: params.granularity
|
|
558
559
|
}
|
|
559
560
|
});
|
|
560
561
|
return {
|
|
561
|
-
snapshots: baseResponse.snapshots.map(import_dataMappers.
|
|
562
|
+
snapshots: baseResponse.snapshots.map(import_dataMappers.mapIndexerNlpSnapshot)
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Retrieves the subaccount's DDA (Direct Deposit Address)
|
|
567
|
+
* @param params
|
|
568
|
+
*/
|
|
569
|
+
async getSubaccountDDA(params) {
|
|
570
|
+
const baseResponse = await this.query("direct_deposit_address", {
|
|
571
|
+
subaccount: (0, import_shared.subaccountToHex)(params.subaccount)
|
|
572
|
+
});
|
|
573
|
+
return {
|
|
574
|
+
address: (0, import_shared.getValidatedAddress)(baseResponse.v1_address)
|
|
562
575
|
};
|
|
563
576
|
}
|
|
564
577
|
async getSequencerBacklog() {
|
|
565
578
|
const baseResponse = await this.query("backlog", {});
|
|
566
579
|
return {
|
|
567
|
-
totalTxs: (0,
|
|
568
|
-
totalSubmissions: (0,
|
|
569
|
-
backlogSize: (0,
|
|
570
|
-
updatedAt: (0,
|
|
571
|
-
backlogEtaInSeconds: baseResponse.backlog_eta_in_seconds ? (0,
|
|
572
|
-
txsPerSecond: baseResponse.txs_per_second ? (0,
|
|
580
|
+
totalTxs: (0, import_shared.toBigDecimal)(baseResponse.total_txs),
|
|
581
|
+
totalSubmissions: (0, import_shared.toBigDecimal)(baseResponse.total_submissions),
|
|
582
|
+
backlogSize: (0, import_shared.toBigDecimal)(baseResponse.backlog_size),
|
|
583
|
+
updatedAt: (0, import_shared.toBigDecimal)(baseResponse.updated_at),
|
|
584
|
+
backlogEtaInSeconds: baseResponse.backlog_eta_in_seconds ? (0, import_shared.toBigDecimal)(baseResponse.backlog_eta_in_seconds) : null,
|
|
585
|
+
txsPerSecond: baseResponse.txs_per_second ? (0, import_shared.toBigDecimal)(baseResponse.txs_per_second) : null
|
|
573
586
|
};
|
|
574
587
|
}
|
|
575
588
|
async query(requestType, params) {
|
|
@@ -583,9 +596,9 @@ var IndexerBaseClient = class {
|
|
|
583
596
|
async sign(requestType, verifyingContract, chainId, params) {
|
|
584
597
|
const walletClient = this.opts.walletClient;
|
|
585
598
|
if (!walletClient) {
|
|
586
|
-
throw new
|
|
599
|
+
throw new import_shared.WalletNotProvidedError();
|
|
587
600
|
}
|
|
588
|
-
return (0,
|
|
601
|
+
return (0, import_shared.getSignedTransactionRequest)({
|
|
589
602
|
chainId,
|
|
590
603
|
requestParams: params,
|
|
591
604
|
requestType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/IndexerBaseClient.ts"],"sourcesContent":["import {\n EIP712LeaderboardAuthenticationParams,\n EIP712LeaderboardAuthenticationValues,\n getDefaultRecvTime,\n getNadoEIP712Values,\n getSignedTransactionRequest,\n SignableRequestType,\n SignableRequestTypeToParams,\n SignedTx,\n subaccountFromHex,\n subaccountToHex,\n WalletClientWithAccount,\n} from '@nadohq/contracts';\nimport {\n getValidatedHex,\n mapValues,\n nowInSeconds,\n removeDecimals,\n toBigDecimal,\n toBigInt,\n toIntegerString,\n WalletNotProvidedError,\n} from '@nadohq/utils';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n mapIndexerCandlesticks,\n mapIndexerEvent,\n mapIndexerEventWithTx,\n mapIndexerFundingRate,\n mapIndexerLeaderboardContest,\n mapIndexerLeaderboardPosition,\n mapIndexerLeaderboardRegistration,\n mapIndexerMakerStatistics,\n mapIndexerMarketSnapshot,\n mapIndexerMatchEventBalances,\n mapIndexerOrder,\n mapIndexerPerpPrices,\n mapIndexerProductPayment,\n mapIndexerServerProduct,\n mapIndexerVlpSnapshot,\n mapSnapshotsIntervalToServerParams,\n} from './dataMappers';\nimport {\n GetIndexerBacklogResponse,\n GetIndexerCandlesticksParams,\n GetIndexerCandlesticksResponse,\n GetIndexerEdgeCandlesticksParams,\n GetIndexerEdgeCandlesticksResponse,\n GetIndexerEdgeMarketSnapshotResponse,\n GetIndexerEdgeMarketSnapshotsParams,\n GetIndexerEventsParams,\n GetIndexerEventsResponse,\n GetIndexerFastWithdrawalSignatureParams,\n GetIndexerFastWithdrawalSignatureResponse,\n GetIndexerFundingRateParams,\n GetIndexerFundingRateResponse,\n GetIndexerInterestFundingPaymentsParams,\n GetIndexerInterestFundingPaymentsResponse,\n GetIndexerLeaderboardContestsParams,\n GetIndexerLeaderboardContestsResponse,\n GetIndexerLeaderboardParams,\n GetIndexerLeaderboardParticipantParams,\n GetIndexerLeaderboardParticipantResponse,\n GetIndexerLeaderboardRegistrationParams,\n GetIndexerLeaderboardRegistrationResponse,\n GetIndexerLeaderboardResponse,\n GetIndexerLinkedSignerParams,\n GetIndexerLinkedSignerResponse,\n GetIndexerMakerStatisticsParams,\n GetIndexerMakerStatisticsResponse,\n GetIndexerMarketSnapshotsParams,\n GetIndexerMarketSnapshotsResponse,\n GetIndexerMatchEventsParams,\n GetIndexerMatchEventsResponse,\n GetIndexerMultiProductFundingRatesParams,\n GetIndexerMultiProductFundingRatesResponse,\n GetIndexerMultiProductPerpPricesParams,\n GetIndexerMultiProductPerpPricesResponse,\n GetIndexerMultiProductSnapshotsParams,\n GetIndexerMultiProductSnapshotsResponse,\n GetIndexerMultiSubaccountSnapshotsParams,\n GetIndexerMultiSubaccountSnapshotsResponse,\n GetIndexerOraclePricesParams,\n GetIndexerOraclePricesResponse,\n GetIndexerOrdersParams,\n GetIndexerOrdersResponse,\n GetIndexerPerpPricesParams,\n GetIndexerPerpPricesResponse,\n GetIndexerProductSnapshotsParams,\n GetIndexerProductSnapshotsResponse,\n GetIndexerQuotePriceResponse,\n GetIndexerReferralCodeParams,\n GetIndexerReferralCodeResponse,\n GetIndexerVlpSnapshotsParams,\n GetIndexerVlpSnapshotsResponse,\n IndexerEventWithTx,\n IndexerMatchEvent,\n IndexerOraclePrice,\n IndexerServerEventsParams,\n IndexerServerQueryRequestByType,\n IndexerServerQueryRequestType,\n IndexerServerQueryResponseByType,\n IndexerSnapshotBalance,\n IndexerSubaccountSnapshot,\n ListIndexerSubaccountsParams,\n ListIndexerSubaccountsResponse,\n UpdateIndexerLeaderboardRegistrationParams,\n UpdateIndexerLeaderboardRegistrationResponse,\n} from './types';\n\nexport interface IndexerClientOpts {\n // Server URLs\n url: string;\n v2Url?: string;\n // Wallet Client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n}\n\ntype IndexerQueryRequestBody = Partial<IndexerServerQueryRequestByType>;\n\n/**\n * Base client for all indexer requests\n */\nexport class IndexerBaseClient {\n readonly opts: IndexerClientOpts;\n readonly v2Url: string;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: IndexerClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n });\n this.v2Url = opts.v2Url ? opts.v2Url : opts.url.replace('v1', 'v2');\n }\n\n /**\n * List all subaccounts\n *\n * @param params\n */\n async listSubaccounts(\n params: ListIndexerSubaccountsParams,\n ): Promise<ListIndexerSubaccountsResponse> {\n const baseResponse = await this.query('subaccounts', params);\n\n return baseResponse.subaccounts.map((item) => {\n const subaccount = subaccountFromHex(item.subaccount);\n return {\n hexId: item.subaccount,\n ...subaccount,\n };\n });\n }\n\n /**\n * Retrieve snapshots of multiple subaccounts at multiple points in time.\n * Each snapshot is a view of the subaccount's balances at this point in time, with tracked variables for interest, funding, etc.\n *\n * @param params\n */\n async getMultiSubaccountSnapshots(\n params: GetIndexerMultiSubaccountSnapshotsParams,\n ): Promise<GetIndexerMultiSubaccountSnapshotsResponse> {\n const subaccountHexIds = params.subaccounts.map(\n ({ subaccountOwner, subaccountName }) =>\n subaccountToHex({\n subaccountOwner,\n subaccountName,\n }),\n );\n\n const baseResponse = await this.query('account_snapshots', {\n subaccounts: subaccountHexIds,\n timestamps: params.timestamps,\n isolated: params.isolated,\n });\n\n const snapshotsBySubaccount = mapValues(\n baseResponse.snapshots,\n (balanceSnapshots) => {\n const snapshotByTimestamp: Record<string, IndexerSubaccountSnapshot> =\n {};\n\n Object.entries(balanceSnapshots).forEach(([timestamp, events]) => {\n const balances: IndexerSnapshotBalance[] =\n events.map(mapIndexerEvent);\n\n snapshotByTimestamp[timestamp] = {\n timestamp: toBigDecimal(timestamp),\n balances,\n };\n });\n\n return snapshotByTimestamp;\n },\n );\n\n return {\n subaccountHexIds,\n snapshots: snapshotsBySubaccount,\n };\n }\n\n /**\n * Retrieves referral code for an address\n *\n * @param params\n */\n async getReferralCode(\n params: GetIndexerReferralCodeParams,\n ): Promise<GetIndexerReferralCodeResponse> {\n const baseResponse = await this.query('referral_code', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n });\n\n return {\n referralCode: baseResponse.referral_code,\n };\n }\n\n /**\n * Retrieves funding rate for a product, where 1 = 100%\n * @param params\n */\n async getFundingRate(\n params: GetIndexerFundingRateParams,\n ): Promise<GetIndexerFundingRateResponse> {\n const baseResponse = await this.query('funding_rate', {\n product_id: params.productId,\n });\n\n return mapIndexerFundingRate(baseResponse);\n }\n\n /**\n * Retrieves funding rate for multiple products, where 1 = 100%\n * @param params\n */\n async getMultiProductFundingRates(\n params: GetIndexerMultiProductFundingRatesParams,\n ): Promise<GetIndexerMultiProductFundingRatesResponse> {\n const baseResponse = await this.query('funding_rates', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerFundingRate);\n }\n\n /**\n * Retrieves latest mark/index price for a perp product\n * @param params\n */\n async getPerpPrices(\n params: GetIndexerPerpPricesParams,\n ): Promise<GetIndexerPerpPricesResponse> {\n const baseResponse = await this.query('price', {\n product_id: params.productId,\n });\n\n return mapIndexerPerpPrices(baseResponse);\n }\n\n /**\n * Retrieves latest mark/index price for multiple perp products\n * @param params\n */\n async getMultiProductPerpPrices(\n params: GetIndexerMultiProductPerpPricesParams,\n ): Promise<GetIndexerMultiProductPerpPricesResponse> {\n const baseResponse = await this.query('perp_prices', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerPerpPrices);\n }\n\n /**\n * Retrieves latest oracle prices for provided products\n * @param params\n */\n async getOraclePrices(\n params: GetIndexerOraclePricesParams,\n ): Promise<GetIndexerOraclePricesResponse> {\n const baseResponse = await this.query('oracle_price', {\n product_ids: params.productIds,\n });\n\n return baseResponse.prices.map((price): IndexerOraclePrice => {\n return {\n oraclePrice: removeDecimals(price.oracle_price_x18),\n updateTime: toBigDecimal(price.update_time),\n productId: price.product_id,\n };\n });\n }\n\n /**\n * Retrieves candlesticks for a product\n * @param params\n */\n async getCandlesticks(\n params: GetIndexerCandlesticksParams,\n ): Promise<GetIndexerCandlesticksResponse> {\n const baseResponse = await this.query('candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves candlesticks for a product from Edge\n * @param params\n */\n async getEdgeCandlesticks(\n params: GetIndexerEdgeCandlesticksParams,\n ): Promise<GetIndexerEdgeCandlesticksResponse> {\n const baseResponse = await this.query('edge_candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves historical snapshots for a product\n * @param params\n */\n async getProductSnapshots(\n params: GetIndexerProductSnapshotsParams,\n ): Promise<GetIndexerProductSnapshotsResponse> {\n const baseResponse = await this.query('products', {\n product_id: params.productId,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.products.map((product) => {\n return {\n ...mapIndexerServerProduct(product.product),\n submissionIndex: product.submission_idx,\n };\n });\n }\n\n /**\n * Retrieves historical snapshots for multiple products\n * @param params\n */\n async getMultiProductSnapshots(\n params: GetIndexerMultiProductSnapshotsParams,\n ): Promise<GetIndexerMultiProductSnapshotsResponse> {\n const timestampToProductsMap = await this.query('product_snapshots', {\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive ?? [nowInSeconds()],\n });\n\n return mapValues(timestampToProductsMap, (productIdToProduct) => {\n return mapValues(productIdToProduct, (indexerProduct) => {\n return {\n ...mapIndexerServerProduct(indexerProduct.product),\n submissionIndex: indexerProduct.submission_idx,\n };\n });\n });\n }\n\n /**\n * Retrieves historical events\n *\n * @param params\n */\n async getEvents(\n params: GetIndexerEventsParams,\n ): Promise<GetIndexerEventsResponse> {\n const serverLimit = ((): IndexerServerEventsParams['limit'] | undefined => {\n if (!params.limit) {\n return;\n }\n\n if (params.limit.type === 'events') {\n return {\n raw: params.limit.value,\n };\n }\n return {\n txs: params.limit.value,\n };\n })();\n\n const baseResponse = await this.query('events', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n event_types: params.eventTypes,\n max_time: params.maxTimestampInclusive,\n desc: params.desc,\n limit: serverLimit,\n idx: params.startCursor,\n });\n\n // Keep track of the last tx index, and go to the next one if the submission_idx for the currently processed event does not match\n // txs are ordered the same as events, so this should be correct\n let lastTxIdx = 0;\n return baseResponse.events.map((event): IndexerEventWithTx => {\n if (baseResponse.txs[lastTxIdx].submission_idx !== event.submission_idx) {\n lastTxIdx += 1;\n }\n const tx = baseResponse.txs[lastTxIdx];\n return mapIndexerEventWithTx(event, tx);\n });\n }\n\n /**\n * Retrieves historical orders\n * @param params\n */\n async getOrders(\n params: GetIndexerOrdersParams,\n ): Promise<GetIndexerOrdersResponse> {\n const baseResponse = await this.query('orders', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n digests: params.digests,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.orders.map(mapIndexerOrder);\n }\n\n /**\n * Gets match order events, this will return the same events as the events query, but with additional information\n * to identify the order that was matched\n *\n * @param params\n */\n async getMatchEvents(\n params: GetIndexerMatchEventsParams,\n ): Promise<GetIndexerMatchEventsResponse> {\n const baseResponse = await this.query('matches', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n // Same as logic in `getEvents`\n let lastTxIdx = 0;\n return baseResponse.matches.map((matchEvent): IndexerMatchEvent => {\n if (\n baseResponse.txs[lastTxIdx].submission_idx !== matchEvent.submission_idx\n ) {\n lastTxIdx += 1;\n }\n const { tx, timestamp } = baseResponse.txs[lastTxIdx];\n\n // We use this to derive the product ID for the match\n const postBalances = mapIndexerMatchEventBalances(\n matchEvent.post_balance,\n );\n\n return {\n productId: postBalances.base.productId,\n isolated: matchEvent.isolated,\n totalFee: toBigDecimal(matchEvent.fee),\n sequencerFee: toBigDecimal(matchEvent.sequencer_fee),\n baseFilled: toBigDecimal(matchEvent.base_filled),\n quoteFilled: toBigDecimal(matchEvent.quote_filled),\n cumulativeFee: toBigDecimal(matchEvent.cumulative_fee),\n cumulativeBaseFilled: toBigDecimal(matchEvent.cumulative_base_filled),\n cumulativeQuoteFilled: toBigDecimal(matchEvent.cumulative_quote_filled),\n digest: matchEvent.digest,\n order: matchEvent.order,\n submissionIndex: matchEvent.submission_idx,\n timestamp: toBigDecimal(timestamp),\n preEventTrackedVars: {\n netEntryUnrealized: toBigDecimal(matchEvent.net_entry_unrealized),\n netEntryCumulative: toBigDecimal(matchEvent.net_entry_cumulative),\n },\n preBalances: mapIndexerMatchEventBalances(matchEvent.pre_balance),\n postBalances,\n tx,\n ...subaccountFromHex(matchEvent.order.sender),\n };\n });\n }\n\n /**\n * Retrieves historical funding & interest payments.\n * NOTE: `limit` is an upperbound. If a user changes position size such that his position is 0 during each funding/interest tick,\n * then the indexer will return fewer than `limit` results per page. However, more events can be present. This means that\n * there isn't a reliable way to determine whether there is a next page. We just need to keep paginating until the next cursor is null.\n *\n * @param params\n */\n async getInterestFundingPayments(\n params: GetIndexerInterestFundingPaymentsParams,\n ): Promise<GetIndexerInterestFundingPaymentsResponse> {\n const baseResponse = await this.query('interest_and_funding', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n max_idx: params.startCursor,\n });\n\n return {\n fundingPayments: baseResponse.funding_payments.map(\n mapIndexerProductPayment,\n ),\n interestPayments: baseResponse.interest_payments.map(\n mapIndexerProductPayment,\n ),\n nextCursor: baseResponse.next_idx,\n };\n }\n\n /**\n * Gets quote (USDC) price in terms of USD\n */\n async getQuotePrice(): Promise<GetIndexerQuotePriceResponse> {\n const baseResponse = await this.query('usdc_price', {});\n return {\n price: removeDecimals(baseResponse.price_x18),\n };\n }\n\n /**\n * Fetches currently registered linked signer with the remaining txs allowed for the subaccount\n */\n async getLinkedSignerWithRateLimit(\n params: GetIndexerLinkedSignerParams,\n ): Promise<GetIndexerLinkedSignerResponse> {\n const baseResponse = await this.query('linked_signer_rate_limit', {\n subaccount: subaccountToHex(params.subaccount),\n });\n return {\n totalTxLimit: toBigDecimal(baseResponse.total_tx_limit),\n remainingTxs: toBigDecimal(baseResponse.remaining_tx),\n signer: baseResponse.signer,\n waitTimeUntilNextTx: toBigDecimal(baseResponse.wait_time),\n };\n }\n\n /**\n * Retrieve historical market snapshots\n * @param params\n */\n async getMarketSnapshots(\n params: GetIndexerMarketSnapshotsParams,\n ): Promise<GetIndexerMarketSnapshotsResponse> {\n const baseResponse = await this.query('market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n product_ids: params.productIds,\n });\n\n return baseResponse.snapshots.map(mapIndexerMarketSnapshot);\n }\n\n /**\n * Retrieve historical market snapshots from Edge\n * @param params\n */\n async getEdgeMarketSnapshots(\n params: GetIndexerEdgeMarketSnapshotsParams,\n ): Promise<GetIndexerEdgeMarketSnapshotResponse> {\n const baseResponse = await this.query('edge_market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n });\n\n return mapValues(baseResponse.snapshots, (snapshots) =>\n snapshots.map(mapIndexerMarketSnapshot),\n );\n }\n\n /**\n * Retrieve maker statistics for a given epoch\n *\n * @param params\n */\n async getMakerStatistics(\n params: GetIndexerMakerStatisticsParams,\n ): Promise<GetIndexerMakerStatisticsResponse> {\n const baseResponse = await this.query('maker_statistics', {\n product_id: params.productId,\n epoch: params.epoch,\n interval: params.interval,\n });\n\n return {\n rewardCoefficient: toBigDecimal(baseResponse.reward_coefficient),\n makers: baseResponse.makers.map(mapIndexerMakerStatistics),\n };\n }\n\n /**\n * Retrieve leaderboard stats for a given contest\n *\n * @param params\n */\n async getLeaderboard(\n params: GetIndexerLeaderboardParams,\n ): Promise<GetIndexerLeaderboardResponse> {\n const baseResponse = await this.query('leaderboard', {\n contest_id: params.contestId,\n rank_type: params.rankType,\n start: params.startCursor,\n limit: params.limit,\n });\n\n return {\n participants: baseResponse.positions.map(mapIndexerLeaderboardPosition),\n };\n }\n\n /**\n * Retrieve leaderboard ranking of a subaccount on a given contest\n *\n * @param params\n */\n async getLeaderboardParticipant(\n params: GetIndexerLeaderboardParticipantParams,\n ): Promise<GetIndexerLeaderboardParticipantResponse> {\n const baseResponse = await this.query('leaderboard_rank', {\n subaccount: subaccountToHex(params.subaccount),\n contest_ids: params.contestIds,\n });\n\n return {\n participant: mapValues(baseResponse.positions, (position) =>\n mapIndexerLeaderboardPosition(position),\n ),\n };\n }\n\n /**\n * Attempts to update a user's registration to the provided `contestId`. This requires signing.\n * @param params\n */\n async updateLeaderboardRegistration(\n params: UpdateIndexerLeaderboardRegistrationParams,\n ): Promise<UpdateIndexerLeaderboardRegistrationResponse> {\n const signatureParams: EIP712LeaderboardAuthenticationParams = {\n // Default to 90 seconds from now if no recvTime is provided\n expiration: toIntegerString(params.recvTime ?? getDefaultRecvTime()),\n subaccountName: params.subaccountName,\n subaccountOwner: params.subaccountOwner,\n };\n\n const tx = getNadoEIP712Values(\n 'leaderboard_authentication',\n signatureParams,\n );\n const signature = await this.sign(\n 'leaderboard_authentication',\n params.updateRegistration.verifyingAddr,\n params.updateRegistration.chainId,\n signatureParams,\n );\n\n const updateRegistrationTx: SignedTx<EIP712LeaderboardAuthenticationValues> =\n {\n tx,\n signature,\n };\n\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: updateRegistrationTx,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieves the registration status for a leaderboard participant for provided `contestId`.\n * @param params\n */\n async getLeaderboardRegistration(\n params: GetIndexerLeaderboardRegistrationParams,\n ): Promise<GetIndexerLeaderboardRegistrationResponse> {\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: null,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieve metadata of provided leaderboard contests\n *\n * @param params\n */\n async getLeaderboardContests(\n params: GetIndexerLeaderboardContestsParams,\n ): Promise<GetIndexerLeaderboardContestsResponse> {\n const baseResponse = await this.query('leaderboard_contests', {\n contest_ids: params.contestIds,\n });\n\n return {\n contests: baseResponse.contests.map(mapIndexerLeaderboardContest),\n };\n }\n\n /**\n * Retrieve signature and tx to submit a fast withdrawal\n *\n * @param params\n */\n async getFastWithdrawalSignature(\n params: GetIndexerFastWithdrawalSignatureParams,\n ): Promise<GetIndexerFastWithdrawalSignatureResponse> {\n const baseResponse = await this.query('fast_withdrawal_signature', params);\n return {\n idx: toBigInt(baseResponse.idx),\n tx: baseResponse.tx,\n txBytes: getValidatedHex(baseResponse.tx_bytes),\n signatures: baseResponse.signatures.map(getValidatedHex),\n };\n }\n\n async getVlpSnapshots(\n params: GetIndexerVlpSnapshotsParams,\n ): Promise<GetIndexerVlpSnapshotsResponse> {\n const baseResponse = await this.query('vlp_snapshots', {\n interval: {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n },\n });\n\n return {\n snapshots: baseResponse.snapshots.map(mapIndexerVlpSnapshot),\n };\n }\n\n async getSequencerBacklog(): Promise<GetIndexerBacklogResponse> {\n const baseResponse = await this.query('backlog', {});\n\n return {\n totalTxs: toBigDecimal(baseResponse.total_txs),\n totalSubmissions: toBigDecimal(baseResponse.total_submissions),\n backlogSize: toBigDecimal(baseResponse.backlog_size),\n updatedAt: toBigDecimal(baseResponse.updated_at),\n backlogEtaInSeconds: baseResponse.backlog_eta_in_seconds\n ? toBigDecimal(baseResponse.backlog_eta_in_seconds)\n : null,\n txsPerSecond: baseResponse.txs_per_second\n ? toBigDecimal(baseResponse.txs_per_second)\n : null,\n };\n }\n\n protected async query<TRequestType extends IndexerServerQueryRequestType>(\n requestType: TRequestType,\n params: IndexerServerQueryRequestByType[TRequestType],\n ): Promise<IndexerServerQueryResponseByType[TRequestType]> {\n const reqBody: IndexerQueryRequestBody = {\n [requestType]: params,\n };\n const response = await this.axiosInstance.post<\n IndexerServerQueryResponseByType[TRequestType]\n >(this.opts.url, reqBody);\n\n this.checkResponseStatus(response);\n\n return response.data;\n }\n\n protected async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n const walletClient = this.opts.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}`,\n );\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAYO;AACP,mBASO;AACP,mBAAoD;AACpD,yBAiBO;AAkFA,IAAM,oBAAN,MAAwB;AAAA,EAK7B,YAAY,MAAyB;AACnC,SAAK,OAAO;AACZ,SAAK,gBAAgB,aAAAA,QAAM,OAAO;AAAA,MAChC,iBAAiB;AAAA,IACnB,CAAC;AACD,SAAK,QAAQ,KAAK,QAAQ,KAAK,QAAQ,KAAK,IAAI,QAAQ,MAAM,IAAI;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,gBACJ,QACyC;AACzC,UAAM,eAAe,MAAM,KAAK,MAAM,eAAe,MAAM;AAE3D,WAAO,aAAa,YAAY,IAAI,CAAC,SAAS;AAC5C,YAAM,iBAAa,oCAAkB,KAAK,UAAU;AACpD,aAAO;AAAA,QACL,OAAO,KAAK;AAAA,QACZ,GAAG;AAAA,MACL;AAAA,IACF,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,4BACJ,QACqD;AACrD,UAAM,mBAAmB,OAAO,YAAY;AAAA,MAC1C,CAAC,EAAE,iBAAiB,eAAe,UACjC,kCAAgB;AAAA,QACd;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACL;AAEA,UAAM,eAAe,MAAM,KAAK,MAAM,qBAAqB;AAAA,MACzD,aAAa;AAAA,MACb,YAAY,OAAO;AAAA,MACnB,UAAU,OAAO;AAAA,IACnB,CAAC;AAED,UAAM,4BAAwB;AAAA,MAC5B,aAAa;AAAA,MACb,CAAC,qBAAqB;AACpB,cAAM,sBACJ,CAAC;AAEH,eAA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F,CAAC;AAED,WAAO;AAAA,MACL,WAAW,aAAa,UAAU,IAAI,wCAAqB;AAAA,IAC7D;AAAA,EACF;AAAA,EAEA,MAAM,sBAA0D;AAC9D,UAAM,eAAe,MAAM,KAAK,MAAM,WAAW,CAAC,CAAC;AAEnD,WAAO;AAAA,MACL,cAAU,2BAAa,aAAa,SAAS;AAAA,MAC7C,sBAAkB,2BAAa,aAAa,iBAAiB;AAAA,MAC7D,iBAAa,2BAAa,aAAa,YAAY;AAAA,MACnD,eAAW,2BAAa,aAAa,UAAU;AAAA,MAC/C,qBAAqB,aAAa,6BAC9B,2BAAa,aAAa,sBAAsB,IAChD;AAAA,MACJ,cAAc,aAAa,qBACvB,2BAAa,aAAa,cAAc,IACxC;AAAA,IACN;AAAA,EACF;AAAA,EAEA,MAAgB,MACd,aACA,QACyD;AACzD,UAAM,UAAmC;AAAA,MACvC,CAAC,WAAW,GAAG;AAAA,IACjB;AACA,UAAM,WAAW,MAAM,KAAK,cAAc,KAExC,KAAK,KAAK,KAAK,OAAO;AAExB,SAAK,oBAAoB,QAAQ;AAEjC,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,MAAgB,KACd,aACA,mBACA,SACA,QACA;AACA,UAAM,eAAe,KAAK,KAAK;AAE/B,QAAI,CAAC,cAAc;AACjB,YAAM,IAAI,oCAAuB;AAAA,IACnC;AAEA,eAAO,8CAA4B;AAAA,MACjC;AAAA,MACA,eAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,oBAAoB,UAAyB;AACnD,QAAI,SAAS,WAAW,OAAO,CAAC,SAAS,MAAM;AAC7C,YAAM;AAAA,QACJ,oCAAoC,SAAS,MAAM,IAAI,SAAS,UAAU;AAAA,MAC5E;AAAA,IACF;AAAA,EACF;AACF;","names":["axios"]}
|
|
1
|
+
{"version":3,"sources":["../src/IndexerBaseClient.ts"],"sourcesContent":["import {\n EIP712LeaderboardAuthenticationParams,\n EIP712LeaderboardAuthenticationValues,\n getDefaultRecvTime,\n getNadoEIP712Values,\n getSignedTransactionRequest,\n getValidatedAddress,\n getValidatedHex,\n mapValues,\n nowInSeconds,\n removeDecimals,\n SignableRequestType,\n SignableRequestTypeToParams,\n SignedTx,\n subaccountFromHex,\n subaccountToHex,\n toBigDecimal,\n toBigInt,\n toIntegerString,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n mapIndexerCandlesticks,\n mapIndexerEvent,\n mapIndexerEventWithTx,\n mapIndexerFundingRate,\n mapIndexerLeaderboardContest,\n mapIndexerLeaderboardPosition,\n mapIndexerLeaderboardRegistration,\n mapIndexerMakerStatistics,\n mapIndexerMarketSnapshot,\n mapIndexerMatchEventBalances,\n mapIndexerNlpSnapshot,\n mapIndexerOrder,\n mapIndexerPerpPrices,\n mapIndexerProductPayment,\n mapIndexerServerProduct,\n mapSnapshotsIntervalToServerParams,\n} from './dataMappers';\nimport {\n GetIndexerBacklogResponse,\n GetIndexerCandlesticksParams,\n GetIndexerCandlesticksResponse,\n GetIndexerEdgeCandlesticksParams,\n GetIndexerEdgeCandlesticksResponse,\n GetIndexerEdgeMarketSnapshotResponse,\n GetIndexerEdgeMarketSnapshotsParams,\n GetIndexerEventsParams,\n GetIndexerEventsResponse,\n GetIndexerFastWithdrawalSignatureParams,\n GetIndexerFastWithdrawalSignatureResponse,\n GetIndexerFundingRateParams,\n GetIndexerFundingRateResponse,\n GetIndexerInterestFundingPaymentsParams,\n GetIndexerInterestFundingPaymentsResponse,\n GetIndexerLeaderboardContestsParams,\n GetIndexerLeaderboardContestsResponse,\n GetIndexerLeaderboardParams,\n GetIndexerLeaderboardParticipantParams,\n GetIndexerLeaderboardParticipantResponse,\n GetIndexerLeaderboardRegistrationParams,\n GetIndexerLeaderboardRegistrationResponse,\n GetIndexerLeaderboardResponse,\n GetIndexerLinkedSignerParams,\n GetIndexerLinkedSignerResponse,\n GetIndexerMakerStatisticsParams,\n GetIndexerMakerStatisticsResponse,\n GetIndexerMarketSnapshotsParams,\n GetIndexerMarketSnapshotsResponse,\n GetIndexerMatchEventsParams,\n GetIndexerMatchEventsResponse,\n GetIndexerMultiProductFundingRatesParams,\n GetIndexerMultiProductFundingRatesResponse,\n GetIndexerMultiProductPerpPricesParams,\n GetIndexerMultiProductPerpPricesResponse,\n GetIndexerMultiProductSnapshotsParams,\n GetIndexerMultiProductSnapshotsResponse,\n GetIndexerMultiSubaccountSnapshotsParams,\n GetIndexerMultiSubaccountSnapshotsResponse,\n GetIndexerNlpSnapshotsParams,\n GetIndexerNlpSnapshotsResponse,\n GetIndexerOraclePricesParams,\n GetIndexerOraclePricesResponse,\n GetIndexerOrdersParams,\n GetIndexerOrdersResponse,\n GetIndexerPerpPricesParams,\n GetIndexerPerpPricesResponse,\n GetIndexerProductSnapshotsParams,\n GetIndexerProductSnapshotsResponse,\n GetIndexerQuotePriceResponse,\n GetIndexerReferralCodeParams,\n GetIndexerReferralCodeResponse,\n GetIndexerSubaccountDDAParams,\n GetIndexerSubaccountDDAResponse,\n IndexerEventWithTx,\n IndexerMatchEvent,\n IndexerOraclePrice,\n IndexerServerEventsParams,\n IndexerServerQueryRequestByType,\n IndexerServerQueryRequestType,\n IndexerServerQueryResponseByType,\n IndexerSnapshotBalance,\n IndexerSubaccountSnapshot,\n ListIndexerSubaccountsParams,\n ListIndexerSubaccountsResponse,\n UpdateIndexerLeaderboardRegistrationParams,\n UpdateIndexerLeaderboardRegistrationResponse,\n} from './types';\n\nexport interface IndexerClientOpts {\n // Server URLs\n url: string;\n v2Url?: string;\n // Wallet Client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n}\n\ntype IndexerQueryRequestBody = Partial<IndexerServerQueryRequestByType>;\n\n/**\n * Base client for all indexer requests\n */\nexport class IndexerBaseClient {\n readonly opts: IndexerClientOpts;\n readonly v2Url: string;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: IndexerClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n });\n this.v2Url = opts.v2Url ? opts.v2Url : opts.url.replace('v1', 'v2');\n }\n\n /**\n * List all subaccounts\n *\n * @param params\n */\n async listSubaccounts(\n params: ListIndexerSubaccountsParams,\n ): Promise<ListIndexerSubaccountsResponse> {\n const baseResponse = await this.query('subaccounts', params);\n\n return baseResponse.subaccounts.map((item) => {\n const subaccount = subaccountFromHex(item.subaccount);\n return {\n hexId: item.subaccount,\n ...subaccount,\n };\n });\n }\n\n /**\n * Retrieve snapshots of multiple subaccounts at multiple points in time.\n * Each snapshot is a view of the subaccount's balances at this point in time, with tracked variables for interest, funding, etc.\n *\n * @param params\n */\n async getMultiSubaccountSnapshots(\n params: GetIndexerMultiSubaccountSnapshotsParams,\n ): Promise<GetIndexerMultiSubaccountSnapshotsResponse> {\n const subaccountHexIds = params.subaccounts.map(\n ({ subaccountOwner, subaccountName }) =>\n subaccountToHex({\n subaccountOwner,\n subaccountName,\n }),\n );\n\n const baseResponse = await this.query('account_snapshots', {\n subaccounts: subaccountHexIds,\n timestamps: params.timestamps,\n isolated: params.isolated,\n });\n\n const snapshotsBySubaccount = mapValues(\n baseResponse.snapshots,\n (balanceSnapshots) => {\n const snapshotByTimestamp: Record<string, IndexerSubaccountSnapshot> =\n {};\n\n Object.entries(balanceSnapshots).forEach(([timestamp, events]) => {\n const balances: IndexerSnapshotBalance[] =\n events.map(mapIndexerEvent);\n\n snapshotByTimestamp[timestamp] = {\n timestamp: toBigDecimal(timestamp),\n balances,\n };\n });\n\n return snapshotByTimestamp;\n },\n );\n\n return {\n subaccountHexIds,\n snapshots: snapshotsBySubaccount,\n };\n }\n\n /**\n * Retrieves referral code for an address\n *\n * @param params\n */\n async getReferralCode(\n params: GetIndexerReferralCodeParams,\n ): Promise<GetIndexerReferralCodeResponse> {\n const baseResponse = await this.query('referral_code', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n });\n\n return {\n referralCode: baseResponse.referral_code,\n };\n }\n\n /**\n * Retrieves funding rate for a product, where 1 = 100%\n * @param params\n */\n async getFundingRate(\n params: GetIndexerFundingRateParams,\n ): Promise<GetIndexerFundingRateResponse> {\n const baseResponse = await this.query('funding_rate', {\n product_id: params.productId,\n });\n\n return mapIndexerFundingRate(baseResponse);\n }\n\n /**\n * Retrieves funding rate for multiple products, where 1 = 100%\n * @param params\n */\n async getMultiProductFundingRates(\n params: GetIndexerMultiProductFundingRatesParams,\n ): Promise<GetIndexerMultiProductFundingRatesResponse> {\n const baseResponse = await this.query('funding_rates', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerFundingRate);\n }\n\n /**\n * Retrieves latest mark/index price for a perp product\n * @param params\n */\n async getPerpPrices(\n params: GetIndexerPerpPricesParams,\n ): Promise<GetIndexerPerpPricesResponse> {\n const baseResponse = await this.query('price', {\n product_id: params.productId,\n });\n\n return mapIndexerPerpPrices(baseResponse);\n }\n\n /**\n * Retrieves latest mark/index price for multiple perp products\n * @param params\n */\n async getMultiProductPerpPrices(\n params: GetIndexerMultiProductPerpPricesParams,\n ): Promise<GetIndexerMultiProductPerpPricesResponse> {\n const baseResponse = await this.query('perp_prices', {\n product_ids: params.productIds,\n });\n\n return mapValues(baseResponse, mapIndexerPerpPrices);\n }\n\n /**\n * Retrieves latest oracle prices for provided products\n * @param params\n */\n async getOraclePrices(\n params: GetIndexerOraclePricesParams,\n ): Promise<GetIndexerOraclePricesResponse> {\n const baseResponse = await this.query('oracle_price', {\n product_ids: params.productIds,\n });\n\n return baseResponse.prices.map((price): IndexerOraclePrice => {\n return {\n oraclePrice: removeDecimals(price.oracle_price_x18),\n updateTime: toBigDecimal(price.update_time),\n productId: price.product_id,\n };\n });\n }\n\n /**\n * Retrieves candlesticks for a product\n * @param params\n */\n async getCandlesticks(\n params: GetIndexerCandlesticksParams,\n ): Promise<GetIndexerCandlesticksResponse> {\n const baseResponse = await this.query('candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves candlesticks for a product from Edge\n * @param params\n */\n async getEdgeCandlesticks(\n params: GetIndexerEdgeCandlesticksParams,\n ): Promise<GetIndexerEdgeCandlesticksResponse> {\n const baseResponse = await this.query('edge_candlesticks', {\n product_id: params.productId,\n max_time: params.maxTimeInclusive,\n limit: params.limit,\n granularity: params.period,\n });\n\n return baseResponse.candlesticks.map(mapIndexerCandlesticks);\n }\n\n /**\n * Retrieves historical snapshots for a product\n * @param params\n */\n async getProductSnapshots(\n params: GetIndexerProductSnapshotsParams,\n ): Promise<GetIndexerProductSnapshotsResponse> {\n const baseResponse = await this.query('products', {\n product_id: params.productId,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.products.map((product) => {\n return {\n ...mapIndexerServerProduct(product.product),\n submissionIndex: product.submission_idx,\n };\n });\n }\n\n /**\n * Retrieves historical snapshots for multiple products\n * @param params\n */\n async getMultiProductSnapshots(\n params: GetIndexerMultiProductSnapshotsParams,\n ): Promise<GetIndexerMultiProductSnapshotsResponse> {\n const timestampToProductsMap = await this.query('product_snapshots', {\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive ?? [nowInSeconds()],\n });\n\n return mapValues(timestampToProductsMap, (productIdToProduct) => {\n return mapValues(productIdToProduct, (indexerProduct) => {\n return {\n ...mapIndexerServerProduct(indexerProduct.product),\n submissionIndex: indexerProduct.submission_idx,\n };\n });\n });\n }\n\n /**\n * Retrieves historical events\n *\n * @param params\n */\n async getEvents(\n params: GetIndexerEventsParams,\n ): Promise<GetIndexerEventsResponse> {\n const serverLimit = ((): IndexerServerEventsParams['limit'] | undefined => {\n if (!params.limit) {\n return;\n }\n\n if (params.limit.type === 'events') {\n return {\n raw: params.limit.value,\n };\n }\n return {\n txs: params.limit.value,\n };\n })();\n\n const baseResponse = await this.query('events', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n event_types: params.eventTypes,\n max_time: params.maxTimestampInclusive,\n desc: params.desc,\n limit: serverLimit,\n idx: params.startCursor,\n });\n\n // Keep track of the last tx index, and go to the next one if the submission_idx for the currently processed event does not match\n // txs are ordered the same as events, so this should be correct\n let lastTxIdx = 0;\n return baseResponse.events.map((event): IndexerEventWithTx => {\n if (baseResponse.txs[lastTxIdx].submission_idx !== event.submission_idx) {\n lastTxIdx += 1;\n }\n const tx = baseResponse.txs[lastTxIdx];\n return mapIndexerEventWithTx(event, tx);\n });\n }\n\n /**\n * Retrieves historical orders\n * @param params\n */\n async getOrders(\n params: GetIndexerOrdersParams,\n ): Promise<GetIndexerOrdersResponse> {\n const baseResponse = await this.query('orders', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n digests: params.digests,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n return baseResponse.orders.map(mapIndexerOrder);\n }\n\n /**\n * Gets match order events, this will return the same events as the events query, but with additional information\n * to identify the order that was matched\n *\n * @param params\n */\n async getMatchEvents(\n params: GetIndexerMatchEventsParams,\n ): Promise<GetIndexerMatchEventsResponse> {\n const baseResponse = await this.query('matches', {\n subaccount: params.subaccount\n ? subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n })\n : undefined,\n product_ids: params.productIds,\n isolated: params.isolated,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n idx: params.startCursor,\n });\n\n // Same as logic in `getEvents`\n let lastTxIdx = 0;\n return baseResponse.matches.map((matchEvent): IndexerMatchEvent => {\n if (\n baseResponse.txs[lastTxIdx].submission_idx !== matchEvent.submission_idx\n ) {\n lastTxIdx += 1;\n }\n const { tx, timestamp } = baseResponse.txs[lastTxIdx];\n\n // We use this to derive the product ID for the match\n const postBalances = mapIndexerMatchEventBalances(\n matchEvent.post_balance,\n );\n\n return {\n productId: postBalances.base.productId,\n isolated: matchEvent.isolated,\n totalFee: toBigDecimal(matchEvent.fee),\n sequencerFee: toBigDecimal(matchEvent.sequencer_fee),\n baseFilled: toBigDecimal(matchEvent.base_filled),\n quoteFilled: toBigDecimal(matchEvent.quote_filled),\n cumulativeFee: toBigDecimal(matchEvent.cumulative_fee),\n cumulativeBaseFilled: toBigDecimal(matchEvent.cumulative_base_filled),\n cumulativeQuoteFilled: toBigDecimal(matchEvent.cumulative_quote_filled),\n digest: matchEvent.digest,\n order: matchEvent.order,\n submissionIndex: matchEvent.submission_idx,\n timestamp: toBigDecimal(timestamp),\n preEventTrackedVars: {\n netEntryUnrealized: toBigDecimal(matchEvent.net_entry_unrealized),\n netEntryCumulative: toBigDecimal(matchEvent.net_entry_cumulative),\n },\n preBalances: mapIndexerMatchEventBalances(matchEvent.pre_balance),\n postBalances,\n tx,\n ...subaccountFromHex(matchEvent.order.sender),\n };\n });\n }\n\n /**\n * Retrieves historical funding & interest payments.\n * NOTE: `limit` is an upperbound. If a user changes position size such that his position is 0 during each funding/interest tick,\n * then the indexer will return fewer than `limit` results per page. However, more events can be present. This means that\n * there isn't a reliable way to determine whether there is a next page. We just need to keep paginating until the next cursor is null.\n *\n * @param params\n */\n async getInterestFundingPayments(\n params: GetIndexerInterestFundingPaymentsParams,\n ): Promise<GetIndexerInterestFundingPaymentsResponse> {\n const baseResponse = await this.query('interest_and_funding', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccount.subaccountOwner,\n subaccountName: params.subaccount.subaccountName,\n }),\n product_ids: params.productIds,\n max_time: params.maxTimestampInclusive,\n limit: params.limit,\n max_idx: params.startCursor,\n });\n\n return {\n fundingPayments: baseResponse.funding_payments.map(\n mapIndexerProductPayment,\n ),\n interestPayments: baseResponse.interest_payments.map(\n mapIndexerProductPayment,\n ),\n nextCursor: baseResponse.next_idx,\n };\n }\n\n /**\n * Gets quote (USDC) price in terms of USD\n */\n async getQuotePrice(): Promise<GetIndexerQuotePriceResponse> {\n const baseResponse = await this.query('usdc_price', {});\n return {\n price: removeDecimals(baseResponse.price_x18),\n };\n }\n\n /**\n * Fetches currently registered linked signer with the remaining txs allowed for the subaccount\n */\n async getLinkedSignerWithRateLimit(\n params: GetIndexerLinkedSignerParams,\n ): Promise<GetIndexerLinkedSignerResponse> {\n const baseResponse = await this.query('linked_signer_rate_limit', {\n subaccount: subaccountToHex(params.subaccount),\n });\n return {\n totalTxLimit: toBigDecimal(baseResponse.total_tx_limit),\n remainingTxs: toBigDecimal(baseResponse.remaining_tx),\n signer: baseResponse.signer,\n waitTimeUntilNextTx: toBigDecimal(baseResponse.wait_time),\n };\n }\n\n /**\n * Retrieve historical market snapshots\n * @param params\n */\n async getMarketSnapshots(\n params: GetIndexerMarketSnapshotsParams,\n ): Promise<GetIndexerMarketSnapshotsResponse> {\n const baseResponse = await this.query('market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n product_ids: params.productIds,\n });\n\n return baseResponse.snapshots.map(mapIndexerMarketSnapshot);\n }\n\n /**\n * Retrieve historical market snapshots from Edge\n * @param params\n */\n async getEdgeMarketSnapshots(\n params: GetIndexerEdgeMarketSnapshotsParams,\n ): Promise<GetIndexerEdgeMarketSnapshotResponse> {\n const baseResponse = await this.query('edge_market_snapshots', {\n interval: mapSnapshotsIntervalToServerParams(params),\n });\n\n return mapValues(baseResponse.snapshots, (snapshots) =>\n snapshots.map(mapIndexerMarketSnapshot),\n );\n }\n\n /**\n * Retrieve maker statistics for a given epoch\n *\n * @param params\n */\n async getMakerStatistics(\n params: GetIndexerMakerStatisticsParams,\n ): Promise<GetIndexerMakerStatisticsResponse> {\n const baseResponse = await this.query('maker_statistics', {\n product_id: params.productId,\n epoch: params.epoch,\n interval: params.interval,\n });\n\n return {\n rewardCoefficient: toBigDecimal(baseResponse.reward_coefficient),\n makers: baseResponse.makers.map(mapIndexerMakerStatistics),\n };\n }\n\n /**\n * Retrieve leaderboard stats for a given contest\n *\n * @param params\n */\n async getLeaderboard(\n params: GetIndexerLeaderboardParams,\n ): Promise<GetIndexerLeaderboardResponse> {\n const baseResponse = await this.query('leaderboard', {\n contest_id: params.contestId,\n rank_type: params.rankType,\n start: params.startCursor,\n limit: params.limit,\n });\n\n return {\n participants: baseResponse.positions.map(mapIndexerLeaderboardPosition),\n };\n }\n\n /**\n * Retrieve leaderboard ranking of a subaccount on a given contest\n *\n * @param params\n */\n async getLeaderboardParticipant(\n params: GetIndexerLeaderboardParticipantParams,\n ): Promise<GetIndexerLeaderboardParticipantResponse> {\n const baseResponse = await this.query('leaderboard_rank', {\n subaccount: subaccountToHex(params.subaccount),\n contest_ids: params.contestIds,\n });\n\n return {\n participant: mapValues(baseResponse.positions, (position) =>\n mapIndexerLeaderboardPosition(position),\n ),\n };\n }\n\n /**\n * Attempts to update a user's registration to the provided `contestId`. This requires signing.\n * @param params\n */\n async updateLeaderboardRegistration(\n params: UpdateIndexerLeaderboardRegistrationParams,\n ): Promise<UpdateIndexerLeaderboardRegistrationResponse> {\n const signatureParams: EIP712LeaderboardAuthenticationParams = {\n // Default to 90 seconds from now if no recvTime is provided\n expiration: toIntegerString(params.recvTime ?? getDefaultRecvTime()),\n subaccountName: params.subaccountName,\n subaccountOwner: params.subaccountOwner,\n };\n\n const tx = getNadoEIP712Values(\n 'leaderboard_authentication',\n signatureParams,\n );\n const signature = await this.sign(\n 'leaderboard_authentication',\n params.updateRegistration.verifyingAddr,\n params.updateRegistration.chainId,\n signatureParams,\n );\n\n const updateRegistrationTx: SignedTx<EIP712LeaderboardAuthenticationValues> =\n {\n tx,\n signature,\n };\n\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: updateRegistrationTx,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieves the registration status for a leaderboard participant for provided `contestId`.\n * @param params\n */\n async getLeaderboardRegistration(\n params: GetIndexerLeaderboardRegistrationParams,\n ): Promise<GetIndexerLeaderboardRegistrationResponse> {\n const baseResponse = await this.query('leaderboard_registration', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n contest_id: params.contestId,\n update_registration: null,\n });\n return {\n registration: baseResponse.registration\n ? mapIndexerLeaderboardRegistration(baseResponse.registration)\n : null,\n };\n }\n\n /**\n * Retrieve metadata of provided leaderboard contests\n *\n * @param params\n */\n async getLeaderboardContests(\n params: GetIndexerLeaderboardContestsParams,\n ): Promise<GetIndexerLeaderboardContestsResponse> {\n const baseResponse = await this.query('leaderboard_contests', {\n contest_ids: params.contestIds,\n });\n\n return {\n contests: baseResponse.contests.map(mapIndexerLeaderboardContest),\n };\n }\n\n /**\n * Retrieve signature and tx to submit a fast withdrawal\n *\n * @param params\n */\n async getFastWithdrawalSignature(\n params: GetIndexerFastWithdrawalSignatureParams,\n ): Promise<GetIndexerFastWithdrawalSignatureResponse> {\n const baseResponse = await this.query('fast_withdrawal_signature', params);\n return {\n idx: toBigInt(baseResponse.idx),\n tx: baseResponse.tx,\n txBytes: getValidatedHex(baseResponse.tx_bytes),\n signatures: baseResponse.signatures.map(getValidatedHex),\n };\n }\n\n async getNlpSnapshots(\n params: GetIndexerNlpSnapshotsParams,\n ): Promise<GetIndexerNlpSnapshotsResponse> {\n const baseResponse = await this.query('nlp_snapshots', {\n interval: {\n count: params.limit,\n max_time: params.maxTimeInclusive\n ? toIntegerString(params.maxTimeInclusive)\n : undefined,\n granularity: params.granularity,\n },\n });\n\n return {\n snapshots: baseResponse.snapshots.map(mapIndexerNlpSnapshot),\n };\n }\n\n /**\n * Retrieves the subaccount's DDA (Direct Deposit Address)\n * @param params\n */\n async getSubaccountDDA(\n params: GetIndexerSubaccountDDAParams,\n ): Promise<GetIndexerSubaccountDDAResponse> {\n const baseResponse = await this.query('direct_deposit_address', {\n subaccount: subaccountToHex(params.subaccount),\n });\n\n return {\n address: getValidatedAddress(baseResponse.v1_address),\n };\n }\n\n async getSequencerBacklog(): Promise<GetIndexerBacklogResponse> {\n const baseResponse = await this.query('backlog', {});\n\n return {\n totalTxs: toBigDecimal(baseResponse.total_txs),\n totalSubmissions: toBigDecimal(baseResponse.total_submissions),\n backlogSize: toBigDecimal(baseResponse.backlog_size),\n updatedAt: toBigDecimal(baseResponse.updated_at),\n backlogEtaInSeconds: baseResponse.backlog_eta_in_seconds\n ? toBigDecimal(baseResponse.backlog_eta_in_seconds)\n : null,\n txsPerSecond: baseResponse.txs_per_second\n ? toBigDecimal(baseResponse.txs_per_second)\n : null,\n };\n }\n\n protected async query<TRequestType extends IndexerServerQueryRequestType>(\n requestType: TRequestType,\n params: IndexerServerQueryRequestByType[TRequestType],\n ): Promise<IndexerServerQueryResponseByType[TRequestType]> {\n const reqBody: IndexerQueryRequestBody = {\n [requestType]: params,\n };\n const response = await this.axiosInstance.post<\n IndexerServerQueryResponseByType[TRequestType]\n >(this.opts.url, reqBody);\n\n this.checkResponseStatus(response);\n\n return response.data;\n }\n\n protected async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n const walletClient = this.opts.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}`,\n );\n }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EACF;AACF;","names":["axios"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { WalletClientWithAccount, SignableRequestType, SignableRequestTypeToParams } from '@nadohq/
|
|
1
|
+
import { WalletClientWithAccount, SignableRequestType, SignableRequestTypeToParams } from '@nadohq/shared';
|
|
2
2
|
import { AxiosInstance } from 'axios';
|
|
3
|
-
import { ListIndexerSubaccountsParams, ListIndexerSubaccountsResponse, GetIndexerMultiSubaccountSnapshotsParams, GetIndexerMultiSubaccountSnapshotsResponse, GetIndexerReferralCodeParams, GetIndexerReferralCodeResponse, GetIndexerFundingRateParams, GetIndexerFundingRateResponse, GetIndexerMultiProductFundingRatesParams, GetIndexerMultiProductFundingRatesResponse, GetIndexerPerpPricesParams, GetIndexerPerpPricesResponse, GetIndexerMultiProductPerpPricesParams, GetIndexerMultiProductPerpPricesResponse, GetIndexerOraclePricesParams, GetIndexerOraclePricesResponse, GetIndexerCandlesticksParams, GetIndexerCandlesticksResponse, GetIndexerEdgeCandlesticksParams, GetIndexerEdgeCandlesticksResponse, GetIndexerProductSnapshotsParams, GetIndexerProductSnapshotsResponse, GetIndexerMultiProductSnapshotsParams, GetIndexerMultiProductSnapshotsResponse, GetIndexerEventsParams, GetIndexerEventsResponse, GetIndexerOrdersParams, GetIndexerOrdersResponse, GetIndexerMatchEventsParams, GetIndexerMatchEventsResponse, GetIndexerInterestFundingPaymentsParams, GetIndexerInterestFundingPaymentsResponse, GetIndexerQuotePriceResponse, GetIndexerLinkedSignerParams, GetIndexerLinkedSignerResponse, GetIndexerMarketSnapshotsParams, GetIndexerMarketSnapshotsResponse, GetIndexerEdgeMarketSnapshotsParams, GetIndexerEdgeMarketSnapshotResponse, GetIndexerMakerStatisticsParams, GetIndexerMakerStatisticsResponse, GetIndexerLeaderboardParams, GetIndexerLeaderboardResponse, GetIndexerLeaderboardParticipantParams, GetIndexerLeaderboardParticipantResponse, UpdateIndexerLeaderboardRegistrationParams, UpdateIndexerLeaderboardRegistrationResponse, GetIndexerLeaderboardRegistrationParams, GetIndexerLeaderboardRegistrationResponse, GetIndexerLeaderboardContestsParams, GetIndexerLeaderboardContestsResponse, GetIndexerFastWithdrawalSignatureParams, GetIndexerFastWithdrawalSignatureResponse,
|
|
3
|
+
import { ListIndexerSubaccountsParams, ListIndexerSubaccountsResponse, GetIndexerMultiSubaccountSnapshotsParams, GetIndexerMultiSubaccountSnapshotsResponse, GetIndexerReferralCodeParams, GetIndexerReferralCodeResponse, GetIndexerFundingRateParams, GetIndexerFundingRateResponse, GetIndexerMultiProductFundingRatesParams, GetIndexerMultiProductFundingRatesResponse, GetIndexerPerpPricesParams, GetIndexerPerpPricesResponse, GetIndexerMultiProductPerpPricesParams, GetIndexerMultiProductPerpPricesResponse, GetIndexerOraclePricesParams, GetIndexerOraclePricesResponse, GetIndexerCandlesticksParams, GetIndexerCandlesticksResponse, GetIndexerEdgeCandlesticksParams, GetIndexerEdgeCandlesticksResponse, GetIndexerProductSnapshotsParams, GetIndexerProductSnapshotsResponse, GetIndexerMultiProductSnapshotsParams, GetIndexerMultiProductSnapshotsResponse, GetIndexerEventsParams, GetIndexerEventsResponse, GetIndexerOrdersParams, GetIndexerOrdersResponse, GetIndexerMatchEventsParams, GetIndexerMatchEventsResponse, GetIndexerInterestFundingPaymentsParams, GetIndexerInterestFundingPaymentsResponse, GetIndexerQuotePriceResponse, GetIndexerLinkedSignerParams, GetIndexerLinkedSignerResponse, GetIndexerMarketSnapshotsParams, GetIndexerMarketSnapshotsResponse, GetIndexerEdgeMarketSnapshotsParams, GetIndexerEdgeMarketSnapshotResponse, GetIndexerMakerStatisticsParams, GetIndexerMakerStatisticsResponse, GetIndexerLeaderboardParams, GetIndexerLeaderboardResponse, GetIndexerLeaderboardParticipantParams, GetIndexerLeaderboardParticipantResponse, UpdateIndexerLeaderboardRegistrationParams, UpdateIndexerLeaderboardRegistrationResponse, GetIndexerLeaderboardRegistrationParams, GetIndexerLeaderboardRegistrationResponse, GetIndexerLeaderboardContestsParams, GetIndexerLeaderboardContestsResponse, GetIndexerFastWithdrawalSignatureParams, GetIndexerFastWithdrawalSignatureResponse, GetIndexerNlpSnapshotsParams, GetIndexerNlpSnapshotsResponse, GetIndexerSubaccountDDAParams, GetIndexerSubaccountDDAResponse, GetIndexerBacklogResponse } from './types/clientTypes.cjs';
|
|
4
4
|
import { IndexerServerQueryRequestType, IndexerServerQueryRequestByType, IndexerServerQueryResponseByType } from './types/serverTypes.cjs';
|
|
5
|
-
import '@nadohq/utils';
|
|
6
5
|
import 'viem';
|
|
7
6
|
import './types/CandlestickPeriod.cjs';
|
|
8
7
|
import './types/IndexerEventType.cjs';
|
|
@@ -173,7 +172,12 @@ declare class IndexerBaseClient {
|
|
|
173
172
|
* @param params
|
|
174
173
|
*/
|
|
175
174
|
getFastWithdrawalSignature(params: GetIndexerFastWithdrawalSignatureParams): Promise<GetIndexerFastWithdrawalSignatureResponse>;
|
|
176
|
-
|
|
175
|
+
getNlpSnapshots(params: GetIndexerNlpSnapshotsParams): Promise<GetIndexerNlpSnapshotsResponse>;
|
|
176
|
+
/**
|
|
177
|
+
* Retrieves the subaccount's DDA (Direct Deposit Address)
|
|
178
|
+
* @param params
|
|
179
|
+
*/
|
|
180
|
+
getSubaccountDDA(params: GetIndexerSubaccountDDAParams): Promise<GetIndexerSubaccountDDAResponse>;
|
|
177
181
|
getSequencerBacklog(): Promise<GetIndexerBacklogResponse>;
|
|
178
182
|
protected query<TRequestType extends IndexerServerQueryRequestType>(requestType: TRequestType, params: IndexerServerQueryRequestByType[TRequestType]): Promise<IndexerServerQueryResponseByType[TRequestType]>;
|
|
179
183
|
protected sign<T extends SignableRequestType>(requestType: T, verifyingContract: string, chainId: number, params: SignableRequestTypeToParams[T]): Promise<`0x${string}`>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { WalletClientWithAccount, SignableRequestType, SignableRequestTypeToParams } from '@nadohq/
|
|
1
|
+
import { WalletClientWithAccount, SignableRequestType, SignableRequestTypeToParams } from '@nadohq/shared';
|
|
2
2
|
import { AxiosInstance } from 'axios';
|
|
3
|
-
import { ListIndexerSubaccountsParams, ListIndexerSubaccountsResponse, GetIndexerMultiSubaccountSnapshotsParams, GetIndexerMultiSubaccountSnapshotsResponse, GetIndexerReferralCodeParams, GetIndexerReferralCodeResponse, GetIndexerFundingRateParams, GetIndexerFundingRateResponse, GetIndexerMultiProductFundingRatesParams, GetIndexerMultiProductFundingRatesResponse, GetIndexerPerpPricesParams, GetIndexerPerpPricesResponse, GetIndexerMultiProductPerpPricesParams, GetIndexerMultiProductPerpPricesResponse, GetIndexerOraclePricesParams, GetIndexerOraclePricesResponse, GetIndexerCandlesticksParams, GetIndexerCandlesticksResponse, GetIndexerEdgeCandlesticksParams, GetIndexerEdgeCandlesticksResponse, GetIndexerProductSnapshotsParams, GetIndexerProductSnapshotsResponse, GetIndexerMultiProductSnapshotsParams, GetIndexerMultiProductSnapshotsResponse, GetIndexerEventsParams, GetIndexerEventsResponse, GetIndexerOrdersParams, GetIndexerOrdersResponse, GetIndexerMatchEventsParams, GetIndexerMatchEventsResponse, GetIndexerInterestFundingPaymentsParams, GetIndexerInterestFundingPaymentsResponse, GetIndexerQuotePriceResponse, GetIndexerLinkedSignerParams, GetIndexerLinkedSignerResponse, GetIndexerMarketSnapshotsParams, GetIndexerMarketSnapshotsResponse, GetIndexerEdgeMarketSnapshotsParams, GetIndexerEdgeMarketSnapshotResponse, GetIndexerMakerStatisticsParams, GetIndexerMakerStatisticsResponse, GetIndexerLeaderboardParams, GetIndexerLeaderboardResponse, GetIndexerLeaderboardParticipantParams, GetIndexerLeaderboardParticipantResponse, UpdateIndexerLeaderboardRegistrationParams, UpdateIndexerLeaderboardRegistrationResponse, GetIndexerLeaderboardRegistrationParams, GetIndexerLeaderboardRegistrationResponse, GetIndexerLeaderboardContestsParams, GetIndexerLeaderboardContestsResponse, GetIndexerFastWithdrawalSignatureParams, GetIndexerFastWithdrawalSignatureResponse,
|
|
3
|
+
import { ListIndexerSubaccountsParams, ListIndexerSubaccountsResponse, GetIndexerMultiSubaccountSnapshotsParams, GetIndexerMultiSubaccountSnapshotsResponse, GetIndexerReferralCodeParams, GetIndexerReferralCodeResponse, GetIndexerFundingRateParams, GetIndexerFundingRateResponse, GetIndexerMultiProductFundingRatesParams, GetIndexerMultiProductFundingRatesResponse, GetIndexerPerpPricesParams, GetIndexerPerpPricesResponse, GetIndexerMultiProductPerpPricesParams, GetIndexerMultiProductPerpPricesResponse, GetIndexerOraclePricesParams, GetIndexerOraclePricesResponse, GetIndexerCandlesticksParams, GetIndexerCandlesticksResponse, GetIndexerEdgeCandlesticksParams, GetIndexerEdgeCandlesticksResponse, GetIndexerProductSnapshotsParams, GetIndexerProductSnapshotsResponse, GetIndexerMultiProductSnapshotsParams, GetIndexerMultiProductSnapshotsResponse, GetIndexerEventsParams, GetIndexerEventsResponse, GetIndexerOrdersParams, GetIndexerOrdersResponse, GetIndexerMatchEventsParams, GetIndexerMatchEventsResponse, GetIndexerInterestFundingPaymentsParams, GetIndexerInterestFundingPaymentsResponse, GetIndexerQuotePriceResponse, GetIndexerLinkedSignerParams, GetIndexerLinkedSignerResponse, GetIndexerMarketSnapshotsParams, GetIndexerMarketSnapshotsResponse, GetIndexerEdgeMarketSnapshotsParams, GetIndexerEdgeMarketSnapshotResponse, GetIndexerMakerStatisticsParams, GetIndexerMakerStatisticsResponse, GetIndexerLeaderboardParams, GetIndexerLeaderboardResponse, GetIndexerLeaderboardParticipantParams, GetIndexerLeaderboardParticipantResponse, UpdateIndexerLeaderboardRegistrationParams, UpdateIndexerLeaderboardRegistrationResponse, GetIndexerLeaderboardRegistrationParams, GetIndexerLeaderboardRegistrationResponse, GetIndexerLeaderboardContestsParams, GetIndexerLeaderboardContestsResponse, GetIndexerFastWithdrawalSignatureParams, GetIndexerFastWithdrawalSignatureResponse, GetIndexerNlpSnapshotsParams, GetIndexerNlpSnapshotsResponse, GetIndexerSubaccountDDAParams, GetIndexerSubaccountDDAResponse, GetIndexerBacklogResponse } from './types/clientTypes.js';
|
|
4
4
|
import { IndexerServerQueryRequestType, IndexerServerQueryRequestByType, IndexerServerQueryResponseByType } from './types/serverTypes.js';
|
|
5
|
-
import '@nadohq/utils';
|
|
6
5
|
import 'viem';
|
|
7
6
|
import './types/CandlestickPeriod.js';
|
|
8
7
|
import './types/IndexerEventType.js';
|
|
@@ -173,7 +172,12 @@ declare class IndexerBaseClient {
|
|
|
173
172
|
* @param params
|
|
174
173
|
*/
|
|
175
174
|
getFastWithdrawalSignature(params: GetIndexerFastWithdrawalSignatureParams): Promise<GetIndexerFastWithdrawalSignatureResponse>;
|
|
176
|
-
|
|
175
|
+
getNlpSnapshots(params: GetIndexerNlpSnapshotsParams): Promise<GetIndexerNlpSnapshotsResponse>;
|
|
176
|
+
/**
|
|
177
|
+
* Retrieves the subaccount's DDA (Direct Deposit Address)
|
|
178
|
+
* @param params
|
|
179
|
+
*/
|
|
180
|
+
getSubaccountDDA(params: GetIndexerSubaccountDDAParams): Promise<GetIndexerSubaccountDDAResponse>;
|
|
177
181
|
getSequencerBacklog(): Promise<GetIndexerBacklogResponse>;
|
|
178
182
|
protected query<TRequestType extends IndexerServerQueryRequestType>(requestType: TRequestType, params: IndexerServerQueryRequestByType[TRequestType]): Promise<IndexerServerQueryResponseByType[TRequestType]>;
|
|
179
183
|
protected sign<T extends SignableRequestType>(requestType: T, verifyingContract: string, chainId: number, params: SignableRequestTypeToParams[T]): Promise<`0x${string}`>;
|