Description
The Factory contract's get_pools_by_asset function does not cache or index results. Each call scans up to 200 pool IDs, even if the same query was made recently.
Current behavior
Every call scans from start_id, checking each pool's asset field.
Expected behavior
Consider:
- Maintaining a secondary index (DataKey::AssetPools)
- Or caching recent query results
- Or allowing callers to provide a hint based on previous results
Why this matters
Frequent queries for popular assets will repeatedly scan the same pools, wasting gas.
Labels
performance, factory, hard
Description
The Factory contract's
get_pools_by_assetfunction does not cache or index results. Each call scans up to 200 pool IDs, even if the same query was made recently.Current behavior
Every call scans from start_id, checking each pool's asset field.
Expected behavior
Consider:
Why this matters
Frequent queries for popular assets will repeatedly scan the same pools, wasting gas.
Labels
performance, factory, hard