Indexer
Location:apps/indexer/Runtime: Node.js 20 (ESNext modules,
tsx)Libraries: ethers.js v6, BullMQ v5, ioredis The indexer is a long-running Node.js process that connects to the HyperPaxeer RPC, listens for smart contract events using ethers.js, and feeds jobs into four BullMQ queues that the backend workers consume.
Directory Structure
Pipeline
Configuration
config/contracts.ts
config/redis.ts
queues/index.ts
Event Listeners
vault.listener.ts — Per-vault events
Listens to a single CopyTradingVault proxy for three events:
TradeExecuted(tokenIn, tokenOut, totalAmountSwapped)
FollowerSubscribed(follower, amount)
FollowerUnsubscribed(follower, amount)
vaultFactory.listener.ts — New vault deployments
Listens to VaultFactory for the VaultDeployed(leader, vaultProxy) event:
Trade Processor
processors/trade.processor.ts maps the on-chain TradeExecuted event to the TradeJobPayload shape the backend trade.worker.ts expects:
| Event Param | Job Payload Field | Notes |
|---|---|---|
tokenIn | assetIn | |
tokenOut | assetOut | |
totalAmountSwapped | amountOut | The amount the vault received |
| (N/A) | amountIn | Set to "0" — not emitted by event |
| (N/A) | isProfit | Set to false — determined later by ProfitSettled |
| (N/A) | pnlAmount | Set to "0" — determined later |
event.log.transactionHash | txHash | |
event.log.blockNumber | used to get timestamp | Via provider.getBlock() |
Entry Point
src/index.ts boots the indexer:
Environment Variables
| Variable | Required | Description |
|---|---|---|
RPC_URL | ✅ | HyperPaxeer JSON-RPC endpoint |
VAULT_FACTORY_ADDRESS | ✅ | Deployed VaultFactory proxy address |
REDIS_URL | ✅ | Redis connection string (must match backend) |
KNOWN_VAULT_ADDRESSES | ❌ | Comma-separated list of pre-existing vault addresses |