feat(homepage): add DeFi section with positions display#26347
Conversation
- Add useDeFiPositionsForHomepage hook to fetch DeFi positions from Redux - Add DeFiSection component with skeleton loading state - Add unit tests for hook and component - DeFi section displays top 5 positions sorted by market value
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Since this is a new feature addition that is:
No E2E tags are required. The unit tests added in this PR provide adequate coverage for the new functionality. Performance Test Selection: |
|
|
cursor review |
| const sortedPositions = sortAssets( | ||
| defiPositionsList, | ||
| defiSortConfig, | ||
| ) as DeFiPositionEntry[]; |
There was a problem hiding this comment.
Duplicated DeFi position flattening and sorting logic
Medium Severity
The position flattening, sort config construction, and sortAssets call in useDeFiPositionsForHomepage are nearly line-for-line identical to the existing logic in DeFiPositionsList.tsx (lines 56–84). Both flatten chainFilteredDeFiPositions via the same Object.entries().map().flat() chain, both construct defiSortConfig with the same tokenFiatAmount key-mapping, and both call sortAssets identically. If the sort config mapping or flattening logic ever changes, both sites need to be updated in sync, risking divergent behavior between the full DeFi positions page and the homepage section.
There was a problem hiding this comment.
This is intended for now
| maxPositions: number = MAX_POSITIONS_DEFAULT, | ||
| ): UseDeFiPositionsForHomepageResult => { | ||
| const tokenSortConfig = useSelector(selectTokenSortConfig); | ||
| const defiPositions = useSelector(selectDeFiPositionsByAddress); |
There was a problem hiding this comment.
New code depends on deprecated selector
Low Severity
Brand-new code imports and uses selectDeFiPositionsByAddress, which is explicitly marked @deprecated with the note "Use selectDefiPositionsByEnabledNetworks instead." The hook relies on the deprecated selector solely to distinguish undefined (loading) from null (error), but selectDefiPositionsByEnabledNetworks already preserves those same undefined/null states via its defiPositionByAddress == null pass-through. The deprecated selector is redundant here and creates a dependency that will break when it's removed.
There was a problem hiding this comment.
This is intended for now





Description
This PR adds the DeFi section to the new Homepage, displaying the user's top DeFi positions.
What changed:
useDeFiPositionsForHomepagehook that fetches DeFi positions from theDeFiPositionsControllerRedux stateWhy:
Part of the Homepage redesign to consolidate wallet views into a single scrollable homepage with sections for Tokens, Perpetuals, Predictions, DeFi, and NFTs.
Changelog
CHANGELOG entry: null
Related issues
Refs: TMCU-420
Refs: TMCU-414
Refs: TMCU-457
Manual testing steps
Screenshots/Recordings
Before
Feature flag OFF (no changes)
Feature flag ON
After
Feature flag OFF (no changes)
Feature flag ON
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
UI now depends on DeFiPositionsController-derived data shaping and sorting; regressions could hide positions or misorder them, but changes are scoped to homepage rendering and tests are included.
Overview
Adds a functional DeFi homepage section that renders up to 5 DeFi protocol positions from controller-backed Redux state, including a skeleton loading UI and
privacyMode-aware list items.Introduces
useDeFiPositionsForHomepageto flatten multi-chain protocol data, derive loading/error/empty states, and sort/limit positions for display; the section now hides itself when disabled, empty, or errored, and exposes a no-oprefreshvia ref. Comprehensive unit tests were added/expanded for both the hook and the section behavior.Written by Cursor Bugbot for commit bce743b. This will update automatically on new commits. Configure here.