@kodiak-finance/orderly-trading-leaderboard 2.8.22-beta.0 → 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.mjs CHANGED
@@ -1,9 +1,9 @@
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
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';
5
6
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
6
- import { useAccount, useConfig, useQuery, useInfiniteQuery, useSWR, useTrack, usePrivateQuery, noCacheConfig, useMemoizedFn, useMutation } from '@kodiak-finance/orderly-hooks';
7
7
  import { TrendingUp, TrendingDown, Wallet, DollarSign, BarChart3 } from 'lucide-react';
8
8
  import { TrackerEventName, AccountStatusEnum, EMPTY_LIST } from '@kodiak-finance/orderly-types';
9
9
  import { sortWith, descend, difference } from 'ramda';
@@ -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();
@@ -244,6 +244,7 @@ var init_column = __esm({
244
244
  init_util();
245
245
  useRankingColumns = (fields, address, enableSort, type) => {
246
246
  const { t } = useTranslation();
247
+ const brokerId = useConfig("brokerId");
247
248
  const { isMobile } = useScreen();
248
249
  return useMemo(() => {
249
250
  const columns = [
@@ -297,11 +298,11 @@ var init_column = __esm({
297
298
  if (!isYou) {
298
299
  if (record.rank === 1) ; else if (record.rank === 2) ; else if (record.rank === 3) ;
299
300
  }
300
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
301
+ return /* @__PURE__ */ jsx("div", { className: "oui-flex oui-flex-col", children: /* @__PURE__ */ jsxs(
301
302
  "a",
302
303
  {
303
304
  className: "oui-flex oui-items-start oui-gap-1",
304
- href: `https://orderly-dashboard.orderly.network/address/${value}?broker_id=${record.broker_id}`,
305
+ href: `https://orderly-dashboard.orderly.network/address/${value}${record.broker_id || brokerId ? `?broker_id=${record.broker_id || brokerId}` : ""}`,
305
306
  target: "_blank",
306
307
  rel: "noreferrer",
307
308
  children: [
@@ -328,6 +329,18 @@ var init_column = __esm({
328
329
  },
329
330
  width: 90
330
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
+ },
331
344
  {
332
345
  title: /* @__PURE__ */ jsx(VolumeColumnTitle, {}),
333
346
  dataIndex: "volume",
@@ -393,6 +406,46 @@ var init_column = __esm({
393
406
  );
394
407
  }, [t, isMobile, address, fields, enableSort, type]);
395
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
+ };
396
449
  FirstRankIcon = () => {
397
450
  return /* @__PURE__ */ jsxs(
398
451
  "svg",
@@ -663,7 +716,8 @@ function useGeneralRankingScript(options) {
663
716
  dateRange = getDateRange(90),
664
717
  address: searchValue,
665
718
  sortKey = "perp_volume",
666
- leaderboardEndpoint
719
+ leaderboardEndpoint,
720
+ foxifyOnly = false
667
721
  } = options || {};
668
722
  const [initialSort] = useState({
669
723
  sortKey,
@@ -711,6 +765,9 @@ function useGeneralRankingScript(options) {
711
765
  if (args.address) {
712
766
  searchParams.set("address", args.address);
713
767
  }
768
+ if (foxifyOnly) {
769
+ searchParams.set("foxify_only", "true");
770
+ }
714
771
  const baseUrl = leaderboardEndpoint || `/v1/broker/leaderboard/daily`;
715
772
  return `${baseUrl}?${searchParams.toString()}`;
716
773
  };
@@ -1025,12 +1082,13 @@ var init_generalRanking_widget = __esm({
1025
1082
  init_ranking_ui();
1026
1083
  init_generalRanking_script();
1027
1084
  GeneralRankingWidget = (props) => {
1028
- const { dateRange, address, fields, sortKey, leaderboardEndpoint, ...rest } = props;
1085
+ const { dateRange, address, fields, sortKey, leaderboardEndpoint, foxifyOnly, ...rest } = props;
1029
1086
  const state = useGeneralRankingScript({
1030
1087
  dateRange,
1031
1088
  address,
1032
1089
  sortKey,
1033
- leaderboardEndpoint
1090
+ leaderboardEndpoint,
1091
+ foxifyOnly
1034
1092
  });
1035
1093
  return /* @__PURE__ */ jsx(Ranking, { ...state, ...rest, fields, type: "general" });
1036
1094
  };
@@ -1066,7 +1124,7 @@ var TradingLeaderboardProvider = (props) => {
1066
1124
  var useTradingLeaderboardContext = () => {
1067
1125
  return useContext(TradingLeaderboardContext);
1068
1126
  };
1069
- var API_BASE = "https://backend.kodiak.finance/orderly/stats";
1127
+ var API_BASE = "https://staging.backend.kodiak.finance/orderly/stats";
1070
1128
  var formatDateLocal = (date) => {
1071
1129
  const year = date.getFullYear();
1072
1130
  const month = String(date.getMonth() + 1).padStart(2, "0");
@@ -3099,6 +3157,18 @@ var LeaderboardTab = /* @__PURE__ */ ((LeaderboardTab2) => {
3099
3157
 
3100
3158
  // src/components/leaderboard/generalLeaderboard/generalLeaderboard.script.ts
3101
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
3102
3172
  var FilterDays2 = [1, 7, 30, 90];
3103
3173
  function useGeneralLeaderboardScript(options) {
3104
3174
  const { campaignDateRange, timeRange } = options || {};
@@ -3121,12 +3191,14 @@ function useGeneralLeaderboardScript(options) {
3121
3191
  customTimeRange: parsedTimeRange
3122
3192
  });
3123
3193
  const searchState = useSearch();
3194
+ const foxifyState = useLeaderboardLocalStorage();
3124
3195
  const useCampaignDateRange = useMemo(() => {
3125
3196
  return !!campaignDateRange;
3126
3197
  }, [campaignDateRange]);
3127
3198
  return {
3128
3199
  ...filterState,
3129
3200
  ...searchState,
3201
+ ...foxifyState,
3130
3202
  activeTab,
3131
3203
  onTabChange: setActiveTab,
3132
3204
  useCampaignDateRange,
@@ -3280,6 +3352,17 @@ var LeaderboardFilter = (props) => {
3280
3352
  value
3281
3353
  );
3282
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
+ );
3283
3366
  if (isMobile) {
3284
3367
  return /* @__PURE__ */ jsxs(
3285
3368
  Flex,
@@ -3292,6 +3375,7 @@ var LeaderboardFilter = (props) => {
3292
3375
  className: cn("oui-mobile-trading-leaderboard-ranking-filter"),
3293
3376
  children: [
3294
3377
  input,
3378
+ /* @__PURE__ */ jsx(Flex, { gap: 2, width: "100%", mt: 3, itemAlign: "center", children: foxifyFilterButton }),
3295
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: [
3296
3380
  dateRangeView,
3297
3381
  /* @__PURE__ */ jsx(ScrollIndicator$1, { className: "oui-w-full", children: /* @__PURE__ */ jsx(Flex, { gap: 3, children: filterDayView }) })
@@ -3313,7 +3397,10 @@ var LeaderboardFilter = (props) => {
3313
3397
  !useCampaignDateRange && dateRangeView,
3314
3398
  !useCampaignDateRange && filterDayView
3315
3399
  ] }),
3316
- /* @__PURE__ */ jsx(Box, { width: 240, children: input })
3400
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, itemAlign: "center", children: [
3401
+ foxifyFilterButton,
3402
+ /* @__PURE__ */ jsx(Box, { width: 240, children: input })
3403
+ ] })
3317
3404
  ]
3318
3405
  }
3319
3406
  );
@@ -3461,12 +3548,8 @@ var GeneralLeaderboard = (props) => {
3461
3548
  props.activeTab === "volume" /* Volume */ ? "volume" : "pnl"
3462
3549
  ];
3463
3550
  }
3464
- const baseFields = [
3465
- "rank",
3466
- "address",
3467
- "volume",
3468
- "pnl"
3469
- ];
3551
+ const baseFields = ["rank", "address"];
3552
+ baseFields.push("volume", "pnl");
3470
3553
  if (props.leaderboardEndpoint) {
3471
3554
  baseFields.push("points");
3472
3555
  }
@@ -3507,7 +3590,8 @@ var GeneralLeaderboard = (props) => {
3507
3590
  address: props.searchValue,
3508
3591
  sortKey: props.activeTab === "volume" /* Volume */ ? "perp_volume" : "realized_pnl",
3509
3592
  fields,
3510
- leaderboardEndpoint: props.leaderboardEndpoint
3593
+ leaderboardEndpoint: props.leaderboardEndpoint,
3594
+ foxifyOnly: props.foxifyOnly
3511
3595
  }
3512
3596
  ) })
3513
3597
  ]
@@ -3539,7 +3623,8 @@ var GeneralLeaderboard = (props) => {
3539
3623
  dateRange: props.dateRange,
3540
3624
  address: props.searchValue,
3541
3625
  fields,
3542
- leaderboardEndpoint: props.leaderboardEndpoint
3626
+ leaderboardEndpoint: props.leaderboardEndpoint,
3627
+ foxifyOnly: props.foxifyOnly
3543
3628
  }
3544
3629
  ) })
3545
3630
  ]
@@ -5900,6 +5985,7 @@ function getCurrentAddressRowKey2(address) {
5900
5985
  }
5901
5986
  var useRankingColumns2 = (fields, address, enableSort, type) => {
5902
5987
  const { t } = useTranslation();
5988
+ const brokerId = useConfig("brokerId");
5903
5989
  const { isMobile } = useScreen();
5904
5990
  return useMemo(() => {
5905
5991
  const columns = [
@@ -5957,7 +6043,7 @@ var useRankingColumns2 = (fields, address, enableSort, type) => {
5957
6043
  "a",
5958
6044
  {
5959
6045
  className: "oui-flex oui-items-start oui-gap-1",
5960
- href: `https://orderly-dashboard.orderly.network/address/${value}?broker_id=${record.broker_id}`,
6046
+ href: `https://orderly-dashboard.orderly.network/address/${value}${record.broker_id || brokerId ? `?broker_id=${record.broker_id || brokerId}` : ""}`,
5961
6047
  target: "_blank",
5962
6048
  rel: "noreferrer",
5963
6049
  children: [