Introduction

Architecture

Five layers, and only the first one is authoritative. Everything above the contracts exists to answer questions the chain can answer correctly but not cheaply.

Layers
5
Write path
Wallet → contracts
Backend
Read-only

The five layers

Listed bottom-up. Each layer reads only from the ones below it, and no layer above the contracts holds state anyone needs to trust.

1

Contracts

Ethereum Sepolia

LayerSubToken and LayerSubStakingVault. Two contracts at pragma 0.8.24, built on OpenZeppelin v5.1.0 primitives.

Authoritative for

All state. Every balance, every accrual and every timestamp is settled here.

ReadsNothing — this is the bottom of the stack.

The vault holds staked principal and the funded reward budget in the same ERC-20, which is the constraint the rest of the design answers to.

Every state change emits an event, so the chain alone is sufficient to reconstruct history — the layers above are convenience, not authority.

2

Indexer

Worker process

Follows the chain from INDEXER_START_BLOCK, decodes the seven events and writes them to Postgres, plus periodic snapshots on a cron.

Authoritative for

Event history and time series — totals, staker counts and the TVL/APR/solvency series no single chain read can produce.

ReadsContract event logs via eth_getLogs

It maintains a cursor, so anything it serves trails the chain head by however many blocks it is behind. /health reports that lag as indexer.lagBlocks.

Snapshots are written on a cron rather than per block, so the raw series is already sparse before /stats/history downsamples it further.

3

Backend API

HTTP service

Seven read-only GET endpoints. Nothing in the API signs or sends a transaction, and there is no authentication.

Authoritative for

Nothing of its own. It joins live chain reads to indexed history and serves the result.

ReadsPostgres, for indexed historyJSON-RPC, for live contract state

The split matters: figures that accrue every second — earned(), faucetAvailableAt() — are read live per request, because the indexer cannot know them between events. Event-derived totals come from the database.

Rate limited to 120 requests per minute per IP, with /health/live exempt so the platform healthcheck is never throttled.

4

Staking dApp

Browser

Faucet, stake, withdraw and claim. Reads the vault directly by multicall and writes through the user's wallet.

Authoritative for

Nothing. It is a client of both the chain and the API.

ReadsContracts, by multicallBackend API, for history and leaderboard

Transactions go straight from the wallet to the contracts — the backend is never in the write path, which is why it needs no authentication.

5

Documentation

This site

Static reference transcribed from the Solidity sources and the backend routes, with no runtime dependency on either.

Authoritative for

Nothing. It is prerendered and can go stale — the sources are canonical.

Readssrc/content/*, transcribed by hand

Chain or indexer?

The single most common integration mistake is caching a figure that accrues per second. This is the rule the backend follows, and the one you should follow too.

Accrues every second?Read it from the chain.

earned(), rewardPerToken(), lastTimeRewardApplicable() and faucetAvailableAt() all move with block.timestamp. An indexer only sees them at event boundaries, so any cached value is stale on arrival.

Needs history or aggregation?Read it from the indexer.

Staker counts, cumulative funding, the leaderboard and the TVL/APR series require scanning every event. eth_getLogs can do it, but not per page load.

Needs both?That is what /stats and /wallets/:address are for.

Each joins a live multicall to indexed rows in one response, and labels which half is which — `live` versus `indexed`.

The API reference marks which half of each response is live and which is indexed.

Trust boundaries

What you do and do not have to trust

  • The backend is read-only and unauthenticated. Compromising it cannot move funds; it can only serve wrong numbers.
  • The leaderboard ranks from indexed balances, so it reflects the indexer cursor rather than the chain head. For one wallet's authoritative figure, /wallets/:address reads live.
  • The owner's three powers — fund the budget, set the rate, recover uncommitted budget — are all on-chain and all emit events. None of them reach staked principal.
  • This documentation is transcribed, not generated. Where it disagrees with the Solidity, the Solidity wins.

The property that makes the vault worth reading closely is on the solvency model page.