Risk reasons (SRR API): a 0-100 risk score with a band and its breakdown, the matched risk categories with direct/indirect exposure, and the full evidence behind a verdict. Plus chain capabilities: which networks support screening, reporting and research.
Options: config and hops (0 to 8) as for screening;
riskProfile for risk-score only.
Functions
chain-capabilities
fn (): Map
fn (opts: Map): Map
{capabilities: {<network>: {chainClass, screening, reporting, research}}}. chainClass is the chain to pass as {chain} elsewhere
(e.g. ethereum → evm).
Example
caps ::cipherowl::risk/chain-capabilities()
::cipherowl::risk/networks-for-chain(caps, "evm")
chain-class
fn (chain: Str): Str
fn (chain: Str, opts: Map): Str
The chain class to use for chain on the Report API, which (unlike
screening and risk reasons) rejects a specific chain such as base
and wants its class (evm). A class passes through without a call;
anything else costs one chain-capabilities request.
Example
// A class passes through without a request
::cipherowl::risk/chain-class("evm")
// A specific chain costs one chain-capabilities request
::cipherowl::risk/chain-class("base")
chain-class-of
fn (chain: Str, capabilities: Any): Str
The chain class for chain from a chain-capabilities result: chain
itself when it is already a class in ::cipherowl/CHAINS, the network's
chainClass when listed, otherwise chain unchanged (CipherOwl's 400
then names the supported set). Pure. Exposed for testing.
Example
caps {capabilities: {base: {chainClass: "evm"}}}
::cipherowl::risk/chain-class-of("base", caps) // "evm"
::cipherowl::risk/chain-class-of("tron", caps) // "tron"
direction-of
fn (value: Any): Str
A direction in lowercase: send, receive, direct, or unspecified
for anything else. Exposed for testing.
Example
::cipherowl::risk/direction-of("RECEIVE") // "receive"
::cipherowl::risk/direction-of(null) // "unspecified"
epoch-seconds-or-null
fn (value: Any): Int?
Unix seconds from CipherOwl's exposure timestamps, which arrive as
strings ("1652499489"); null when absent or not numeric. Exposed for
testing.
Example
::cipherowl::risk/epoch-seconds-or-null("1652499489") // 1652499489
::cipherowl::risk/epoch-seconds-or-null("soon") // null
networks-for-chain
fn (capabilities: Any, chain: Str): Vec<Str>
The network names in a chain-capabilities result whose chainClass is
chain. Pure.
Example
caps {capabilities: {base: {chainClass: "evm"}, ethereum: {chainClass: "evm"}, tron: {chainClass: "tron"}}}
::cipherowl::risk/networks-for-chain(caps, "evm") // ["base", "ethereum"]
parse-detail
fn (body: Any): Map
Normalize a risk-detail result: {chain, requested-chain, address, config, found-risk, reasons} with each reason from parse-reason. The
paths are counterparty addresses: wallet-risk evidence to keep with the
case, not in logs.
Example
out ::cipherowl::risk/parse-detail({foundRisk: true, reasons: [{category: "ofac", direction: "SEND", hops: 2}]})
out.found-risk // true
first(out.reasons).hops // 2
parse-reason
fn (raw: Map): Map
Normalize one detail reason: {category, direction, hops, total-usd-value (null for "Infinity"), total-percentage, first-exposure-at, last-exposure-at (Unix seconds), paths (each a Vec of addresses, risk source first), partial (paths is a sample), label, standard-label}. Exposed for testing.
Example
out ::cipherowl::risk/parse-reason({category: "ofac", direction: "DIRECT", totalUsdValue: "Infinity", paths: [{addresses: ["0x93df2c9c8786242b8fdca3f96b3914b8b4a9f704"]}]})
out.direction // "direct"
out.total-usd-value // null
out.paths // [["0x93df2c9c8786242b8fdca3f96b3914b8b4a9f704"]]
parse-score
fn (body: Any): Map
Normalize a risk-score result: {chain, requested-chain, address, config, risk-profile, score (0-100), band ("low" | "medium" | "high" | "severe", or null when unrecognized), band-label (CipherOwl's spelling), breakdown, computed-at}. breakdown items are
{category, direction, hops, usd-value, contribution}, largest
contribution first. computed-at is when the score was computed,
not when the exposure happened.
Example
out ::cipherowl::risk/parse-score({riskScore: 82, riskBand: "High Risk", breakdown: [{category: "ofac", direction: "RECEIVE", hops: 1, riskContribution: 82}]})
out.band // "high"
first(out.breakdown).direction // "receive"
reason-path
fn (chain: Str, address: Str, kind: Str, options: Map): Str
/api/reason/v2/chains/{chain}/addresses/{address}/{kind} plus the
query, with chain, address and hops validated. Exposed for testing.
Example
::cipherowl::risk/reason-path("evm", "0x0000000000000000000000000000000000000001", "detail", {hops: 2})
// "/api/reason/v2/chains/evm/addresses/0x0000000000000000000000000000000000000001/detail?hops=2"
risk-breakdown
fn (chain: Str, address: Str): Map
fn (chain: Str, address: Str, options: Map): Map
fn (chain: Str, address: Str, options: Map, opts: Map): Map
The matched risk categories: {chain, address, config, risks: [{type ("DIRECT" | "INDIRECT"), category, direction, percentage, hops, totalUsdValue}], version}.
Example
out ::cipherowl::risk/risk-breakdown("evm", "0x93df2c9c8786242b8fdca3f96b3914b8b4a9f704", {config: "co-sandbox", hops: 2})
map(out.risks, (r) { r.category })
risk-detail
fn (chain: Str, address: Str): Map
fn (chain: Str, address: Str, options: Map): Map
fn (chain: Str, address: Str, options: Map, opts: Map): Map
The evidence (normalize it with parse-detail): {chain, requested-chain, address, config, foundRisk, reasons: [{category, direction, hops, totalUsdValue, totalPercentage, firstExposureTimestamp, lastExposureTimestamp, paths, label, standardLabel, ...}], version}. totalUsdValue can be the string
"Infinity" for a directly flagged address; paths lists the
counterparty addresses on each exposure path.
Example
out ::cipherowl::risk/risk-detail("evm", "0x93df2c9c8786242b8fdca3f96b3914b8b4a9f704", {config: "co-sandbox"})
::cipherowl::risk/parse-detail(out).found-risk
risk-score
fn (chain: Str, address: Str): Map
fn (chain: Str, address: Str, options: Map): Map
fn (chain: Str, address: Str, options: Map, opts: Map): Map
A deterministic 0-100 risk score (normalize it with parse-score,
which also turns "Severe Risk" into "severe"): {chain, requested-chain, address, config, riskProfile, riskScore, riskBand ("Low Risk" | "Medium Risk" | "High Risk" | "Severe Risk"), breakdown: [{category, direction ("DIRECT" | "SEND" | "RECEIVE"), hops, usdValue, riskContribution}], timestamp, version}.
Example
score ::cipherowl::risk/risk-score("evm", "0x93df2c9c8786242b8fdca3f96b3914b8b4a9f704", {config: "co-sandbox"})
score.riskBand