Skip to content

Perf: Optimize multi-pool health check with batched storage reads #635

Description

@devdianax

Context

Liquidators and frontends query health across multiple pools. Each query is a separate storage read.

Current Limitation/Problem

Health check per pool requires separate cross-contract call. N pools = N calls with N storage reads each.

Expected Outcome

Batched health check function that reads multiple pool states in a single call and computes health for all.

Acceptance Criteria

  • BatchView function: accepts array of (pool, user, asset) tuples
  • Single storage read to load pool config for all queried pools
  • Parallel health computation: no cross-contract calls between computations
  • Response: array of health factors, collateral values, debt values
  • Gas comparison: batched vs individual per query count
  • Pagination for large queries (100+ positions)
  • Caching: cache batched results within transaction scope

Technical Scope

  • contracts/lending-pool/src/batch_view.rs - batched health check
  • Frontend use: batch all visible positions in single query
  • Gas benchmark: individual vs batched at various query sizes
  • Edge cases: partial results on pool failure, stale data in cached results

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions