Skip to content

fix: exclude zero-LTV reserves from collateral swap destinations - #3196

Open
tydavid5 wants to merge 1 commit into
aave:mainfrom
tydavid5:fix/2522-exclude-zero-ltv-swaps
Open

tydavid5 wants to merge 1 commit into
aave:mainfrom
tydavid5:fix/2522-exclude-zero-ltv-swaps

Conversation

@tydavid5

Copy link
Copy Markdown

The collateral swap modal offers assets with a Loan-to-Value of 0 as swap targets. That is what this issue reports: swapping sDAI collateral to EURe leaves the user holding an asset that will not be enabled as collateral after the swap, since validateAutomaticUseAsCollateral returns false for a zero effective LTV.

This filters the destination list through the effective-LTV check the codebase already uses, hasNonZeroEffectiveLtv, which mirrors on-chain getUserReserveLtv. So an asset with base LTV 0 that still counts as collateral inside the user's e-mode category keeps showing up, and a genuinely zero-LTV asset does not. The check lives in its own module, collateralSwapDestination.ts, with a regression test covering the zero-LTV case, the e-mode cases, and the no-user fallback.

Verified locally: jest 10/10 (6 new tests plus the 4 existing ZeroLTVBlockingGuard tests), prettier clean, full tsc typecheck clean.

Fixes #2522

General Changes

  • Exclude zero-LTV reserves from collateral swap destinations in CollateralSwapModalContent
  • Add collateralSwapDestination.ts, filtering destinations through hasNonZeroEffectiveLtv
  • Add a regression test covering the zero-LTV case, the e-mode cases, and the no-user fallback

Developer Notes

Verified locally: jest 10/10 (6 new tests plus the 4 existing ZeroLTVBlockingGuard tests), prettier clean, full tsc typecheck clean.

Author Checklist

  • Tests were added and pass locally
  • Prettier and typecheck are clean
  • There are no breaking changes

Reviewer Checklist

Please ensure you, as the reviewer(s), have gone through this checklist to ensure that the code changes are ready to ship safely and to help mitigate any downstream issues that may occur.

  • End-to-end tests are passing without any errors
  • Code changes do not significantly increase the application bundle size
  • If there are new 3rd-party packages, they do not introduce potential security threats
  • If there are new environment variables being added, they have been added to the .env.example file
  • There are no CI changes, or they have been approved by the DevOps and Engineering team(s)

The collateral swap modal offered assets with a Loan-to-Value of 0 as swap targets, even though such an asset is not enabled as collateral after the swap. The destination list now filters with the repo's own effective-LTV helper, which mirrors on-chain getUserReserveLtv, so an asset that counts as collateral inside the user's e-mode category is still offered while a truly zero-LTV asset is not.

The check lives in collateralSwapDestination.ts with a regression test.

Fixes aave#2522
@vercel

vercel Bot commented Nov 21, 2026

Copy link
Copy Markdown

@tydavid5 is attempting to deploy a commit to the Aave Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

Aave swap allow wrong swap

1 participant