Skip to content

feat: update withdraw from matured Pendle vault flow#5612

Open
therealemjy wants to merge 1 commit into
mainfrom
feat/pendle-withdraw
Open

feat: update withdraw from matured Pendle vault flow#5612
therealemjy wants to merge 1 commit into
mainfrom
feat/pendle-withdraw

Conversation

@therealemjy
Copy link
Copy Markdown
Member

@therealemjy therealemjy commented Jun 3, 2026

Jira ticket(s)

VEN-1322

Changes

  • update withdraw from matured Pendle vault flow

Do not merge until the Pendle vault has matured and this update has been QA tested.

@therealemjy therealemjy requested a review from cuzz-venus June 3, 2026 12:56
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

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

Project Deployment Actions Updated (UTC)
dapp-preview Ready Ready Preview Jun 3, 2026 2:04pm
dapp-testnet Ready Ready Preview Jun 3, 2026 2:04pm
venus.io Ready Ready Preview Jun 3, 2026 2:04pm

Request Review

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Jun 3, 2026

Greptile Summary

This PR replaces the old matured-vault withdrawal path (which called a generic useWithdraw against the Venus comptroller) with a dedicated useWithdrawAtMaturityFromPendleVault hook that calls redeemAtMaturity directly on the PendlePtVault contract. The UI now auto-fills the full staked amount and locks the input field when the market has matured, and the "Convert" details panel adapts to show a simple 1:1 redemption view instead of swap-quote rows.

  • New useWithdrawAtMaturityFromPendleVault hook — builds and dispatches the redeemAtMaturity contract call, then invalidates caches and emits an analytics event on confirmation.
  • WithdrawForm refactor — detects maturity at render time, auto-fills the amount via useEffect, disables the input, and routes handleSubmit to the correct mutation based on the hasMatured flag.
  • invalidatePendleVaultCaches decoupled — input type loosened to { fromToken; toToken } so it is reusable across all three Pendle mutation hooks.
  • Snapshot test cleanup — large inline ABI snapshot removed in favour of targeted toMatchObject / toMatchInlineSnapshot assertions.

Confidence Score: 5/5

Safe to merge — the change is well-scoped and the non-matured withdrawal path is untouched. The only observations are advisory suggestions on the matured-path contract call.

No defects were found on any changed code path. Both the matured and non-matured flows are exercised by the updated tests. The two flagged items are stylistic/advisory, not current misbehaviours.

apps/evm/src/clients/api/mutations/useWithdrawAtMaturityFromPendleVault/index.ts — contains the hardcoded minTokenOut: 0n and the analytics amount convention worth a second look.

Important Files Changed

Filename Overview
apps/evm/src/clients/api/mutations/useWithdrawAtMaturityFromPendleVault/index.ts New hook calling redeemAtMaturity on PendlePtVault; hardcodes minTokenOut: 0n and tracks analytics amounts in vToken units rather than PT-token units.
apps/evm/src/containers/VaultCard/PendleVaultModal/PositionTab/WithdrawForm/index.tsx Updated to detect vault maturity, auto-fill the full staked amount, disable input, and dispatch withdrawAtMaturity instead of the old generic useWithdraw.
apps/evm/src/clients/api/mutations/useWithdrawFromPendleVault/index.ts Removed the redeemAtMaturity branch; formatWithdrawParams inlined from the deleted helper.
apps/evm/src/containers/VaultCard/PendleVaultModal/PositionTab/Footer/PendleConvertDetails/index.tsx Added isMatured and userStakedTokens props; shows a simple Received row when matured.
apps/evm/src/utilities/invalidatePendleVaultCaches/index.ts Decoupled from TrimmedPendlePtVaultInput; input type is now a minimal { fromToken; toToken } shape.
apps/evm/src/containers/VaultCard/PendleVaultModal/PositionTab/Footer/index.tsx Removed actionMode !== 'redeemAtMaturity' guard so PendleConvertDetails renders for matured vaults using the new isMatured prop.
apps/evm/src/clients/api/mutations/useWithdrawAtMaturityFromPendleVault/tests/index.spec.ts Good coverage: happy path, no-vToken case, analytics without vToken, and both guard-throw paths.
apps/evm/src/libs/errors/handleError/index.ts Trivial change: BaseError import converted to type-only.

Reviews (2): Last reviewed commit: "feat: update withdraw from matured Pendl..." | Re-trigger Greptile

@therealemjy therealemjy force-pushed the feat/pendle-withdraw branch from 659f9a6 to 849ad6b Compare June 3, 2026 13:39
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 3, 2026

🦋 Changeset detected

Latest commit: 012dae5

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 Minor

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

Coverage Report for ./apps/evm

Status Category Percentage Covered / Total
🔵 Lines 81.34% 45909 / 56434
🔵 Statements 81.34% 45909 / 56434
🔵 Functions 62.28% 649 / 1042
🔵 Branches 72.37% 5177 / 7153
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/evm/src/clients/api/index.ts 100% 100% 100% 100%
apps/evm/src/clients/api/mutations/useWithdrawAtMaturityFromPendleVault/index.ts 98.8% 90% 100% 98.8% 3
apps/evm/src/clients/api/mutations/useWithdrawFromPendleVault/index.ts 88.7% 85.71% 100% 88.7% 1, 39-51
apps/evm/src/containers/VaultCard/PendleVaultModal/PositionTab/Footer/index.tsx 100% 90% 100% 100%
apps/evm/src/containers/VaultCard/PendleVaultModal/PositionTab/Footer/PendleConvertDetails/index.tsx 100% 91.66% 100% 100%
apps/evm/src/containers/VaultCard/PendleVaultModal/PositionTab/WithdrawForm/index.tsx 96.12% 74.07% 100% 96.12% 100, 148-153
apps/evm/src/containers/VaultCard/TransactionForm/index.tsx 94.02% 88.57% 75% 94.02% 172-181, 188, 205-206
apps/evm/src/libs/errors/handleError/index.ts 92.1% 33.33% 100% 92.1% 3, 32-33
apps/evm/src/utilities/invalidatePendleVaultCaches/index.ts 98.27% 50% 100% 98.27% 1
Generated in workflow #13554 for commit 012dae5 by the Vitest Coverage Report Action

@therealemjy therealemjy force-pushed the feat/pendle-withdraw branch from dbdb61c to 012dae5 Compare June 3, 2026 14:01
@therealemjy
Copy link
Copy Markdown
Member Author

@greptile

makingAmount: BigInt(makingAmount),
}));

const formatWithdrawParams = ({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Curious why we moved formatWithdrawParams from its own file into the hook closure here — is it because it no longer has other consumers, or was there a typing reason?

A few concerns with the current shape: it conflicts with our "one export per file" convention, the helpers get re-created on every fn() call, and we lose the standalone unit-testability the original file had.

Happy to discuss if there's context I'm missing 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants