Skip to content

Add a lastUpdated timestamp to the Pool interface in models/liquidity.ts so clients can tell how fresh aggregated data is #167

Description

@Jagadeeshftw

📌 Description

LiquidityEntry carries an updatedAt timestamp, but the aggregated Pool interface ({ asset, total, anchors }, computed on-the-fly by LiquidityRepository.pools()) has no timestamp at all. A client reading GET /api/v1/liquidity or GET /api/v1/liquidity/:asset has no way to tell how recently any of the underlying entries changed without separately fetching /entries and computing a max updatedAt themselves.

🧩 Requirements and context

  • Add an optional lastUpdated?: string field to the Pool interface, computed as the max updatedAt across the asset's contributing LiquidityEntry records.
  • Compute it in LiquidityRepository.pools() alongside the existing total/anchors aggregation, with no extra full-table pass.
  • Update LiquidityService.listPools/getPool callers implicitly (no code change needed if they just pass the Pool through) and openapi.ts's documented response shape.

🛠️ Suggested execution

  • Modify src/repositories/liquidityRepository.ts's pools() method to track and set lastUpdated while iterating entries.
  • Modify src/models/liquidity.ts's Pool interface.
  • Update src/openapi.ts's /api/v1/liquidity and /api/v1/liquidity/{asset} response documentation.
  • Add tests in src/repositories/liquidityRepository.test.ts and src/services/liquidityService.test.ts asserting lastUpdated reflects the most recent contributing entry's updatedAt.

✅ Acceptance criteria

  • Pool.lastUpdated reflects the maximum updatedAt among the asset's entries.
  • GET /api/v1/liquidity and GET /api/v1/liquidity/:asset include the new field.
  • New tests pass; existing pool-shape tests are extended, not broken, by the additive field.

🔒 Security notes

N/A — read-only freshness metadata over already-exposed aggregate data.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issueapiHTTP/WebSocket APIenhancementNew feature or improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions