@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.d.mts CHANGED
@@ -168,7 +168,7 @@ type TradingListWidgetProps = Pick<TradingListProps, "style" | "className">;
168
168
  */
169
169
  declare const TradingListWidget: FC<TradingListWidgetProps>;
170
170
 
171
- type RankingColumnFields = "rank" | "address" | "volume" | "pnl" | "rewards" | "points";
171
+ type RankingColumnFields = "rank" | "address" | "tier" | "volume" | "pnl" | "rewards" | "points";
172
172
 
173
173
  type ListStyle = "disc" | "decimal" | "none" | "circle" | "square" | "decimal-leading-zero" | "lower-alpha" | "upper-alpha" | "lower-roman" | "upper-roman";
174
174
  type DescriptionItem = {
@@ -421,6 +421,33 @@ type GeneralRankingData = {
421
421
  perp_volume: number;
422
422
  realized_pnl: number;
423
423
  total_fee: number;
424
+ vip_tier?: string;
425
+ vipTier?: string;
426
+ vip_tier_name?: string;
427
+ vipTierName?: string;
428
+ vip_badge_url?: string;
429
+ vipBadgeUrl?: string;
430
+ vip_tier_image?: string;
431
+ vipTierImage?: string;
432
+ vip_tier_badge?: string;
433
+ vipTierBadge?: string;
434
+ tier?: string | {
435
+ name?: string;
436
+ label?: string;
437
+ tier?: string;
438
+ badge_url?: string;
439
+ badgeUrl?: string;
440
+ image?: string;
441
+ imageUrl?: string;
442
+ };
443
+ tier_name?: string;
444
+ tierName?: string;
445
+ tier_label?: string;
446
+ tierLabel?: string;
447
+ tier_image?: string;
448
+ tierImage?: string;
449
+ tier_badge_url?: string;
450
+ tierBadgeUrl?: string;
424
451
  key?: string;
425
452
  rank?: number | string;
426
453
  volume?: number;
@@ -433,6 +460,7 @@ type GeneralRankingScriptOptions = {
433
460
  address?: string;
434
461
  sortKey?: "perp_volume" | "realized_pnl";
435
462
  leaderboardEndpoint?: string;
463
+ foxifyOnly?: boolean;
436
464
  };
437
465
  declare function useGeneralRankingScript(options?: GeneralRankingScriptOptions): {
438
466
  pagination: _kodiak_finance_orderly_ui.PaginationMeta;
@@ -493,6 +521,8 @@ declare function useGeneralLeaderboardScript(options?: GeneralLeaderboardScriptO
493
521
  useCampaignDateRange: boolean;
494
522
  weeklyRanges: WeeklyDateRange[];
495
523
  currentOrAllTimeRange: WeeklyDateRange | undefined;
524
+ foxifyOnly: any;
525
+ setFoxifyOnly: (value: boolean) => void;
496
526
  searchValue: string;
497
527
  onSearchValueChange: (value: string) => void;
498
528
  clearSearchValue: () => void;
package/dist/index.d.ts CHANGED
@@ -168,7 +168,7 @@ type TradingListWidgetProps = Pick<TradingListProps, "style" | "className">;
168
168
  */
169
169
  declare const TradingListWidget: FC<TradingListWidgetProps>;
170
170
 
171
- type RankingColumnFields = "rank" | "address" | "volume" | "pnl" | "rewards" | "points";
171
+ type RankingColumnFields = "rank" | "address" | "tier" | "volume" | "pnl" | "rewards" | "points";
172
172
 
173
173
  type ListStyle = "disc" | "decimal" | "none" | "circle" | "square" | "decimal-leading-zero" | "lower-alpha" | "upper-alpha" | "lower-roman" | "upper-roman";
174
174
  type DescriptionItem = {
@@ -421,6 +421,33 @@ type GeneralRankingData = {
421
421
  perp_volume: number;
422
422
  realized_pnl: number;
423
423
  total_fee: number;
424
+ vip_tier?: string;
425
+ vipTier?: string;
426
+ vip_tier_name?: string;
427
+ vipTierName?: string;
428
+ vip_badge_url?: string;
429
+ vipBadgeUrl?: string;
430
+ vip_tier_image?: string;
431
+ vipTierImage?: string;
432
+ vip_tier_badge?: string;
433
+ vipTierBadge?: string;
434
+ tier?: string | {
435
+ name?: string;
436
+ label?: string;
437
+ tier?: string;
438
+ badge_url?: string;
439
+ badgeUrl?: string;
440
+ image?: string;
441
+ imageUrl?: string;
442
+ };
443
+ tier_name?: string;
444
+ tierName?: string;
445
+ tier_label?: string;
446
+ tierLabel?: string;
447
+ tier_image?: string;
448
+ tierImage?: string;
449
+ tier_badge_url?: string;
450
+ tierBadgeUrl?: string;
424
451
  key?: string;
425
452
  rank?: number | string;
426
453
  volume?: number;
@@ -433,6 +460,7 @@ type GeneralRankingScriptOptions = {
433
460
  address?: string;
434
461
  sortKey?: "perp_volume" | "realized_pnl";
435
462
  leaderboardEndpoint?: string;
463
+ foxifyOnly?: boolean;
436
464
  };
437
465
  declare function useGeneralRankingScript(options?: GeneralRankingScriptOptions): {
438
466
  pagination: _kodiak_finance_orderly_ui.PaginationMeta;
@@ -493,6 +521,8 @@ declare function useGeneralLeaderboardScript(options?: GeneralLeaderboardScriptO
493
521
  useCampaignDateRange: boolean;
494
522
  weeklyRanges: WeeklyDateRange[];
495
523
  currentOrAllTimeRange: WeeklyDateRange | undefined;
524
+ foxifyOnly: any;
525
+ setFoxifyOnly: (value: boolean) => void;
496
526
  searchValue: string;
497
527
  onSearchValueChange: (value: string) => void;
498
528
  clearSearchValue: () => void;
package/dist/index.js CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  var dateFns = require('date-fns');
4
4
  var react = require('react');
5
+ var orderlyHooks = require('@kodiak-finance/orderly-hooks');
5
6
  var orderlyI18n = require('@kodiak-finance/orderly-i18n');
6
7
  var orderlyUi = require('@kodiak-finance/orderly-ui');
7
8
  var jsxRuntime = require('react/jsx-runtime');
8
- var orderlyHooks = require('@kodiak-finance/orderly-hooks');
9
9
  var lucideReact = require('lucide-react');
10
10
  var orderlyTypes = require('@kodiak-finance/orderly-types');
11
11
  var ramda = require('ramda');
@@ -237,7 +237,7 @@ var init_util = __esm({
237
237
  "src/components/ranking/shared/util.ts"() {
238
238
  }
239
239
  });
240
- var useRankingColumns, FirstRankIcon, SecondRankIcon, ThirdRankIcon, PnLColumnTitle, VolumeColumnTitle, PointsColumnTitle;
240
+ var useRankingColumns, getTierInfo, TierBadge, FirstRankIcon, SecondRankIcon, ThirdRankIcon, PnLColumnTitle, VolumeColumnTitle, PointsColumnTitle;
241
241
  var init_column = __esm({
242
242
  "src/components/ranking/shared/column.tsx"() {
243
243
  init_first_badge();
@@ -246,6 +246,7 @@ var init_column = __esm({
246
246
  init_util();
247
247
  useRankingColumns = (fields, address, enableSort, type) => {
248
248
  const { t } = orderlyI18n.useTranslation();
249
+ const brokerId = orderlyHooks.useConfig("brokerId");
249
250
  const { isMobile } = orderlyUi.useScreen();
250
251
  return react.useMemo(() => {
251
252
  const columns = [
@@ -299,11 +300,11 @@ var init_column = __esm({
299
300
  if (!isYou) {
300
301
  if (record.rank === 1) ; else if (record.rank === 2) ; else if (record.rank === 3) ;
301
302
  }
302
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(
303
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex oui-flex-col", children: /* @__PURE__ */ jsxRuntime.jsxs(
303
304
  "a",
304
305
  {
305
306
  className: "oui-flex oui-items-start oui-gap-1",
306
- href: `https://orderly-dashboard.orderly.network/address/${value}?broker_id=${record.broker_id}`,
307
+ href: `https://orderly-dashboard.orderly.network/address/${value}${record.broker_id || brokerId ? `?broker_id=${record.broker_id || brokerId}` : ""}`,
307
308
  target: "_blank",
308
309
  rel: "noreferrer",
309
310
  children: [
@@ -330,6 +331,18 @@ var init_column = __esm({
330
331
  },
331
332
  width: 90
332
333
  },
334
+ {
335
+ title: "VIP Tier",
336
+ dataIndex: "tier",
337
+ render: (_value, record) => {
338
+ const tierInfo = getTierInfo(record);
339
+ if (!tierInfo?.label) {
340
+ return "-";
341
+ }
342
+ return /* @__PURE__ */ jsxRuntime.jsx(TierBadge, { label: tierInfo.label, imageUrl: tierInfo.imageUrl });
343
+ },
344
+ width: 120
345
+ },
333
346
  {
334
347
  title: /* @__PURE__ */ jsxRuntime.jsx(VolumeColumnTitle, {}),
335
348
  dataIndex: "volume",
@@ -395,6 +408,46 @@ var init_column = __esm({
395
408
  );
396
409
  }, [t, isMobile, address, fields, enableSort, type]);
397
410
  };
411
+ getTierInfo = (record) => {
412
+ if (!record) {
413
+ return {};
414
+ }
415
+ const tierValue = record.tier;
416
+ if (tierValue && typeof tierValue === "object") {
417
+ return {
418
+ label: tierValue.name || tierValue.label || tierValue.tier,
419
+ imageUrl: tierValue.badge_url || tierValue.badgeUrl || tierValue.image || tierValue.imageUrl
420
+ };
421
+ }
422
+ 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;
423
+ 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;
424
+ return { label, imageUrl };
425
+ };
426
+ TierBadge = ({
427
+ label,
428
+ imageUrl,
429
+ className
430
+ }) => {
431
+ return /* @__PURE__ */ jsxRuntime.jsxs(
432
+ orderlyUi.Flex,
433
+ {
434
+ itemAlign: "center",
435
+ gap: 1,
436
+ className: orderlyUi.cn("oui-text-2xs", className),
437
+ children: [
438
+ imageUrl && /* @__PURE__ */ jsxRuntime.jsx(
439
+ "img",
440
+ {
441
+ src: imageUrl,
442
+ alt: `${label} badge`,
443
+ className: "oui-h-4 oui-w-4 oui-object-contain"
444
+ }
445
+ ),
446
+ /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Text, { className: "oui-text-2xs", children: label })
447
+ ]
448
+ }
449
+ );
450
+ };
398
451
  FirstRankIcon = () => {
399
452
  return /* @__PURE__ */ jsxRuntime.jsxs(
400
453
  "svg",
@@ -665,7 +718,8 @@ function useGeneralRankingScript(options) {
665
718
  dateRange = exports.getDateRange(90),
666
719
  address: searchValue,
667
720
  sortKey = "perp_volume",
668
- leaderboardEndpoint
721
+ leaderboardEndpoint,
722
+ foxifyOnly = false
669
723
  } = options || {};
670
724
  const [initialSort] = react.useState({
671
725
  sortKey,
@@ -713,6 +767,9 @@ function useGeneralRankingScript(options) {
713
767
  if (args.address) {
714
768
  searchParams.set("address", args.address);
715
769
  }
770
+ if (foxifyOnly) {
771
+ searchParams.set("foxify_only", "true");
772
+ }
716
773
  const baseUrl = leaderboardEndpoint || `/v1/broker/leaderboard/daily`;
717
774
  return `${baseUrl}?${searchParams.toString()}`;
718
775
  };
@@ -1027,12 +1084,13 @@ var init_generalRanking_widget = __esm({
1027
1084
  init_ranking_ui();
1028
1085
  init_generalRanking_script();
1029
1086
  exports.GeneralRankingWidget = (props) => {
1030
- const { dateRange, address, fields, sortKey, leaderboardEndpoint, ...rest } = props;
1087
+ const { dateRange, address, fields, sortKey, leaderboardEndpoint, foxifyOnly, ...rest } = props;
1031
1088
  const state = useGeneralRankingScript({
1032
1089
  dateRange,
1033
1090
  address,
1034
1091
  sortKey,
1035
- leaderboardEndpoint
1092
+ leaderboardEndpoint,
1093
+ foxifyOnly
1036
1094
  });
1037
1095
  return /* @__PURE__ */ jsxRuntime.jsx(exports.Ranking, { ...state, ...rest, fields, type: "general" });
1038
1096
  };
@@ -1068,7 +1126,7 @@ var TradingLeaderboardProvider = (props) => {
1068
1126
  var useTradingLeaderboardContext = () => {
1069
1127
  return react.useContext(TradingLeaderboardContext);
1070
1128
  };
1071
- var API_BASE = "https://backend.kodiak.finance/orderly/stats";
1129
+ var API_BASE = "https://staging.backend.kodiak.finance/orderly/stats";
1072
1130
  var formatDateLocal = (date) => {
1073
1131
  const year = date.getFullYear();
1074
1132
  const month = String(date.getMonth() + 1).padStart(2, "0");
@@ -3101,6 +3159,18 @@ var LeaderboardTab = /* @__PURE__ */ ((LeaderboardTab2) => {
3101
3159
 
3102
3160
  // src/components/leaderboard/generalLeaderboard/generalLeaderboard.script.ts
3103
3161
  init_utils();
3162
+ var useLeaderboardLocalStorage = () => {
3163
+ const [foxifyOnly, setFoxifyOnly] = orderlyHooks.useLocalStorage(
3164
+ "leaderboard_foxify_only",
3165
+ false
3166
+ );
3167
+ return {
3168
+ foxifyOnly,
3169
+ setFoxifyOnly
3170
+ };
3171
+ };
3172
+
3173
+ // src/components/leaderboard/generalLeaderboard/generalLeaderboard.script.ts
3104
3174
  var FilterDays2 = [1, 7, 30, 90];
3105
3175
  function useGeneralLeaderboardScript(options) {
3106
3176
  const { campaignDateRange, timeRange } = options || {};
@@ -3123,12 +3193,14 @@ function useGeneralLeaderboardScript(options) {
3123
3193
  customTimeRange: parsedTimeRange
3124
3194
  });
3125
3195
  const searchState = useSearch();
3196
+ const foxifyState = useLeaderboardLocalStorage();
3126
3197
  const useCampaignDateRange = react.useMemo(() => {
3127
3198
  return !!campaignDateRange;
3128
3199
  }, [campaignDateRange]);
3129
3200
  return {
3130
3201
  ...filterState,
3131
3202
  ...searchState,
3203
+ ...foxifyState,
3132
3204
  activeTab,
3133
3205
  onTabChange: setActiveTab,
3134
3206
  useCampaignDateRange,
@@ -3282,6 +3354,17 @@ var LeaderboardFilter = (props) => {
3282
3354
  value
3283
3355
  );
3284
3356
  });
3357
+ const foxifyFilterButton = /* @__PURE__ */ jsxRuntime.jsx(
3358
+ "button",
3359
+ {
3360
+ 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"}`,
3361
+ onClick: () => {
3362
+ props.setFoxifyOnly(!props.foxifyOnly);
3363
+ },
3364
+ title: t("tradingLeaderboard.foxifyOnly.tooltip"),
3365
+ children: t("tradingLeaderboard.foxifyOnly")
3366
+ }
3367
+ );
3285
3368
  if (isMobile) {
3286
3369
  return /* @__PURE__ */ jsxRuntime.jsxs(
3287
3370
  orderlyUi.Flex,
@@ -3294,6 +3377,7 @@ var LeaderboardFilter = (props) => {
3294
3377
  className: orderlyUi.cn("oui-mobile-trading-leaderboard-ranking-filter"),
3295
3378
  children: [
3296
3379
  input,
3380
+ /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Flex, { gap: 2, width: "100%", mt: 3, itemAlign: "center", children: foxifyFilterButton }),
3297
3381
  useCampaignDateRange ? /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Flex, { gap: 3, className: "oui-w-full oui-py-3", children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.ScrollIndicator, { className: "oui-w-full", children: weeklyView }) }) : /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { gap: 3, className: "oui-w-full", children: [
3298
3382
  dateRangeView,
3299
3383
  /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.ScrollIndicator, { className: "oui-w-full", children: /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Flex, { gap: 3, children: filterDayView }) })
@@ -3315,7 +3399,10 @@ var LeaderboardFilter = (props) => {
3315
3399
  !useCampaignDateRange && dateRangeView,
3316
3400
  !useCampaignDateRange && filterDayView
3317
3401
  ] }),
3318
- /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Box, { width: 240, children: input })
3402
+ /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { gap: 2, itemAlign: "center", children: [
3403
+ foxifyFilterButton,
3404
+ /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Box, { width: 240, children: input })
3405
+ ] })
3319
3406
  ]
3320
3407
  }
3321
3408
  );
@@ -3463,12 +3550,8 @@ var GeneralLeaderboard = (props) => {
3463
3550
  props.activeTab === "volume" /* Volume */ ? "volume" : "pnl"
3464
3551
  ];
3465
3552
  }
3466
- const baseFields = [
3467
- "rank",
3468
- "address",
3469
- "volume",
3470
- "pnl"
3471
- ];
3553
+ const baseFields = ["rank", "address"];
3554
+ baseFields.push("volume", "pnl");
3472
3555
  if (props.leaderboardEndpoint) {
3473
3556
  baseFields.push("points");
3474
3557
  }
@@ -3509,7 +3592,8 @@ var GeneralLeaderboard = (props) => {
3509
3592
  address: props.searchValue,
3510
3593
  sortKey: props.activeTab === "volume" /* Volume */ ? "perp_volume" : "realized_pnl",
3511
3594
  fields,
3512
- leaderboardEndpoint: props.leaderboardEndpoint
3595
+ leaderboardEndpoint: props.leaderboardEndpoint,
3596
+ foxifyOnly: props.foxifyOnly
3513
3597
  }
3514
3598
  ) })
3515
3599
  ]
@@ -3541,7 +3625,8 @@ var GeneralLeaderboard = (props) => {
3541
3625
  dateRange: props.dateRange,
3542
3626
  address: props.searchValue,
3543
3627
  fields,
3544
- leaderboardEndpoint: props.leaderboardEndpoint
3628
+ leaderboardEndpoint: props.leaderboardEndpoint,
3629
+ foxifyOnly: props.foxifyOnly
3545
3630
  }
3546
3631
  ) })
3547
3632
  ]
@@ -5902,6 +5987,7 @@ function getCurrentAddressRowKey2(address) {
5902
5987
  }
5903
5988
  var useRankingColumns2 = (fields, address, enableSort, type) => {
5904
5989
  const { t } = orderlyI18n.useTranslation();
5990
+ const brokerId = orderlyHooks.useConfig("brokerId");
5905
5991
  const { isMobile } = orderlyUi.useScreen();
5906
5992
  return react.useMemo(() => {
5907
5993
  const columns = [
@@ -5959,7 +6045,7 @@ var useRankingColumns2 = (fields, address, enableSort, type) => {
5959
6045
  "a",
5960
6046
  {
5961
6047
  className: "oui-flex oui-items-start oui-gap-1",
5962
- href: `https://orderly-dashboard.orderly.network/address/${value}?broker_id=${record.broker_id}`,
6048
+ href: `https://orderly-dashboard.orderly.network/address/${value}${record.broker_id || brokerId ? `?broker_id=${record.broker_id || brokerId}` : ""}`,
5963
6049
  target: "_blank",
5964
6050
  rel: "noreferrer",
5965
6051
  children: [