Skip to main content
POST
/
agent
/
check-risk
Check risk for a DeFi action
curl --request POST \
  --url https://api.circular.rosetta.sh/api/v1/agent/check-risk \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "marketId": "<string>",
  "amountUsd": 123,
  "walletAddress": "<string>",
  "policy": {
    "minRating": "BBB",
    "maxUtilization": 0.85,
    "maxConcentrationPct": 0.05,
    "requireFreshOracle": true,
    "maxLeverage": 3
  }
}
'
import requests

url = "https://api.circular.rosetta.sh/api/v1/agent/check-risk"

payload = {
"marketId": "<string>",
"amountUsd": 123,
"walletAddress": "<string>",
"policy": {
"minRating": "BBB",
"maxUtilization": 0.85,
"maxConcentrationPct": 0.05,
"requireFreshOracle": True,
"maxLeverage": 3
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
marketId: '<string>',
amountUsd: 123,
walletAddress: '<string>',
policy: {
minRating: 'BBB',
maxUtilization: 0.85,
maxConcentrationPct: 0.05,
requireFreshOracle: true,
maxLeverage: 3
}
})
};

fetch('https://api.circular.rosetta.sh/api/v1/agent/check-risk', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.circular.rosetta.sh/api/v1/agent/check-risk",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'marketId' => '<string>',
'amountUsd' => 123,
'walletAddress' => '<string>',
'policy' => [
'minRating' => 'BBB',
'maxUtilization' => 0.85,
'maxConcentrationPct' => 0.05,
'requireFreshOracle' => true,
'maxLeverage' => 3
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.circular.rosetta.sh/api/v1/agent/check-risk"

payload := strings.NewReader("{\n \"marketId\": \"<string>\",\n \"amountUsd\": 123,\n \"walletAddress\": \"<string>\",\n \"policy\": {\n \"minRating\": \"BBB\",\n \"maxUtilization\": 0.85,\n \"maxConcentrationPct\": 0.05,\n \"requireFreshOracle\": true,\n \"maxLeverage\": 3\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.circular.rosetta.sh/api/v1/agent/check-risk")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"marketId\": \"<string>\",\n \"amountUsd\": 123,\n \"walletAddress\": \"<string>\",\n \"policy\": {\n \"minRating\": \"BBB\",\n \"maxUtilization\": 0.85,\n \"maxConcentrationPct\": 0.05,\n \"requireFreshOracle\": true,\n \"maxLeverage\": 3\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.circular.rosetta.sh/api/v1/agent/check-risk")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"marketId\": \"<string>\",\n \"amountUsd\": 123,\n \"walletAddress\": \"<string>\",\n \"policy\": {\n \"minRating\": \"BBB\",\n \"maxUtilization\": 0.85,\n \"maxConcentrationPct\": 0.05,\n \"requireFreshOracle\": true,\n \"maxLeverage\": 3\n }\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "reasons": [
      {
        "check": "<string>",
        "message": "<string>",
        "value": "<unknown>",
        "threshold": "<unknown>"
      }
    ],
    "market": {
      "name": "<string>",
      "rating": "<string>",
      "riskScore": 123,
      "utilization": 123,
      "tvl": 123,
      "supplyApy": 123,
      "borrowApy": 123
    },
    "position": {
      "healthFactor": 123,
      "currentLeverage": 123,
      "distanceToLiq": 123
    },
    "alternative": {
      "marketId": "<string>",
      "name": "<string>",
      "rating": "<string>",
      "riskScore": 123,
      "supplyApy": 123,
      "borrowApy": 123,
      "tvl": 123,
      "utilization": 123,
      "chainId": 123,
      "protocol": "<string>",
      "reason": "<string>"
    },
    "alternatives": [
      {
        "marketId": "<string>",
        "name": "<string>",
        "rating": "<string>",
        "riskScore": 123,
        "supplyApy": 123,
        "borrowApy": 123,
        "tvl": 123,
        "utilization": 123,
        "chainId": 123,
        "protocol": "<string>",
        "reason": "<string>"
      }
    ],
    "meta": {
      "latencyMs": 123,
      "policyApplied": {
        "minRating": "BBB",
        "maxUtilization": 0.85,
        "maxConcentrationPct": 0.05,
        "requireFreshOracle": true,
        "maxLeverage": 3
      },
      "checksRun": [
        "<string>"
      ],
      "timestamp": "2023-11-07T05:31:56Z"
    }
  },
  "meta": {
    "latencyMs": 123,
    "freshness": "<string>",
    "source": "<string>"
  }
}
{
"error": "<string>",
"meta": {
"latencyMs": 123,
"freshness": "<string>",
"source": "<string>"
}
}

Authorizations

Authorization
string
header
required

API key in format circ_live_* or circ_test_*

Body

application/json
action
enum<string>
required
Available options:
deposit,
borrow,
withdraw,
swap
marketId
string
required
amountUsd
number
required
walletAddress
string
policy
object

Response

Risk check result

data
object
meta
object