harb/services/ponder
openhands e49938bd0a fix: Ponder: add test infrastructure + coverage for helpers (target 95%) (#287)
- Add vitest ^2 + @vitest/coverage-v8 ^2 as devDependencies
- Add `test` and `test:coverage` scripts to package.json
- Create vitest.config.ts with resolve.alias to mock ponder virtual modules
  (ponder:schema, ponder:registry) and point kraiken-lib/version to source
- Add coverage/  to .gitignore
- Add vitest.config.ts to tsconfig.json include so eslint project-aware rules apply
- Create src/tests/__mocks__/ponder-schema.ts and ponder-registry.ts stubs
- Create src/tests/stats.test.ts — 48 tests covering ring buffer logic,
  segment updates, hourly advancement, projections, ETH reserve snapshots,
  all exported async helpers with mock Ponder contexts
- Create src/tests/version.test.ts — 14 tests covering isCompatibleVersion,
  getVersionMismatchError, and validateContractVersion (compatible / mismatch /
  error paths, existing-meta upsert path)
- Create src/tests/abi.test.ts — 6 tests covering validateAbi and
  validateContractAbi

Result: 68 tests pass, 100% line/statement/function coverage on all helpers
(stats.ts, version.ts, abi.ts, logger.ts) — exceeds 95% target.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-25 22:29:57 +00:00
..
.husky feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52) 2025-10-04 15:37:26 +02:00
abis feat: OptimizerV3 with direct 2D staking-to-LP parameter mapping 2026-02-13 18:21:18 +00:00
generated fix: address review — migration comment, link ring buffer constants (#170) 2026-02-22 18:56:36 +00:00
scripts move ponder 2025-09-23 20:29:51 +02:00
src fix: Ponder: add test infrastructure + coverage for helpers (target 95%) (#287) 2026-02-25 22:29:57 +00:00
.env.example move ponder 2025-09-23 20:29:51 +02:00
.gitignore fix: Ponder: add test infrastructure + coverage for helpers (target 95%) (#287) 2026-02-25 22:29:57 +00:00
.lintstagedrc.json feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52) 2025-10-04 15:37:26 +02:00
.prettierrc feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52) 2025-10-04 15:37:26 +02:00
AGENTS.md migrate/podman-to-docker (#92) 2025-11-08 14:08:46 +01:00
DEPLOYMENT.md move ponder 2025-09-23 20:29:51 +02:00
eslint.config.js fix: Add architectural lint rules with agent-friendly error messages (#232) 2026-02-24 20:44:17 +00:00
package-lock.json fix: Ponder: add test infrastructure + coverage for helpers (target 95%) (#287) 2026-02-25 22:29:57 +00:00
package.json fix: Ponder: add test infrastructure + coverage for helpers (target 95%) (#287) 2026-02-25 22:29:57 +00:00
ponder-env.d.ts tax rate, version and compose (#70) 2025-10-07 19:26:08 +02:00
ponder.config.ts feat/ponder-lm-indexing (#142) 2026-02-18 00:19:05 +01:00
ponder.schema.ts feat: replace tax with holders in ring buffer, add sparkline charts (#170) 2026-02-22 18:56:36 +00:00
README.md docs: consolidate and update all documentation for launch readiness 2026-02-13 19:22:34 +00:00
tsconfig.json fix: Ponder: add test infrastructure + coverage for helpers (target 95%) (#287) 2026-02-25 22:29:57 +00:00
vitest.config.ts fix: Ponder: add test infrastructure + coverage for helpers (target 95%) (#287) 2026-02-25 22:29:57 +00:00

KRAIKEN Ponder Indexer

A high-performance blockchain indexer for the KRAIKEN protocol using Ponder framework, providing 10-15x faster indexing than The Graph with superior developer experience.

Features

  • Multi-network support: Local (Anvil fork), Base Sepolia, Base mainnet
  • Hot reload: Instant updates during development
  • Type safety: Full TypeScript support with auto-completion
  • Ring buffer: 7-day hourly metrics with projections
  • GraphQL API: Auto-generated from schema
  • Efficient indexing: In-memory operations during sync

Quick Start

1. Install Dependencies

npm install

2. Configure Environment

cp .env.example .env

Edit .env to select your network:

  • PONDER_NETWORK=BASE_SEPOLIA_LOCAL_FORK - Local Anvil fork managed by scripts/dev.sh
  • PONDER_NETWORK=BASE_SEPOLIA - Base Sepolia testnet
  • PONDER_NETWORK=BASE - Base mainnet

3. Local Development (Anvil Fork)

# Terminal 1: Start Anvil fork of Base mainnet
anvil --fork-url https://base.llamarpc.com

# Terminal 2: Start Ponder indexer
PONDER_NETWORK=BASE_SEPOLIA_LOCAL_FORK npm run dev

4. Testnet Deployment (Base Sepolia)

PONDER_NETWORK=BASE_SEPOLIA npm run dev

5. Production Deployment (Base Mainnet)

PONDER_NETWORK=BASE npm run start

GraphQL Queries

Once running, access the GraphQL playground at http://localhost:42069/graphql

Example Queries

Get Protocol Stats

{
  stats(id: "0x01") {
    kraikenTotalSupply
    stakeTotalSupply
    outstandingStake
    mintedLastWeek
    mintedLastDay
    mintNextHourProjected
    burnedLastWeek
    burnedLastDay
    burnNextHourProjected
  }
}

Get All Positions

{
  positions(where: { status: "Active" }) {
    items {
      id
      owner
      share
      taxRate
      kraikenDeposit
      taxPaid
      createdAt
    }
  }
}

Get User Positions

{
  positions(where: { owner: "0x..." }) {
    items {
      id
      share
      taxRate
      kraikenDeposit
      stakeDeposit
      taxPaid
      status
    }
  }
}

Architecture

Schema (ponder.schema.ts)

  • stats: Global protocol metrics with ring buffer
  • hourlyData: 168-hour circular buffer for time-series
  • positions: Harberger tax staking positions

Event Handlers

  • kraiken.ts: Handles Transfer events for minting, burning, tax, UBI
  • stake.ts: Handles position lifecycle events

Ring Buffer Implementation

  • 168 hourly slots (7 days)
  • Automatic hourly rollover
  • Projection calculation using median smoothing
  • Rolling 24h and 7d aggregations

Deployment

Self-Hosted

DATABASE_URL=postgresql://... PONDER_NETWORK=BASE npm run start

Troubleshooting

  • "No chain configured": Ensure PONDER_NETWORK is set in .env
  • Slow initial sync: Provide a faster RPC URL
  • Database errors: Use PostgreSQL for production (DATABASE_URL env var)

License

GPL-3.0-or-later