Skip to content

Commit

Permalink
feat: update vault schema & display spot price for v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Dec 29, 2023
1 parent 7ee15b0 commit 4241b37
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.3.5 (29/12/2023)

- Feat: Update the vault schema to take into account the new V3 composite elements.
- Feat: For the V3 vaults, display the spot expected APR next to the Net APR.

# 0.3.4 (22/12/2023)

- Fix: display v3 vaults on the V2 app.
Expand Down
4 changes: 3 additions & 1 deletion apps/common/schemas/yDaemonVaultsSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ export const yDaemonVaultSchema = z.object({
boostedAPR: z.number().default(0).catch(0),
baseAPR: z.number().default(0).catch(0),
cvxAPR: z.number().default(0).catch(0),
rewardsAPR: z.number().default(0).catch(0)
rewardsAPR: z.number().default(0).catch(0),
v3OracleCurrentAPR: z.number().default(0).catch(0),
v3OracleStratRatioAPR: z.number().default(0).catch(0)
})
.default({})
})
Expand Down
33 changes: 32 additions & 1 deletion apps/vaults-v3/components/list/VaultsV3ListRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,37 @@ function VaultForwardAPR({currentVault}: {currentVault: TYDaemonVault}): ReactEl
);
}

const hasV3Composite =
!isZero(currentVault?.apr?.forwardAPR.composite.v3OracleCurrentAPR) &&
!isZero(currentVault?.apr?.forwardAPR.composite.v3OracleStratRatioAPR);
if (hasV3Composite) {
return (
<div className={'-mb-0 flex flex-col md:-mb-4 md:text-right'}>
<b className={'yearn--table-data-section-item-value transition-opacity'}>
<Renderable
shouldRender={!currentVault.apr.forwardAPR?.type.includes('new')}
fallback={'NEW'}>
<RenderAmount
shouldHideTooltip
value={currentVault?.apr?.forwardAPR.composite.v3OracleStratRatioAPR}
symbol={'percent'}
decimals={6}
/>
</Renderable>
</b>
<small className={'text-xs text-neutral-900/40'}>
{`SPOT: `}
<RenderAmount
shouldHideTooltip
value={currentVault?.apr?.forwardAPR.composite.v3OracleCurrentAPR}
symbol={'percent'}
decimals={6}
/>
</small>
</div>
);
}

const hasZeroAPR = isZero(currentVault.apr?.netAPR) || Number((currentVault.apr?.netAPR || 0).toFixed(2)) === 0;
return (
<div className={'flex flex-col md:text-right'}>
Expand All @@ -240,7 +271,7 @@ function VaultForwardAPR({currentVault}: {currentVault: TYDaemonVault}): ReactEl
fallback={'NEW'}>
<RenderAmount
shouldHideTooltip={hasZeroAPR}
value={currentVault.apr.forwardAPR.netAPR}
value={currentVault.apr.netAPR}
symbol={'percent'}
decimals={6}
/>
Expand Down

1 comment on commit 4241b37

@vercel
Copy link

@vercel vercel bot commented on 4241b37 Dec 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.