Skip to content

[Chore] Add KNOWN_POOLS early-exit guard in api/v1/vaults/[vaultId].ts #279

Closed

Description

@collinsezedike

Problem

api/v1/vaults/[vaultId].ts calls fetchAllVaults() before checking whether the requested vaultId is known. On a cache miss, this triggers a full DeFiLlama round-trip only to return a 404. An unknown vault ID should be rejected immediately with no I/O.

Fix

Check KNOWN_POOLS (an O(1) map lookup by vault ID) before calling fetchAllVaults() and return 404 immediately for unrecognised IDs:

if (!KNOWN_POOLS[vaultId]) {
  return res.status(404).json({ error: "Vault not found" });
}
const vaults = await fetchAllVaults();

Acceptance Criteria

  • pnpm lint && pnpm typecheck && pnpm test pass with no errors
  • A request for an unknown vault ID returns 404 without making any network call

Activity

  1. added
    enhancementNew feature or request
    trivialSelf-contained task, completable in < 2 hours with no deep protocol knowledge required
    apiAdds or modifies a REST endpoint in apps/api
    on Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiAdds or modifies a REST endpoint in apps/apienhancementNew feature or requesttrivialSelf-contained task, completable in < 2 hours with no deep protocol knowledge required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions