Skip to content

Commit 03634e4

Browse files
authored
Merge pull request #477 from stabilitydao/dev-leaf
upd: total apr
2 parents b33d561 + 9b19b69 commit 03634e4

File tree

6 files changed

+68
-157
lines changed

6 files changed

+68
-157
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 = () => {

0 commit comments

Comments
 (0)