Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apy modal #2341

Merged
merged 7 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions public/assets/icons/bal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,546 changes: 1,546 additions & 0 deletions public/assets/icons/bcvxcrv.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/assets/icons/boosted badger.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/assets/icons/vault compounding.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/assets/icons/vault flywheel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/components-v2/TokenLogo/TokenLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import React, { SyntheticEvent } from 'react';
import { getTokenIconPath } from '../../utils/componentHelpers';

interface Props extends React.HTMLAttributes<HTMLImageElement> {
token: Token;
token: Token | { symbol: string };
width?: string;
height?: string;
}

const TokenLogo = ({ token, ...imageProps }: Props): JSX.Element => {
Expand Down
101 changes: 99 additions & 2 deletions src/components-v2/VaultApyBreakdownItem/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ValueSource, VaultDTO } from '@badger-dao/sdk';
import { Grid, Link, makeStyles, Typography } from '@material-ui/core';
import { Box, Grid, Link, makeStyles, Typography } from '@material-ui/core';
import { MAX_BOOST_RANK } from 'config/system/boost-ranks';
import { StoreContext } from 'mobx/stores/store-context';
import { observer } from 'mobx-react-lite';
Expand All @@ -10,6 +10,10 @@ import { BoostedRewards } from 'utils/enums/boosted-rewards.enum';
import routes from '../../config/routes';
import { useVaultInformation } from '../../hooks/useVaultInformation';
import { numberWithCommas } from '../../mobx/utils/helpers';
import { FLAGS } from 'config/environment';
import { YieldValueSource } from 'components-v2/VaultApyInformation';
import TokenLogo from 'components-v2/TokenLogo';
import { isFlywheelSource } from 'utils/componentHelpers';

const useStyles = makeStyles({
apyBreakdownIcon: {
Expand All @@ -24,11 +28,21 @@ const useStyles = makeStyles({
link: {
cursor: 'pointer',
},
totalVaultRewardsRow: {
padding: 10,
'& .MuiBox-root > *': {
marginRight: 5,
},
'& .MuiBox-root > img': {
marginRight: 10,
},
},
earnedAs: { color: 'rgba(255,255,255,0.6)' },
});

interface Props {
vault: VaultDTO;
source: ValueSource;
source: YieldValueSource;
}

const VaultApyBreakdownItem = ({ vault, source }: Props): JSX.Element => {
Expand All @@ -49,6 +63,89 @@ const VaultApyBreakdownItem = ({ vault, source }: Props): JSX.Element => {
await router.goTo(routes.boostOptimizer);
};

if (FLAGS.APY_EVOLUTION) {
if (isBoostBreakdown && vault.boost.enabled) {
return (
<>
<Grid container className={classes.totalVaultRewardsRow}>
<Grid item xs={9}>
<Box display="flex" alignItems="center">
<TokenLogo
width="24"
height="24"
token={{ symbol: source.yieldVault ? source.yieldVault.token : source.name }}
/>
<Typography component="span">{`🚀 Boosted BADGER Rewards (max: ${numberWithCommas(
source.maxApr.toFixed(2),
)}%)`}</Typography>
</Box>
</Grid>
<Grid item xs={3}>
<Typography align="right">{`${numberWithCommas(sourceApr.toFixed(2))}%`}</Typography>
</Grid>
</Grid>
</>
);
}

return (
<>
<Grid container className={classes.totalVaultRewardsRow}>
<Grid item xs={9}>
<Box display="flex" alignItems="center">
<TokenLogo
width="24"
height="24"
token={{ symbol: source.yieldVault ? source.yieldVault.token : source.name }}
/>
{!isFlywheelSource(source) ? (
<>
<Typography component="span">{source.yieldVault ? source.yieldVault.token : source.name}</Typography>
{source.yieldVault && (
<>
<Typography component="span" className={classes.earnedAs}>
earned as
</Typography>
<img
width="12"
height="16"
src="assets/icons/yield-bearing-rewards.svg"
alt="Yield-Bearing Rewards"
/>
<Typography component="span" color="primary">
{source.yieldVault ? source.yieldVault.vaultName : source.name}
</Typography>
</>
)}
</>
) : (
// showing source `Vault Flywheel` as Compounding of Yield-Bearing Rewards
<>
<Typography component="span">Compounding</Typography>
<Typography component="span" className={classes.earnedAs}>
of
</Typography>
<img
width="12"
height="16"
src="assets/icons/yield-bearing-rewards.svg"
alt="Yield-Bearing Rewards"
/>
<Typography component="span" color="primary">
Yield-Bearing Rewards
</Typography>
</>
)}
</Box>
</Grid>
<Grid item xs={3}>
<Typography align="right">{numberWithCommas(source.apr.toFixed(2))}%</Typography>
</Grid>
</Grid>
</>
);
}

if (isBoostBreakdown && vault.boost.enabled) {
return (
<Grid item container direction="column">
Expand Down
Loading