Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions src/components/incentives/IncentivesButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Box, Typography } from '@mui/material';
import { useState } from 'react';
import { useEthenaIncentives } from 'src/hooks/useEthenaIncentives';
import { useEtherfiIncentives } from 'src/hooks/useEtherfiIncentives';
import { useMeritIncentives } from 'src/hooks/useMeritIncentives';
import { ExtendedReserveIncentiveResponse, useMerklIncentives } from 'src/hooks/useMerklIncentives';
import { useMerklPointsIncentives } from 'src/hooks/useMerklPointsIncentives';
import { useSonicIncentives } from 'src/hooks/useSonicIncentives';
Expand All @@ -18,7 +17,6 @@ import { FormattedNumber } from '../primitives/FormattedNumber';
import { EthenaAirdropTooltipContent } from './EthenaIncentivesTooltipContent';
import { EtherFiAirdropTooltipContent } from './EtherfiIncentivesTooltipContent';
import { IncentivesTooltipContent } from './IncentivesTooltipContent';
import { MeritIncentivesTooltipContent } from './MeritIncentivesTooltipContent';
import { MerklIncentivesTooltipContent } from './MerklIncentivesTooltipContent';
import { SonicAirdropTooltipContent } from './SonicIncentivesTooltipContent';

Expand Down Expand Up @@ -128,45 +126,6 @@ const BlankIncentives = () => {
);
};

export const MeritIncentivesButton = (params: {
symbol: string;
market: string;
protocolAction?: ProtocolAction;
protocolAPY?: number;
protocolIncentives?: ReserveIncentiveResponse[];
hideValue?: boolean;
}) => {
const [open, setOpen] = useState(false);
const { data: meritIncentives } = useMeritIncentives(params);

if (!meritIncentives) {
return null;
}

// Show only merit incentives APR
const displayValue = +meritIncentives.incentiveAPR;

return (
<ContentWithTooltip
tooltipContent={
<MeritIncentivesTooltipContent
meritIncentives={meritIncentives}
onClose={() => setOpen(false)}
/>
}
withoutHover
setOpen={setOpen}
open={open}
>
<Content
incentives={[meritIncentives]}
incentivesNetAPR={displayValue}
hideValue={params.hideValue}
/>
</ContentWithTooltip>
);
};

