Getting started
Core concepts
The model behind every number Rivisk returns. Read this before acting on one: the units are fixed-point, and two of them use sentinel values that invert a naive comparison.
From a wallet to a risk snapshot#
Every figure comes out of the same four stages, in order:
| Stage | What happens | Output |
|---|---|---|
| Discover | One adapter per protocol reads the wallet's on-chain state at a specific block. | NormalizedPosition[] |
| Value | Assets are priced; debt is subtracted from equity rather than counted as value. | Portfolio value, per-protocol and per-asset totals |
| Score | Deterministic formulas: collateral health, liquidation distance, concentration, accessibility. | RiskSnapshot |
| Attest | The canonical report is hashed with SHA-256 and, when publishing is enabled, written to the Clarity registry. | Report hash, on-chain snapshot |
Nothing is a model or an opinion: the same inputs always produce the same numbers. The methodology version is carried on every snapshot (currently rivisk-v1.2), so a change in the formulas is visible in the data.
Adapters#
Each protocol is read by an adapter that emits the same normalised position shape. Nothing above the adapter knows which protocol a position came from, which is why a new venue does not change the engine, the API or the SDK.
| Adapter | Reads | Enabled by |
|---|---|---|
| Native Stacks | STX and SIP-010 balances, including sBTC | Always on |
| Zest Protocol V2 | Lending obligations: collateral, scaled debt, the position's own LTV thresholds | ZEST_V2_ENABLED=true |
| BitPay | Payment streams: locked, vested, withdrawable sBTC | BITPAY_CORE_CONTRACT=… |
Units#
The API sends integers so nothing is lost to floating point. There are three conventions, and the SDK exports helpers for each.
| Field | Meaning | Example | SDK helper |
|---|---|---|---|
*Bps | Basis points. 10000 = 100%. | 4400 → 44% | fromBps |
healthFactorE4 | Health factor × 10000. | 14700 → 1.47 | fromE4 |
| Money | Decimal strings, never numbers. | "121381.09" | Parse with a decimal library |
import { fromE4, bpsToPercent } from '@rivisk/sdk'; fromE4(14700); // 1.47bpsToPercent(4400); // 44Health factor and liquidation distance#
For a lending position, the health factor compares the position with the protocol's own partial-liquidation threshold. Above 1.00 the position is clear of it; at or below 1.00 it has crossed and may be liquidated. Liquidation distance is how far the collateral price can fall before that happens.
Both are estimates. Rivisk marks positions to its own price source, while a protocol liquidates on its own oracle, so the figures can differ from the protocol's screen by the spread between the two.
A wallet with no debt#
It has no health factor and nothing to liquidate. The two surfaces report that differently, and both are chosen so that a careless reader treats the wallet as safe:
| Surface | healthFactorE4 | liquidationDistanceBps |
|---|---|---|
| REST API / SDK | null | null |
| On-chain registry | u340282366920938463463374607431768211455 | u10000 |
Risk levels#
riskLevel is derived from the worst health factor across the wallet's lending positions. Only when there is no lending position does it fall back to the composite risk score.
| Level | With a lending position | Without one (risk score) |
|---|---|---|
| critical | health factor < 1.20 | ≥ 7500 bps |
| elevated | 1.20 – 1.50 | 5000 – 7499 |
| moderate | 1.50 – 2.00 | 2500 – 4999 |
| healthy | ≥ 2.00 | < 2500 |
| unknown | not enough data | not enough data |
Concentration and accessibility#
- Protocol concentration: the largest single protocol's share of the portfolio. 9970 bps means 99.7% sits in one venue.
- Asset concentration: the same, by asset.
- Capital accessibility and liquidity score: how much of the portfolio is spendable now, as opposed to locked as collateral or unvested in a stream. This is an accessibility measure, not market depth. It does not tell you what price you could exit at.
Valuation coverage#
valuationCoverageBps is the share of assets that could be priced. It counts assets, not value: a wallet holding $300k of priced sBTC and five unpriced meme tokens reports low coverage even though almost all of its value is priced. The rule is deliberately conservative: an unpriced debt asset must never hide behind a partly valued position.
Source block and freshness#
Every snapshot records the sourceBlock the chain state was read at. On chain, a snapshot also records published-at, the block it was written in. Freshness is measured from published-at; the data describes source-block.
Report hash#
The full risk report is canonicalised (object keys sorted, recursively), serialised as JSON and hashed with SHA-256. The hash is stored with the snapshot and, when attested, on chain. Anyone can re-hash the report and prove it was not edited after publication.

