Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the DeFi Market (Aave/Benqi) UX and safety checks by adding health-score projection/alerts, tightening withdraw/borrow constraints, and making several UI/layout refinements across deposit/borrow/repay flows.
Changes:
- Add projected health score UI (and blocking errors) to borrow/deposit/withdraw amount selection flows.
- Add collateral-disable confirmation alerts based on projected health score; fetch protocol-specific collateral/ltv factors where needed.
- Refactor collateral selection screen into protocol-specific content components and apply assorted UI tweaks (logos, dropdowns, list headers, icons).
Reviewed changes
Copilot reviewed 43 out of 44 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/k2-alpine/src/components/TokenUnitInput/SendTokenUnitInputWidget.tsx | Add maxAmountZeroMessage prop to customize “max=0” error messaging. |
| packages/k2-alpine/src/assets/icons/expand_more.svg | Update expand-more icon path. |
| packages/core-mobile/app/utils/formatNumber/formatNumber.ts | Allow passing a custom formatter for “normal” magnitude numbers. |
| packages/core-mobile/app/new/features/defiMarket/utils/healthRisk.ts | Use formatNumber for large (>=100) health score formatting. |
| packages/core-mobile/app/new/features/defiMarket/utils/collateralHealthAlert.ts | Add helper to show a confirm/blocking alert when disabling collateral harms health score. |
| packages/core-mobile/app/new/features/defiMarket/utils/borrow.ts | Add Aave ltv + Benqi collateralFactor; reduce duplicate scaling via WAD_SCALE; extend Benqi data fetch via multicall. |
| packages/core-mobile/app/new/features/defiMarket/utils/benqiBorrowPositionsSummary.ts | Use WAD_SCALE constant for health score math. |
| packages/core-mobile/app/new/features/defiMarket/utils/benqiBorrowPositionsSummary.test.ts | Update mocks for new Benqi borrow-data shape (collateralFactor). |
| packages/core-mobile/app/new/features/defiMarket/utils/aaveBorrowPositionsSummary.test.ts | Update mocks for new Aave borrow-data shape (ltv). |
| packages/core-mobile/app/new/features/defiMarket/types.ts | Extend market/borrow types with baseLTVasCollateral, ltv, and collateralFactor. |
| packages/core-mobile/app/new/features/defiMarket/screens/repay/RepaySelectAmountScreen.tsx | Simplify navigation dismissal using dismissAll(). |
| packages/core-mobile/app/new/features/defiMarket/screens/DepositTabScreen.tsx | Improve list refresh behavior with stable keying + hide dropdowns when empty; minor spacing tweaks. |
| packages/core-mobile/app/new/features/defiMarket/screens/DepositDetailScreen.tsx | Pass theme-based border color to logos and fix memo deps. |
| packages/core-mobile/app/new/features/defiMarket/screens/borrow/SelectCollateralScreen.tsx | Refactor to protocol-specific content components. |
| packages/core-mobile/app/new/features/defiMarket/hooks/benqi/useBenqiWithdraw.ts | Invalidate Benqi borrow-data query after withdraw confirmation. |
| packages/core-mobile/app/new/features/defiMarket/hooks/benqi/useBenqiSetCollateral.ts | Invalidate Benqi borrow-data query after collateral toggle settles. |
| packages/core-mobile/app/new/features/defiMarket/hooks/benqi/useBenqiHealthScore.ts | New hook for current/projected Benqi health score calculations. |
| packages/core-mobile/app/new/features/defiMarket/hooks/aave/useAaveZeroLtvCollateral.ts | New hook to detect Aave “LTV=0 collateral enabled” situations that can block actions. |
| packages/core-mobile/app/new/features/defiMarket/hooks/aave/useAaveWithdraw.ts | Invalidate Aave borrow/reserves queries after withdraw confirmation. |
| packages/core-mobile/app/new/features/defiMarket/hooks/aave/useAaveSetCollateral.ts | Invalidate Aave borrow-data query after collateral toggle settles. |
| packages/core-mobile/app/new/features/defiMarket/hooks/aave/useAaveHealthScore.ts | New hook for current/projected Aave health factor calculations. |
| packages/core-mobile/app/new/features/defiMarket/hooks/aave/useAaveAvailableMarkets.ts | Populate baseLTVasCollateral in available-market objects. |
| packages/core-mobile/app/new/features/defiMarket/consts.ts | Add WAD_SCALE BigInt constant (1e18). |
| packages/core-mobile/app/new/features/defiMarket/components/withdraw/BenqiSelectAmountForm.tsx | Add max-safe-withdraw and health score projection to Benqi withdraw flow; customize labels/messages. |
| packages/core-mobile/app/new/features/defiMarket/components/withdraw/AaveSelectAmountForm.tsx | Add max-safe-withdraw, health score projection, and Aave zero-LTV blocking to Aave withdraw flow. |
| packages/core-mobile/app/new/features/defiMarket/components/SelectAmountFormBase.tsx | Show projected health score card and optional blocking error; support custom balance label + max=0 message. |
| packages/core-mobile/app/new/features/defiMarket/components/repay/RepaySelectAmountFormBase.tsx | Improve “full repay” health-score handling; show transition (current → projected). |
| packages/core-mobile/app/new/features/defiMarket/components/HealthScoreCard.tsx | Show current→projected transition and compute colors locally. |
| packages/core-mobile/app/new/features/defiMarket/components/deposit/BenqiErc20SelectAmountForm.tsx | Add Benqi health score projection to deposit flow. |
| packages/core-mobile/app/new/features/defiMarket/components/deposit/BenqiAvaxSelectAmountForm.tsx | Add Benqi health score projection to AVAX deposit flow. |
| packages/core-mobile/app/new/features/defiMarket/components/deposit/AaveErc20SelectAmountForm.tsx | Add Aave health score projection; use underlying address consistently for allowance check. |
| packages/core-mobile/app/new/features/defiMarket/components/deposit/AaveAvaxSelectAmountForm.tsx | Add Aave health score projection for AVAX deposit flow. |
| packages/core-mobile/app/new/features/defiMarket/components/DefiMarketLogo.tsx | Add configurable border styling for protocol logos. |
| packages/core-mobile/app/new/features/defiMarket/components/DefiMarketAssetLogo.tsx | Route border styling through to protocol logo; adjust sizing for border. |
| packages/core-mobile/app/new/features/defiMarket/components/BorrowProtocolSelector.tsx | Layout tweaks for the borrow protocol selector trigger. |
| packages/core-mobile/app/new/features/defiMarket/components/borrow/SelectCollateralBase.tsx | Extract shared collateral selection list UI into a reusable base component. |
| packages/core-mobile/app/new/features/defiMarket/components/borrow/BorrowTabContent.tsx | Hide dropdowns when empty and adjust header spacing. |
| packages/core-mobile/app/new/features/defiMarket/components/borrow/BorrowSelectAmountFormBase.tsx | Add optional blocking error + show current→projected health transition. |
| packages/core-mobile/app/new/features/defiMarket/components/borrow/BenqiSelectCollateralContent.tsx | Implement Benqi collateral toggle with health-impact confirmation and toggling state. |
| packages/core-mobile/app/new/features/defiMarket/components/borrow/BenqiSelectAmountForm.tsx | Use shared USD→token conversion util + WAD_SCALE and update health math. |
| packages/core-mobile/app/new/features/defiMarket/components/borrow/AaveSelectCollateralContent.tsx | Implement Aave collateral toggle with health-impact confirmation. |
| packages/core-mobile/app/new/features/defiMarket/components/borrow/AaveSelectAmountForm.tsx | Use shared USD→token conversion util + add Aave zero-LTV blocking. |
| packages/core-mobile/app/new/features/defiMarket/abis/benqiComptroller.ts | Add markets() ABI entry for collateral factor lookup. |
| packages/core-mobile/app/new/features/approval/components/SpendLimits/SpendLimitOptions.tsx | Adjust dropdown trigger layout and display value formatting. |
Comments suppressed due to low confidence (1)
packages/core-mobile/app/new/features/defiMarket/utils/borrow.ts:214
- The “Re-export for backward compatibility” comment no longer matches the code (the export was removed). Either restore the re-export or delete/update this comment to avoid confusion for future maintainers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/core-mobile/app/new/features/defiMarket/hooks/benqi/useBenqiHealthScore.ts
Show resolved
Hide resolved
packages/core-mobile/app/new/features/defiMarket/hooks/benqi/useBenqiHealthScore.ts
Show resolved
Hide resolved
packages/core-mobile/app/new/features/defiMarket/components/borrow/BenqiSelectAmountForm.tsx
Show resolved
Hide resolved
...s/core-mobile/app/new/features/defiMarket/components/borrow/BenqiSelectCollateralContent.tsx
Show resolved
Hide resolved
packages/core-mobile/app/new/features/defiMarket/components/withdraw/AaveSelectAmountForm.tsx
Outdated
Show resolved
Hide resolved
packages/core-mobile/app/new/features/defiMarket/components/withdraw/BenqiSelectAmountForm.tsx
Outdated
Show resolved
Hide resolved
packages/core-mobile/app/new/features/defiMarket/utils/collateralHealthAlert.ts
Show resolved
Hide resolved
packages/core-mobile/app/new/features/defiMarket/components/HealthScoreCard.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 43 out of 44 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
packages/core-mobile/app/new/features/defiMarket/utils/borrow.ts:214
- This file still contains the comment
// Re-export for backward compatibility, but the actual re-export has been removed. Please either restore the re-export (if still needed) or delete the stale comment to avoid misleading future changes.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/core-mobile/app/new/features/defiMarket/components/withdraw/AaveSelectAmountForm.tsx
Outdated
Show resolved
Hide resolved
packages/core-mobile/app/new/features/defiMarket/components/withdraw/BenqiSelectAmountForm.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 43 out of 44 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
packages/core-mobile/app/new/features/defiMarket/utils/borrow.ts:214
- There’s now a dangling
// Re-export for backward compatibilitycomment at the end of the file, but the re-export itself was removed. Either restore the export (if consumers still rely on it) or remove the comment to avoid confusion.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/core-mobile/app/new/features/defiMarket/utils/collateralHealthAlert.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 43 out of 44 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
packages/core-mobile/app/new/features/defiMarket/utils/borrow.ts:214
- The file still has a
// Re-export for backward compatibilitycomment, but the re-export was removed. Either restore the re-export (if external call sites still rely on it) or remove/update the comment to avoid implying compatibility that no longer exists.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/core-mobile/app/new/features/defiMarket/components/HealthScoreCard.tsx
Show resolved
Hide resolved
packages/core-mobile/app/new/features/defiMarket/components/HealthScoreCard.tsx
Outdated
Show resolved
Hide resolved
...es/core-mobile/app/new/features/defiMarket/components/borrow/AaveSelectCollateralContent.tsx
Outdated
Show resolved
Hide resolved
packages/core-mobile/app/new/features/defiMarket/components/withdraw/BenqiSelectAmountForm.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 44 out of 45 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
packages/core-mobile/app/new/features/defiMarket/utils/borrow.ts:214
- The file ends with
// Re-export for backward compatibilitybut the re-export was removed. Either restore the re-export (if external callers rely on it) or remove/update this comment to avoid misleading future maintainers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/core-mobile/app/new/features/defiMarket/hooks/benqi/useBenqiHealthScore.ts
Show resolved
Hide resolved
packages/core-mobile/app/new/features/defiMarket/components/withdraw/BenqiSelectAmountForm.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 44 out of 45 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
packages/core-mobile/app/new/features/defiMarket/utils/borrow.ts:214
- The file still says "Re-export for backward compatibility" but the actual re-export was removed. Either restore the intended re-export or remove/update this comment to avoid misleading future readers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Ticket: CP-13209
useAaveHealthScore,useBenqiHealthScore)SelectCollateralBasecomponent for Aave and BenqiScreenshots/Videos
ScreenRecording_03-12-2026.13-14-14_1.MP4
ScreenRecording_03-18-2026.12-40-12_1.MP4
Testing
iOS: 7773
Android: 7774
Health score on deposit/withdraw
Withdraw max safety
Zero LTV collateral blocking
Max repay health score
Collateral toggle pre-check
Non-collateral asset health score isolation
Checklist