Kerne Logo
Documentation

Live APY Math

Every protocol publishes an APY number. Few publish the formula, every constant, and the live inputs in one machine readable endpoint that updates in real time. We do, because the only way a depositor can verify what the protocol earns is to see every input that produces the headline number.

If the displayed APY ever drifts from what these constants and inputs imply, the page is wrong, not the protocol. The math is checkable on the same visit by the same caller, against the same upstream feeds we use ourselves.

The Formula

The displayed APY is computed by computeLiveAPY() in app.kerne.fi-terminal/src/app/api/apy/route.ts. The methodology string in the JSON spells it out in one line:

3× (Lido 7d SMA + HL 180d trailing funding) × (1 − 22.32% strategy costs) × (1 − 10% insurance) × (1 − 0% Genesis fee)

In English: take the staked ETH base yield plus the trailing perpetual funding rate, multiply by the leverage ratio to get gross APY, deduct strategy operating costs, route a fixed portion of the remainder to the Insurance Fund, then deduct the protocol fee. The protocol fee is 0% during the Genesis phase; the methodology string shows the live value, not a target.

Where Each Constant Comes From

  • Lido 7-day SMA: live, sourced from the Lido staking yield feed and smoothed over the last seven days. Reported as stakingYield in the JSON.
  • Hyperliquid 180-day trailing funding: live, computed from 4,320 hourly Hyperliquid funding samples (180 days × 24 hours). The window length is reported as fundingWindowDays and the sample count as fundingEntries.
  • Leverage 3×: fixed strategy parameter. Reported as leverage in the JSON.
  • Strategy costs 22.32%: fixed cost fraction covering perp execution slippage, exchange fees, and bridging cost. Reported as strategyCostFraction.
  • Insurance allocation 10%: fraction of net yield routed to the Insurance Fund. Reported as insuranceAllocation.
  • Genesis fee 0%: protocol fee during the Genesis phase. Reported as protocolFee and feePhase. When the fee schedule changes, both fields update on the same release.

Verify It Yourself

Hit the endpoint directly and read the live values:

curl -s https://app.kerne.fi/api/apy | jq

Each numeric field above appears as its own key. The methodology field is the same one-line formula rendered with the live inputs substituted in. The isLive flag is true while live sources are reachable; if either upstream feed is unavailable the endpoint falls back to a frozen value and the flag flips to false.

The two derived intermediates are also published so the chain of arithmetic is auditable: grossAPY is leverage × (staking + funding), and strategyNetAPY is grossAPY × (1 − strategyCostFraction). Multiplying strategyNetAPY by (1 − insuranceAllocation) × (1 − protocolFee) reproduces expectedAPY.

Raw JSON

The unprocessed feed lives at app.kerne.fi/api/apy. Mirror it, cache it, or diff it against historical snapshots. Nothing on this chapter is paywalled and no signed request is required. If the rendered APY anywhere on kerne.fi disagrees with what this endpoint produces from its own published constants, the rendered page is wrong, not the endpoint.

24h Funding Forecast (Neural Engine v3)

The 180-day trailing window in the APY formula above is a backward-looking smoothing. The protocol also publishes its forward-looking 24h funding-income forecast, produced by the same linear model the bot uses to size its hedge: kerne.fi/api/forecast.

Three feature inputs: trailing 24h funding sum, current premium, trailing 24h premium sum. The model coefficients, intercept, and residual standard deviation are all returned in the response under the model.coefficients object so anyone can reproduce the prediction by hand. The training metrics are returned alongside: testR2 is 0.44 against a naive last-24h-sum baseline of 0.31. That is a real, modest, publishable lift on a noisy target rather than the constant-predictor degenerate the previous LSTM attempt produced.

The TypeScript implementation in frontend/src/lib/forecast-engine.ts mirrors the Python implementation in bot/funding_forecast.py byte-for-byte. The bot's own forecast is persisted to /opt/kerne/bot/data/forecast_latest.json on every periodic-task tick (30 min cadence); operators compare the two implementations to verify the public surface has not drifted from the model the hedger actually uses.

curl -s https://kerne.fi/api/forecast | jq '{predictedSum, annualizedApy, lowerBound, upperBound, model}'

Forecast accuracy is bounded by the model. R² of 0.44 means the prediction explains 44% of next-day funding variance; the 80% interval is wide because the residual is real. The honest framing is that the model is publishable, the math is checkable, and the metric a depositor cares about is whether the published forecast tracks realised funding over time. We expose both, you decide.