export const MerklIncentivesButton = (params: {
market: string;
rewardedAsset?: string;
Expand Down
32 changes: 3 additions & 29 deletions src/components/incentives/IncentivesCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ReserveIncentiveResponse } from '@aave/math-utils/dist/esm/formatters/i
import { Box, Typography } from '@mui/material';
import { useRouter } from 'next/router';
import { ReactNode } from 'react';
import { ENABLE_SELF_CAMPAIGN, useMeritIncentives } from 'src/hooks/useMeritIncentives';
import { useMerklIncentives } from 'src/hooks/useMerklIncentives';
import { useMerklPointsIncentives } from 'src/hooks/useMerklPointsIncentives';
import { convertAprToApy } from 'src/utils/utils';
Expand All @@ -14,7 +13,6 @@ import {
EthenaIncentivesButton,
EtherfiIncentivesButton,
IncentivesButton,
MeritIncentivesButton,
MerklIncentivesButton,
SonicIncentivesButton,
} from './IncentivesButton';
Expand Down Expand Up @@ -62,13 +60,6 @@ export const IncentivesCard = ({
const protocolIncentivesAPY = convertAprToApy(
protocolIncentivesAPR === 'Infinity' ? 0 : protocolIncentivesAPR
);
const { data: meritIncentives } = useMeritIncentives({
symbol,
market,
protocolAction,
protocolAPY,
protocolIncentives: incentives || [],
});

const { data: merklIncentives } = useMerklIncentives({
market,
Expand All @@ -86,13 +77,6 @@ export const IncentivesCard = ({
protocolIncentives: incentives || [],
});

const meritIncentivesAPR = meritIncentives?.breakdown?.meritIncentivesAPR || 0;

// TODO: This is a one-off for the Self campaign.
// Remove once the Self incentives are finished.
const selfAPY = ENABLE_SELF_CAMPAIGN ? meritIncentives?.variants?.selfAPY ?? 0 : 0;
const totalMeritAPY = meritIncentivesAPR + selfAPY;

const merklIncentivesAPR = merklPointsIncentives?.breakdown?.points
? merklPointsIncentives.breakdown.merklIncentivesAPR || 0
: merklIncentives?.breakdown?.merklIncentivesAPR || 0;
Expand All @@ -105,12 +89,9 @@ export const IncentivesCard = ({
const displayAPY = hasInfiniteIncentives
? 'Infinity'
: isBorrow
? protocolAPY - (protocolIncentivesAPY as number) - totalMeritAPY - merklIncentivesAPR
: protocolAPY + (protocolIncentivesAPY as number) + totalMeritAPY + merklIncentivesAPR;
? protocolAPY - (protocolIncentivesAPY as number) - merklIncentivesAPR
: protocolAPY + (protocolIncentivesAPY as number) + merklIncentivesAPR;

const isSghoPage =
typeof router?.asPath === 'string' && router.asPath.toLowerCase().startsWith('/sgho');
const hideMeritValue = symbol === 'GHO' && !isSghoPage;
const isMarketsOrDashboardPage =
typeof router?.pathname === 'string' &&
(router.pathname.startsWith('/dashboard') || router.pathname.startsWith('/markets'));
Expand All @@ -130,14 +111,7 @@ export const IncentivesCard = ({
protocolAPY={protocolAPY}
address={address}
/>
<MeritIncentivesButton
symbol={symbol}
market={market}
protocolAction={protocolAction}
protocolAPY={protocolAPY}
protocolIncentives={incentives || []}
hideValue={hideMeritValue}
/>

<MerklIncentivesButton
market={market}
rewardedAsset={address}
Expand Down
59 changes: 4 additions & 55 deletions src/components/incentives/IncentivesTooltipContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ProtocolAction } from '@aave/contract-helpers';
import { ReserveIncentiveResponse } from '@aave/math-utils/dist/esm/formatters/incentive/calculate-reserve-incentives';
import { Trans } from '@lingui/macro';
import { Box, Typography } from '@mui/material';
import { useMeritIncentives } from 'src/hooks/useMeritIncentives';
import { useMerklIncentives } from 'src/hooks/useMerklIncentives';
import { convertAprToApy } from 'src/utils/utils';

Expand Down Expand Up @@ -298,14 +297,6 @@ export const IncentivesTooltipContent = ({
}: IncentivesTooltipContentProps) => {
const typographyVariant = 'secondary12';

const { data: meritIncentives } = useMeritIncentives({
symbol,
market: market || '',
protocolAction,
protocolAPY,
protocolIncentives: incentives,
});

const { data: merklIncentives } = useMerklIncentives({
market: market || '',
rewardedAsset: address,
Expand Down Expand Up @@ -336,20 +327,13 @@ export const IncentivesTooltipContent = ({
);
};

const meritIncentivesAPR = meritIncentives?.breakdown?.meritIncentivesAPR || 0;
const merklIncentivesAPR = merklIncentives?.breakdown?.merklIncentivesAPR || 0;

// For borrow, incentives are subtracted; for supply, they're added
const isBorrow = protocolAction === ProtocolAction.borrow;
const totalAPY = isBorrow
? protocolAPY -
(incentivesNetAPR === 'Infinity' ? 0 : incentivesNetAPR) -
meritIncentivesAPR -
merklIncentivesAPR
: protocolAPY +
(incentivesNetAPR === 'Infinity' ? 0 : incentivesNetAPR) +
meritIncentivesAPR +
merklIncentivesAPR;
? protocolAPY - (incentivesNetAPR === 'Infinity' ? 0 : incentivesNetAPR) - merklIncentivesAPR
: protocolAPY + (incentivesNetAPR === 'Infinity' ? 0 : incentivesNetAPR) + merklIncentivesAPR;

return (
<Box
Expand Down Expand Up @@ -419,41 +403,6 @@ export const IncentivesTooltipContent = ({
);
})}

{/* Show Merit Incentives if available */}
{meritIncentives && meritIncentives.breakdown && (
<Row
height={32}
caption={
<Box sx={{ display: 'flex', alignItems: 'center', mb: 2 }}>
<img
src={'/icons/other/aci-black.svg'}
width="20px"
height="20px"
alt="Merit"
style={{ marginRight: '8px' }}
/>
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<Typography variant={typographyVariant}>Merit Incentives</Typography>
<Typography variant={typographyVariant} sx={{ ml: 0.5 }}>
{isBorrow ? '(-)' : '(+)'}
</Typography>
</Box>
</Box>
}
width="100%"
>
<FormattedNumber
value={
isBorrow
? -meritIncentives.breakdown.meritIncentivesAPR
: meritIncentives.breakdown.meritIncentivesAPR
}
percent
variant={typographyVariant}
/>
</Row>
)}

{/* Show Merkl Incentives if available */}
{merklIncentives && merklIncentives.breakdown && (
<Row
Expand Down Expand Up @@ -507,8 +456,8 @@ export const IncentivesTooltipContent = ({
</Box>
)}

{/* Show Total APY if we have Merit incentives or protocol APY */}
{(meritIncentives?.breakdown || protocolAPY > 0) && (
{/* Show Total APY if we have Merkl incentives or protocol APY */}
{protocolAPY > 0 && (
<Box sx={() => ({ pt: 1, mt: 1, borderTop: '1px solid rgba(255, 255, 255, 0.1)' })}>
<Row
caption={
Expand Down
Loading
Loading