Rivisk

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:

StageWhat happensOutput
DiscoverOne adapter per protocol reads the wallet's on-chain state at a specific block.NormalizedPosition[]
ValueAssets are priced; debt is subtracted from equity rather than counted as value.Portfolio value, per-protocol and per-asset totals
ScoreDeterministic formulas: collateral health, liquidation distance, concentration, accessibility.RiskSnapshot
AttestThe 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.

AdapterReadsEnabled by
Native StacksSTX and SIP-010 balances, including sBTCAlways on
Zest Protocol V2Lending obligations: collateral, scaled debt, the position's own LTV thresholdsZEST_V2_ENABLED=true
BitPayPayment streams: locked, vested, withdrawable sBTCBITPAY_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.

FieldMeaningExampleSDK helper
*BpsBasis points. 10000 = 100%.4400 → 44%fromBps
healthFactorE4Health factor × 10000.14700 → 1.47fromE4
MoneyDecimal strings, never numbers."121381.09"Parse with a decimal library
ts
import { fromE4, bpsToPercent } from '@rivisk/sdk'; fromE4(14700);          // 1.47bpsToPercent(4400);     // 44

Health 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:

SurfacehealthFactorE4liquidationDistanceBps
REST API / SDKnullnull
On-chain registryu340282366920938463463374607431768211455u10000

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.

LevelWith a lending positionWithout one (risk score)
criticalhealth factor < 1.20≥ 7500 bps
elevated1.20 – 1.505000 – 7499
moderate1.50 – 2.002500 – 4999
healthy≥ 2.00< 2500
unknownnot enough datanot 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.