Skip to content

fix: runepool position loading on account pages + view position redirect - #12512

Open
kaladinlight wants to merge 1 commit into
developfrom
fix/runepool-position-fetch-and-redirect
Open

fix: runepool position loading on account pages + view position redirect#12512
kaladinlight wants to merge 1 commit into
developfrom
fix/runepool-position-fetch-and-redirect

Conversation

@kaladinlight

@kaladinlight kaladinlight commented Jul 31, 2026

Copy link
Copy Markdown
Member

Description

Two follow-up fixes to the savers/lending removal + RUNEPool extraction (#12511):

  1. Infinite spinner opening the RUNEPool opportunity from account pages. Account/asset pages render the DeFi section (EarnOpportunities) but nothing on those pages mounts the opportunities fetch — the only fetcher was DeFiEarn (earn dashboard / wallet drawer). The row balance and overview modal previously worked off redux-persisted userStaking entries from earlier earn-dashboard sessions; the savers-removal migration (v7) correctly wiped that state and exposed the gap, leaving the modal spinning forever on isLoaded: false. Fix: mount useFetchOpportunities() alongside the section — fully deduped with the earn dashboard via the shared react-query key, so no extra fetches when both are mounted.

  2. Broken layout after "View Position". The deposit/withdraw status screens navigated to /accounts/:accountId — the legacy chain-account page whose swap "sidebar" renders inside a plain block Container and has never laid out beside the content. Now routes to /accounts/:accountId/:assetId (the asset account page users actually browse, same target AccountEntryRow uses).

Issue (if applicable)

closes #

Risk

Low — one hook mount on account pages (deduped query, no new fetch volume when the earn dashboard is also mounted) and two navigation target changes. No transaction building or signing paths touched.

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

None — read-only opportunity data fetching and client-side routing only.

Testing

Engineering

  • On a wallet with a THORChain account, hard-reload directly on the account page (/#/accounts/<thorchain accountId>/cosmos:thorchain-1/slip44:931) without visiting the earn dashboard first. The RUNEPool row should show a balance, and clicking it should resolve the overview modal (position or empty state) instead of an infinite spinner.
  • Complete a RUNEPool deposit or withdraw and hit "View Position" on the status screen — it should land on the RUNE asset account page with the standard layout.

Operations

  • Account page → DeFi section → RUNEPool row opens and shows the position.
  • RUNEPool deposit/withdraw "View Position" lands on the RUNE account page.

Screenshots (if applicable)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Earn opportunities now load when viewing account or asset pages, even outside the main Earn dashboard.
    • Position links from deposit and withdrawal status views now open the relevant asset-specific account page.
  • Bug Fixes

    • Improved navigation to ensure positions lead to the correct account and asset context.

Account/asset pages render the DeFi section without anything mounting the
opportunities fetch, so the RUNEPool row balance and overview modal relied on
persisted state - wiped by the savers-removal migration, leaving an infinite
spinner. Mount useFetchOpportunities alongside the section (deduped with the
earn dashboard by the shared query key).

View position now routes to the asset account page instead of the legacy
chain account page, whose sidebar has never laid out beside the content.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kaladinlight
kaladinlight requested a review from a team as a code owner July 31, 2026 21:26
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change fetches earn opportunities when the opportunities section renders independently. RunePool deposit and withdraw status handlers now route positions to account pages that include both account and asset identifiers.

Changes

Earn opportunities and position navigation

Layer / File(s) Summary
Standalone opportunity loading
src/components/StakingVaults/EarnOpportunities.tsx
EarnOpportunitiesContent imports and invokes useFetchOpportunities during rendering.
Asset-specific position routing
src/features/defi/providers/runepool/components/RunePoolManager/{Deposit,Withdraw}/components/Status.tsx
Deposit and withdraw position handlers require assetId and navigate to /accounts/{accountId}/{assetId}.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: 0xapotheosis

Poem

A rabbit checks the vault with care,
Fetching opportunities everywhere.
Deposit, withdraw, routes align,
Account and asset now combine.
Hop, hop—position views are fine!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes both main changes: account-page position loading and the View Position redirect.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/runepool-position-fetch-and-redirect

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kaladinlight
kaladinlight enabled auto-merge (squash) July 31, 2026 21:28

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/features/defi/providers/runepool/components/RunePoolManager/Deposit/components/Status.tsx`:
- Around line 100-103: Update both Status navigation handlers in
src/features/defi/providers/runepool/components/RunePoolManager/Deposit/components/Status.tsx
(lines 100-103) and
src/features/defi/providers/runepool/components/RunePoolManager/Withdraw/components/Status.tsx
(lines 101-104) to URL-encode accountId and assetId before constructing the
/accounts navigation path, preserving the existing guard and navigate behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 727b09d5-0b90-406f-94da-e20c17239c6a

📥 Commits

Reviewing files that changed from the base of the PR and between 6391fc2 and a6d0c7f.

📒 Files selected for processing (3)
  • src/components/StakingVaults/EarnOpportunities.tsx
  • src/features/defi/providers/runepool/components/RunePoolManager/Deposit/components/Status.tsx
  • src/features/defi/providers/runepool/components/RunePoolManager/Withdraw/components/Status.tsx

Comment on lines +100 to +103
if (!accountId || !assetId) return
// The full-page earn dashboard is mobile-only - the asset account page shows the position on both layouts
navigate(`/accounts/${accountId}/${assetId}`)
}, [accountId, assetId, navigate])

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

rg -n -C 4 \
  'accounts/:accountId/:assetId|handleViewPosition|encodeURIComponent|generatePath' \
  src/features/defi/providers/runepool \
  src/components/AssetAccounts \
  src/hooks/useRouteAssetId

Repository: shapeshift/web

Length of output: 7457


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf 'Candidate files:\n'
fd -a 'Status.tsx|useRouteAssetId.ts|AssetAccountRow.tsx|Routing|Routes|react-router-dom' src | sed 's#^#  #' | head -80

printf '\nAssetAccountRow generated path section:\n'
sed -n '60,95p' src/components/AssetAccounts/AssetAccountRow.tsx

printf '\nRouteAssetId hook:\n'
sed -n '1,120p' src/hooks/useRouteAssetId/useRouteAssetId.ts

printf '\nRunePool deposit/withdraw status navigation imports and handlers:\n'
for f in \
  src/features/defi/providers/runepool/components/RunePoolManager/Deposit/components/Status.tsx \
  src/features/defi/providers/runepool/components/RunePoolManager/Withdraw/components/Status.tsx
do
  echo "--- $f"
  sed -n '1,115p' "$f"
done

printf '\nReact Router usage around AssetAccountRow path:\n'
rg -n -C 5 'routesForAsset|Route|path=.*accountId|AssetAccountRow' src | head -200

printf '\nCAIP assetId/accountId references:\n'
rg -n 'type AssetId|AccountId.*= string|fromAccountId|toAccountId|assetId.*chain/asset|AccountId<|AssetId<' -g '*.{ts,tsx}' src | head -200

Repository: shapeshift/web

Length of output: 50370


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf 'Assets definitions for CAIP types:\n'
fd -a 'assets.ts|index.ts' src | rg 'caip|assets' | head -80

printf '\nAccounts route definitions:\n'
rg -n -C 8 'path=.*accounts|Route.*Account|Link to /accounts|generatePath.*accountId|encodeURIComponent|useRouteAssetId' src/pages src/components src/Routes | head -220

printf '\nTest deterministic route matching for raw vs encoded path params via Node URL parsing only:\n'
node - <<'JS'
const accountId = 'eip155:1:0xabc/def'
const assetId = 'eip155:1/ERC20:0xdef/abc'
const raw = `/accounts/${accountId}/${assetId}`
console.log({ raw, segments: raw.split('/').filter(Boolean).length })
console.log({ encoded: `/accounts/${encodeURIComponent(accountId)}/${encodeURIComponent(assetId)}` })
JS

Repository: shapeshift/web

Length of output: 17757


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf 'Accounts page route rendering:\n'
sed -n '1,170p' src/pages/Accounts/Accounts.tsx

printf '\nAccounts Account route params routing:\n'
sed -n '1,220p' src/pages/Accounts/Account.tsx

printf '\nAll direct /accounts/:accountId/:assetId generatePath/navigate calls:\n'
rg -n -C 3 "generatePath\\('/accounts/:accountId/:assetId'|generatePath\\(\\\"/accounts/:accountId/:assetId\"|navigate\\(`/accounts/\\$|navigate\\(`/accounts/${accountId}/${assetId}`|navigate\\(`/accounts/\\$\\{accountId\\}/\\$\\{assetId\\}`" src

Repository: shapeshift/web

Length of output: 5934


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf 'Navigations between RunePool status and asset account subroutes:\n'
rg -n -C 5 "navigate\\(`/accounts/\\$\\{accountId\\}/\\$\\{assetId\\}`|navigate\\(\\`/accounts/\\$\\{accountId\\}/\\$\\{assetId\\}\\`|navigate\\(/accounts/|Link\\|useLocation|useParams|assetId\\)" \
  src/features/defi/providers/runepool \
  src/pages/Accounts \
  src/components/AssetAccountDetails \
  src/hooks/useRouteAssetId \
  src/components/AssetAccounts/AssetAccountRow.tsx

Repository: shapeshift/web

Length of output: 43320


Encode account ID and asset ID in the account navigation.

Both RunePool status screens build /accounts/${accountId}/${assetId} with raw CAIP values. If either value contains /, React Router split that pathname into extra segments, and the :accountId/* / :accountId/:chainId/:assetSubId routes receive the wrong params. URL-encode accountId and assetId before navigation in both status handlers.

📍 Affects 2 files
  • src/features/defi/providers/runepool/components/RunePoolManager/Deposit/components/Status.tsx#L100-L103 (this comment)
  • src/features/defi/providers/runepool/components/RunePoolManager/Withdraw/components/Status.tsx#L101-L104
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/features/defi/providers/runepool/components/RunePoolManager/Deposit/components/Status.tsx`
around lines 100 - 103, Update both Status navigation handlers in
src/features/defi/providers/runepool/components/RunePoolManager/Deposit/components/Status.tsx
(lines 100-103) and
src/features/defi/providers/runepool/components/RunePoolManager/Withdraw/components/Status.tsx
(lines 101-104) to URL-encode accountId and assetId before constructing the
/accounts navigation path, preserving the existing guard and navigate behavior.

Source: Learnings

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.

1 participant