Skip to content

Commit 9732913

Browse files
authored
SOV-4467: Spice Leaderboard adjustments for Season 3 (#1016)
* feat: spice season 3 update * Create spotty-poems-happen.md
1 parent b41a6af commit 9732913

File tree

6 files changed

+92
-32
lines changed

6 files changed

+92
-32
lines changed

.changeset/spotty-poems-happen.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"frontend": patch
3+
---
4+
5+
SOV-4467: Spice Leaderboard adjustments for Season 3

apps/frontend/src/app/3_organisms/Header/Header.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const Header: FC = () => {
7474
text={t(translations.header.nav.spicePoints)}
7575
style={ButtonStyle.primary}
7676
className="bg-[#24BFB74D]/[0.3] border-[#24BFB74D]/[0.3] hover:bg-[#24BFB74D]"
77-
onClick={() => navigate('/claim-lp')}
77+
onClick={() => navigate('/bob-lp-points')}
7878
/>
7979
)}
8080
</ol>

apps/frontend/src/app/5_pages/LeaderboardPointsPage/LeaderboardPointsPage.types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ export type UserDeposit = {
1717
export type UserPoints = {
1818
wallet: string;
1919
points: number;
20+
s3Points: number;
21+
total: number;
2022
};

apps/frontend/src/app/5_pages/LeaderboardPointsPage/components/LeaderboardPoints/LeaderboardPoints.constants.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import { translations } from '../../../../../locales/i18n';
1111
export const DATA_ENDPOINT_URL =
1212
'https://season2-spice-points-bucket.s3.us-east-2.amazonaws.com/Total_S1&S2_Spice_Leaderboard.json';
1313

14+
export const S3_DATA_ENDPOINT_URL =
15+
'https://season2-spice-points-bucket.s3.us-east-2.amazonaws.com/Total_S3_Spice_Leaderboard.json';
16+
1417
export const PAGE_SIZE = 50;
1518

1619
export const COLUMNS_CONFIG = (isSingleUser: boolean = false) => [
@@ -38,4 +41,16 @@ export const COLUMNS_CONFIG = (isSingleUser: boolean = false) => [
3841
cellRenderer: user => <AmountRenderer value={user.points} />,
3942
sampleData: '111,111,111.1111',
4043
},
44+
{
45+
id: '',
46+
title: t(translations.leaderboardPointsPage.table.spice3),
47+
cellRenderer: user => <AmountRenderer value={user.s3Points} />,
48+
sampleData: '111,111,111.1111',
49+
},
50+
{
51+
id: '',
52+
title: t(translations.leaderboardPointsPage.table.total),
53+
cellRenderer: user => <AmountRenderer value={user.total} />,
54+
sampleData: '111,111,111.1111',
55+
},
4156
];

apps/frontend/src/app/5_pages/LeaderboardPointsPage/components/LeaderboardPoints/hooks/useGetPoints.ts

+65-29
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,102 @@
1-
import { useEffect, useMemo, useState } from 'react';
1+
import { useMemo } from 'react';
22

3+
import { RSK_CHAIN_ID } from '../../../../../../config/chains';
4+
5+
import { useCacheCall } from '../../../../../../hooks';
36
import { useAccount } from '../../../../../../hooks/useAccount';
47
import { areAddressesEqual } from '../../../../../../utils/helpers';
58
import { UserPoints } from '../../../LeaderboardPointsPage.types';
6-
import { DATA_ENDPOINT_URL } from '../LeaderboardPoints.constants';
9+
import {
10+
DATA_ENDPOINT_URL,
11+
S3_DATA_ENDPOINT_URL,
12+
} from '../LeaderboardPoints.constants';
713

814
export const useGetPoints = () => {
915
const { account } = useAccount();
1016

11-
const [data, setData] = useState<UserPoints[]>([]);
17+
const { value: data } = useCacheCall(
18+
'bob-lp-points',
19+
RSK_CHAIN_ID,
20+
async () => {
21+
const [data, s3Data] = await Promise.all([
22+
fetch(DATA_ENDPOINT_URL).then(response => response?.json()),
23+
fetch(S3_DATA_ENDPOINT_URL).then(response => response?.json()),
24+
]);
25+
26+
const result: { [key: string]: UserPoints } = {};
27+
28+
data.forEach(user => {
29+
const points = parseFloat(user.points.replace(/,/g, ''));
30+
31+
result[user.toAddress.toLowerCase()] = {
32+
wallet: user.toAddress,
33+
points,
34+
s3Points: 0,
35+
total: points,
36+
};
37+
});
1238

13-
useEffect(() => {
14-
if (!data || data.length === 0) {
15-
fetch(DATA_ENDPOINT_URL)
16-
.then(response => response?.json())
17-
.then(data => {
18-
if (!data) {
19-
return;
20-
}
39+
s3Data.forEach(user => {
40+
const s3Points = parseFloat(user.points.replace(/,/g, ''));
41+
const key = user.toAddress.toLowerCase();
2142

22-
const result: UserPoints[] = data.map(user => ({
43+
if (!(key in result)) {
44+
result[key] = {
2345
wallet: user.toAddress,
24-
points: parseFloat(user.points.replace(/,/g, '')),
25-
}));
46+
points: 0,
47+
s3Points,
48+
total: s3Points,
49+
};
50+
} else {
51+
const points = result[key].points;
2652

27-
setData(result);
28-
});
29-
}
30-
}, [data]);
53+
result[key] = {
54+
wallet: user.toAddress,
55+
points,
56+
s3Points,
57+
total: points + s3Points,
58+
};
59+
}
60+
});
3161

32-
const sortedUsers = useMemo(() => {
33-
return data.sort((a, b) => b.points - a.points);
34-
}, [data]);
62+
return Object.keys(result)
63+
.map(key => ({ ...result[key] }))
64+
.sort((user1, user2) => (user1.total < user2.total ? 1 : -1));
65+
},
66+
[],
67+
[],
68+
);
3569

3670
const userIndex = useMemo(() => {
37-
return sortedUsers.findIndex(user =>
38-
areAddressesEqual(user.wallet, account),
39-
);
40-
}, [sortedUsers, account]);
71+
return data.findIndex(user => areAddressesEqual(user.wallet, account));
72+
}, [data, account]);
4173

