Skip to content

Commit

Permalink
🩹 filter rewards with low rate
Browse files Browse the repository at this point in the history
  • Loading branch information
franm91 committed Oct 26, 2023
1 parent eff67fd commit f737d6d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions components/APRWithBreakdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { FC, PropsWithChildren, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { toPercentage } from 'utils/utils';
import MultiRewardPill from 'components/markets/MultiRewardPill';
import numbers from 'config/numbers.json';

type APR = {
apr?: number;
Expand All @@ -19,6 +20,8 @@ type APRWithBreakdownProps = {
rewardAPR?: string;
};

const { minRewardsRate } = numbers;

const APRWithBreakdown: FC<PropsWithChildren & APRWithBreakdownProps> = ({
directionMobile = 'row-reverse',
directionDesktop = 'row',
Expand All @@ -29,9 +32,11 @@ const APRWithBreakdown: FC<PropsWithChildren & APRWithBreakdownProps> = ({
natives = [],
rewardAPR,
}) => {
const filteredRewards = useMemo(() => rewards.filter(({ apr }) => (apr ? apr >= minRewardsRate : 0)), [rewards]);

const symbols = useMemo(
() => [...rewards.map(({ symbol }) => symbol), ...natives.map(({ symbol }) => symbol)],
[natives, rewards],
() => [...filteredRewards.map(({ symbol }) => symbol), ...natives.map(({ symbol }) => symbol)],
[natives, filteredRewards],
);

return (
Expand Down Expand Up @@ -60,14 +65,15 @@ const APRWithBreakdown: FC<PropsWithChildren & APRWithBreakdownProps> = ({

const APRBreakdown: FC<Omit<APRWithBreakdownProps, 'rewardAPR'>> = ({ markets, rewards = [], natives = [] }) => {
const { t } = useTranslation();
const filteredRewards = useMemo(() => rewards.filter(({ apr }) => (apr ? apr >= minRewardsRate : 0)), [rewards]);

return (
<Box display="flex" flexDirection="column" gap={1}>
{Boolean(markets.length) && <APRBreakdownItem title={t('Market APR')} values={markets} />}
{Boolean(rewards.length) && (
{Boolean(filteredRewards.length) && (
<>
{Boolean(markets.length) && <Divider flexItem sx={{ mx: 0.5 }} />}
<APRBreakdownItem title={t('Rewards APR')} values={rewards} />
<APRBreakdownItem title={t('Rewards APR')} values={filteredRewards} />
</>
)}
{Boolean(natives.length) && (
Expand Down

1 comment on commit f737d6d

@vercel
Copy link

@vercel vercel bot commented on f737d6d Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

app – ./

exactly-development.vercel.app
app.exact.ly
app.exactly.app
exactly.app
app-git-main.exactly.app

Please sign in to comment.