Skip to content

Commit

Permalink
showing source as Compounding of Yield-Bearing Rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
mranilrai committed Sep 5, 2022
1 parent c4d1798 commit 1ffa284
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
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.
30 changes: 26 additions & 4 deletions src/components-v2/VaultApyBreakdownItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 Down Expand Up @@ -97,11 +98,32 @@ const VaultApyBreakdownItem = ({ vault, source }: Props): JSX.Element => {
height="24"
token={{ symbol: source.yieldVault ? source.yieldVault.token : source.name }}
/>
<Typography component="span">{source.yieldVault ? source.yieldVault.token : source.name}</Typography>
{source.yieldVault && (
{!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}>
earned as
of
</Typography>
<img
width="12"
Expand All @@ -110,7 +132,7 @@ const VaultApyBreakdownItem = ({ vault, source }: Props): JSX.Element => {
alt="Yield-Bearing Rewards"
/>
<Typography component="span" color="primary">
{source.yieldVault ? source.yieldVault.vaultName : source.name}
Yield-Bearing Rewards
</Typography>
</>
)}
Expand Down
5 changes: 3 additions & 2 deletions src/components-v2/VaultApyInformation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { isInfluenceVault } from 'components-v2/InfluenceVault/InfluenceVaultUti
import { StoreContext } from 'mobx/stores/store-context';
import { observer } from 'mobx-react-lite';
import React, { MouseEvent, useContext } from 'react';
import { isBadgerSource } from 'utils/componentHelpers';
import { isBadgerSource, isFlywheelSource } from 'utils/componentHelpers';

import routes from '../../config/routes';
import { numberWithCommas } from '../../mobx/utils/helpers';
Expand Down Expand Up @@ -170,8 +170,9 @@ const VaultApyInformation = ({ open, onClose, boost, vault, projectedBoost }: Pr
}
return list;
}, [])
.sort((a) => (a.yieldVault ? 1 : -1))
.sort((_, b) => (isFlywheelSource(b) ? -1 : 1))
.sort((_, b) => (isBadgerSource(b) ? -1 : 1))
.sort((a, b) => (a.yieldVault ? 1 : isBadgerSource(a) ? 1 : -1));

return (
<Dialog
Expand Down
4 changes: 4 additions & 0 deletions src/utils/componentHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export function isBadgerSource(source: { name: string }): boolean {
return source.name === BoostedRewards.Badger || source.name === BoostedRewards.BoostedBadger;
}

export function isFlywheelSource(source: { name: string }): boolean {
return /vault flywheel/i.test(source?.name);
}

export function getUserVaultBoost(vault: VaultDTO, boost: number, apr = false): number {
if (vault.state === VaultState.Discontinued || vault.sources.length === 0) {
return 0;
Expand Down

0 comments on commit 1ffa284

Please sign in to comment.