4274
const connectedWalletPoints = useMemo(() => {
4375
if (userIndex !== -1) {
44-
const { wallet, points } = sortedUsers[userIndex];
76+
const { wallet, points, s3Points, total } = data[userIndex];
4577
return [
4678
{
4779
id: userIndex + 1,
4880
wallet,
4981
points,
82+
s3Points,
83+
total,
5084
},
5185
];
5286
}
5387
return [];
54-
}, [sortedUsers, userIndex]);
88+
}, [data, userIndex]);
5589

5690
const points = useMemo(
5791
() =>
58-
sortedUsers.map(({ wallet, points }, index) => ({
92+
data.map(({ wallet, points, s3Points, total }, index) => ({
5993
id: index + 1,
6094
wallet,
6195
points,
96+
s3Points,
97+
total,
6298
})),
63-
[sortedUsers],
99+
[data],
64100
);
65101

66102
return {

apps/frontend/src/locales/en/translations.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@
938938
"title": "Spice Leaderboard - Sovryn"
939939
},
940940
"title": "Spice Leaderboard",
941-
"description1": "Spice Points are rewards earned by providing liquidity and staking SOV on the Sovryn DEX on the BOB chain. These points track user contributions and engagement, helping determine future rewards allocated by the BOB team. This leaderboard displays only the rewards distributed by Sovryn (combined Season 1 &2) and allows you to check your accumulated points and current position.",
941+
"description1": "Spice Points are rewards earned by providing liquidity and staking SOV on the Sovryn DEX on the BOB chain. These points track user contributions and engagement, helping determine future rewards allocated by the BOB team. This leaderboard displays only the rewards distributed by Sovryn and allows you to check your accumulated points and current position.",
942942
"description2": "If you want to earn your Spice points simply bridge your funds via <0>BOB Fusion and</0> start providing liquidity via our the <1>Market Making</1> page or start <2>Staking SOV</2> tokens.",
943943
"claimDescription": "Users who participated in the Season 1 Liquidity Provisioning campaign can claim their LP tokens here:",
944944
"leaderboard": "Leaderboard",
@@ -955,7 +955,9 @@
955955
"participant": "Participant",
956956
"balance": "Balance",
957957
"points": "Points",
958-
"spice": "Spice",
958+
"spice": "Season 1 and 2 Spice",
959+
"spice3": "Season 3 Spice",
960+
"total": "Total",
959961
"extraSpice": "Extra Spice",
960962
"extraSpiceShot": "Extra Spice Shot",
961963
"runes": "Runes"

0 commit comments

Comments
 (0)