@kodiak-finance/orderly-trading-leaderboard 2.8.22-beta.1 → 2.8.22-beta.2
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 +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +100 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +100 -16
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { subDays, parseISO, differenceInDays, isBefore, addDays, isAfter, isWithinInterval, format } from 'date-fns';
|
|
2
2
|
import { createContext, lazy, memo, useState, useRef, useCallback, useEffect, useMemo, useContext, Suspense } from 'react';
|
|
3
|
+
import { useAccount, useConfig, useQuery, useInfiniteQuery, useSWR, useTrack, usePrivateQuery, noCacheConfig, useMemoizedFn, useLocalStorage, useMutation } from '@kodiak-finance/orderly-hooks';
|
|
3
4
|
import { useTranslation, i18n, Trans } from '@kodiak-finance/orderly-i18n';
|
|
4
|
-
import { useAccount, useConfig, useQuery, useInfiniteQuery, useSWR, useTrack, usePrivateQuery, noCacheConfig, useMemoizedFn, useMutation } from '@kodiak-finance/orderly-hooks';
|
|
5
5
|
import { useEmblaCarousel, ChevronLeftIcon, ChevronRightIcon, cn, Text, useScreen, DataTable, Flex, Spinner, usePagination, Box, Select, Button, DataFilter, Input, CloseCircleFillIcon, Divider, ScrollIndicator as ScrollIndicator$1, Tabs, TabPanel, toast, Tooltip, InfoCircleIcon } from '@kodiak-finance/orderly-ui';
|
|
6
6
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
7
7
|
import { TrendingUp, TrendingDown, Wallet, DollarSign, BarChart3 } from 'lucide-react';
|
|
@@ -235,7 +235,7 @@ var init_util = __esm({
|
|
|
235
235
|
"src/components/ranking/shared/util.ts"() {
|
|
236
236
|
}
|
|
237
237
|
});
|
|
238
|
-
var useRankingColumns, FirstRankIcon, SecondRankIcon, ThirdRankIcon, PnLColumnTitle, VolumeColumnTitle, PointsColumnTitle;
|
|
238
|
+
var useRankingColumns, getTierInfo, TierBadge, FirstRankIcon, SecondRankIcon, ThirdRankIcon, PnLColumnTitle, VolumeColumnTitle, PointsColumnTitle;
|
|
239
239
|
var init_column = __esm({
|
|
240
240
|
"src/components/ranking/shared/column.tsx"() {
|
|
241
241
|
init_first_badge();
|
|
@@ -298,7 +298,7 @@ var init_column = __esm({
|
|
|
298
298
|
if (!isYou) {
|
|
299
299
|
if (record.rank === 1) ; else if (record.rank === 2) ; else if (record.rank === 3) ;
|
|
300
300
|
}
|
|
301
|
-
return /* @__PURE__ */ jsx(
|
|
301
|
+
return /* @__PURE__ */ jsx("div", { className: "oui-flex oui-flex-col", children: /* @__PURE__ */ jsxs(
|
|
302
302
|
"a",
|
|
303
303
|
{
|
|
304
304
|
className: "oui-flex oui-items-start oui-gap-1",
|
|
@@ -329,6 +329,18 @@ var init_column = __esm({
|
|
|
329
329
|
},
|
|
330
330
|
width: 90
|
|
331
331
|
},
|
|
332
|
+
{
|
|
333
|
+
title: "VIP Tier",
|
|
334
|
+
dataIndex: "tier",
|
|
335
|
+
render: (_value, record) => {
|
|
336
|
+
const tierInfo = getTierInfo(record);
|
|
337
|
+
if (!tierInfo?.label) {
|
|
338
|
+
return "-";
|
|
339
|
+
}
|
|
340
|
+
return /* @__PURE__ */ jsx(TierBadge, { label: tierInfo.label, imageUrl: tierInfo.imageUrl });
|
|
341
|
+
},
|
|
342
|
+
width: 120
|
|
343
|
+
},
|
|
332
344
|
{
|
|
333
345
|
title: /* @__PURE__ */ jsx(VolumeColumnTitle, {}),
|
|
334
346
|
dataIndex: "volume",
|
|
@@ -394,6 +406,46 @@ var init_column = __esm({
|
|
|
394
406
|
);
|
|
395
407
|
}, [t, isMobile, address, fields, enableSort, type]);
|
|
396
408
|
};
|
|
409
|
+
getTierInfo = (record) => {
|
|
410
|
+
if (!record) {
|
|
411
|
+
return {};
|
|
412
|
+
}
|
|
413
|
+
const tierValue = record.tier;
|
|
414
|
+
if (tierValue && typeof tierValue === "object") {
|
|
415
|
+
return {
|
|
416
|
+
label: tierValue.name || tierValue.label || tierValue.tier,
|
|
417
|
+
imageUrl: tierValue.badge_url || tierValue.badgeUrl || tierValue.image || tierValue.imageUrl
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
const label = record.vip_tier || record.vipTier || record.vip_tier_name || record.vipTierName || record.tier || record.tier_name || record.tierName || record.tier_label || record.tierLabel;
|
|
421
|
+
const imageUrl = record.vip_badge_url || record.vipBadgeUrl || record.vip_tier_image || record.vipTierImage || record.vip_tier_badge || record.vipTierBadge || record.tier_image || record.tierImage || record.tier_badge_url || record.tierBadgeUrl;
|
|
422
|
+
return { label, imageUrl };
|
|
423
|
+
};
|
|
424
|
+
TierBadge = ({
|
|
425
|
+
label,
|
|
426
|
+
imageUrl,
|
|
427
|
+
className
|
|
428
|
+
}) => {
|
|
429
|
+
return /* @__PURE__ */ jsxs(
|
|
430
|
+
Flex,
|
|
431
|
+
{
|
|
432
|
+
itemAlign: "center",
|
|
433
|
+
gap: 1,
|
|
434
|
+
className: cn("oui-text-2xs", className),
|
|
435
|
+
children: [
|
|
436
|
+
imageUrl && /* @__PURE__ */ jsx(
|
|
437
|
+
"img",
|
|
438
|
+
{
|
|
439
|
+
src: imageUrl,
|
|
440
|
+
alt: `${label} badge`,
|
|
441
|
+
className: "oui-h-4 oui-w-4 oui-object-contain"
|
|
442
|
+
}
|
|
443
|
+
),
|
|
444
|
+
/* @__PURE__ */ jsx(Text, { className: "oui-text-2xs", children: label })
|
|
445
|
+
]
|
|
446
|
+
}
|
|
447
|
+
);
|
|
448
|
+
};
|
|
397
449
|
FirstRankIcon = () => {
|
|
398
450
|
return /* @__PURE__ */ jsxs(
|
|
399
451
|
"svg",
|
|
@@ -664,7 +716,8 @@ function useGeneralRankingScript(options) {
|
|
|
664
716
|
dateRange = getDateRange(90),
|
|
665
717
|
address: searchValue,
|
|
666
718
|
sortKey = "perp_volume",
|
|
667
|
-
leaderboardEndpoint
|
|
719
|
+
leaderboardEndpoint,
|
|
720
|
+
foxifyOnly = false
|
|
668
721
|
} = options || {};
|
|
669
722
|
const [initialSort] = useState({
|
|
670
723
|
sortKey,
|
|
@@ -712,6 +765,9 @@ function useGeneralRankingScript(options) {
|
|
|
712
765
|
if (args.address) {
|
|
713
766
|
searchParams.set("address", args.address);
|
|
714
767
|
}
|
|
768
|
+
if (foxifyOnly) {
|
|
769
|
+
searchParams.set("foxify_only", "true");
|
|
770
|
+
}
|
|
715
771
|
const baseUrl = leaderboardEndpoint || `/v1/broker/leaderboard/daily`;
|
|
716
772
|
return `${baseUrl}?${searchParams.toString()}`;
|
|
717
773
|
};
|
|
@@ -1026,12 +1082,13 @@ var init_generalRanking_widget = __esm({
|
|
|
1026
1082
|
init_ranking_ui();
|
|
1027
1083
|
init_generalRanking_script();
|
|
1028
1084
|
GeneralRankingWidget = (props) => {
|
|
1029
|
-
const { dateRange, address, fields, sortKey, leaderboardEndpoint, ...rest } = props;
|
|
1085
|
+
const { dateRange, address, fields, sortKey, leaderboardEndpoint, foxifyOnly, ...rest } = props;
|
|
1030
1086
|
const state = useGeneralRankingScript({
|
|
1031
1087
|
dateRange,
|
|
1032
1088
|
address,
|
|
1033
1089
|
sortKey,
|
|
1034
|
-
leaderboardEndpoint
|
|
1090
|
+
leaderboardEndpoint,
|
|
1091
|
+
foxifyOnly
|
|
1035
1092
|
});
|
|
1036
1093
|
return /* @__PURE__ */ jsx(Ranking, { ...state, ...rest, fields, type: "general" });
|
|
1037
1094
|
};
|
|
@@ -1067,7 +1124,7 @@ var TradingLeaderboardProvider = (props) => {
|
|
|
1067
1124
|
var useTradingLeaderboardContext = () => {
|
|
1068
1125
|
return useContext(TradingLeaderboardContext);
|
|
1069
1126
|
};
|
|
1070
|
-
var API_BASE = "https://backend.kodiak.finance/orderly/stats";
|
|
1127
|
+
var API_BASE = "https://staging.backend.kodiak.finance/orderly/stats";
|
|
1071
1128
|
var formatDateLocal = (date) => {
|
|
1072
1129
|
const year = date.getFullYear();
|
|
1073
1130
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
@@ -3100,6 +3157,18 @@ var LeaderboardTab = /* @__PURE__ */ ((LeaderboardTab2) => {
|
|
|
3100
3157
|
|
|
3101
3158
|
// src/components/leaderboard/generalLeaderboard/generalLeaderboard.script.ts
|
|
3102
3159
|
init_utils();
|
|
3160
|
+
var useLeaderboardLocalStorage = () => {
|
|
3161
|
+
const [foxifyOnly, setFoxifyOnly] = useLocalStorage(
|
|
3162
|
+
"leaderboard_foxify_only",
|
|
3163
|
+
false
|
|
3164
|
+
);
|
|
3165
|
+
return {
|
|
3166
|
+
foxifyOnly,
|
|
3167
|
+
setFoxifyOnly
|
|
3168
|
+
};
|
|
3169
|
+
};
|
|
3170
|
+
|
|
3171
|
+
// src/components/leaderboard/generalLeaderboard/generalLeaderboard.script.ts
|
|
3103
3172
|
var FilterDays2 = [1, 7, 30, 90];
|
|
3104
3173
|
function useGeneralLeaderboardScript(options) {
|
|
3105
3174
|
const { campaignDateRange, timeRange } = options || {};
|
|
@@ -3122,12 +3191,14 @@ function useGeneralLeaderboardScript(options) {
|
|
|
3122
3191
|
customTimeRange: parsedTimeRange
|
|
3123
3192
|
});
|
|
3124
3193
|
const searchState = useSearch();
|
|
3194
|
+
const foxifyState = useLeaderboardLocalStorage();
|
|
3125
3195
|
const useCampaignDateRange = useMemo(() => {
|
|
3126
3196
|
return !!campaignDateRange;
|
|
3127
3197
|
}, [campaignDateRange]);
|
|
3128
3198
|
return {
|
|
3129
3199
|
...filterState,
|
|
3130
3200
|
...searchState,
|
|
3201
|
+
...foxifyState,
|
|
3131
3202
|
activeTab,
|
|
3132
3203
|
onTabChange: setActiveTab,
|
|
3133
3204
|
useCampaignDateRange,
|
|
@@ -3281,6 +3352,17 @@ var LeaderboardFilter = (props) => {
|
|
|
3281
3352
|
value
|
|
3282
3353
|
);
|
|
3283
3354
|
});
|
|
3355
|
+
const foxifyFilterButton = /* @__PURE__ */ jsx(
|
|
3356
|
+
"button",
|
|
3357
|
+
{
|
|
3358
|
+
className: `oui-px-3 oui-py-1 oui-rounded oui-text-xs oui-font-medium oui-transition-colors oui-whitespace-nowrap ${props.foxifyOnly ? "oui-bg-primary oui-text-white" : "oui-bg-base-6 oui-text-base-contrast-60 hover:oui-bg-base-4 hover:oui-text-base-contrast"}`,
|
|
3359
|
+
onClick: () => {
|
|
3360
|
+
props.setFoxifyOnly(!props.foxifyOnly);
|
|
3361
|
+
},
|
|
3362
|
+
title: t("tradingLeaderboard.foxifyOnly.tooltip"),
|
|
3363
|
+
children: t("tradingLeaderboard.foxifyOnly")
|
|
3364
|
+
}
|
|
3365
|
+
);
|
|
3284
3366
|
if (isMobile) {
|
|
3285
3367
|
return /* @__PURE__ */ jsxs(
|
|
3286
3368
|
Flex,
|
|
@@ -3293,6 +3375,7 @@ var LeaderboardFilter = (props) => {
|
|
|
3293
3375
|
className: cn("oui-mobile-trading-leaderboard-ranking-filter"),
|
|
3294
3376
|
children: [
|
|
3295
3377
|
input,
|
|
3378
|
+
/* @__PURE__ */ jsx(Flex, { gap: 2, width: "100%", mt: 3, itemAlign: "center", children: foxifyFilterButton }),
|
|
3296
3379
|
useCampaignDateRange ? /* @__PURE__ */ jsx(Flex, { gap: 3, className: "oui-w-full oui-py-3", children: /* @__PURE__ */ jsx(ScrollIndicator$1, { className: "oui-w-full", children: weeklyView }) }) : /* @__PURE__ */ jsxs(Flex, { gap: 3, className: "oui-w-full", children: [
|
|
3297
3380
|
dateRangeView,
|
|
3298
3381
|
/* @__PURE__ */ jsx(ScrollIndicator$1, { className: "oui-w-full", children: /* @__PURE__ */ jsx(Flex, { gap: 3, children: filterDayView }) })
|
|
@@ -3314,7 +3397,10 @@ var LeaderboardFilter = (props) => {
|
|
|
3314
3397
|
!useCampaignDateRange && dateRangeView,
|
|
3315
3398
|
!useCampaignDateRange && filterDayView
|
|
3316
3399
|
] }),
|
|
3317
|
-
/* @__PURE__ */
|
|
3400
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, itemAlign: "center", children: [
|
|
3401
|
+
foxifyFilterButton,
|
|
3402
|
+
/* @__PURE__ */ jsx(Box, { width: 240, children: input })
|
|
3403
|
+
] })
|
|
3318
3404
|
]
|
|
3319
3405
|
}
|
|
3320
3406
|
);
|
|
@@ -3462,12 +3548,8 @@ var GeneralLeaderboard = (props) => {
|
|
|
3462
3548
|
props.activeTab === "volume" /* Volume */ ? "volume" : "pnl"
|
|
3463
3549
|
];
|
|
3464
3550
|
}
|
|
3465
|
-
const baseFields = [
|
|
3466
|
-
|
|
3467
|
-
"address",
|
|
3468
|
-
"volume",
|
|
3469
|
-
"pnl"
|
|
3470
|
-
];
|
|
3551
|
+
const baseFields = ["rank", "address"];
|
|
3552
|
+
baseFields.push("volume", "pnl");
|
|
3471
3553
|
if (props.leaderboardEndpoint) {
|
|
3472
3554
|
baseFields.push("points");
|
|
3473
3555
|
}
|
|
@@ -3508,7 +3590,8 @@ var GeneralLeaderboard = (props) => {
|
|
|
3508
3590
|
address: props.searchValue,
|
|
3509
3591
|
sortKey: props.activeTab === "volume" /* Volume */ ? "perp_volume" : "realized_pnl",
|
|
3510
3592
|
fields,
|
|
3511
|
-
leaderboardEndpoint: props.leaderboardEndpoint
|
|
3593
|
+
leaderboardEndpoint: props.leaderboardEndpoint,
|
|
3594
|
+
foxifyOnly: props.foxifyOnly
|
|
3512
3595
|
}
|
|
3513
3596
|
) })
|
|
3514
3597
|
]
|
|
@@ -3540,7 +3623,8 @@ var GeneralLeaderboard = (props) => {
|
|
|
3540
3623
|
dateRange: props.dateRange,
|
|
3541
3624
|
address: props.searchValue,
|
|
3542
3625
|
fields,
|
|
3543
|
-
leaderboardEndpoint: props.leaderboardEndpoint
|
|
3626
|
+
leaderboardEndpoint: props.leaderboardEndpoint,
|
|
3627
|
+
foxifyOnly: props.foxifyOnly
|
|
3544
3628
|
}
|
|
3545
3629
|
) })
|
|
3546
3630
|
]
|