Skip to content

fix: v2 balances #685

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

Merged
merged 8 commits into from
Jun 17, 2025
Merged

fix: v2 balances #685

merged 8 commits into from
Jun 17, 2025

Conversation

w84april
Copy link
Collaborator

Description

There was a bug in balances filtering: if vault has staking balance, but not balance, it wasn't taken into consideration in sum amount.
Also removed some unused code to keep things cleaner

Related Issue

rossgalloway/ySHIP#78

Copy link

vercel bot commented Jun 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
yearnfi ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2025 4:40pm

Copilot

This comment was marked as outdated.

@rossgalloway
Copy link
Collaborator

This still does not account for the value deposited into the retired vaults in the "total deposited" display. See account: 0x8ee796309494a10B4170F8912613Ee78C75a3430

image

@rossgalloway
Copy link
Collaborator

rossgalloway commented Jun 10, 2025

FWIW, it looks like it is correctly displayed in the V3 total deposited component.
This is not correct either. Adding dollar values gets me ~228,030, but ~210,121 is shown.

And the first entry shows no dollar amount.

image

@rossgalloway
Copy link
Collaborator

But then for this account, the numbers don't add up, even in v3: 0xd0002c648CCa8DeE2f2b8D70D542Ccde8ad6EC03

shows $321 but adding all the dollar values of vaults is $437


And in V2, the staked balances don't show up and are not added to the total value deposited.

image

@w84april
Copy link
Collaborator Author

@rossgalloway That were a bit tricky ones! Pushed fix:

  1. Instead of including Pendle vaults into total deposited, we had to hide them from v2 vault list as they are v3, so had to update filtering logic a bit:
    image
  2. cumulatedValueInVXVaults didn't actually take into consideration any vault other than active
  3. Same stuff with balances calculation, now migrations and retired vaults are included

@rossgalloway rossgalloway requested a review from Copilot June 11, 2025 23:00
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in the balances filtering logic by ensuring that vaults with a staking balance (even if their regular balance is zero) are correctly included, as well as cleaning up unused code.

  • Updated hook import paths across multiple pages.
  • Adjusted filtering logic in useFilteredVaults and useYearnBalances to correctly account for staking balances.
  • Updated token type references from TYToken to TToken throughout affected files.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pages/vaults/index.tsx Updated useFilteredVaults import to use @lib/hooks/useFilteredVaults.
pages/vaults-beta/index.tsx Minor reordering of CSS classes in the container div.
pages/v3/index.tsx Updated useFilteredVaults import to use @lib/hooks/useFilteredVaults.
apps/vaults/components/table/CombinedVaultsTable.tsx Updated useFilteredVaults import to use @lib/hooks/useFilteredVaults.
apps/lib/hooks/useYearnToken.ts Updated return type from TYToken to TToken.
apps/lib/hooks/useFilteredVaults.ts Added conditional logic for vault version filtering and updated dependencies.
apps/lib/contexts/useYearn.tsx Updated default token and aggregated vault maps for cumulated value calculation.
apps/lib/contexts/useYearn.helper.tsx Adjusted token filtering logic and onRefresh callback for balance updates.

if (v3 && !vault.version?.startsWith('3') && !vault.version?.startsWith('~3')) {
return false;
}
if (!v3 && vault.version?.startsWith('3') && !vault.version?.startsWith('~3')) {
Copy link
Preview

Copilot AI Jun 11, 2025

Choose a reason for hiding this comment

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

When v3 is false, the current condition only flags vaults starting with '3' but not those starting with '~3'. Consider replacing the '&&' with an '||' so that both cases are filtered out: if (!v3 && (vault.version?.startsWith('3') || vault.version?.startsWith('~3'))) { return false; }.

Suggested change
if (!v3 && vault.version?.startsWith('3') && !vault.version?.startsWith('~3')) {
if (!v3 && (vault.version?.startsWith('3') || vault.version?.startsWith('~3'))) {

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@w84april can you confirm this and update if necessary. Otherwise, LGTM

@rossgalloway
Copy link
Collaborator

Oops, thought we were good but found a new bug that we might as well address here:

rossgalloway/ySHIP#104

@rossgalloway rossgalloway merged commit eb89e32 into main Jun 17, 2025
9 checks passed
@rossgalloway rossgalloway deleted the fix/v2-balances branch June 17, 2025 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants