Skip to content

Fix/rate limit pools swaps dto normalize#463

Open
james2177 wants to merge 4 commits into
Vatix-Protocol:mainfrom
james2177:fix/rate-limit-pools-swaps-dto-normalize
Open

Fix/rate limit pools swaps dto normalize#463
james2177 wants to merge 4 commits into
Vatix-Protocol:mainfrom
james2177:fix/rate-limit-pools-swaps-dto-normalize

Conversation

@james2177

Copy link
Copy Markdown

Summary

Related issue

Closes #373
closes #374
closes #375
closes #376

What was implemented

Issue 1 — Rate limit POST /transactions

File: rate-limit/rate-limit.middleware.ts

Added a specific sliding-window rule for POST /transactions in endpointRuleFor(): 20 req/min for public callers, 120 req/min for internal. The routeBucketFor() method now buckets /transactions separately so its Redis key is isolated from the global counter. Two new env vars control the limits: TRANSACTION_RATE_LIMIT_PER_MINUTE and INTERNAL_TRANSACTION_RATE_LIMIT_PER_MINUTE. Two tests were added verifying the X-RateLimit-Limit: 20 header is applied to POST but not GET on that path.


Issue 2 — GET /pools filter by token pair

Files: pools/dto/get-pools-query.dto.ts, pools/pool.types.ts, pools/pools.repository.ts, pools/pools.service.ts

Added optional token0 and token1 query params. When both are supplied the repository performs a bidirectional exact-pair match ((t0=A AND t1=B) OR (t0=B AND t1=A)). When only one is supplied it matches either position. These coexist with the existing search param. The service passes them through and includes them in the cache key to isolate pair-filtered results. Two unit tests added.


Issue 3 — GET /swaps pagination by pool

Files: swaps/dto/get-swaps-query.dto.ts, swaps/swap.types.ts, swaps/swaps.repository.ts, swaps/swaps.service.ts, swaps/swaps.controller.ts

Renamed the ambiguous pool query param to poolId throughout the DTO, internal SwapsQuery type, and repository so the intent is unambiguous. Added @apitags('Swaps'), @apioperation, and @apiresponse to SwapsController so the endpoint is fully documented in Swagger. Tests updated to use poolId.


Issue 4 — Normalize DTO field names tokenPair

Files: swaps/swaps.service.ts, swaps/swaps.service.spec.ts

Added a tokenPair: string field to SwapResponse computed as "TOKEN0SYMBOL/TOKEN1SYMBOL" (e.g. "USDC/XLM"). The existing token0Symbol/token1Symbol fields are kept for backward compatibility. A dedicated test asserts the field is present and correctly formatted.

Type of change

  • Bug fix
  • New feature
  • Docs update
  • Chore / refactor

Checklist

  • CI passes (lint + tests + build)
  • Self-reviewed the diff
  • Added or updated tests where relevant
  • Docs updated if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Normalize DTO field names tokenPair GET /swaps pagination by pool GET /pools filter by token pair Rate limit POST /transactions

1 participant