Skip to content

Commit

Permalink
refactor: utilize all gross apr
Browse files Browse the repository at this point in the history
  • Loading branch information
okjintao committed Sep 9, 2022
1 parent 9982d43 commit 8ebecf2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ const InfluenceVaultPerfomanceTab = ({ vault, config }: Props): JSX.Element => {
const classes = useStyles();
const sortedSources = vault.apy.sources
.slice()
.sort((a, b) => (b.performance.baseYield > a.performance.baseYield ? 1 : -1));
const apy = vaults.vaultsFilters.showAPR ? vault.apr : vault.apy;
.sort((a, b) => (b.performance.grossYield > a.performance.grossYield ? 1 : -1));
const apy = vault.apy;
const lockedBalance = lockedDeposits.getLockedDepositBalances(vault.underlyingToken);
const { processingEmissions, emissionsSchedules, swapPercentage } = influenceVaultStore.getInfluenceVault(
vault.vaultToken,
Expand Down Expand Up @@ -96,7 +96,7 @@ const InfluenceVaultPerfomanceTab = ({ vault, config }: Props): JSX.Element => {
APY
</Typography>
<Typography variant="body1" display="inline">
{numberWithCommas(String(apy.baseYield.toFixed(2)))}%
{numberWithCommas(String(apy.grossYield.toFixed(2)))}%
</Typography>
</Box>
<Divider className={classes.divider} />
Expand Down
1 change: 0 additions & 1 deletion src/components-v2/VaultApyBreakdownItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ const VaultApyBreakdownItem = ({ vault, source }: Props): JSX.Element => {
const maxBoost = calculateUserBoost(MAX_BOOST_RANK.stakeRatioBoundary);
const userBoost = user.accountDetails?.boost ?? 1;

// TODO: this is now duplicated p sure - probably should do a helper fn
const sourceApr = source.boostable
? source.minApr + (source.maxApr - source.minApr) * (userBoost / maxBoost)
: source.apr;
Expand Down
10 changes: 5 additions & 5 deletions src/components-v2/VaultApyInformation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ export interface YieldValueSource extends ValueSource {
* @returns value source derived from yield source
*/
export function yieldToValueSource(source: YieldSource): ValueSource {
const { baseYield, minYield, maxYield } = source.performance;
const { grossYield, minGrossYield, maxGrossYield } = source.performance;
return {
name: source.name,
apr: baseYield,
apr: grossYield,
boostable: source.boostable,
minApr: minYield,
maxApr: maxYield,
minApr: minGrossYield,
maxApr: maxGrossYield,
};
}

Expand All @@ -150,7 +150,7 @@ const VaultApyInformation = ({ open, onClose, boost, vault, projectedBoost }: Pr
const classes = useStyles();
const sortedSources = sources
.slice()
.sort((a, b) => (isBadgerSource(b) ? -1 : b.performance.baseYield > a.performance.baseYield ? 1 : -1));
.sort((a, b) => (isBadgerSource(b) ? -1 : b.performance.grossYield > a.performance.grossYield ? 1 : -1));
const badgerRewardsSources = sortedSources.filter(isBadgerSource);
const harvestSources: YieldSourceDisplay[] = harvestPeriodSourcesApy;
const additionalSources: YieldSourceDisplay[] = nonHarvestSourcesApy.map(yieldToValueSource);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useVaultInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function useVaultInformation(vault: VaultDTOV3): VaultInformation {

const depositBalance = user.getBalance(vaultToken);
const boostContribution = getBoostContribution(vault, user.accountDetails?.boost ?? 0);
const vaultBoost = apy.baseYield + boostContribution;
const vaultBoost = apy.grossYield + boostContribution;

let projectedVaultBoost = null;
if (vault.version === VaultVersion.v1_5) {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/vaults/__snapshots__/VaultItemApr.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports[`VaultItemApr No APR Vaults renders zero APR 1`] = `
<p
class="MuiTypography-root-10 MuiTypography-body1-12 MuiTypography-colorTextPrimary-35 MuiTypography-displayInline-38"
>
0.31%
0.00%
</p>
<img
alt="apy info icon"
Expand Down

0 comments on commit 8ebecf2

Please sign in to comment.