> ## 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.

# Funding architecture

> Fifteen-minute funding observations, reserve accounting, publication, settlement, and audit semantics.

# Fifteen-minute funding

TAYHO advances monotonic payer and receiver indices per live market every 15 minutes. Positions
snapshot both indices when opened and settle their gross legs lazily on margin changes, closes,
liquidations, or force-flattening; updating a market never loops over positions.

For each interval the isolated oracle attester publishes two smoothed observations:

* `impactPrice`: the executable book impact price for the configured size and smoothing policy;
* `indexPrice`: an independent fair-value probability source, not a transformation of the same BBO.

The on-chain hourly rate is:

```text theme={null}
premium = clamp((impactPrice - indexPrice) / indexPrice, -2%, +2%)
skew    = clamp((longQ - shortQ) / D_max * 1%, -1%, +1%)
rate    = clamp(premium + skew, -3%, +3%)
indexDelta = rate / 4
```

A positive rate makes longs pay and shorts receive; a negative rate reverses the direction. The
vault is counterparty to unmatched exposure. Before publishing an index increment, `TayhoFunding`
reserves LP capital for the complete receiving side after buffer B and senior liabilities. If the
full formula cannot be backed, publication reverts instead of changing the rate. Separate monotonic
pay/receive indices preserve gross claims across a rate reversal; per-side market reserves are
released on settlement, with aggregate rounding dust released when that side reaches zero OI.
Reserved capital cannot be withdrawn, skimmed, paid to an unrelated winner, or consumed by the FIFO queue.

The two-replica `tayho-oracle` Railway service samples independent HTTPS origins every five seconds,
stores bounded sample windows in Redis, rejects stale/gapped windows, and publishes completed-window
time-weighted averages through two funding-only attester keys. A Redis lease avoids duplicate discovery
while PostgreSQL's durable transaction journal provides idempotency, nonce serialization, retry, and
failover. Observations are current-interval, interval-aligned, attester-only, and one-shot. Anyone may call
`updateFunding`; the two automation replicas retry permissionless best-effort batches once per minute.
An opening requires the current interval to be initialized, while exits remain available if a new
observation is delayed. Missed intervals are not backfilled using a later price.

The auditor independently recomputes premium, skew, total rate, interval delta, and required reserve
from the inputs recorded at publication. It also reconciles every market/side reserve to the vault
total and checks interval lag, price domains, oracle agreement, and future intervals. One missed
interval is a warning; more than one is critical for a live market.

## Boundaries and failure behavior

* Inputs are authenticated impact and index observations plus current on-chain open interest and
  risk configuration.
* The funding attesters output only `attestFunding`; permissionless automation outputs the bounded
  update call after an observation exists.
* Redis retains smoothing windows and leases but is not the publication authority. PostgreSQL owns
  jobs, outbox delivery, signer nonce allocation, and transaction lineage. Contracts own the
  accepted observation and cumulative indices.
* Oracle source gaps pause new observation publication. A failed current interval prevents new
  opens but does not block exits. Later observations never backfill a missing interval.
* Readiness validates source freshness, chain identity, contract linkage, signer separation,
  balance, and exact funding-attester authorization.

Sources:
[`TayhoFunding.sol`](https://github.com/Tay-Ho/app/blob/develop/packages/contracts/src/TayhoFunding.sol),
[`funding services`](https://github.com/Tay-Ho/app/tree/develop/apps/keeper/src/services), and
[`funding tests`](https://github.com/Tay-Ho/app/tree/develop/apps/keeper/test).
