Skip to content

feat(app-data): read pool reserves and user positions from the backend - #3226

Draft
mgrabina wants to merge 6 commits into
mainfrom
v3-app-data-backend-reads
Draft

mgrabina wants to merge 6 commits into
mainfrom
v3-app-data-backend-reads

Conversation

@mgrabina

@mgrabina mgrabina commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Context: AppDataProvider polls UiPoolDataProvider and UiIncentiveDataProvider every 60s per tab, though the backend market query has the same data.

Now: reserves, eModes and the user summary come from the backend on the markets it serves, and refetch once a tx is indexed. Claimable rewards and getEModes keep their RPC reads. Unserved markets, forks and any failed backend read fall back to RPC.

  • (implicit) Backend balances feed the existing formatUserSummary with unit indexes, so the HF and yield math stays as it is.

Checked: field by field against RPC on 5 markets: 24/24 accounts match on the prod backend, and 12,286 reserve values differ only in token names and the weETH price drift. Locally: 3 requests a minute per tab, 0 while hidden.

Review in order:

  1. sdkLegacyReserves.ts, sdkLegacyUser.ts
  2. useBackendAppData.ts, useAppDataProvider.tsx
  3. refreshPoolData.ts and call sites

Part of SDK-1126

…d behind a flag

With NEXT_PUBLIC_ENABLE_BACKEND_POOL_READS=true, AppDataProvider builds the
legacy reserves, eModes and user summary from the @aave/client market,
userSupplies and userBorrows queries on markets the backend serves, and the
UiPoolDataProvider and UiIncentiveDataProvider polls stop there. Claimable
incentives keep their RPC reads in the claim modal and dashboard panel.
After a tx the backend data is refetched once the backend indexes it.

Off by default: the prod backend prices weETH 0.26% off the chain.
@mgrabina

mgrabina commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@vercel

vercel Bot commented Dec 3, 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 Dec 3, 2026 8:11pm UTC

Request Review

@linear-code

linear-code Bot commented Dec 3, 2026

Copy link
Copy Markdown

SDK-1126

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T19:28:19.035006Z c5c7a37 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af18d5e42d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +15 to +16
const rpcUser = useExtendedUserSummariesAndIncentives(rpcMarkets)[0];
const rpcReserves = usePoolsFormattedReserves(rpcMarkets)[0];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid re-enabling full RPC polling for claimable rewards

With backend pool reads enabled, the dashboard still polls the entire RPC data graph because DashboardTopPanel calls this hook unconditionally. useExtendedUserSummariesAndIncentives transitively subscribes to pool reserves, user reserves, reserve incentives, user incentives and eModes, and these hooks retain their 60-second polling intervals. Consequently, the dashboard adds the backend requests without eliminating the RPC reads this feature is intended to replace. Read only the incentive data needed for claims instead of constructing a complete RPC user summary; the dashboard's existing useEnhancedUserYield subscription also needs to use backend app data to avoid independently keeping the same polling graph active.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Dec 3, 2026

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! 🙌

…led read

The markets query polls and refetches on focus only with the flag on, with
one retry so an outage falls back to RPC quickly. A failed getEModes read or
eMode-id fallback now sends the market back to RPC instead of loading forever.
@mgrabina

mgrabina commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4671b0acc2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +108 to +110
failed:
(positionsQuery.isError && !positions) ||
(!!eModesQuery?.isError && !eModesQuery.data) ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fall back to RPC when backend refreshes fail

With backend reads enabled, an outage after the first successful fetch never activates the RPC fallback: React Query retains cached data on refetch errors, so positionsQuery.isError && !positions remains false. Errors from the market snapshot query are also not considered by servedByBackend in useAppDataProvider.tsx. Consequently, the provider continues serving stale balances, prices and health factors with loading cleared for the duration of the outage, even when RPC is healthy. Include refresh errors from both backend queries in the fallback decision rather than limiting fallback to errors without cached data.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Dec 3, 2026

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! 🙌

React Query keeps cached data on refetch errors, so the fallback also has
to trigger on errors with data, for both the market and the positions query.
@mgrabina

mgrabina commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: c5c7a37c43

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@mgrabina mgrabina changed the title feat(app-data): read pool reserves and user positions from the backend behind a flag feat(app-data): read pool reserves and user positions from the backend Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Dec 3, 2026

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! 🙌

…fetches

A refetch of a query that never got data resets react-query's isPending and
isError, so every pool invalidation dropped the RPC reads on forks and on any
market whose backend read had failed, emptying reserves mid-transaction.
Decide from the last settled fetch instead.
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Dec 3, 2026

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 — 9a384bf3 Deployed Dec 3, 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.

1 participant