@orderly.network/trading-leaderboard 2.2.0 → 2.3.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/index.d.mts +290 -33
- package/dist/index.d.ts +290 -33
- package/dist/index.js +42 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -10
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +12 -10
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { FC,
|
|
2
|
+
import { PropsWithChildren, FC, ReactNode } from 'react';
|
|
3
3
|
import * as embla_carousel_react from 'embla-carousel-react';
|
|
4
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
4
|
import * as _orderly_network_ui from '@orderly.network/ui';
|
|
6
5
|
import { TableSort } from '@orderly.network/ui';
|
|
7
|
-
|
|
8
|
-
type CampaignsWidgetProps = {
|
|
9
|
-
className?: string;
|
|
10
|
-
style?: React.CSSProperties;
|
|
11
|
-
};
|
|
12
|
-
declare const CampaignsWidget: FC<CampaignsWidgetProps>;
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
13
7
|
|
|
14
8
|
type Campaign = {
|
|
15
9
|
title: string;
|
|
@@ -27,7 +21,7 @@ type Campaign = {
|
|
|
27
21
|
/**
|
|
28
22
|
* Trading leaderboard provider state
|
|
29
23
|
*/
|
|
30
|
-
type TradingLeaderboardState = {
|
|
24
|
+
type TradingLeaderboardState$1 = {
|
|
31
25
|
/** campaigns config, if not provided, will not show campaigns section */
|
|
32
26
|
campaigns?: Campaign[];
|
|
33
27
|
/** background src, it can be a image resource or video resource */
|
|
@@ -37,13 +31,38 @@ type TradingLeaderboardState = {
|
|
|
37
31
|
trading: string;
|
|
38
32
|
};
|
|
39
33
|
};
|
|
34
|
+
type TradingLeaderboardProviderProps$1 = PropsWithChildren<TradingLeaderboardState$1>;
|
|
35
|
+
|
|
36
|
+
type LeaderboardScriptReturn = ReturnType<typeof useLeaderboardScript>;
|
|
37
|
+
type LeaderboardScriptOptions = {
|
|
38
|
+
backgroundSrc?: string;
|
|
39
|
+
campaigns?: Campaign[];
|
|
40
|
+
};
|
|
41
|
+
declare function useLeaderboardScript(options: LeaderboardScriptOptions): {
|
|
42
|
+
backgroundSrc: string | undefined;
|
|
43
|
+
isVideo: boolean;
|
|
44
|
+
showCampaigns: boolean;
|
|
45
|
+
isMobile: boolean;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type LeaderboardProps = {
|
|
49
|
+
style?: React.CSSProperties;
|
|
50
|
+
className?: string;
|
|
51
|
+
} & LeaderboardScriptReturn;
|
|
52
|
+
declare const Leaderboard: FC<LeaderboardProps>;
|
|
53
|
+
|
|
54
|
+
type LeaderboardWidgetProps = TradingLeaderboardProviderProps$1 & Pick<LeaderboardProps, "style" | "className">;
|
|
40
55
|
/**
|
|
41
|
-
*
|
|
56
|
+
* @deprecated use LeaderboardPage instead
|
|
57
|
+
* it will be removed in next version
|
|
42
58
|
*/
|
|
43
|
-
declare const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
59
|
+
declare const LeaderboardWidget: FC<LeaderboardWidgetProps>;
|
|
60
|
+
|
|
61
|
+
type CampaignsWidgetProps = {
|
|
62
|
+
className?: string;
|
|
63
|
+
style?: React.CSSProperties;
|
|
64
|
+
};
|
|
65
|
+
declare const CampaignsWidget: FC<CampaignsWidgetProps>;
|
|
47
66
|
|
|
48
67
|
type CampaignsScriptReturn = ReturnType<typeof useCampaignsScript>;
|
|
49
68
|
type CategorizedCampaigns = {
|
|
@@ -108,17 +127,17 @@ type TradingData = {
|
|
|
108
127
|
key?: string;
|
|
109
128
|
};
|
|
110
129
|
type TradingListScriptReturn = ReturnType<typeof useTradingListScript>;
|
|
111
|
-
declare const FilterDays: readonly [7, 14, 30, 90];
|
|
112
|
-
type TFilterDays = (typeof FilterDays)[number];
|
|
113
|
-
type DateRange = {
|
|
130
|
+
declare const FilterDays$1: readonly [7, 14, 30, 90];
|
|
131
|
+
type TFilterDays$1 = (typeof FilterDays$1)[number];
|
|
132
|
+
type DateRange$1 = {
|
|
114
133
|
from?: Date;
|
|
115
134
|
to?: Date;
|
|
116
135
|
};
|
|
117
136
|
declare function useTradingListScript(): {
|
|
118
137
|
pagination: _orderly_network_ui.PaginationMeta;
|
|
119
|
-
dateRange: DateRange;
|
|
138
|
+
dateRange: DateRange$1;
|
|
120
139
|
filterDay: 30 | 7 | 14 | 90 | null;
|
|
121
|
-
updateFilterDay: (day: TFilterDays) => void;
|
|
140
|
+
updateFilterDay: (day: TFilterDays$1) => void;
|
|
122
141
|
filterItems: any;
|
|
123
142
|
onFilter: (filter: {
|
|
124
143
|
name: string;
|
|
@@ -135,7 +154,6 @@ declare function useTradingListScript(): {
|
|
|
135
154
|
sentinelRef: react.MutableRefObject<HTMLDivElement | null>;
|
|
136
155
|
dataList: TradingData[];
|
|
137
156
|
address: string | undefined;
|
|
138
|
-
canTrade: boolean | "" | undefined;
|
|
139
157
|
};
|
|
140
158
|
|
|
141
159
|
type TradingListProps = {
|
|
@@ -145,27 +163,266 @@ type TradingListProps = {
|
|
|
145
163
|
declare const TradingList: FC<TradingListProps>;
|
|
146
164
|
|
|
147
165
|
type TradingListWidgetProps = Pick<TradingListProps, "style" | "className">;
|
|
166
|
+
/**
|
|
167
|
+
* @deprecated use TradingListPage instead
|
|
168
|
+
* it will be removed in next version
|
|
169
|
+
*/
|
|
148
170
|
declare const TradingListWidget: FC<TradingListWidgetProps>;
|
|
149
171
|
|
|
150
|
-
|
|
151
|
-
|
|
172
|
+
declare enum CampaignTagEnum {
|
|
173
|
+
ONGOING = "ongoing",
|
|
174
|
+
COMING = "coming",
|
|
175
|
+
ENDED = "ended",
|
|
176
|
+
EXCLUSIVE = "exclusive"
|
|
177
|
+
}
|
|
178
|
+
interface CampaignStatistics {
|
|
179
|
+
total_participants?: number;
|
|
180
|
+
total_volume?: number;
|
|
181
|
+
}
|
|
182
|
+
interface PrizePoolTier {
|
|
183
|
+
position?: number;
|
|
184
|
+
position_range?: [number, number];
|
|
185
|
+
amount: number;
|
|
186
|
+
}
|
|
187
|
+
interface PrizePool {
|
|
188
|
+
pool_id: string;
|
|
189
|
+
label: string;
|
|
190
|
+
total_prize: number;
|
|
191
|
+
currency: string;
|
|
192
|
+
metric: "volume" | "pnl";
|
|
193
|
+
tiers: PrizePoolTier[];
|
|
194
|
+
}
|
|
195
|
+
interface TicketTierRule {
|
|
196
|
+
value: number;
|
|
197
|
+
tickets: number;
|
|
198
|
+
}
|
|
199
|
+
interface TicketLinearRule {
|
|
200
|
+
every: number;
|
|
201
|
+
tickets: number;
|
|
202
|
+
}
|
|
203
|
+
interface TicketRules {
|
|
204
|
+
total_prize: number;
|
|
205
|
+
currency: string;
|
|
206
|
+
metric: "volume" | "pnl";
|
|
207
|
+
mode: "tiered" | "linear";
|
|
208
|
+
tiers?: TicketTierRule[];
|
|
209
|
+
linear?: TicketLinearRule;
|
|
210
|
+
}
|
|
211
|
+
interface CampaignConfig {
|
|
212
|
+
campaign_id: number | string;
|
|
213
|
+
title: string;
|
|
214
|
+
description: string;
|
|
215
|
+
start_time: string;
|
|
216
|
+
end_time: string;
|
|
217
|
+
reward_distribution_time?: string;
|
|
218
|
+
volume_scope?: string | string[];
|
|
219
|
+
referral_codes?: string[] | string;
|
|
220
|
+
prize_pools?: PrizePool[];
|
|
221
|
+
ticket_rules?: TicketRules;
|
|
222
|
+
image?: string;
|
|
223
|
+
rule_url?: string;
|
|
224
|
+
trading_url?: string;
|
|
225
|
+
href?: string;
|
|
226
|
+
}
|
|
227
|
+
interface UserData {
|
|
228
|
+
rank?: number | string;
|
|
229
|
+
pnl: number;
|
|
230
|
+
total_participants?: number;
|
|
231
|
+
volume: number;
|
|
232
|
+
referral_code?: string;
|
|
233
|
+
}
|
|
234
|
+
type CampaignStatsDetailsResponse = {
|
|
235
|
+
broker_id: string;
|
|
236
|
+
user_count: number;
|
|
237
|
+
volume: number;
|
|
238
|
+
symbol: string;
|
|
239
|
+
}[];
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Trading leaderboard provider state
|
|
243
|
+
*/
|
|
244
|
+
type TradingLeaderboardState = {
|
|
245
|
+
/** campaigns config, if not provided, will not show campaigns section */
|
|
246
|
+
campaigns?: CampaignConfig[];
|
|
247
|
+
/** background src, it can be a image resource or video resource */
|
|
152
248
|
backgroundSrc?: string;
|
|
153
|
-
|
|
249
|
+
href?: {
|
|
250
|
+
/** default trading now button url */
|
|
251
|
+
trading: string;
|
|
252
|
+
};
|
|
253
|
+
currentCampaignId: string;
|
|
254
|
+
currentCampaign?: CampaignConfig;
|
|
255
|
+
onCampaignChange: (campaignId: string) => void;
|
|
256
|
+
/** leaderboard user data, it will be used to calculate the rewards */
|
|
257
|
+
userData?: UserData;
|
|
258
|
+
/** set leaderboard user data */
|
|
259
|
+
setUserData?: (userdata: UserData) => void;
|
|
260
|
+
/** campaign ranking list updated time */
|
|
261
|
+
updatedTime?: number;
|
|
262
|
+
/** set snapshot time */
|
|
263
|
+
setUpdatedTime?: (updatedTime?: number) => void;
|
|
154
264
|
};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
265
|
+
/**
|
|
266
|
+
* Trading leaderboard context
|
|
267
|
+
*/
|
|
268
|
+
declare const TradingLeaderboardContext: react.Context<TradingLeaderboardState>;
|
|
269
|
+
type TradingLeaderboardProviderProps = PropsWithChildren<Pick<TradingLeaderboardState, "campaigns" | "href" | "backgroundSrc">> & {
|
|
270
|
+
campaignId?: string | number;
|
|
271
|
+
onCampaignChange?: (campaignId: string | number) => void;
|
|
272
|
+
};
|
|
273
|
+
declare const TradingLeaderboardProvider: (props: TradingLeaderboardProviderProps) => react_jsx_runtime.JSX.Element;
|
|
274
|
+
declare const useTradingLeaderboardContext: () => TradingLeaderboardState;
|
|
275
|
+
|
|
276
|
+
type CampaignRankingData = {
|
|
277
|
+
broker_id: string;
|
|
278
|
+
account_id: string;
|
|
279
|
+
address: string;
|
|
280
|
+
volume: number;
|
|
281
|
+
pnl: number;
|
|
282
|
+
total_deposit_amount: number;
|
|
283
|
+
total_withdrawal_amount: number;
|
|
284
|
+
start_account_value: number;
|
|
285
|
+
end_account_value: number;
|
|
286
|
+
key?: string;
|
|
287
|
+
rank?: number | string;
|
|
288
|
+
rewards?: {
|
|
289
|
+
amount: number;
|
|
290
|
+
currency: string;
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
type CampaignRankingScriptOptions = {
|
|
294
|
+
campaignId: number | string;
|
|
295
|
+
sortKey?: "volume" | "pnl";
|
|
296
|
+
};
|
|
297
|
+
declare function useCampaignRankingScript(options: CampaignRankingScriptOptions): {
|
|
298
|
+
pagination: _orderly_network_ui.PaginationMeta;
|
|
299
|
+
initialSort: TableSort;
|
|
300
|
+
dataSource: any[];
|
|
301
|
+
isLoading: boolean;
|
|
159
302
|
isMobile: boolean;
|
|
303
|
+
sentinelRef: react.MutableRefObject<HTMLDivElement | null>;
|
|
304
|
+
dataList: any[];
|
|
305
|
+
address: string | undefined;
|
|
160
306
|
};
|
|
161
307
|
|
|
162
|
-
type
|
|
308
|
+
type DateRange = {
|
|
309
|
+
from?: Date;
|
|
310
|
+
to?: Date;
|
|
311
|
+
};
|
|
312
|
+
declare enum LeaderboardTab {
|
|
313
|
+
Volume = "volume",
|
|
314
|
+
Pnl = "pnl"
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
type GeneralRankingData = {
|
|
318
|
+
account_id: string;
|
|
319
|
+
address: string;
|
|
320
|
+
broker_fee: number;
|
|
321
|
+
date: string;
|
|
322
|
+
perp_maker_volume: number;
|
|
323
|
+
perp_taker_volume: number;
|
|
324
|
+
perp_volume: number;
|
|
325
|
+
realized_pnl: number;
|
|
326
|
+
total_fee: number;
|
|
327
|
+
key?: string;
|
|
328
|
+
rank?: number | string;
|
|
329
|
+
volume?: number;
|
|
330
|
+
pnl?: number;
|
|
331
|
+
};
|
|
332
|
+
type GeneralRankingScriptReturn = ReturnType<typeof useGeneralRankingScript>;
|
|
333
|
+
type GeneralRankingScriptOptions = {
|
|
334
|
+
dateRange?: DateRange;
|
|
335
|
+
address?: string;
|
|
336
|
+
sortKey?: "perp_volume" | "realized_pnl";
|
|
337
|
+
};
|
|
338
|
+
declare function useGeneralRankingScript(options?: GeneralRankingScriptOptions): {
|
|
339
|
+
pagination: _orderly_network_ui.PaginationMeta;
|
|
340
|
+
initialSort: TableSort;
|
|
341
|
+
onSort: (sort?: TableSort) => void;
|
|
342
|
+
dataSource: any[];
|
|
343
|
+
isLoading: boolean;
|
|
344
|
+
isMobile: boolean;
|
|
345
|
+
sentinelRef: react.MutableRefObject<HTMLDivElement | null>;
|
|
346
|
+
dataList: any[];
|
|
347
|
+
address: string | undefined;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
type RankingColumnFields = "rank" | "address" | "volume" | "pnl" | "rewards";
|
|
351
|
+
|
|
352
|
+
type RankingData = GeneralRankingData | CampaignRankingData;
|
|
353
|
+
type RankingProps = {
|
|
163
354
|
style?: React.CSSProperties;
|
|
164
355
|
className?: string;
|
|
165
|
-
|
|
166
|
-
|
|
356
|
+
fields: RankingColumnFields[];
|
|
357
|
+
} & Omit<GeneralRankingScriptReturn, "dataList" | "dataSource"> & {
|
|
358
|
+
dataList: RankingData[];
|
|
359
|
+
dataSource: RankingData[];
|
|
360
|
+
};
|
|
361
|
+
declare const Ranking: FC<RankingProps>;
|
|
167
362
|
|
|
168
|
-
type
|
|
169
|
-
declare const
|
|
363
|
+
type GeneralRankingWidgetProps = Pick<RankingProps, "style" | "className" | "fields"> & GeneralRankingScriptOptions;
|
|
364
|
+
declare const GeneralRankingWidget: FC<GeneralRankingWidgetProps>;
|
|
365
|
+
|
|
366
|
+
type CampaignRankingWidgetProps = Pick<RankingProps, "style" | "className" | "fields"> & CampaignRankingScriptOptions;
|
|
367
|
+
declare const CampaignRankingWidget: FC<CampaignRankingWidgetProps>;
|
|
368
|
+
|
|
369
|
+
type GeneralLeaderboardScriptReturn = ReturnType<typeof useGeneralLeaderboardScript>;
|
|
370
|
+
declare const FilterDays: readonly [7, 14, 30, 90];
|
|
371
|
+
type TFilterDays = (typeof FilterDays)[number];
|
|
372
|
+
declare function useGeneralLeaderboardScript(): {
|
|
373
|
+
activeTab: LeaderboardTab;
|
|
374
|
+
onTabChange: react.Dispatch<react.SetStateAction<LeaderboardTab>>;
|
|
375
|
+
searchValue: string;
|
|
376
|
+
onSearchValueChange: (value: string) => void;
|
|
377
|
+
clearSearchValue: () => void;
|
|
378
|
+
filterItems: any;
|
|
379
|
+
onFilter: (filter: {
|
|
380
|
+
name: string;
|
|
381
|
+
value: any;
|
|
382
|
+
}) => void;
|
|
383
|
+
dateRange: DateRange;
|
|
384
|
+
filterDay: 30 | 7 | 14 | 90 | null;
|
|
385
|
+
updateFilterDay: (day: TFilterDays) => void;
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
type GeneralLeaderboardProps = {
|
|
389
|
+
style?: React.CSSProperties;
|
|
390
|
+
className?: string;
|
|
391
|
+
} & GeneralLeaderboardScriptReturn;
|
|
392
|
+
declare const GeneralLeaderboard: FC<GeneralLeaderboardProps>;
|
|
393
|
+
|
|
394
|
+
type GeneralLeaderboardWidgetProps = Pick<GeneralLeaderboardProps, "style" | "className">;
|
|
395
|
+
declare const GeneralLeaderboardWidget: FC<GeneralLeaderboardWidgetProps>;
|
|
396
|
+
|
|
397
|
+
type CampaignLeaderboardScriptReturn = ReturnType<typeof useCampaignLeaderboardScript>;
|
|
398
|
+
declare function useCampaignLeaderboardScript(): {
|
|
399
|
+
activeTab: LeaderboardTab;
|
|
400
|
+
onTabChange: react.Dispatch<react.SetStateAction<LeaderboardTab>>;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
type CampaignLeaderboardProps = {
|
|
404
|
+
style?: React.CSSProperties;
|
|
405
|
+
className?: string;
|
|
406
|
+
campaignId: number | string;
|
|
407
|
+
} & CampaignLeaderboardScriptReturn;
|
|
408
|
+
declare const CampaignLeaderboard: FC<CampaignLeaderboardProps>;
|
|
409
|
+
|
|
410
|
+
type CampaignLeaderboardWidgetProps = Pick<CampaignLeaderboardProps, "style" | "className" | "campaignId">;
|
|
411
|
+
declare const CampaignLeaderboardWidget: FC<CampaignLeaderboardWidgetProps>;
|
|
412
|
+
|
|
413
|
+
type LeaderboardPageProps = GeneralLeaderboardWidgetProps & TradingLeaderboardProviderProps & {
|
|
414
|
+
style?: React.CSSProperties;
|
|
415
|
+
className?: string;
|
|
416
|
+
};
|
|
417
|
+
declare const LeaderboardPage: FC<LeaderboardPageProps>;
|
|
418
|
+
type LeaderboardSectionProps = {
|
|
419
|
+
style?: React.CSSProperties;
|
|
420
|
+
className?: string;
|
|
421
|
+
};
|
|
422
|
+
declare const LeaderboardSection: FC<LeaderboardSectionProps>;
|
|
423
|
+
declare const LeaderboardTitle: (props: {
|
|
424
|
+
title: ReactNode;
|
|
425
|
+
isMobile?: boolean;
|
|
426
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
170
427
|
|
|
171
|
-
export { type Campaign, Campaigns, type CampaignsProps, CampaignsWidget, Leaderboard, type LeaderboardProps, LeaderboardWidget, type LeaderboardWidgetProps, TradingLeaderboardContext, TradingLeaderboardProvider, type TradingLeaderboardProviderProps, type TradingLeaderboardState, TradingList, type TradingListProps, TradingListWidget, type TradingListWidgetProps, useCampaignsScript, useLeaderboardScript, useTradingLeaderboardContext, useTradingListScript };
|
|
428
|
+
export { type Campaign, type CampaignConfig, CampaignLeaderboard, type CampaignLeaderboardProps, CampaignLeaderboardWidget, type CampaignLeaderboardWidgetProps, CampaignRankingWidget, type CampaignRankingWidgetProps, type CampaignStatistics, type CampaignStatsDetailsResponse, CampaignTagEnum, Campaigns, type CampaignsProps, CampaignsWidget, GeneralLeaderboard, type GeneralLeaderboardProps, GeneralLeaderboardWidget, type GeneralLeaderboardWidgetProps, GeneralRankingWidget, type GeneralRankingWidgetProps, Leaderboard, LeaderboardPage, type LeaderboardPageProps, type LeaderboardProps, LeaderboardSection, LeaderboardTitle, LeaderboardWidget, type LeaderboardWidgetProps, type PrizePool, type PrizePoolTier, Ranking, type RankingProps, type TicketLinearRule, type TicketRules, type TicketTierRule, TradingLeaderboardContext, TradingLeaderboardProvider, type TradingLeaderboardProviderProps, type TradingLeaderboardState, TradingList, type TradingListProps, TradingListWidget, type TradingListWidgetProps, type UserData, useCampaignLeaderboardScript, useCampaignRankingScript, useCampaignsScript, useGeneralLeaderboardScript, useGeneralRankingScript, useLeaderboardScript, useTradingLeaderboardContext, useTradingListScript };
|