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

@therealemjy therealemjy commented Jun 3, 2026

Copy link
Copy Markdown
Member

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

vercel Bot commented Jun 3, 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 24, 2026 2:54pm
dapp-testnet Ready Ready Preview Jun 24, 2026 2:54pm
venus.io Ready Ready Preview Jun 24, 2026 2:54pm

Request Review

@greptile-apps

greptile-apps Bot commented Jun 3, 2026

Copy link
Copy Markdown

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

changeset-bot Bot commented Jun 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a349313

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

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for ./apps/evm

Status Category Percentage Covered / Total
🔵 Lines 82% 48869 / 59592
🔵 Statements 82% 48869 / 59592
🔵 Functions 62.73% 675 / 1076
🔵 Branches 73.17% 5554 / 7590
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 98.64% 80% 100% 98.64% 4
apps/evm/src/clients/api/mutations/useWithdrawFromPendleVault/formatWithdrawParams/index.ts 97.36% 0% 100% 97.36% 1
apps/evm/src/clients/api/mutations/useWithdrawFromPendleVault/formatWithdrawParams/formatFillOrderParams/index.ts 100% 0% 100% 100%
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.17% 74.07% 100% 96.17% 101, 149-154
apps/evm/src/containers/VaultForm/index.tsx 95.06% 93.61% 75% 95.06% 186-195, 221-222
apps/evm/src/utilities/invalidatePendleVaultCaches/index.ts 98.27% 50% 100% 98.27% 1
Generated in workflow #13719 for commit a349313 by the Vitest Coverage Report Action

@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 🙏

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes you're right, let me update this.

@cuzz-venus cuzz-venus left a comment

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.

LGTM (except the conflicts)

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