Skip to content

Instantly share code, notes, and snippets.

@mgild
Created September 29, 2025 03:29
Show Gist options
  • Select an option

  • Save mgild/7a06a1a4000190c0c6846944244fe458 to your computer and use it in GitHub Desktop.

Select an option

Save mgild/7a06a1a4000190c0c6846944244fe458 to your computer and use it in GitHub Desktop.
function getRangeRiskScoreJob(payer: Keypair): OracleJob {
const job = OracleJob.fromObject({
tasks: [
{
httpTask: {
url: "https://api.range.org/v1/risk/address?address=${ADDRESS}&network=solana",
headers: [
{ key: "accept", value: "application/json" },
// placeholder resolved on-oracle by Secrets
{ key: "X-API-KEY", value: "${RANGE_API_KEY}" },
],
},
},
// Only accept numeric riskScore >= 0; null => no match => failure so no Risk
{ jsonParseTask: { path: "$.riskScore" } },
{ multiplyTask: { scalar: 10 } }, // 0–10 => 0–100
{
boundTask: {
lowerBoundValue: "0",
onExceedsLowerBoundValue: "0",
upperBoundValue: "100",
onExceedsUpperBoundValue: "100",
},
},
],
});
return job;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment