Skip to content

fix: align zero-LTV collateral guards and swap HF with on-chain rules - #3189

Open
sammdec wants to merge 1 commit into
mainfrom
samm/zero-ltv-collateral-actions
Open

sammdec wants to merge 1 commit into
mainfrom
samm/zero-ltv-collateral-actions

Conversation

@sammdec

@sammdec sammdec commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Reported by a tBTC holder on V3 Ethereum Core (tBTC frozen, LTV 0, enabled as collateral alongside WETH, with stablecoin debt). The interface blocked actions the Pool allows, and the collateral-swap review showed Health Factor going up when on-chain it goes down.

The interface applied the zero-LTV check (validateHFAndLtvzero) more broadly than the protocol does. On-chain it only runs when collateral is removed: withdrawing, transferring or disabling an aToken that is enabled as collateral.

  • Collateral toggle: enabling collateral was blocked by the zero-LTV error. It now only blocks when disabling a non-zero-LTV asset.
  • Withdraw: withdrawing a supply that is not enabled as collateral was blocked. It is now allowed.
  • Swap guard (collateral swap / repay with collateral / withdraw and swap): same gap; it now checks the withdrawn asset's collateral flag.
  • Collateral swap HF: calculateHFAfterSwap assumed the received asset always becomes collateral. Supply only auto-enables collateral on the first supply, so an existing supply keeps the user's current flag. The calculation now takes toAssetUserData into account.

Withdraw and the collateral toggle share a new isBlockedByZeroLTV helper in useZeroLTVBlockingWithdraw.tsx. Follows on from #3164.

Testing

  • New unit tests: isBlockedByZeroLTV, calculateHFAfterSwap, and two extra hasZeroLTVBlocking cases. Each was written failing first.
  • tsc is clean and lint shows no errors. 4 suites in src/utils/__tests__ (6 tests) fail on main as well.
  • Not yet checked manually on a fork.

Open question

The user reports the first aWBTC from the swap arrived with collateral disabled. By the auto-enable rule a first supply should enable it, so they may already have held aWBTC, or the adapter path behaves differently. Worth a fork simulation with their address. If it's the adapter, the first-swap HF preview can still be too high.

🤖 Generated with Claude Code

- Only block collateral toggle when disabling a non-zero-LTV asset; enabling
  collateral never runs validateHFAndLtvzero.
- Only block withdraw / swaps from a supply that is enabled as collateral;
  executeWithdraw and finalizeTransfer skip the check otherwise.
- Collateral swap HF: the received asset only counts as collateral when it
  is a first supply that auto-enables, or the existing supply already has
  collateral enabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
interface Ready Ready Preview Nov 17, 2026 1:40pm UTC

Request Review

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

📦 Next.js Bundle Analysis for aave-ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

This branch was successfully deployed

1 active deployment
Preview — 282e5873 Deployed Nov 17, 2026 by vercel[bot]
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