Skip to content

Commit 4534142

Browse files
committed
upd: total apr
1 parent a82f706 commit 4534142

File tree

6 files changed

+68
-155
lines changed

6 files changed

+68
-155
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "stability-ui",
33
"type": "module",
4-
"version": "0.8.21-alpha",
4+
"version": "0.8.22-alpha",
55
"scripts": {
66
"dev": "astro dev",
77
"start": "astro dev",

src/constants/tables.ts

+2-53
Original file line numberDiff line numberDiff line change
@@ -8,57 +8,25 @@ const TABLE_FILTERS: TTableFilters[] = [
88
];
99

1010
const SONIC_TABLE: TTableColumn[] = [
11-
// { name: "Symbol", keyName: "symbol", sortType: "none", dataType: "string" },
1211
{
1312
name: "Assets",
1413
keyName: "assetsSymbol",
1514
sortType: "none",
1615
dataType: "string",
1716
},
18-
// { name: "Status", keyName: "status", sortType: "none", dataType: "number" },
19-
// {
20-
// name: "Type",
21-
// keyName: "type",
22-
// sortType: "none",
23-
// dataType: "string",
24-
// },
2517
{
2618
name: "Strategy",
2719
keyName: "strategy",
2820
sortType: "none",
2921
dataType: "string",
3022
},
3123
{
32-
name: "Income APR",
24+
name: "Total APR",
3325
keyName: "earningData",
3426
sortType: "none",
3527
dataType: "number",
3628
},
37-
// {
38-
// name: "VS HODL APR",
39-
// keyName: "vsHoldAPR",
40-
// sortType: "none",
41-
// dataType: "number",
42-
// },
43-
{
44-
name: "Extra rewards APR",
45-
keyName: "",
46-
sortType: "none",
47-
dataType: "",
48-
unsortable: true,
49-
},
50-
// {
51-
// name: "Points",
52-
// keyName: "sonicActivePoints",
53-
// sortType: "none",
54-
// dataType: "number",
55-
// },
56-
// {
57-
// name: "RISK",
58-
// keyName: "il",
59-
// sortType: "none",
60-
// dataType: "number",
61-
// },
29+
6230
{ name: "TVL", keyName: "tvl", sortType: "none", dataType: "number" },
6331
{
6432
name: "Balance",
@@ -76,13 +44,6 @@ const TABLE: TTableColumn[] = [
7644
sortType: "none",
7745
dataType: "string",
7846
},
79-
// { name: "Status", keyName: "status", sortType: "none", dataType: "number" },
80-
// {
81-
// name: "Type",
82-
// keyName: "type",
83-
// sortType: "none",
84-
// dataType: "string",
85-
// },
8647
{
8748
name: "Strategy",
8849
keyName: "strategy",
@@ -135,18 +96,6 @@ const CHAINS_TABLE: TTableColumn[] = [
13596
sortType: "none",
13697
dataType: "number",
13798
},
138-
// {
139-
// name: "Treasury",
140-
// keyName: "multisig",
141-
// sortType: "none",
142-
// dataType: "string",
143-
// },
144-
// {
145-
// name: "Issue",
146-
// keyName: "chainLibGithubId",
147-
// sortType: "none",
148-
// dataType: "number",
149-
// },
15099
{ name: "Status", keyName: "status", sortType: "none", dataType: "string" },
151100
{
152101
name: "Strategies",

src/layouts/AppStore.tsx

+46-10
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@ const AppStore = (props: React.PropsWithChildren): JSX.Element => {
255255
daily: "0",
256256
weekly: "0",
257257
};
258+
let totalAPRArray = {
259+
latest: "0",
260+
daily: "0",
261+
weekly: "0",
262+
};
258263
let APYArray = {
259264
latest: "0",
260265
daily: "0",
@@ -270,6 +275,11 @@ const AppStore = (props: React.PropsWithChildren): JSX.Element => {
270275
daily: "0",
271276
weekly: "0",
272277
};
278+
let gemsAPR = {
279+
latest: "0",
280+
daily: "0",
281+
weekly: "0",
282+
};
273283

274284
const fee = vault?.almFee?.income || 0;
275285

@@ -328,8 +338,6 @@ const AppStore = (props: React.PropsWithChildren): JSX.Element => {
328338
2
329339
);
330340

331-
APY = calculateAPY(APR).toFixed(2);
332-
333341
APRWithoutFees = Number(vault?.income?.aprLatest).toFixed(2) || "0";
334342

335343
///////
@@ -359,23 +367,51 @@ const AppStore = (props: React.PropsWithChildren): JSX.Element => {
359367
vault.strategyShortId
360368
),
361369
};
370+
371+
gemsAPR = {
372+
latest: String(
373+
Number(APRArray.latest) *
374+
stabilityAPIData.rewards.gemsAprMultiplier
375+
),
376+
daily: String(
377+
Number(APRArray.daily) *
378+
stabilityAPIData.rewards.gemsAprMultiplier
379+
),
380+
weekly: String(
381+
Number(APRArray.weekly) *
382+
stabilityAPIData.rewards.gemsAprMultiplier
383+
),
384+
};
385+
386+
totalAPRArray = {
387+
latest: (Number(APRArray.latest) + Number(gemsAPR.latest)).toFixed(
388+
2
389+
),
390+
daily: (Number(APRArray.daily) + Number(gemsAPR.daily)).toFixed(2),
391+
weekly: (Number(APRArray.weekly) + Number(gemsAPR.weekly)).toFixed(
392+
2
393+
),
394+
};
395+
396+
APY = calculateAPY(totalAPRArray.latest).toFixed(2);
397+
362398
APYArray = {
363-
latest: Number(APR) < 0 ? "0" : APY,
399+
latest: Number(totalAPRArray.latest) < 0 ? "0" : APY,
364400
daily:
365-
dailyTotalAPRWithFees < 0
401+
Number(totalAPRArray.daily) < 0
366402
? "0"
367403
: determineAPR(
368404
vault?.income?.apr24h,
369-
calculateAPY(dailyTotalAPRWithFees).toFixed(2),
405+
calculateAPY(totalAPRArray.daily).toFixed(2),
370406
APY,
371407
vault.strategyShortId
372408
),
373409
weekly:
374-
weeklyTotalAPRWithFees < 0
410+
Number(totalAPRArray.weekly) < 0
375411
? "0"
376412
: determineAPR(
377413
vault?.income?.aprWeek,
378-
calculateAPY(weeklyTotalAPRWithFees).toFixed(2),
414+
calculateAPY(Number(totalAPRArray.weekly)).toFixed(2),
379415
APY,
380416
vault.strategyShortId
381417
),
@@ -632,7 +668,6 @@ const AppStore = (props: React.PropsWithChildren): JSX.Element => {
632668
sonicActivePoints = Number(points.toFixed(1));
633669
break;
634670
}
635-
636671
// Leverage lending live APR & asset APR
637672
if (
638673
vault?.address?.toLowerCase() ===
@@ -700,12 +735,13 @@ const AppStore = (props: React.PropsWithChildren): JSX.Element => {
700735
gasReserve: vault.gasReserve,
701736
rebalances,
702737
earningData: {
703-
apr: APRArray,
738+
apr: totalAPRArray,
704739
apy: APYArray,
705740
poolSwapFeesAPR,
706741
farmAPR,
742+
gemsAPR,
707743
},
708-
sortAPR: APRArray?.latest,
744+
sortAPR: totalAPRArray?.latest,
709745
pool: vault.pool,
710746
alm: vault.alm,
711747
risk: vault?.risk,

src/modules/SonicVaults/components/ColumnSort.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,13 @@ type TProps = {
99

1010
const ColumnSort: React.FC<TProps> = ({ index, value, table, sort }) => {
1111
const styles: Record<string, string> = {
12-
// Type: "hidden xl:table-cell",
1312
Assets: "min-w-[180px] text-left",
1413
Strategy: "w-[190px]",
15-
"Income APR": "min-w-[130px] text-right",
16-
// "VS HODL APR": "min-w-[130px]",
14+
"Total APR": "min-w-[130px] text-right",
1715
"Extra rewards APR": "min-w-[100px] text-right",
18-
// Status: "table-cell",
19-
// RISK: "text-center pl-2",
2016
Price: "min-w-[80px]",
2117
TVL: "min-w-[95px] text-right",
22-
Balance: "min-w-[100px]",
18+
Balance: "min-w-[100px] text-end",
2319
};
2420

2521
const tabController = () => {

src/modules/SonicVaults/index.tsx

+16-85
Original file line numberDiff line numberDiff line change
@@ -583,13 +583,6 @@ const SonicVaults = (): JSX.Element => {
583583
vault?.earningData?.apr[$aprFilter]
584584
);
585585

586-
let gemsAprValue = 0;
587-
588-
if (aprValue >= 0) {
589-
gemsAprValue =
590-
aprValue * $apiData.rewards?.gemsAprMultiplier;
591-
}
592-
593586
const apyValue = vault.earningData.apy[$aprFilter];
594587

595588
const swapFeesAPRValue =
@@ -602,6 +595,10 @@ const SonicVaults = (): JSX.Element => {
602595
Number(vault?.earningData?.apr[$aprFilter]) / 365
603596
).toFixed(2);
604597

598+
const gemsAprValue = Number(
599+
vault.earningData.gemsAPR[$aprFilter]
600+
);
601+
605602
const isSTBLVault =
606603
Array.isArray(vault?.assets) &&
607604
vault.assets.some(
@@ -648,7 +645,6 @@ const SonicVaults = (): JSX.Element => {
648645
</span>
649646
</div>
650647
)}
651-
652648
{SILO_POINTS[
653649
vault.address as keyof typeof SILO_POINTS
654650
] && (
@@ -689,21 +685,6 @@ const SonicVaults = (): JSX.Element => {
689685
</div>
690686
</div>
691687
</td>
692-
{/* <td className="px-2 min-[1130px]:px-1 py-2 table-cell w-[50px]">
693-
<div className="flex items-center justify-center">
694-
{vault?.risk?.isRektStrategy ? (
695-
<div
696-
className="h-5 w-5 md:w-3 md:h-3 rounded-full mr-2 bg-[#EE6A63]"
697-
title={vault?.risk?.isRektStrategy as string}
698-
></div>
699-
) : (
700-
<VaultState status={vault.status} />
701-
)}
702-
</div>
703-
</td>
704-
<td className="px-2 min-[1130px]:px-1 py-2 hidden xl:table-cell w-[90px]">
705-
<VaultType type={vault.type} />
706-
</td> */}
707688
<td className="pl-2 py-2 whitespace-nowrap">
708689
<div className="flex items-center border-0 rounded-[8px] pl-0 py-1 border-[#935ec2]">
709690
{vault.strategyInfo && (
@@ -761,7 +742,6 @@ const SonicVaults = (): JSX.Element => {
761742
)}
762743
</div>
763744
</td>
764-
765745
<td
766746
onClick={(e) => {
767747
if (isMobile) {
@@ -853,6 +833,18 @@ const SonicVaults = (): JSX.Element => {
853833
{formatNumber(dailyAPRValue, "formatAPR")}%
854834
</p>
855835
</div>
836+
{!isSTBLVault && (
837+
<div className="font-bold flex items-center justify-between">
838+
<p>Gems APR</p>
839+
<div className="flex items-center justify-end">
840+
{formatNumber(
841+
gemsAprValue.toFixed(2),
842+
"formatAPR"
843+
)}
844+
%
845+
</div>
846+
</div>
847+
)}
856848
</div>
857849
<div className="flex items-center justify-between w-full">
858850
<p>Last Hard Work</p>
@@ -864,67 +856,6 @@ const SonicVaults = (): JSX.Element => {
864856
<i></i>
865857
</div>
866858
</td>
867-
<td className="px-2 min-[1130px]:px-4 py-2 whitespace-nowrap">
868-
{!isSTBLVault && (
869-
<div className="flex items-center justify-end">
870-
{formatNumber(
871-
gemsAprValue.toFixed(2),
872-
"formatAPR"
873-
)}
874-
%
875-
<img
876-
src="https://raw.githubusercontent.com/stabilitydao/.github/main/tokens/sGEM1.png"
877-
className="w-[24px] h-[24px] ml-1.5"
878-
title="sGEM1"
879-
alt="sGEM1"
880-
/>
881-
</div>
882-
)}
883-
</td>
884-
{/* <td className="px-2 min-[1130px]:px-4 py-2 whitespace-nowrap">
885-
<div className="flex items-center justify-center gap-2">
886-
<div
887-
title="Sonic Activity Points"
888-
className="flex items-center rounded-full border border-[#6EBD70] bg-[#6EBD70]/[0.16] pr-[6px]"
889-
>
890-
<img
891-
src="/sonic.png"
892-
alt="sonic"
893-
className="w-5 h-5 rounded-full"
894-
/>
895-
<span className="text-[10px] ml-[3px] mr-[2px]">
896-
x{vault.sonicActivePoints}
897-
</span>
898-
</div>
899-
900-
{SILO_POINTS[vault.address] && (
901-
<div
902-
title="Silo Points per $ / day"
903-
className="flex items-center rounded-full border border-[#fff699] bg-[#fff699]/[0.16] pr-[6px]"
904-
>
905-
<img
906-
src="https://raw.githubusercontent.com/stabilitydao/.github/main/assets/silo.png"
907-
alt="silo"
908-
className="w-5 h-5 rounded-full"
909-
/>
910-
<span className="text-[10px] ml-[3px] mr-[2px]">
911-
{SILO_POINTS[vault.address]}
912-
</span>
913-
</div>
914-
)}
915-
</div>
916-
</td> */}
917-
{/* <td className="px-2 min-[1130px]:px-4 py-2 whitespace-nowrap">
918-
<div className="flex items-center justify-center">
919-
<RiskIndicator
920-
riskSymbol={
921-
vault?.risk?.isRektStrategy
922-
? vault?.risk?.symbol
923-
: (vault.strategyInfo.il?.title as string)
924-
}
925-
/>
926-
</div>
927-
</td> */}
928859
<td className="px-2 min-[1130px]:px-4 py-2 text-right">
929860
{formatNumber(vault.tvl, "abbreviate")}
930861
</td>

src/types/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ type TEarningData = {
127127
apy: TAPRData;
128128
poolSwapFeesAPR: TAPRData;
129129
farmAPR: TAPRData;
130+
gemsAPR: TAPRData;
130131
};
131132

132133
type TVaults = {

0 commit comments

Comments
 (0)