@nadohq/indexer-client 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/IndexerBaseClient.cjs +102 -27
- package/dist/IndexerBaseClient.cjs.map +1 -1
- package/dist/IndexerBaseClient.d.cts +29 -7
- package/dist/IndexerBaseClient.d.ts +29 -7
- package/dist/IndexerBaseClient.js +102 -27
- package/dist/IndexerBaseClient.js.map +1 -1
- package/dist/IndexerClient.cjs +6 -1
- package/dist/IndexerClient.cjs.map +1 -1
- package/dist/IndexerClient.js +6 -1
- package/dist/IndexerClient.js.map +1 -1
- package/dist/dataMappers.cjs +26 -12
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.js +26 -12
- package/dist/dataMappers.js.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/types/IndexerLeaderboardType.cjs.map +1 -1
- package/dist/types/IndexerLeaderboardType.d.cts +9 -1
- package/dist/types/IndexerLeaderboardType.d.ts +9 -1
- package/dist/types/clientTypes.cjs.map +1 -1
- package/dist/types/clientTypes.d.cts +64 -18
- package/dist/types/clientTypes.d.ts +64 -18
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/dist/types/serverModelTypes.cjs.map +1 -1
- package/dist/types/serverModelTypes.d.cts +25 -10
- package/dist/types/serverModelTypes.d.ts +25 -10
- package/dist/types/serverTypes.cjs.map +1 -1
- package/dist/types/serverTypes.d.cts +38 -11
- package/dist/types/serverTypes.d.ts +38 -11
- package/package.json +4 -4
- package/src/IndexerBaseClient.ts +132 -36
- package/src/IndexerClient.ts +13 -5
- package/src/dataMappers.ts +26 -10
- package/src/types/IndexerLeaderboardType.ts +14 -2
- package/src/types/clientTypes.ts +78 -30
- package/src/types/serverModelTypes.ts +29 -9
- package/src/types/serverTypes.ts +46 -10
package/src/IndexerBaseClient.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EIP712LeaderboardAuthenticationParams,
|
|
3
3
|
EIP712LeaderboardAuthenticationValues,
|
|
4
|
+
EIP712SocialAuthenticationParams,
|
|
4
5
|
getDefaultRecvTime,
|
|
5
6
|
getNadoEIP712Values,
|
|
6
7
|
getSignedTransactionRequest,
|
|
@@ -42,6 +43,8 @@ import {
|
|
|
42
43
|
mapSnapshotsIntervalToServerParams,
|
|
43
44
|
} from './dataMappers';
|
|
44
45
|
import {
|
|
46
|
+
ConnectSocialAccountParams,
|
|
47
|
+
ConnectSocialAccountResponse,
|
|
45
48
|
GetIndexerBacklogResponse,
|
|
46
49
|
GetIndexerCandlesticksParams,
|
|
47
50
|
GetIndexerCandlesticksResponse,
|
|
@@ -62,8 +65,8 @@ import {
|
|
|
62
65
|
GetIndexerLeaderboardParams,
|
|
63
66
|
GetIndexerLeaderboardParticipantParams,
|
|
64
67
|
GetIndexerLeaderboardParticipantResponse,
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
GetIndexerLeaderboardRegistrationsParams,
|
|
69
|
+
GetIndexerLeaderboardRegistrationsResponse,
|
|
67
70
|
GetIndexerLeaderboardResponse,
|
|
68
71
|
GetIndexerLinkedSignerParams,
|
|
69
72
|
GetIndexerLinkedSignerResponse,
|
|
@@ -115,10 +118,14 @@ import {
|
|
|
115
118
|
IndexerServerV2TickersResponse,
|
|
116
119
|
IndexerSnapshotBalance,
|
|
117
120
|
IndexerSubaccountSnapshot,
|
|
121
|
+
ListIndexerSocialAccountsParams,
|
|
122
|
+
ListIndexerSocialAccountsResponse,
|
|
118
123
|
ListIndexerSubaccountsParams,
|
|
119
124
|
ListIndexerSubaccountsResponse,
|
|
120
|
-
|
|
121
|
-
|
|
125
|
+
RegisterLeaderboardParams,
|
|
126
|
+
RegisterLeaderboardResponse,
|
|
127
|
+
RevokeSocialAccountParams,
|
|
128
|
+
RevokeSocialAccountResponse,
|
|
122
129
|
} from './types';
|
|
123
130
|
|
|
124
131
|
export interface IndexerClientOpts {
|
|
@@ -664,6 +671,7 @@ export class IndexerBaseClient {
|
|
|
664
671
|
rank_type: params.rankType,
|
|
665
672
|
start: params.startCursor,
|
|
666
673
|
limit: params.limit,
|
|
674
|
+
order: params.order,
|
|
667
675
|
});
|
|
668
676
|
|
|
669
677
|
return {
|
|
@@ -692,17 +700,18 @@ export class IndexerBaseClient {
|
|
|
692
700
|
}
|
|
693
701
|
|
|
694
702
|
/**
|
|
695
|
-
*
|
|
696
|
-
*
|
|
703
|
+
* Registers a subaccount for one or more contests. Requires EIP-712 signing.
|
|
704
|
+
*
|
|
705
|
+
* @param params - Registration parameters including contest IDs and signing config.
|
|
697
706
|
*/
|
|
698
|
-
async
|
|
699
|
-
params:
|
|
700
|
-
): Promise<
|
|
707
|
+
async registerLeaderboard(
|
|
708
|
+
params: RegisterLeaderboardParams,
|
|
709
|
+
): Promise<RegisterLeaderboardResponse> {
|
|
701
710
|
const signatureParams: EIP712LeaderboardAuthenticationParams = {
|
|
702
|
-
// Default to 90 seconds from now if no recvTime is provided
|
|
703
711
|
expiration: toIntegerString(params.recvTime ?? getDefaultRecvTime()),
|
|
704
712
|
subaccountName: params.subaccountName,
|
|
705
713
|
subaccountOwner: params.subaccountOwner,
|
|
714
|
+
contestIds: params.contestIds,
|
|
706
715
|
};
|
|
707
716
|
|
|
708
717
|
const tx = getNadoEIP712Values(
|
|
@@ -711,8 +720,8 @@ export class IndexerBaseClient {
|
|
|
711
720
|
);
|
|
712
721
|
const signature = await this.sign(
|
|
713
722
|
'leaderboard_authentication',
|
|
714
|
-
params.
|
|
715
|
-
params.
|
|
723
|
+
params.verifyingAddr,
|
|
724
|
+
params.chainId,
|
|
716
725
|
signatureParams,
|
|
717
726
|
);
|
|
718
727
|
|
|
@@ -722,40 +731,36 @@ export class IndexerBaseClient {
|
|
|
722
731
|
signature,
|
|
723
732
|
};
|
|
724
733
|
|
|
725
|
-
const baseResponse = await this.query('
|
|
726
|
-
subaccount: subaccountToHex({
|
|
727
|
-
subaccountOwner: params.subaccountOwner,
|
|
728
|
-
subaccountName: params.subaccountName,
|
|
729
|
-
}),
|
|
730
|
-
contest_id: params.contestId,
|
|
734
|
+
const baseResponse = await this.query('leaderboard_register', {
|
|
731
735
|
update_registration: updateRegistrationTx,
|
|
732
736
|
});
|
|
737
|
+
|
|
733
738
|
return {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
739
|
+
registrations: baseResponse.registrations.map(
|
|
740
|
+
mapIndexerLeaderboardRegistration,
|
|
741
|
+
),
|
|
737
742
|
};
|
|
738
743
|
}
|
|
739
744
|
|
|
740
745
|
/**
|
|
741
|
-
* Retrieves
|
|
742
|
-
*
|
|
746
|
+
* Retrieves contest registrations for a subaccount. Supports batch lookup
|
|
747
|
+
* across multiple contests with an optional active filter.
|
|
748
|
+
*
|
|
749
|
+
* @param params - Query parameters including subaccount and contest IDs.
|
|
743
750
|
*/
|
|
744
|
-
async
|
|
745
|
-
params:
|
|
746
|
-
): Promise<
|
|
747
|
-
const baseResponse = await this.query('
|
|
748
|
-
subaccount: subaccountToHex(
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
}),
|
|
752
|
-
contest_id: params.contestId,
|
|
753
|
-
update_registration: null,
|
|
751
|
+
async getLeaderboardRegistrations(
|
|
752
|
+
params: GetIndexerLeaderboardRegistrationsParams,
|
|
753
|
+
): Promise<GetIndexerLeaderboardRegistrationsResponse> {
|
|
754
|
+
const baseResponse = await this.query('leaderboard_registrations', {
|
|
755
|
+
subaccount: subaccountToHex(params.subaccount),
|
|
756
|
+
contest_ids: params.contestIds,
|
|
757
|
+
active: params.active,
|
|
754
758
|
});
|
|
759
|
+
|
|
755
760
|
return {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
761
|
+
registrations: baseResponse.registrations.map(
|
|
762
|
+
mapIndexerLeaderboardRegistration,
|
|
763
|
+
),
|
|
759
764
|
};
|
|
760
765
|
}
|
|
761
766
|
|
|
@@ -769,6 +774,7 @@ export class IndexerBaseClient {
|
|
|
769
774
|
): Promise<GetIndexerLeaderboardContestsResponse> {
|
|
770
775
|
const baseResponse = await this.query('leaderboard_contests', {
|
|
771
776
|
contest_ids: params.contestIds,
|
|
777
|
+
active: params.active,
|
|
772
778
|
});
|
|
773
779
|
|
|
774
780
|
return {
|
|
@@ -892,6 +898,96 @@ export class IndexerBaseClient {
|
|
|
892
898
|
};
|
|
893
899
|
}
|
|
894
900
|
|
|
901
|
+
/**
|
|
902
|
+
* Initiates a social account connection flow. Returns a URL the user must visit to complete the OAuth flow.
|
|
903
|
+
* Requires EIP-712 signing.
|
|
904
|
+
*
|
|
905
|
+
* @param params - Connection parameters including provider and signing config.
|
|
906
|
+
*/
|
|
907
|
+
async connectSocialAccount(
|
|
908
|
+
params: ConnectSocialAccountParams,
|
|
909
|
+
): Promise<ConnectSocialAccountResponse> {
|
|
910
|
+
const signatureParams: EIP712SocialAuthenticationParams = {
|
|
911
|
+
expiration: toIntegerString(params.recvTime ?? getDefaultRecvTime()),
|
|
912
|
+
subaccountName: params.subaccountName,
|
|
913
|
+
subaccountOwner: params.subaccountOwner,
|
|
914
|
+
provider: params.provider,
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
const tx = getNadoEIP712Values('social_authentication', signatureParams);
|
|
918
|
+
const signature = await this.sign(
|
|
919
|
+
'social_authentication',
|
|
920
|
+
params.verifyingAddr,
|
|
921
|
+
params.chainId,
|
|
922
|
+
signatureParams,
|
|
923
|
+
);
|
|
924
|
+
|
|
925
|
+
const baseResponse = await this.query('social_connect', {
|
|
926
|
+
update_social_account: { tx, signature },
|
|
927
|
+
});
|
|
928
|
+
|
|
929
|
+
return { url: baseResponse.url };
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
* Lists linked social accounts for a given address.
|
|
934
|
+
*
|
|
935
|
+
* @param params - Query parameters including the wallet address.
|
|
936
|
+
*/
|
|
937
|
+
async listSocialAccounts(
|
|
938
|
+
params: ListIndexerSocialAccountsParams,
|
|
939
|
+
): Promise<ListIndexerSocialAccountsResponse> {
|
|
940
|
+
const baseResponse = await this.query('list_social_accounts', {
|
|
941
|
+
address: params.address,
|
|
942
|
+
});
|
|
943
|
+
|
|
944
|
+
return {
|
|
945
|
+
accounts: baseResponse.accounts.map((a) => ({
|
|
946
|
+
provider: a.provider,
|
|
947
|
+
username: a.username,
|
|
948
|
+
displayName: a.display_name,
|
|
949
|
+
profileImageUrl: a.profile_image_url,
|
|
950
|
+
})),
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* Revokes a linked social account. Requires EIP-712 signing.
|
|
956
|
+
*
|
|
957
|
+
* @param params - Revocation parameters including provider and signing config.
|
|
958
|
+
*/
|
|
959
|
+
async revokeSocialAccount(
|
|
960
|
+
params: RevokeSocialAccountParams,
|
|
961
|
+
): Promise<RevokeSocialAccountResponse> {
|
|
962
|
+
const signatureParams: EIP712SocialAuthenticationParams = {
|
|
963
|
+
expiration: toIntegerString(params.recvTime ?? getDefaultRecvTime()),
|
|
964
|
+
subaccountName: params.subaccountName,
|
|
965
|
+
subaccountOwner: params.subaccountOwner,
|
|
966
|
+
provider: params.provider,
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
const tx = getNadoEIP712Values('social_authentication', signatureParams);
|
|
970
|
+
const signature = await this.sign(
|
|
971
|
+
'social_authentication',
|
|
972
|
+
params.verifyingAddr,
|
|
973
|
+
params.chainId,
|
|
974
|
+
signatureParams,
|
|
975
|
+
);
|
|
976
|
+
|
|
977
|
+
const baseResponse = await this.query('revoke_social_account', {
|
|
978
|
+
update_social_account: { tx, signature },
|
|
979
|
+
});
|
|
980
|
+
|
|
981
|
+
return {
|
|
982
|
+
accounts: baseResponse.accounts.map((a) => ({
|
|
983
|
+
provider: a.provider,
|
|
984
|
+
username: a.username,
|
|
985
|
+
displayName: a.display_name,
|
|
986
|
+
profileImageUrl: a.profile_image_url,
|
|
987
|
+
})),
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
|
|
895
991
|
/**
|
|
896
992
|
* Get tickers from the v2 indexer endpoint
|
|
897
993
|
* @param params
|
package/src/IndexerClient.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
toBigNumber,
|
|
7
7
|
toIntegerString,
|
|
8
8
|
} from '@nadohq/shared';
|
|
9
|
+
import BigNumber from 'bignumber.js';
|
|
9
10
|
|
|
10
11
|
import { IndexerBaseClient } from './IndexerBaseClient';
|
|
11
12
|
import {
|
|
@@ -447,11 +448,18 @@ export class IndexerClient extends IndexerBaseClient {
|
|
|
447
448
|
startCursor: params.startCursor,
|
|
448
449
|
});
|
|
449
450
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
451
|
+
const overflowParticipant = baseResponse.participants[requestedLimit];
|
|
452
|
+
let nextCursor: BigNumber | undefined;
|
|
453
|
+
if (overflowParticipant) {
|
|
454
|
+
// If rankType specified, use it directly. Otherwise it's a single-track
|
|
455
|
+
// contest so grab the rank from the only track present.
|
|
456
|
+
const trackData = (
|
|
457
|
+
params.rankType
|
|
458
|
+
? overflowParticipant.tracks[params.rankType]
|
|
459
|
+
: Object.values(overflowParticipant.tracks)[0]
|
|
460
|
+
)!;
|
|
461
|
+
nextCursor = trackData.rank;
|
|
462
|
+
}
|
|
455
463
|
|
|
456
464
|
return {
|
|
457
465
|
...baseResponse,
|
package/src/dataMappers.ts
CHANGED
|
@@ -256,16 +256,24 @@ export function mapIndexerMakerStatistics(
|
|
|
256
256
|
export function mapIndexerLeaderboardPosition(
|
|
257
257
|
position: IndexerServerLeaderboardPosition,
|
|
258
258
|
): IndexerLeaderboardParticipant {
|
|
259
|
+
const tracks = mapValues(position.tracks, (trackData) => ({
|
|
260
|
+
value: toBigNumber(trackData.value),
|
|
261
|
+
rank: toBigNumber(trackData.rank),
|
|
262
|
+
qualificationStatus: trackData.qualification_status,
|
|
263
|
+
}));
|
|
264
|
+
|
|
259
265
|
return {
|
|
260
266
|
subaccount: subaccountFromHex(position.subaccount),
|
|
261
267
|
contestId: position.contest_id,
|
|
262
|
-
pnl: toBigNumber(position.pnl),
|
|
263
|
-
pnlRank: toBigNumber(position.pnl_rank),
|
|
264
|
-
percentRoi: toBigNumber(position.roi),
|
|
265
|
-
roiRank: toBigNumber(position.roi_rank),
|
|
266
268
|
accountValue: toBigNumber(position.account_value),
|
|
267
|
-
volume: position.volume ? toBigNumber(position.volume) : undefined,
|
|
268
269
|
updateTime: toBigNumber(position.update_time),
|
|
270
|
+
tracks,
|
|
271
|
+
socialAccounts: position.social_accounts.map((account) => ({
|
|
272
|
+
provider: account.provider,
|
|
273
|
+
username: account.username,
|
|
274
|
+
displayName: account.display_name,
|
|
275
|
+
profileImageUrl: account.profile_image_url,
|
|
276
|
+
})),
|
|
269
277
|
};
|
|
270
278
|
}
|
|
271
279
|
|
|
@@ -282,17 +290,25 @@ export function mapIndexerLeaderboardRegistration(
|
|
|
282
290
|
export function mapIndexerLeaderboardContest(
|
|
283
291
|
contest: IndexerServerLeaderboardContest,
|
|
284
292
|
): IndexerLeaderboardContest {
|
|
293
|
+
const startTime = toBigNumber(contest.start_time);
|
|
294
|
+
const endTime = toBigNumber(contest.end_time);
|
|
295
|
+
|
|
285
296
|
return {
|
|
286
297
|
contestId: contest.contest_id,
|
|
287
|
-
startTime
|
|
288
|
-
endTime
|
|
289
|
-
period: toBigNumber(contest.threshold),
|
|
298
|
+
startTime,
|
|
299
|
+
endTime,
|
|
290
300
|
totalParticipants: toBigNumber(contest.count),
|
|
291
|
-
minRequiredAccountValue: toBigNumber(contest.threshold),
|
|
292
|
-
minRequiredVolume: toBigNumber(contest.volume_threshold),
|
|
293
301
|
requiredProductIds: contest.product_ids,
|
|
294
302
|
active: contest.active,
|
|
295
303
|
lastUpdated: toBigNumber(contest.last_updated),
|
|
304
|
+
title: contest.title,
|
|
305
|
+
description: contest.description,
|
|
306
|
+
tracks: contest.tracks.map((track) => ({
|
|
307
|
+
trackId: track.track_id,
|
|
308
|
+
rankType: track.rank_type,
|
|
309
|
+
sortOrder: track.sort_order,
|
|
310
|
+
minRequiredAccountValue: toBigNumber(track.threshold),
|
|
311
|
+
})),
|
|
296
312
|
};
|
|
297
313
|
}
|
|
298
314
|
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Leaderboard ranking metric.
|
|
3
|
+
* - `pnl` ranks by absolute PnL value
|
|
4
|
+
* - `roi` ranks by percentage ROI value
|
|
5
|
+
* - `volume` ranks by trading volume
|
|
6
|
+
* - `liquidation` ranks by liquidation count
|
|
7
|
+
* - `balance` ranks by spot balance
|
|
8
|
+
*/
|
|
9
|
+
export type IndexerLeaderboardRankType =
|
|
10
|
+
| 'pnl'
|
|
11
|
+
| 'roi'
|
|
12
|
+
| 'volume'
|
|
13
|
+
| 'liquidation'
|
|
14
|
+
| 'balance';
|
package/src/types/clientTypes.ts
CHANGED
|
@@ -558,26 +558,43 @@ export interface GetIndexerMakerStatisticsResponse {
|
|
|
558
558
|
|
|
559
559
|
export interface GetIndexerLeaderboardParams {
|
|
560
560
|
contestId: number;
|
|
561
|
-
|
|
561
|
+
/**
|
|
562
|
+
* The ranking metric to query by.
|
|
563
|
+
* Optional for single-track contests (auto-selects the only track).
|
|
564
|
+
* Required for multi-track contests — omitting it returns an error.
|
|
565
|
+
*/
|
|
566
|
+
rankType?: IndexerLeaderboardRankType;
|
|
562
567
|
// Min rank inclusive
|
|
563
568
|
startCursor?: string;
|
|
564
569
|
limit?: number;
|
|
570
|
+
/** Sort order. Defaults to `'DESC'`. */
|
|
571
|
+
order?: 'ASC' | 'DESC';
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
export interface IndexerSocialAccountInfo {
|
|
575
|
+
provider: 'twitter';
|
|
576
|
+
username: string;
|
|
577
|
+
displayName: string;
|
|
578
|
+
profileImageUrl: string;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
export interface IndexerLeaderboardTrackPosition {
|
|
582
|
+
value: BigNumber;
|
|
583
|
+
rank: BigNumber;
|
|
584
|
+
qualificationStatus: 'qualified' | 'insufficient_account_value';
|
|
565
585
|
}
|
|
566
586
|
|
|
567
587
|
export interface IndexerLeaderboardParticipant {
|
|
568
588
|
subaccount: Subaccount;
|
|
569
589
|
contestId: number;
|
|
570
|
-
pnl: BigNumber;
|
|
571
|
-
pnlRank: BigNumber;
|
|
572
|
-
percentRoi: BigNumber;
|
|
573
|
-
roiRank: BigNumber;
|
|
574
590
|
// Float indicating the ending account value at the time the snapshot was taken i.e: at updateTime
|
|
575
591
|
accountValue: BigNumber;
|
|
576
|
-
// Float indicating the trading volume at the time the snapshot was taken i.e: at updateTime.
|
|
577
|
-
// Null for contests that have no volume requirement.
|
|
578
|
-
volume?: BigNumber;
|
|
579
592
|
// Seconds
|
|
580
593
|
updateTime: BigNumber;
|
|
594
|
+
tracks: Partial<
|
|
595
|
+
Record<IndexerLeaderboardRankType, IndexerLeaderboardTrackPosition>
|
|
596
|
+
>;
|
|
597
|
+
socialAccounts: IndexerSocialAccountInfo[];
|
|
581
598
|
}
|
|
582
599
|
|
|
583
600
|
export interface GetIndexerLeaderboardResponse {
|
|
@@ -595,19 +612,21 @@ export interface GetIndexerLeaderboardParticipantResponse {
|
|
|
595
612
|
participant: Record<string, IndexerLeaderboardParticipant>;
|
|
596
613
|
}
|
|
597
614
|
|
|
598
|
-
interface
|
|
599
|
-
// endpoint address
|
|
615
|
+
interface SignatureParams {
|
|
600
616
|
verifyingAddr: string;
|
|
601
617
|
chainId: number;
|
|
602
618
|
}
|
|
603
619
|
|
|
604
|
-
export interface
|
|
605
|
-
|
|
620
|
+
export interface GetIndexerLeaderboardRegistrationsParams {
|
|
621
|
+
subaccount: Subaccount;
|
|
622
|
+
contestIds: number[];
|
|
623
|
+
/** Filter to active contests only. Defaults to `true`. */
|
|
624
|
+
active?: boolean;
|
|
606
625
|
}
|
|
607
626
|
|
|
608
|
-
export interface
|
|
609
|
-
|
|
610
|
-
|
|
627
|
+
export interface RegisterLeaderboardParams extends Subaccount, SignatureParams {
|
|
628
|
+
contestIds: number[];
|
|
629
|
+
/** In millis, defaults to 90s in the future. */
|
|
611
630
|
recvTime?: BigNumber;
|
|
612
631
|
}
|
|
613
632
|
|
|
@@ -618,45 +637,74 @@ export interface IndexerLeaderboardRegistration {
|
|
|
618
637
|
updateTime: BigNumber;
|
|
619
638
|
}
|
|
620
639
|
|
|
621
|
-
export interface
|
|
622
|
-
|
|
623
|
-
// For tiered contests (i.e., related contests), null if the user is not registered for any of the contests in the tier group.
|
|
624
|
-
registration: IndexerLeaderboardRegistration | null;
|
|
640
|
+
export interface GetIndexerLeaderboardRegistrationsResponse {
|
|
641
|
+
registrations: IndexerLeaderboardRegistration[];
|
|
625
642
|
}
|
|
626
643
|
|
|
627
|
-
export type
|
|
628
|
-
|
|
644
|
+
export type RegisterLeaderboardResponse =
|
|
645
|
+
GetIndexerLeaderboardRegistrationsResponse;
|
|
629
646
|
|
|
630
647
|
export interface GetIndexerLeaderboardContestsParams {
|
|
631
648
|
contestIds: number[];
|
|
649
|
+
/** Filter to active contests only. Defaults to `true`. Pass `false` to include inactive contests. */
|
|
650
|
+
active?: boolean;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
export interface IndexerLeaderboardContestTrack {
|
|
654
|
+
trackId: number;
|
|
655
|
+
rankType: IndexerLeaderboardRankType;
|
|
656
|
+
sortOrder: 'ASC' | 'DESC';
|
|
657
|
+
// Float indicating the min account value required to qualify for this track e.g: 250.0
|
|
658
|
+
minRequiredAccountValue: BigNumber;
|
|
632
659
|
}
|
|
633
660
|
|
|
634
661
|
export interface IndexerLeaderboardContest {
|
|
635
662
|
contestId: number;
|
|
636
|
-
// NOTE: Start / End times are ignored when `period` is non-zero.
|
|
637
663
|
// Start time in seconds
|
|
638
664
|
startTime: BigNumber;
|
|
639
665
|
// End time in seconds
|
|
640
666
|
endTime: BigNumber;
|
|
641
|
-
//
|
|
642
|
-
// Otherwise, contest runs indefinitely in the interval [lastUpdated - period, lastUpdated] if active;
|
|
643
|
-
period: BigNumber;
|
|
644
|
-
// Last updated time in Seconds
|
|
667
|
+
// Last updated time in seconds
|
|
645
668
|
lastUpdated: BigNumber;
|
|
646
669
|
totalParticipants: BigNumber;
|
|
647
|
-
// Float indicating the min account value required to be eligible for this contest e.g: 250.0
|
|
648
|
-
minRequiredAccountValue: BigNumber;
|
|
649
|
-
// Float indicating the min trading volume required to be eligible for this contest e.g: 1000.0
|
|
650
|
-
minRequiredVolume: BigNumber;
|
|
651
670
|
// For market-specific contests, only the volume from these products will be counted.
|
|
652
671
|
requiredProductIds: number[];
|
|
653
672
|
active: boolean;
|
|
673
|
+
title: string;
|
|
674
|
+
description: string;
|
|
675
|
+
tracks: IndexerLeaderboardContestTrack[];
|
|
654
676
|
}
|
|
655
677
|
|
|
656
678
|
export interface GetIndexerLeaderboardContestsResponse {
|
|
657
679
|
contests: IndexerLeaderboardContest[];
|
|
658
680
|
}
|
|
659
681
|
|
|
682
|
+
/**
|
|
683
|
+
* Social Accounts
|
|
684
|
+
*/
|
|
685
|
+
|
|
686
|
+
export interface ConnectSocialAccountParams
|
|
687
|
+
extends Subaccount, SignatureParams {
|
|
688
|
+
provider: 'twitter';
|
|
689
|
+
/** In millis, defaults to 90s in the future. */
|
|
690
|
+
recvTime?: BigNumber;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
export interface ConnectSocialAccountResponse {
|
|
694
|
+
url: string;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
export interface ListIndexerSocialAccountsParams {
|
|
698
|
+
address: Address;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
export interface ListIndexerSocialAccountsResponse {
|
|
702
|
+
accounts: IndexerSocialAccountInfo[];
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
export type RevokeSocialAccountParams = ConnectSocialAccountParams;
|
|
706
|
+
export type RevokeSocialAccountResponse = ListIndexerSocialAccountsResponse;
|
|
707
|
+
|
|
660
708
|
export type GetIndexerFastWithdrawalSignatureParams =
|
|
661
709
|
IndexerServerFastWithdrawalSignatureParams;
|
|
662
710
|
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from '@nadohq/engine-client';
|
|
7
7
|
import { EIP712OrderValues } from '@nadohq/shared';
|
|
8
8
|
import { IndexerEventType } from './IndexerEventType';
|
|
9
|
+
import { IndexerLeaderboardRankType } from './IndexerLeaderboardType';
|
|
9
10
|
import { NadoTx } from './NadoTx';
|
|
10
11
|
|
|
11
12
|
export interface IndexerServerSnapshotsInterval {
|
|
@@ -249,29 +250,48 @@ export interface IndexerServerMaker {
|
|
|
249
250
|
* Leaderboard
|
|
250
251
|
*/
|
|
251
252
|
|
|
253
|
+
export interface IndexerServerSocialAccount {
|
|
254
|
+
provider: 'twitter';
|
|
255
|
+
username: string;
|
|
256
|
+
display_name: string;
|
|
257
|
+
profile_image_url: string;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export interface IndexerServerLeaderboardTrackPosition {
|
|
261
|
+
value: string;
|
|
262
|
+
rank: string;
|
|
263
|
+
qualification_status: 'qualified' | 'insufficient_account_value';
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export interface IndexerServerLeaderboardContestTrack {
|
|
267
|
+
track_id: number;
|
|
268
|
+
rank_type: IndexerLeaderboardRankType;
|
|
269
|
+
sort_order: 'ASC' | 'DESC';
|
|
270
|
+
threshold: string;
|
|
271
|
+
}
|
|
272
|
+
|
|
252
273
|
export interface IndexerServerLeaderboardPosition {
|
|
253
274
|
subaccount: string;
|
|
254
275
|
contest_id: number;
|
|
255
|
-
pnl: string;
|
|
256
|
-
pnl_rank: string;
|
|
257
|
-
roi: string;
|
|
258
|
-
roi_rank: string;
|
|
259
276
|
account_value: string;
|
|
260
|
-
volume?: string;
|
|
261
277
|
update_time: string;
|
|
278
|
+
tracks: Partial<
|
|
279
|
+
Record<IndexerLeaderboardRankType, IndexerServerLeaderboardTrackPosition>
|
|
280
|
+
>;
|
|
281
|
+
social_accounts: IndexerServerSocialAccount[];
|
|
262
282
|
}
|
|
263
283
|
|
|
264
284
|
export interface IndexerServerLeaderboardContest {
|
|
265
285
|
contest_id: number;
|
|
266
286
|
start_time: string;
|
|
267
287
|
end_time: string;
|
|
268
|
-
timeframe: string;
|
|
269
288
|
count: string;
|
|
270
|
-
threshold: string;
|
|
271
|
-
volume_threshold: string;
|
|
272
|
-
product_ids: number[];
|
|
273
289
|
last_updated: string;
|
|
290
|
+
product_ids: number[];
|
|
274
291
|
active: boolean;
|
|
292
|
+
title: string;
|
|
293
|
+
description: string;
|
|
294
|
+
tracks: IndexerServerLeaderboardContestTrack[];
|
|
275
295
|
}
|
|
276
296
|
|
|
277
297
|
export interface IndexerServerLeaderboardRegistration {
|