Skip to content

Conversation

@citrusinesis
Copy link
Contributor

@citrusinesis citrusinesis commented Sep 19, 2025

Summary by CodeRabbit

  • New Features

    • Added integration to fetch funding rates from Hyperliquid.
    • Introduced separate hourly jobs for Mainnet and Testnet.
    • API endpoint now accepts a network parameter to manually trigger the funding rates job.
    • Raw funding data is archived and processed for improved visibility in the app.
  • Refactor

    • Reworked the funding rates workflow into a modular, reusable design for better reliability and scalability.

citrusinesis and others added 2 commits September 19, 2025 19:54
- Add modular service architecture with separate concerns:
  - FundingDataProcessorService: handles database operations
  - FundingDataStorageService: handles S3 storage operations
- Create network-specific job classes:
  - BaseFundingRatesJob: abstract base class
  - MainnetFundingRatesJob: mainnet-specific implementation
  - TestnetFundingRatesJob: testnet-specific implementation
- Update TasksController to accept network parameter via request body
- Add network-aware S3 storage paths (funding-rates/{network}/raw/)
- Maintain backward compatibility with existing FundingRatesJob

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@coderabbitai
Copy link

coderabbitai bot commented Sep 19, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a Hyperliquid NestJS module and service with shared types; introduces a base job for funding-rate workflows; splits funding-rate jobs into mainnet and testnet with hourly schedules; adds services to process and store data; updates tasks module wiring and controller to route triggers by network.

Changes

Cohort / File(s) Summary
Hyperliquid module and types
packages/server/src/common/hyperliquid/index.ts, packages/server/src/common/hyperliquid/service.ts, packages/server/src/common/hyperliquid/types.ts
New module exporting HyperliquidService and types; service wraps Hyperliquid API calls (spot/perp indices, predicted fundings) with logging and error handling.
Tasks module wiring
packages/server/src/domain/tasks/index.ts, packages/server/src/domain/tasks/services/index.ts
Updates module imports to include HyperliquidModule and scheduling; registers new jobs and services; re-exports task services.
Tasks controller
packages/server/src/domain/tasks/controller.ts
POST trigger accepts optional network and dispatches to mainnet or testnet job; constructor injects both jobs; response reflects chosen network.
Funding-rate jobs (base and per-network)
packages/server/src/domain/tasks/jobs/base-funding-rates.ts, packages/server/src/domain/tasks/jobs/mainnet-funding-rates.ts, packages/server/src/domain/tasks/jobs/testnet-funding-rates.ts, packages/server/src/domain/tasks/jobs/index.ts
Adds abstract BaseFundingRatesJob with shared fetch-and-save flow; concrete mainnet/testnet jobs schedule hourly runs and delegate to base; updates jobs barrel exports.
FundingRatesJob refactor
packages/server/src/domain/tasks/jobs/funding-rates.ts
Replaces direct HTTP with HyperliquidService; removes local types and HTTP logic; constructor and fetch path updated; persists data as before.
Task services (process/store)
packages/server/src/domain/tasks/services/funding-data-processor.ts, packages/server/src/domain/tasks/services/funding-data-storage.ts
New services: processor writes normalized funding data to DB; storage uploads raw payloads to S3 with timestamped keys; both log and rethrow on errors.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant Controller as TasksController
  participant Job as Mainnet/Testnet Job
  participant Base as BaseFundingRatesJob
  participant HL as HyperliquidService
  participant S3 as FundingDataStorageService
  participant DB as FundingDataProcessorService

  Client->>Controller: POST /tasks/funding-rates { network? }
  Controller->>Job: scheduledFetch()
  Job->>Base: fetchAndSaveFundingData()
  Base->>HL: fetchPredictedFundings()
  HL-->>Base: { rawData, hlPerpData }
  par Store raw
    Base->>S3: saveRawData(rawData, network)
    S3-->>Base: OK
  and Process normalized
    Base->>DB: processFundingData(hlPerpData, network)
    DB-->>Base: OK
  end
  Base-->>Job: Done
  Job-->>Controller: Done
  Controller-->>Client: { message: "Triggered for <network>" }
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

I hop through wires at the top of each hour,
Sniffing rates where the funding flowers.
Mainnet meadows, testnet trails,
I bag the bytes in S3 pails.
With tidy paws I file and log—
Another carrot for this codebase hog! 🥕🐇


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between be940e3 and 402174d.

📒 Files selected for processing (13)
  • packages/server/src/common/hyperliquid/index.ts (1 hunks)
  • packages/server/src/common/hyperliquid/service.ts (1 hunks)
  • packages/server/src/common/hyperliquid/types.ts (1 hunks)
  • packages/server/src/domain/tasks/controller.ts (1 hunks)
  • packages/server/src/domain/tasks/index.ts (1 hunks)
  • packages/server/src/domain/tasks/jobs/base-funding-rates.ts (1 hunks)
  • packages/server/src/domain/tasks/jobs/funding-rates.ts (2 hunks)
  • packages/server/src/domain/tasks/jobs/index.ts (1 hunks)
  • packages/server/src/domain/tasks/jobs/mainnet-funding-rates.ts (1 hunks)
  • packages/server/src/domain/tasks/jobs/testnet-funding-rates.ts (1 hunks)
  • packages/server/src/domain/tasks/services/funding-data-processor.ts (1 hunks)
  • packages/server/src/domain/tasks/services/funding-data-storage.ts (1 hunks)
  • packages/server/src/domain/tasks/services/index.ts (1 hunks)

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@citrusinesis citrusinesis merged commit 2b94c37 into main Sep 19, 2025
3 of 4 checks passed
@citrusinesis citrusinesis deleted the citrus/testnet branch September 19, 2025 11:31
@citrusinesis citrusinesis restored the citrus/testnet branch September 19, 2025 13:22
@junhoyeo junhoyeo deleted the citrus/testnet branch September 20, 2025 15:27
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.

2 participants