Skip to content

feat: protocol-wide deposit and loan totals on the markets header - #3107

Open
mgrabina wants to merge 2 commits into
mainfrom
protocol-wide-totals
Open

mgrabina wants to merge 2 commits into
mainfrom
protocol-wide-totals

Conversation

@mgrabina

@mgrabina mgrabina commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

General Changes

  • Adds Aave-wide "total deposits" and "total loans" to the markets page header, ahead of the market-specific stats, with a tooltip breaking each figure down by protocol version (V1 to V4).
  • Adds /api/protocol-totals, a server route that reads TokenLogic's markets snapshot with TL_API_KEY, prices token-unit deposits and borrows by reserve_price, groups rows by protocol, and returns USD totals. Good readings carry a 30-minute CDN cache header; errors are never cached.
  • The header renders nothing until a reading exists, so an unconfigured key or a failing upstream leaves the page exactly as it is today.

Context: #aave-v3-app thread. Same approach as Pro's ecosystem totals (aave/aave-pro#1443), pulling straight from TokenLogic rather than importing a second aave-kit instance.

Developer Notes

  • New server-only env var TL_API_KEY (TokenLogic REST API). It is a different credential from the Hasura TOKENLOGIC_API_KEY already used for sGHO APY; that key returns 401 on the REST endpoint. Same name as Pro so the Vercel secret can be copied over. Needs to be set on Vercel for the stats to appear.
  • TokenLogic's protocol ids are aave_v2, aave_v3 and aave_v4 (verified on the preview deployment after the key was added). The UI maps ids onto "Aave V1..V4" by matching a v1..v4 token and shows the raw id for anything else.
  • Deposits and borrows arrive in token units, not USD. The route multiplies by reserve_price and rejects empty or non-numeric fields while still accepting a genuine 0.
  • Verified on the preview deployment with the real key: the route returns 200 with about $34.1B deposits and $13.3B loans (V3 $32.8B, V4 $1.15B, V2 $0.13B), and the header, divider, tooltip and mobile wrap render as expected. Without the key the route returns 503 and the header is unchanged. Unit tests cover aggregation, field guards and version grouping.
  • Design is still being discussed in the thread (Stani floated moving stats into the filter row and showing all networks at once). This follows the Pro layout and can be reshaped when designs land.
  • Not covered by this PR: the static export build has no API routes, so the fetch 404s and the stats stay hidden there, same as the CoinGecko categories route.

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 as well as the pertinant .github/actions/* files
  • There are no CI changes, or they have been approved by the DevOps and Engineering team(s)

The markets header only showed figures for the selected market. Aave-wide
numbers (every version, every chain) now sit ahead of them, with a tooltip
breaking the total down by protocol version.

The v3 data sources are market-scoped, so the figures come from TokenLogic's
markets snapshot through a new server route, /api/protocol-totals. The route
reads TL_API_KEY, prices token-unit deposits and borrows by reserve_price,
groups by protocol, and lets the CDN cache a good reading for 30 minutes.
Errors are never cached and the header renders nothing until a reading
exists, so an unconfigured key leaves the page as it was.
@odin-by-borg

odin-by-borg Bot commented Sep 18, 2026

Copy link
Copy Markdown

Mjolnir Security Review

New commits since last review at 873571f.

Run Mjolnir Review


19 PRs reviewed · 1 finding

@vercel

vercel Bot commented Sep 18, 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 Sep 21, 2026 2:52pm UTC

Request 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: 873571f476

ℹ️ 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".

return useQuery<ProtocolTotals>({
queryKey: ['protocol-totals'],
queryFn: async () => {
const response = await fetch('/api/protocol-totals');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Fetch totals from a production-reachable endpoint

The production workflow in .github/workflows/build-test-deploy.yml invokes the composite build action, whose default command is build:static, and deploys the resulting out directory to IPFS for app.aave.com. That export contains no pages/api functions, so in production this same-origin request returns 404 and ProtocolTotalsStats renders nothing. The totals must come from an endpoint deployed independently of the static bundle or be included in the exported data.

Useful? React with 👍 / 👎.

Comment on lines +29 to +30
const totals = await fetchProtocolTotals(apiKey);
res.setHeader('Cache-Control', CACHE_CONTROL);

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 Prevent query strings from bypassing the upstream cache

In server-hosted deployments, this public route ignores req.query while its CDN cache is keyed by the requested URL. A caller can therefore request /api/protocol-totals?nonce=<unique> repeatedly, forcing a fresh authenticated TokenLogic request each time and defeating the cache intended to protect the upstream quota. Reject unexpected query parameters or cache the upstream result under a fixed server-side key.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown

📦 Next.js Bundle Analysis for aave-ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 1.34 MB (🟡 +1.28 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Sixteen Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/ 93.08 KB (🟡 +1.18 KB) 1.43 MB
/404 2.11 KB (🟢 -1 B) 1.34 MB
/500 2.44 KB (🟢 -1 B) 1.34 MB
/bridge 38.26 KB (🟢 -138 B) 1.37 MB
/dashboard 81.73 KB (🟢 -92 B) 1.42 MB
/faucet 11.37 KB (🟢 -105 B) 1.35 MB
/governance 43.18 KB (🟡 +108 B) 1.38 MB
/governance/ipfs-preview 97.74 KB (🟡 +96 B) 1.43 MB
/governance/v3/proposal 84.5 KB (🟡 +82 B) 1.42 MB
/history 28.62 KB (🟢 -3.95 KB) 1.37 MB
/markets 54.24 KB (🟡 +1.23 KB) 1.39 MB
/reserve-overview 39 KB (🟡 +108 B) 1.38 MB
/safety-module 55.26 KB (🟡 +77 B) 1.39 MB
/sgho 92.33 KB (🟡 +77 B) 1.43 MB
/staking 31.45 KB (🟢 -62 B) 1.37 MB
/v3-migration 48.59 KB (🟢 -57 B) 1.38 MB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

@github-actions

Copy link
Copy Markdown

@aave-code-review aave-code-review 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.

This review covered an earlier commit. It is superseded by the review for 76028464.

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

📦 Next.js Bundle Analysis for aave-ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 1.34 MB (🟡 +1.26 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Sixteen Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/ 93.08 KB (🟡 +1.18 KB) 1.43 MB
/404 2.11 KB (🟢 -1 B) 1.34 MB
/500 2.44 KB (🟢 -1 B) 1.34 MB
/bridge 38.26 KB (🟢 -138 B) 1.37 MB
/dashboard 81.73 KB (🟢 -92 B) 1.42 MB
/faucet 11.37 KB (🟢 -105 B) 1.35 MB
/governance 43.18 KB (🟡 +108 B) 1.38 MB
/governance/ipfs-preview 97.74 KB (🟡 +96 B) 1.43 MB
/governance/v3/proposal 84.5 KB (🟡 +82 B) 1.42 MB
/history 28.62 KB (🟢 -3.95 KB) 1.37 MB
/markets 54.24 KB (🟡 +1.23 KB) 1.39 MB
/reserve-overview 39 KB (🟡 +108 B) 1.38 MB
/safety-module 55.26 KB (🟡 +77 B) 1.39 MB
/sgho 92.33 KB (🟡 +77 B) 1.43 MB
/staking 31.45 KB (🟢 -62 B) 1.37 MB
/v3-migration 48.59 KB (🟢 -57 B) 1.38 MB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

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