Skip to content

Feature/api backlog batch - #682

Merged
Mimah97 merged 4 commits into
Vatix-Protocol:mainfrom
deeejaymu-afk:feature/api-backlog-batch
Jul 27, 2026
Merged

Feature/api backlog batch#682
Mimah97 merged 4 commits into
Vatix-Protocol:mainfrom
deeejaymu-afk:feature/api-backlog-batch

Conversation

@deeejaymu-afk

Copy link
Copy Markdown
Contributor

Summary

Related issue

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

Add CANDLES_QUEUE_NAME alongside the existing QUEUE_NAMES map in
indexer/queues.ts so the candle-aggregation queue name lives in the same
module as the indexer's queue names instead of as a standalone string
literal in candles.processor.ts. Kept out of QUEUE_NAMES itself since
IndexerWorker iterates Object.values(QUEUE_NAMES) to attach its DLQ
QueueEvents listeners, and the candle queue has its own listeners.
Bound CandlesWorker.onModuleDestroy with a timeout (mirroring
IndexerWorker's SHUTDOWN_TIMEOUT_MS pattern) so a stuck candle job can't
hang the process past a deploy platform's kill grace period, log the
drain start/end, expose isShuttingDown, and guard against closing an
unset worker if SIGTERM arrives before onModuleInit finishes.

Each priceCandle write is already a single upsert of the fully-computed
OHLCV row, so there's no partial/incremental write to corrupt if a job is
interrupted between pools — documented in candles.processor.ts and in a
new "Graceful Shutdown" section of docs/OPS_DEPLOYMENT.md, alongside a
test suite covering the drain, timeout, and pre-init-shutdown paths.
mockToken/mockPool/mockSwap in mock-factories.ts didn't match the actual
Prisma schema (e.g. mockPool used address/token0Id/tvlUsd — fields that
don't exist on the real Pool model) and were unused anywhere, so they
silently drifted. Fix them to mirror prisma/schema.prisma, drop the
unused mockOhlcv (no Ohlcv model exists), and add mockPoolDetailData(),
a composite factory for the { pool, token0, token1 } shape
PoolsRepository.getPoolDetailById() returns.

Refactor pools.service.spec.ts's getPoolTicks() and findPoolById() suites
to build fixtures from these factories instead of three near-duplicate
20-line inline object literals.
There was no swap-quote endpoint in the API at all — quote math only
existed client-side in packages/sdk/src/quote.ts, using a placeholder
constant-product formula with hardcoded reserves. Add a real endpoint
that estimates a quote from the pool's actual current spot price
(decoded from currentSqrtPrice) and feeTier, going through PoolsService
so it reuses the existing pool lookup path.

SwapQuoteRequestDto/SwapQuoteResponseDto carry realistic @ApiProperty
examples, and the controller's @ApiBody adds a full request example —
both verified to appear in the generated OpenAPI JSON by a new
swaps.swagger.spec.ts test that builds the document via
SwaggerModule.createDocument() and asserts on it directly.

Also fixes swaps.e2e.spec.ts's `import * as request from 'supertest'`
to the default import used everywhere else in the codebase — the
namespace import made every test in the file throw "request is not a
function", which was silently swallowing failures (including two
pre-existing, unrelated test bugs the fix now surfaces: a poolId/pool
query-param mismatch and a non-Stellar-format wallet address in two
GET /swaps tests — left alone as out of scope here).
@Mimah97
Mimah97 merged commit 1d71400 into Vatix-Protocol:main Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants