Context
Transaction simulations (preview deposit, preview borrow) are recomputed on every call with no caching.
Current Limitation/Problem
Each simulation query recomputes state from scratch. Identical simulations within same block waste compute.
Expected Outcome
Block-scoped simulation cache that reuses results for identical simulation parameters within the same block.
Acceptance Criteria
- Cache key: (operation, pool, user, asset, amount) hashed
- Cache scope: single block, cleared on new block
- Read path: check cache before computing simulation
- Write-through: update cache as operations execute
- Cache size limit: LRU eviction for large caches
- Gas savings: identical simulation in same block uses cached result
- Integration with frontend: batch simulation requests for position preview
Technical Scope
contracts/lending-pool/src/simulation_cache.rs - simulation cache
- Frontend integration for batch simulations
- Gas benchmark: cached vs uncached simulation
- Edge cases: cache poisoning, state change mid-block invalidation
Context
Transaction simulations (preview deposit, preview borrow) are recomputed on every call with no caching.
Current Limitation/Problem
Each simulation query recomputes state from scratch. Identical simulations within same block waste compute.
Expected Outcome
Block-scoped simulation cache that reuses results for identical simulation parameters within the same block.
Acceptance Criteria
Technical Scope
contracts/lending-pool/src/simulation_cache.rs- simulation cache