Skip to content

Add a GET /api/v1/quote alias accepting query params, so this side-effect-free computation doesn't require a POST body #142

Description

@Jagadeeshftw

📌 Description

QuoteService.quote is a pure, side-effect-free computation (it reads pool state and returns a projected route/fee without mutating anything), yet routes/quote.ts only exposes it via POST /api/v1/quote. Read-only client integrations that want to preview a quote (e.g. from a browser via a plain link, or cached by an intermediary) currently must construct a POST request body for what is semantically a read.

🧩 Requirements and context

  • Add GET /api/v1/quote?asset=&amount= as an alternative to the existing POST /api/v1/quote, both calling the same QuoteService.quote.
  • Keep the existing POST endpoint and its request-body shape completely unchanged.
  • The stricter quote-specific rate limiter already mounted on /api/v1/quote in app.ts should apply equally to GET — confirm rather than assume this, since the existing rateLimiter() middleware only gates MUTATING_METHODS, which a GET is not.

🛠️ Suggested execution

  • Add a GET / handler in src/routes/quote.ts that maps req.query.asset/req.query.amount into the same shape service.quote(...) expects.
  • Because rateLimiter() only limits mutating methods, add an explicit note/decision in app.ts and this issue's PR about whether the new GET route needs its own non-mutating-aware limiter, since the existing quote-specific limiter effectively won't apply to it.
  • Update src/openapi.ts to add the new GET /api/v1/quote operation.
  • Add tests in src/routes/quote.test.ts for the new GET route including invalid/missing query params.

✅ Acceptance criteria

  • GET /api/v1/quote?asset=USDC&amount=100 returns the same result shape as the equivalent POST body.
  • Existing POST /api/v1/quote behavior and tests are unchanged.
  • The rate-limiting implication of adding an unthrottled GET route for a compute-bearing endpoint is explicitly addressed (either a limiter is added, or the decision not to is documented).

🔒 Security notes

Because QuoteService.quote does real computation (sorting/aggregating pool entries) on every call, an unthrottled GET alias could reintroduce the same abuse risk the quote-specific POST rate limiter was added to prevent — this must be resolved as part of the same change, not left as a follow-up.

📋 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