Skip to content

Commit 1cf09a1

Browse files
author
tiltom
authored
SOV-5202: Hide LM rewards (#1112)
* Hide LM rewards * Create lazy-coats-design.md * Use one week average for calculating return rate
1 parent 122b15f commit 1cf09a1

7 files changed

Lines changed: 35 additions & 70 deletions

File tree

.changeset/lazy-coats-design.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"frontend": patch
3+
---
4+
5+
SOV-5202: Hide LM rewards

apps/frontend/src/app/5_pages/LandingPage/components/QuickLaunch/QuickLaunch.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export const QuickLaunch: FC = () => {
4040
const maxRate = useMemo(() => {
4141
let maxRewards = '0';
4242
rates.forEach(rate => {
43-
if (Number(rate.afterRewards) > Number(maxRewards)) {
44-
maxRewards = rate.afterRewards;
43+
if (Number(rate.beforeRewards) > Number(maxRewards)) {
44+
maxRewards = rate.beforeRewards;
4545
}
4646
});
4747

apps/frontend/src/app/5_pages/MarketMakingPage/components/MarketMaking/MarketMaking.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { RSK_STORAGE_KEY } from '../../../../2_molecules/MarketMakingNetworkBann
1818
import { useIsMobile } from '../../../../../hooks/useIsMobile';
1919
import { translations } from '../../../../../locales/i18n';
2020
import { PoolsTable } from '../PoolsTable/PoolsTable';
21-
import { Promotions } from '../Promotions/Promotions';
2221

2322
export const MarketMaking: FC = () => {
2423
const { isMobile } = useIsMobile();
@@ -61,11 +60,6 @@ export const MarketMaking: FC = () => {
6160
{t(translations.marketMakingPage.subtitle)}
6261
</Paragraph>
6362

64-
<Promotions
65-
setActivePool={setActivePool}
66-
onClick={setIsPromoCardClicked}
67-
/>
68-
6963
<div className="w-full my-4">
7064
<Input
7165
value={searchInputValue}

apps/frontend/src/app/5_pages/MarketMakingPage/components/PoolDetails/components/PoolChart/hooks/useGetPoolVolumeData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const useGetPoolVolumeData = (pool: AmmLiquidityPool) => {
2929
pool.poolTokenA.toLowerCase()
3030
].map(item => ({
3131
timestamp: dayjs(item.activity_date).format('YYYY-MM-DD'),
32-
apy: Number(item.APY_pc),
32+
apy: Number(item.APY_fees_pc),
3333
btcVolume: String(item.btc_volume),
3434
}));
3535

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import React, { FC, useMemo } from 'react';
22

3-
import { t } from 'i18next';
3+
import classNames from 'classnames';
44

5-
import { ContextLink } from '@sovryn/ui';
6-
7-
import { translations } from '../../../../../../../locales/i18n';
85
import { useGetReturnRate } from '../../../../hooks/useGetReturnRate';
96
import { AmmLiquidityPool } from '../../../../utils/AmmLiquidityPool';
107
import styles from './PoolsTableReturns.module.css';
@@ -20,52 +17,13 @@ export const PoolsTableReturns: FC<PoolsTableReturnsProps> = ({
2017
}) => {
2118
const { returnRates } = useGetReturnRate(pool);
2219

23-
const hasRewards = useMemo(
24-
() => Number(returnRates.afterRewards) > 0,
25-
[returnRates],
26-
);
27-
28-
const renderTooltipChildren = useMemo(
29-
() => (
30-
<div className="flex flex-col">
31-
<div>
32-
{t(translations.marketMakingPage.poolsTableReturns.before, {
33-
percent: returnRates.beforeRewards,
34-
})}
35-
</div>
36-
<div>
37-
{t(translations.marketMakingPage.poolsTableReturns.after, {
38-
percent: returnRates.afterRewards,
39-
})}
40-
</div>
41-
</div>
42-
),
43-
[returnRates],
44-
);
45-
46-
const renderChildren = useMemo(
20+
const returnRate = useMemo(
4721
() =>
48-
hasRewards
49-
? t(translations.marketMakingPage.poolsTableReturns.title, {
50-
percent: returnRates.afterRewards,
51-
})
52-
: '0%',
53-
[returnRates, hasRewards],
22+
returnRates.beforeRewards === '0.00' ? '0' : returnRates.beforeRewards,
23+
[returnRates],
5424
);
5525

56-
const renderComponent = useMemo(
57-
() =>
58-
hasRewards ? (
59-
<ContextLink
60-
className={className}
61-
children={renderChildren}
62-
tooltipContent={renderTooltipChildren}
63-
/>
64-
) : (
65-
<div className={styles.rewards}>{renderChildren}</div>
66-
),
67-
[className, hasRewards, renderChildren, renderTooltipChildren],
26+
return (
27+
<div className={classNames(styles.rewards, className)}>{returnRate}%</div>
6828
);
69-
70-
return renderComponent;
7129
};

apps/frontend/src/app/5_pages/MarketMakingPage/hooks/useGetReturnRate.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,26 @@ export const useGetReturnRate = ({
4949
? data[converter].data[Object.keys(data[converter].data)[0]]
5050
: data[converter].data[poolTokenA];
5151

52-
const lastEntry = poolData[poolData.length - 1];
52+
if (poolData && poolData.length > 0) {
53+
const sumFeesApy = poolData.reduce(
54+
(acc, entry) => acc + parseFloat(entry.APY_fees_pc),
55+
0,
56+
);
57+
const sumTotalApy = poolData.reduce(
58+
(acc, entry) => acc + parseFloat(entry.APY_pc),
59+
0,
60+
);
5361

54-
const totalAPY = {
55-
beforeRewards: lastEntry
56-
? parseFloat(lastEntry.APY_rewards_pc).toFixed(2)
57-
: '0',
58-
afterRewards: lastEntry
59-
? parseFloat(lastEntry.APY_pc).toFixed(2)
60-
: '0',
61-
};
62+
const avgFeesApy = (sumFeesApy / poolData.length).toFixed(2);
63+
const avgTotalApy = (sumTotalApy / poolData.length).toFixed(2);
6264

63-
setReturnRates(totalAPY);
65+
setReturnRates({
66+
beforeRewards: avgFeesApy,
67+
afterRewards: avgTotalApy,
68+
});
69+
} else {
70+
setReturnRates({ beforeRewards: '0', afterRewards: '0' });
71+
}
6472
} else {
6573
setReturnRates({ beforeRewards: '0', afterRewards: '0' });
6674
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@
510510
},
511511
"earn": {
512512
"title": "Earn up to {{amount}}% APR in AMM",
513-
"description": "Deposit in the AMM pools, earn from trades and get SOV rewards.",
513+
"description": "Deposit in the AMM pools and earn from trades.",
514514
"action": "Deposit in AMM"
515515
},
516516
"lend": {
@@ -1211,7 +1211,7 @@
12111211
},
12121212
"yieldFarmingBanner": {
12131213
"title": "Yield farming",
1214-
"description": "Deposit in the AMM pools, earn from trades in Sovryn and get rewards",
1214+
"description": "Deposit in the AMM pools and earn from trades in Sovryn",
12151215
"action": "Deposit in AMM"
12161216
},
12171217
"staking": {
@@ -2109,4 +2109,4 @@
21092109
"invalidNumberFormat": "Invalid number format."
21102110
}
21112111
}
2112-
}
2112+
}

0 commit comments

Comments
 (0)