Integrating

Backend API

The indexer exposes 7 read-only endpoints over indexed chain state. Everything here is a GET; nothing in the API signs or sends a transaction.

Live figures such as earned() are read from the chain per request, because they accrue every second and no indexer can know them between events. Event-derived totals come from the database.

Base URL
Endpoints
7
Auth
None — public read
Rate limit
120 req/min per IP

Conventions

These hold across every endpoint. The first two account for most integration bugs.

  • Amounts are decimal strings

    $SUB is an 18-decimal token, so amounts routinely exceed Number.MAX_SAFE_INTEGER. Every uint256 is serialised as a decimal string and never as a JSON number. Parse with BigInt(value), or viem's formatUnits(value, 18) for display.

  • Unknown query parameters are rejected

    A typo such as ?limitt=10 returns 400 rather than being silently ignored, so a mistake in an integration surfaces immediately instead of looking like a backend bug.

  • Timestamps are ISO 8601

    Database timestamps are returned as ISO strings in UTC. On-chain timestamps (periodFinish, faucetAvailableAt, block.timestamp) stay as Unix-second strings, matching the contract.

  • Errors are structured

    Failures return { "error": "<code>", "message": "<text>" }. Server-side messages are deliberately generic — upstream RPC and database detail stays in the logs, where it cannot leak credentials.

  • Rate limiting

    120 requests per minute per IP by default, with /health/live exempt. Exceeding it returns 429.

/health/live

GET/health/live

Liveness only. Touches no dependencies.

Example response

{
  "status": "ok",
  "uptimeSeconds": 1042
}

Notes

  • This is the platform healthcheck path, and the one route exempt from rate limiting.

/health

GET/health

Readiness: database, RPC and indexer lag.

Returns 503 when either dependency is down, so a deployment that cannot serve real data is not rotated in.

Selected response fields

  • database.okboolean

    Whether a SELECT 1 succeeded, with latency.

  • rpc.okboolean

    Whether eth_blockNumber succeeded, with latency.

  • indexer.lagBlocksstring

    How far the indexer cursor trails the chain head.

Example response

{
  "status": "ok",
  "chainId": 11155111,
  "database": { "ok": true, "latencyMs": 2 },
  "rpc": { "ok": true, "latencyMs": 49, "blockNumber": "11781453" },
  "indexer": { "lastBlock": "11781447", "lagBlocks": "6" }
}

/stats

GET/stats

Live vault state, APR, event-derived totals and the latest solvency verdict.

The vault and token figures are read live from the chain — the same values the dApp fetches by multicall. The totals and the solvency verdict come from indexed events, which no single chain read can provide.

Selected response fields

  • vault.totalStakedstring

    TVL in wei-denominated $SUB.

  • vault.secondsRemainingnumber

    Seconds until periodFinish, floored at zero.

  • apr.bpsstring | null

    APR in basis points. Null while nothing is staked.

  • totals.stakerCountnumber

    Wallets with a non-zero indexed stake.

  • solvency.solventboolean

    Whether the invariant held at the checked block.

Example response

{
  "block": { "number": "11781453", "timestamp": "1790366364" },
  "vault": {
    "totalStaked": "0",
    "rewardRate": "11574074074074074",
    "periodFinish": "1799004696",
    "rewardsAvailable": "100000000000000000000000",
    "emissionsActive": true,
    "secondsRemaining": 8638330
  },
  "apr": { "bps": null, "percent": null },
  "totals": { "totalFunded": "100000000000000000000000", "stakerCount": 0 },
  "solvency": { "solvent": true, "consistent": true, "surplus": "100000000000000000000000" }
}

/stats/history

GET/stats/history

TVL, APR and solvency time series from the snapshot table.

Snapshots are written on a cron, so the raw series is already sparse. `interval` downsamples further by keeping the newest snapshot in each bucket.

Query parameters

  • intervalenum

    One of 5m, 15m, 1h, 6h, 1d.

    default: 1h
  • fromdate-time

    ISO 8601 lower bound on takenAt.

  • todate-time

    ISO 8601 upper bound on takenAt.

  • limitinteger

    Maximum buckets, 1 to 2000.

    default: 500

Example response

{
  "interval": "1h",
  "bucketSeconds": 3600,
  "count": 1,
  "series": [
    {
      "bucket": "2026-09-25T19:00:00.000Z",
      "blockNumber": "11781447",
      "totalStaked": "0",
      "aprBps": null,
      "surplus": "100000000000000000000000",
      "solvent": true,
      "consistent": true
    }
  ]
}

/wallets/:address

GET/wallets/:address

One wallet's live position, indexed history, rank and recent events.

`live` is read from the chain because earned() accrues every second and the indexer cannot know it between events. `indexed` is the event history the chain does not retain cheaply, and is null for a wallet that has never staked, withdrawn, claimed or used the faucet.

Query parameters

  • eventsinteger

    Recent events to include, 0 to 200.

    default: 20

Selected response fields

  • live.earnedstring

    Claimable yield right now, in wei.

  • live.faucetReadyboolean

    Whether the faucet cooldown has elapsed.

  • ranknumber | null

    Position by staked balance. Null when not staking.

Example response

{
  "address": "0x2702214714e3EA5a6B91731D7E031A3574fe0F07",
  "live": {
    "stakedBalance": "0",
    "earned": "0",
    "walletBalance": "900000000000000000000000",
    "faucetReady": true
  },
  "indexed": null,
  "rank": null,
  "events": []
}

Notes

  • A malformed address is a 400, not a 404.

/leaderboard

GET/leaderboard

Largest stakers, with each one's share of TVL.

Query parameters

  • limitinteger

    Rows to return, 1 to 500.

    default: 50

Selected response fields

  • indexedTvlstring

    Sum of indexed staked balances, in wei.

  • leaders[].shareBpsstring | null

    Share of indexed TVL in basis points.

Notes

  • Ranked from indexed balances, so it reflects the indexer cursor rather than the chain head. For a single wallet's authoritative figure use /wallets/:address.

/events

GET/events

Raw decoded event feed, newest first.

Query parameters

  • walletaddress

    Filter to one wallet.

  • typeenum

    One of Staked, Withdrawn, RewardClaimed, RewardRateUpdated, RewardsFunded, UnallocatedRewardsRecovered, FaucetMinted.

  • limitinteger

    Rows to return, 1 to 200.

    default: 50
  • beforeinteger

    Cursor: the id of the previous page's last row.

Selected response fields

  • nextBeforenumber | null

    Pass as `before` for the next page. Null on the last page.

  • events[].amountstring | null

    Primary uint256 payload, or the new rate for RewardRateUpdated.

Example response

{
  "count": 1,
  "nextBefore": null,
  "events": [
    {
      "id": 1,
      "eventName": "RewardsFunded",
      "blockNumber": "11781321",
      "blockTime": "2026-09-25T19:31:36.000Z",
      "txHash": "0x14040188e01661f45519f31f662cde276f06a1fdb59d3272f00b328adfed169b",
      "wallet": "0x2702214714e3EA5a6B91731D7E031A3574fe0F07",
      "amount": "100000000000000000000000",
      "meta": { "periodFinish": "1790364696" }
    }
  ]
}