> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tayho.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Market-data normalization

> Private HIP-4 normalization inputs, validation, funding/depth outputs, and failure boundaries.

# Market-data normalization

Tayho workers consume a small, stable fact protocol instead of coupling transaction-signing code to
Hyperliquid's evolving exchange API. Two stateless `tayho-market-data` replicas translate the
testnet-only `outcomeMeta` catalog and `l2Book` snapshots into authenticated WAD observations.

```text theme={null}
Hyperliquid /info ──► tayho-market-data x2
                         ├─ impact + index ─► tayho-oracle x2 ─► attestFunding
                         └─ depth + pending resolution ─► tayho-attester x2
```

Outcome assets use `100_000_000 + 10 * outcome + side`, with sides restricted to zero and one. The
adapter queries `#<10 * outcome + side>`, validates a fresh monotonic two-sided book, and derives:

* impact: the midpoint of bid and ask VWAPs that each fill `MARKET_DATA_IMPACT_NOTIONAL_WAD`;
* index: the BBO midpoint;
* depth: the smaller USDC notional available on either side inside `MARKET_DATA_DEPTH_BAND_BPS`;
* resolution: pending unless an upstream supplies an explicit final side.

The funding and attester workers separately authenticate each route, validate identity/freshness
again, smooth funding samples in Redis, and use their durable PostgreSQL transaction journals for
on-chain publication. The adapter owns neither a signer nor durable protocol state.

Testnet intentionally permits one upstream so end-to-end deployment can be exercised. That is not
source independence: production keeps the worker's independent-origin gates and substitutes separately
governed index and resolution providers. A second replica improves process availability but does not
turn one upstream into two independent sources.

## Service contract

The private Elysia service exposes four independently authenticated, read-only facts:
`/v1/funding/impact`, `/v1/funding/index`, `/v1/oracle/depth`, and
`/v1/oracle/resolution`. Inputs are an asset and oracle key. Outputs use bounded decimal strings and
carry freshness/source metadata. Invalid identity, one-sided or crossed books, stale samples,
insufficient notional, and ambiguous resolution fail closed.

The service is stateless and signerless. It receives no PostgreSQL, Redis, RPC, contract address,
coordination token, or public domain. `/livez` proves process liveness; `/readyz` qualifies the
configured upstream and normalization path without exposing resolved credentials. Loss pauses new
oracle/attester observations but cannot mutate prior on-chain state.

Sources:
[`apps/market-data/src`](https://github.com/Tay-Ho/app/tree/develop/apps/market-data/src),
[`schemas`](https://github.com/Tay-Ho/app/blob/develop/apps/market-data/src/schemas.ts), and
[`qualification tests`](https://github.com/Tay-Ho/app/tree/develop/apps/market-data/test).
