Skip to content

Add a LiquidityRepository.byAnchor(anchor) method to list every asset balance for one anchor #161

Description

@Jagadeeshftw

📌 Description

LiquidityRepository exposes byAsset(asset) (used by QuoteService) but has no symmetric byAnchor(anchor) to list every asset balance held by a single anchor. LiquidityService/routes currently have no efficient way to answer "what does anchor X hold across all assets" without calling all() and filtering client-side.

🧩 Requirements and context

  • Add byAnchor(anchor: string): LiquidityEntry[] to LiquidityRepository, mirroring the existing byAsset method's shape and doc-comment style.
  • Add a corresponding LiquidityService.listByAnchor(anchor) and a GET /api/v1/liquidity/anchors/:anchor route (chosen to avoid colliding with the existing GET /:asset route).

🛠️ Suggested execution

  • Add byAnchor to src/repositories/liquidityRepository.ts.
  • Add listByAnchor to src/services/liquidityService.ts.
  • Add the route to src/routes/liquidity.ts, taking care of route-ordering relative to the existing /:asset and /entries routes.
  • Update src/openapi.ts with the new path.
  • Add tests in src/repositories/liquidityRepository.test.ts, src/services/liquidityService.test.ts, and src/routes/liquidity.test.ts.

✅ Acceptance criteria

  • byAnchor returns exactly the entries belonging to the given anchor across all assets.
  • The new route doesn't shadow or get shadowed by /:asset or /entries, verified by a routing test.
  • New tests pass at all three layers.

🔒 Security notes

N/A — read-only addition exposing data already reachable (less conveniently) via the existing unfiltered entries endpoint.

📋 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 issuedatabasePostgreSQL / persistenceenhancementNew feature or improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions