Skip to content

Commit

Permalink
Merge branch 'main' into feat/kelp-points
Browse files Browse the repository at this point in the history
  • Loading branch information
NandyBa committed Feb 19, 2025
2 parents 94a980d + 4f4fe06 commit 78c98ad
Show file tree
Hide file tree
Showing 31 changed files with 575 additions and 190 deletions.
1 change: 1 addition & 0 deletions .github/workflows/crowdin-download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
download-from-crowdin:
name: Download sources from Crowdin
runs-on: ubuntu-latest
if: github.repository == 'aave/interface'

steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"test:coverage": "jest --coverage"
},
"dependencies": {
"@aave/contract-helpers": "1.30.5",
"@aave/math-utils": "1.30.5",
"@aave/contract-helpers": "1.32.1",
"@aave/math-utils": "1.32.1",
"@bgd-labs/aave-address-book": "4.10.0",
"@emotion/cache": "11.10.3",
"@emotion/react": "11.10.4",
Expand Down
1 change: 1 addition & 0 deletions public/icons/other/ethena.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/tokens/rez.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/UserDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const UserDisplay: React.FC<UserDisplayProps> = ({
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
<Avatar
fallbackImage={fallbackImage}
image={defaultDomain?.avatar}
loading={loading}
badge={<ExclamationBadge size={BadgeSize.SM} />}
invisibleBadge={!readOnlyMode}
Expand Down
29 changes: 29 additions & 0 deletions src/components/incentives/EthenaIncentivesTooltipContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Trans } from '@lingui/macro';
import { Box } from '@mui/material';

import { Link } from '../primitives/Link';

export const EthenaAirdropTooltipContent = ({ points }: { points: number }) => {
return (
<Box>
<Trans>{`This asset is eligible for ${(<b>{points}x</b>)} Ethena Rewards.\n`}</Trans>
<br />
<Trans>{'Learn more about Ethena Rewards program'}</Trans>{' '}
<Link
href="https://app.ethena.fi/join"
sx={{ textDecoration: 'underline' }}
variant="caption"
color="text.secondary"
>
{'here'}
</Link>
{'.'}
<br />
<br />
<Trans>
{`Aave Labs does not
guarantee the program and accepts no liability.\n`}
</Trans>
</Box>
);
};
60 changes: 60 additions & 0 deletions src/components/incentives/IncentivesButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ReserveIncentiveResponse } from '@aave/math-utils/dist/esm/formatters/i
import { DotsHorizontalIcon } from '@heroicons/react/solid';
import { Box, SvgIcon, Typography } from '@mui/material';
import { useState } from 'react';
import { useEthenaIncentives } from 'src/hooks/useEthenaIncentives';
import { useMeritIncentives } from 'src/hooks/useMeritIncentives';
import { useZkSyncIgniteIncentives } from 'src/hooks/useZkSyncIgniteIncentives';
import { useRootStore } from 'src/store/root';
Expand All @@ -12,6 +13,7 @@ import { DASHBOARD } from 'src/utils/mixPanelEvents';
import { ContentWithTooltip } from '../ContentWithTooltip';
import { FormattedNumber } from '../primitives/FormattedNumber';
import { TokenIcon } from '../primitives/TokenIcon';
import { EthenaAirdropTooltipContent } from './EthenaIncentivesTooltipContent';
import { getSymbolMap, IncentivesTooltipContent } from './IncentivesTooltipContent';
import { MeritIncentivesTooltipContent } from './MeritIncentivesTooltipContent';
import { ZkSyncIgniteIncentivesTooltipContent } from './ZkSyncIgniteIncentivesTooltipContent';
Expand Down Expand Up @@ -92,6 +94,26 @@ export const ZkIgniteIncentivesButton = (params: {
);
};

export const EthenaIncentivesButton = ({ rewardedAsset }: { rewardedAsset?: string }) => {
const [open, setOpen] = useState(false);
const points = useEthenaIncentives(rewardedAsset);

if (!points) {
return null;
}

return (
<ContentWithTooltip
tooltipContent={<EthenaAirdropTooltipContent points={points} />}
withoutHover
setOpen={setOpen}
open={open}
>
<ContentEthenaButton points={points} />
</ContentWithTooltip>
);
};

export const IncentivesButton = ({ incentives, symbol, displayBlank }: IncentivesButtonProps) => {
const [open, setOpen] = useState(false);

Expand Down Expand Up @@ -271,3 +293,41 @@ const Content = ({
</Box>
);
};

const ContentEthenaButton = ({ points }: { points: number }) => {
const [open, setOpen] = useState(false);
const trackEvent = useRootStore((store) => store.trackEvent);

return (
<Box
sx={(theme) => ({
p: { xs: '0 4px', xsm: '2px 4px' },
border: `1px solid ${open ? theme.palette.action.disabled : theme.palette.divider}`,
borderRadius: '4px',
cursor: 'pointer',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
transition: 'opacity 0.2s ease',
bgcolor: open ? 'action.hover' : 'transparent',
'&:hover': {
bgcolor: 'action.hover',
borderColor: 'action.disabled',
},
})}
onClick={() => {
trackEvent(DASHBOARD.VIEW_LM_DETAILS_DASHBOARD, {});
setOpen(!open);
}}
>
<Box sx={{ mr: 2 }}>
<Typography component="span" variant="secondary12" color="text.secondary">
{`${points}x`}
</Typography>
</Box>
<Box sx={{ display: 'inline-flex' }}>
<img src={'/icons/other/ethena.svg'} width={12} height={12} alt="ethena-icon" />
</Box>
</Box>
);
};
2 changes: 2 additions & 0 deletions src/components/incentives/IncentivesCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ReactNode } from 'react';
import { FormattedNumber } from '../primitives/FormattedNumber';
import { NoData } from '../primitives/NoData';
import {
EthenaIncentivesButton,
IncentivesButton,
MeritIncentivesButton,
ZkIgniteIncentivesButton,
Expand Down Expand Up @@ -85,6 +86,7 @@ export const IncentivesCard = ({
rewardedAsset={address}
protocolAction={protocolAction}
/>
<EthenaIncentivesButton rewardedAsset={address} />
</Box>
</Box>
);
Expand Down
15 changes: 15 additions & 0 deletions src/components/incentives/IncentivesTooltipContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ const IncentivesSymbolMap: {
symbol: 'aPYUSD',
aToken: true,
},
aArbWETH: {
tokenIconSymbol: 'WETH',
symbol: 'aWETH',
aToken: true,
},
aArbwstETH: {
tokenIconSymbol: 'wstETH',
symbol: 'awstETH',
aToken: true,
},
aBaswstETH: {
tokenIconSymbol: 'wstETH',
symbol: 'awstETH',
aToken: true,
},
aAvaSAVAX: {
tokenIconSymbol: 'sAVAX',
symbol: 'asAVAX',
Expand Down
35 changes: 35 additions & 0 deletions src/hooks/app-data-provider/useAppDataProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {
ComputedUserReserve,
FormattedGhoReserveData,
FormattedGhoUserData,
formatUserSummaryWithDiscount,
USD_DECIMALS,
UserReserveData,
} from '@aave/math-utils';
import { AaveV3Ethereum } from '@bgd-labs/aave-address-book';
import { formatUnits } from 'ethers/lib/utils';
import React, { PropsWithChildren, useContext } from 'react';
import { EmodeCategory } from 'src/helpers/types';
Expand Down Expand Up @@ -140,9 +142,42 @@ export const AppDataProvider: React.FC<PropsWithChildren> = ({ children }) => {
formatUnits(baseCurrencyData.marketReferenceCurrencyPriceInUsd, USD_DECIMALS)
),
});

const userGhoReserve = user.userReservesData.find(
(r) => r.reserve.underlyingAsset === AaveV3Ethereum.ASSETS.GHO.UNDERLYING.toLowerCase()
);

if (!userGhoReserve) {
throw new Error('GHO reserve not found in user reserves data');
}

const mergeUserReserves = (reserve: ComputedUserReserve<FormattedReservesAndIncentives>) => {
if (reserve.underlyingAsset !== AaveV3Ethereum.ASSETS.GHO.UNDERLYING.toLowerCase()) {
return reserve;
}

if (reserve.variableBorrows === '0') {
return reserve;
}

// This amount takes into account the discount applied on the accrued interest.
const userGhoDebtBalance = formattedGhoUserData.userGhoBorrowBalance.toString();

// Merge with the user reserves so the correct debt balance can be shown throughout the app.
return {
...reserve,
variableBorrows: userGhoDebtBalance,
variableBorrowsUSD: userGhoDebtBalance,
totalBorrowsUSD: userGhoDebtBalance,
totalBorrows: userGhoDebtBalance,
totalBorrowsMarketReferenceCurrency: userGhoDebtBalance,
};
};

user = {
...user,
...userSummaryWithDiscount,
userReservesData: user.userReservesData.map(mergeUserReserves),
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/pool/useUserYield.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const useUserYields = (
) => {
return formatUserYield(formattedPoolReserves, undefined, undefined, user, marketData.market);
};
if (GHO_MINTING_MARKETS.includes(marketData.marketTitle))
if (GHO_MINTING_MARKETS.includes(marketData.market))
return combineQueries(
[
elem,
Expand Down
18 changes: 18 additions & 0 deletions src/hooks/useEthenaIncentives.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { AaveV3Ethereum, AaveV3EthereumLido } from '@bgd-labs/aave-address-book';

const getEthenaData = (assetAddress: string): number | undefined =>
ETHENA_DATA_MAP.get(assetAddress);

const ETHENA_DATA_MAP: Map<string, number> = new Map([
[AaveV3Ethereum.ASSETS.USDe.A_TOKEN, 25],
[AaveV3Ethereum.ASSETS.sUSDe.A_TOKEN, 5],
[AaveV3EthereumLido.ASSETS.sUSDe.A_TOKEN, 5],
]);

export const useEthenaIncentives = (rewardedAsset?: string) => {
if (!rewardedAsset) {
return undefined;
}

return getEthenaData(rewardedAsset);
};
Loading

0 comments on commit 78c98ad

Please sign in to comment.