Skip to content

fix: vaults decimals#5669

Merged
cuzz-venus merged 5 commits into
mainfrom
fix/vaults
Jun 25, 2026
Merged

fix: vaults decimals#5669
cuzz-venus merged 5 commits into
mainfrom
fix/vaults

Conversation

@cuzz-venus

@cuzz-venus cuzz-venus commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Jira ticket(s)

VEN-XXX

Changes

  • fix vaults withdraw with decimals

@cuzz-venus cuzz-venus requested a review from therealemjy June 25, 2026 16:42
@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dapp-preview Ready Ready Preview Jun 25, 2026 7:06pm
dapp-testnet Ready Ready Preview Jun 25, 2026 7:06pm
venus.io Ready Ready Preview Jun 25, 2026 7:06pm

Request Review

@changeset-bot

changeset-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3b0756e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@venusprotocol/evm Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@greptile-apps

greptile-apps Bot commented Jun 25, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a decimals mismatch in the Pendle vault's post-maturity withdraw flow: full redeems now pass the user's actual vToken balance (fetched via useGetVTokenBalance) rather than a mantissa derived from the displayed underlying token amount, and partial redeems now use the underlying token's decimals instead of the vToken's decimals — mirroring the Market page WithdrawForm logic. The submit button is also correctly disabled while the vToken balance query is in-flight.

  • Full redeem fix: withdrawAmountMantissa is set to vTokenBalanceMantissa when withdrawing the full supply, preventing revert-causing under/over-estimates from the previous convertTokensToMantissa call.
  • Partial redeem fix: convertTokensToMantissa is now called with vault.asset.vToken.underlyingToken (not the vToken itself), matching the redeemUnderlying contract expectation.
  • Loading guard: isLoading on TransactionForm now includes hasMatured && isGetVTokenBalanceLoading, preventing submission before the balance is available.

Confidence Score: 5/5

Safe to merge — the logic change is narrowly scoped to the post-maturity redeem path and directly mirrors the already-working Market page withdraw flow.

The fix is correct and well-targeted: full redeems use the on-chain vToken balance to avoid mantissa mismatches, partial redeems switch to underlying token decimals as the contract expects, and the loading guard prevents premature submission. The test update confirms the new expected value. The only nit is in the changeset, which does not affect runtime behavior.

.changeset/cruel-carrots-sit.md — wrong bump level (major instead of patch) and a typo in the description.

Important Files Changed

Filename Overview
.changeset/cruel-carrots-sit.md Changeset uses "major" bump for a bug fix and contains a typo ("valuts") in the description.
apps/evm/src/containers/VaultCard/PendleVaultModal/PositionTab/WithdrawForm/index.tsx Fixes decimals mismatch for post-maturity withdrawals: full redeems now use the actual vToken balance from useGetVTokenBalance, partial redeems use the underlying token's decimals, and the submit button is disabled while the vToken balance is loading.
apps/evm/src/containers/VaultCard/PendleVaultModal/PositionTab/WithdrawForm/tests/index.spec.tsx Adds mock for useGetVTokenBalance and updates the post-maturity full-withdraw assertion to expect the vToken balance (1150000000) rather than the previously computed value (1200000000).

Reviews (2): Last reviewed commit: "fix: add loading" | Re-trigger Greptile

Comment on lines +160 to +165
if (!withdrawAmountMantissa) {
throw new VError({
type: 'unexpected',
code: 'somethingWentWrong',
});
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Submit blocked by unloaded vToken balance

When hasMatured and withdrawFull is true, the guard if (!withdrawAmountMantissa) will throw a VError whenever the useGetVTokenBalance query has not yet returned — meaning a user who submits the form while that request is still in-flight will see a generic "something went wrong" error with no explanation. The submit button is not wired to the loading state of that query, so it's fully clickable the moment the form is valid. Consider passing the loading state of getVTokenBalanceData into the isLoading prop of TransactionForm so the button stays disabled until the balance is available when hasMatured is true.

@therealemjy therealemjy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me. Greptile's comment is relevant, the fix is to link the loading state of the submit button to the loading state of the vToken balance

@cuzz-venus

Copy link
Copy Markdown
Contributor Author

@greptile review again

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report for ./apps/evm

Status Category Percentage Covered / Total
🔵 Lines 81.95% 48773 / 59515
🔵 Statements 81.95% 48773 / 59515
🔵 Functions 62.73% 675 / 1076
🔵 Branches 73.1% 5542 / 7581
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/evm/src/containers/VaultCard/PendleVaultModal/PositionTab/WithdrawForm/index.tsx 92.77% 60.71% 100% 92.77% 92, 144-149, 156-158, 162-165
Generated in workflow #13727 for commit 3b0756e by the Vitest Coverage Report Action

@cuzz-venus cuzz-venus merged commit 7c3774e into main Jun 25, 2026
5 checks passed
@cuzz-venus cuzz-venus deleted the fix/vaults branch June 25, 2026 19:18
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