Rivisk

Getting started

Rivisk documentation

Rivisk is shared risk infrastructure for Bitcoin capital on Stacks. It reads a wallet across protocols, normalises the positions, computes deterministic risk, and makes that risk available to your product over an API, a TypeScript SDK, signed webhooks and an on-chain Clarity registry.

Why Rivisk exists#

A wallet's sBTC can sit in a plain balance, a Zest lending position and a BitPay stream at the same time, and every protocol only reports its own slice. A yield router, a lending product or an autonomous agent that wants to know whether a wallet is safe would otherwise have to index Stacks, read each protocol's contracts, derive health factors and run stress scenarios itself.

Rivisk does that once and exposes the answer. The dashboard is one consumer of it; your product can be another.

Two ways to integrate#

PathYou getUse it when
Off-chainThe full picture over REST or the TypeScript SDK: positions, collateral health, liquidation distance, concentration, stress scenarios, alerts and webhooks.Your decision runs in a backend, a frontend or an agent.
On-chainA compact attested snapshot read from risk-registry through risk-provider-trait, with a freshness bound that cannot be skipped.Your decision runs inside a Clarity contract.

What is live today#

Stated precisely, because integrations are built on it:

  • The Clarity contracts are live on Stacks testnet, with a real attestation already published and read back by an external contract. See Smart contracts.
  • The SDK is published as @rivisk/sdk on npm.
  • A hosted beta API is live at https://api.13.49.129.179.sslip.io/api/v1, and it powers the Rivisk dashboard. It runs on deliberately small, low-cost infrastructure for the beta: treat it as a testing endpoint, not a production service with availability guarantees. You can also run the whole stack yourself.

Read an attestation right now#

The testnet registry already holds a snapshot, so this works without running anything. It calls the read-only function directly on a public Stacks node:

read-attestation.mjs
import { Cl, cvToString, deserializeCV, serializeCV } from '@stacks/transactions'; const REGISTRY = 'ST2F3J1PK46D6XVRBB9SQ66PY89P8G0EBDW5E05M7';const wallet = 'ST2F3J1PK46D6XVRBB9SQ66PY89P8G0EBDW5E05M7'; const res = await fetch(  `https://api.testnet.hiro.so/v2/contracts/call-read/${REGISTRY}/risk-registry/get-latest-risk`,  {    method: 'POST',    headers: { 'content-type': 'application/json' },    body: JSON.stringify({ sender: REGISTRY, arguments: ['0x' + serializeCV(Cl.principal(wallet))] }),  },);const { result } = await res.json();console.log(cvToString(deserializeCV(result)));// (ok (some (tuple (health-factor-e4 u3402...) ... (snapshot-id u1) (source-block u454752))))

Where to go next#

  • Quickstart: install the SDK and make your first requests.
  • Core concepts: read this before trusting any number. The units are fixed-point, and two of them have sentinel values that invert naive checks.
  • Consuming on-chain: if your consumer is a smart contract.