Skip to content

feat: persist pools repository with Prisma and include poolId in pric…#457

Merged
Mimah97 merged 1 commit into
Vatix-Protocol:mainfrom
CHKM001:feat/persist-pools-repository
Jun 30, 2026
Merged

feat: persist pools repository with Prisma and include poolId in pric…#457
Mimah97 merged 1 commit into
Vatix-Protocol:mainfrom
CHKM001:feat/persist-pools-repository

Conversation

@CHKM001

@CHKM001 CHKM001 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

PR #315 ## Persist Pools Repository with Prisma + Include poolId in Price Response

What

Replaces the in-memory Map-based PoolsRepository with a Prisma-backed implementation so pool state (especially currentPrice) survives API restarts. Also fixes the price controller response to include poolId for frontend consumption.

Changes

API — PoolsRepository (apps/api/src/pools/pools.repository.ts)

  • All methods (listActivePools, upsertPoolState, getTicksByPoolId, poolExists, getPoolDetailById) now query/update Prisma instead of an in-memory Map
  • Migration 20260624000000_persist_pool_price adds currentPrice and updatedAt columns to the Pool table

API — Price controller (apps/api/src/price/price.controller.ts)

  • GET /prices/:tokenA/:tokenB/:interval now returns { poolId, candles } instead of { candles }
  • Tests updated to assert the new shape

Web — usePriceCandles hook (apps/web/hooks/usePriceCandles.ts)

  • Parses string-valued candle fields from the API (open, high, low, close, volumeNumber(...))
  • Exposes poolId alongside candles, loading, currentPrice
  • Cleans up WebSocket reconnect logic and dependency array

Web — Tests

  • usePoolDetail.test.ts: Wraps hooks in QueryClientProvider to match current react-query requirements
  • SwapCard.test.tsx: Replaces brittle vi.mocked(require(...)) with module-level mutable variables for cleaner state transitions

Testing

Test Suites: 26 passed, 2 skipped (integration, no DB)
Tests:       204 passed, 26 skipped
  • pools.repository.spec.ts — 4 tests, all pass
  • price.controller.spec.ts — updated expectations, all pass
  • pools.service.spec.ts — 11 tests, all pass
  • Full API suite: 0 failures

Notes

  • The pnpm-lock.yaml change is a lockfile reformat from a newer pnpm version (no dependency changes)
  • TypeScript errors exist pre-existing in unrelated modules (horizon.service.ts, positions.service.spec.ts) and are not addressed here
  • Integration tests (pools.ticks.integration.spec.ts, all-exceptions.filter.spec.ts) require a running DB and are intentionally skipped in CI without one

Closes #315

…e response

- PoolsRepository now uses PrismaService instead of in-memory Map
- Add migration to persist pool currentPrice and updatedAt columns
- Price controller CandlesResponseDto now includes poolId
- usePriceCandles hook parses string-based candle values from API
- Fix web tests (QueryClientProvider wrapping, mutable mock state)
@Mimah97 Mimah97 merged commit c27c400 into Vatix-Protocol:main Jun 30, 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

Development

Successfully merging this pull request may close these issues.

Replace in-memory PoolsRepository with Prisma

2 participants