Skip to main content
Agent Tools
View .md

POST /v1/validate

The core endpoint. Analyzes a proposed trade against real-time market data and returns a structured risk assessment.

Request

POST https://api.canonprotocol.org/v1/validate

Headers

HeaderRequiredValue
AuthorizationYesBearer YOUR_API_KEY
Content-TypeYesapplication/json

Body

{
"asset": "BTC",
"action": "long",
"size": 50000,
"leverage": 10,
"wallet": "0x7a3b1234567890abcdef1234567890abcdef1234",
"mode": "cross"
}
FieldTypeRequiredDescription
assetstringYesAsset ticker (e.g. "BTC", "ETH", "HYPE")
actionstringYesTrade direction: "long", "short", or "close"
sizenumberYesPosition size in USD. Must be positive, max $100,000,000
leveragenumberNoLeverage multiplier. Cannot exceed the asset's maximum leverage
walletstringYesEthereum wallet address (42 characters, 0x prefix)
modestringNoMargin mode: "cross" (default) or "isolated"
monte_carlobooleanNoEnable Monte Carlo simulation in the response (default: false)

Validation Rules

  • wallet must be a valid 42-character hex address starting with 0x
  • size must be positive and not exceed $100M
  • leverage cannot exceed the asset's maximum allowed leverage
  • asset must be a currently listed (not delisted) asset on Hyperliquid
  • Some assets are isolated-margin only and will reject "cross" mode

Response

{
"risk_score": 42,
"recommendation": "proceed_with_caution",
"flags": ["funding_anomaly"],
"slippage": {
"bps": 5.2,
"fill_price": 67432.10,
"mid_price": 67420.00,
"depth_50bps": 2150000,
"depth_100bps": 4800000,
"bid_ask_imbalance": 0.12
},
"liquidation": {
"price": 61200.50,
"distance_pct": 9.2,
"margin_used_pct": 68.4,
"effective_leverage": 10.8,
"mode": "cross"
},
"funding": {
"funding_rate": 0.000012,
"annualized_pct": 9.7,
"vs_cex_divergence": 1.8,
"direction": "longs_pay",
"agent_pays": true
},
"impact": {
"expected_bps": 8.1,
"participation_pct": 2.3
},
"var": {
"pct_95_24h": 4.2,
"pct_99_24h": 6.8,
"dollar_95_24h": 2100,
"dollar_99_24h": 3400,
"lvar_95_24h": 2250,
"lvar_99_24h": 3650,
"es_95_24h": 5.1,
"es_99_24h": 8.3,
"margin_var_99_pct": 68.0
},
"oi": {
"current": 485000000,
"at_cap": false,
"utilization_pct": 72.3
},
"stress": [
{
"scenario": "luna_collapse",
"description": "LUNA/UST collapse (May 2022): -30% BTC, severe alt drawdowns",
"pnl_pct": -37.0,
"pnl_usd": -18500,
"funding_cost_pct": 2.1,
"liquidity_cost_pct": 1.8,
"liquidation_distance_pct": 3.2,
"survives": true
}
],
"portfolio_risk": {
"portfolio_var_99_24h": 8200,
"portfolio_es_99_24h": 12500,
"position_count": 3
},
"portfolio_stress": {
"scenario": "ftx_crash",
"total_pnl_usd": -24000,
"total_pnl_pct": -12.5,
"total_funding_cost_pct": 3.2,
"account_survives": true,
"positions_liquidated": 0
},
"fees": {
"taker_fee_bps": 3.5,
"estimated_fee_usd": 17.50,
"fee_pct_of_margin": 0.35
},
"cost_analysis": {
"total_entry_cost_bps": 16.8,
"total_round_trip_cost_bps": 33.6,
"breakeven_move_pct": 0.34,
"funding_drag_24h_pct": 0.027,
"cost_score": 0.17
},
"sizing": {
"max_safe_size_usd": 1250000,
"suggested_size_usd": 875000,
"size_limit_reason": "book_depth"
},
"meta": {
"asset": "BTC",
"mark_price": 67500.00,
"max_leverage": 50,
"latency_ms": 52,
"request_id": "req_d4f8a2b1"
},
"model_version": {
"engine_version": "0.2.0"
}
}

Top-Level Fields

FieldTypeDescription
risk_scorenumberComposite risk score from 0 (lowest risk) to 100 (highest risk)
recommendationstring"proceed", "proceed_with_caution", or "abort"
flagsstring[]Array of risk flags identifying specific concerns. See Risk Flags
slippageobjectOrder book slippage analysis
liquidationobjectLiquidation proximity metrics
fundingobjectFunding rate analysis
impactobjectMarket impact estimation
varobjectValue-at-Risk calculations
oiobjectOpen interest utilization
stressarrayStress test results against historical scenarios
portfolio_riskobject or nullPortfolio-level risk (present when wallet has existing positions)
portfolio_stressobject or nullPortfolio-level stress test (present when wallet has existing positions)
feesobjectEstimated trading fees
cost_analysisobjectTrade cost aggregation and breakeven analysis
sizingobject or nullPosition sizing guidance based on market conditions. Omitted in error responses
monte_carloobject or nullMonte Carlo simulation results. Present when "monte_carlo": true in request
evtobject or nullExtreme Value Theory tail risk estimates
greeksobject or nullPosition Greeks (delta, gamma, vega, theta, liquidation gamma)
regimeobject or nullLiquidity regime state (normal/stressed/crisis)
drawdownobject or nullDrawdown metrics and stop-loss suggestions
portfolio_attributionobject or nullMarginal/component VaR decomposition
metaobjectRequest metadata including current mark price and latency
model_versionobjectEngine version and calibration identifiers

Slippage Object

FieldTypeDescription
bpsnumberExpected slippage in basis points
fill_pricenumberEstimated average fill price
mid_pricenumberCurrent mid price from the order book
depth_50bpsnumberUSD liquidity available within 50bps of mid
depth_100bpsnumberUSD liquidity available within 100bps of mid
bid_ask_imbalancenumberOrder book imbalance ratio (-1 to 1). Positive = bid-heavy (buying pressure), 0 = balanced

Liquidation Object

FieldTypeDescription
pricenumberEstimated liquidation price
distance_pctnumberDistance from mark price to liquidation as percentage
margin_used_pctnumberPercentage of available margin consumed
effective_leveragenumberEffective leverage accounting for existing positions
modestringMargin mode used for calculation: "cross", "isolated", or "close"

Funding Object

FieldTypeDescription
funding_ratenumberCurrent hourly funding rate (1/8th of the 8-hour rate)
annualized_pctnumberProjected annualized funding cost as percentage
vs_cex_divergencenumberRatio of Hyperliquid to CEX funding rate (e.g. 3.0 = HL rate is 3x CEX). 0 when rates are negligible
directionstring"longs_pay" or "shorts_pay"
agent_paysbooleantrue if the agent pays funding (a cost), false if the agent receives funding (income). When false, the funding component contributes zero to the risk score

Impact Object

FieldTypeDescription
expected_bpsnumberEstimated market impact in basis points
participation_pctnumberTrade size as percentage of recent volume

VaR Object

FieldTypeDescription
pct_95_24hnumber24-hour Value-at-Risk at 95% confidence (percentage of notional)
pct_99_24hnumber24-hour Value-at-Risk at 99% confidence (percentage of notional)
dollar_95_24hnumber95% VaR in USD
dollar_99_24hnumber99% VaR in USD
lvar_95_24hnumberLiquidity-adjusted VaR at 95% in USD (includes spread and slippage costs)
lvar_99_24hnumberLiquidity-adjusted VaR at 99% in USD
pct_99_4hnumber4-hour Value-at-Risk at 99% confidence (percentage of notional)
pct_99_7dnumber7-day Value-at-Risk at 99% confidence (percentage of notional)
dollar_99_4hnumber4-hour 99% VaR in USD
dollar_99_7dnumber7-day 99% VaR in USD
es_95_24hnumberExpected Shortfall (CVaR) at 95% confidence
es_99_24hnumberExpected Shortfall (CVaR) at 99% confidence
margin_var_99_pctnumberVaR as percentage of margin (not notional). At 20x leverage, 5% notional VaR = 100% margin VaR
volatility_regimestringCurrent volatility regime: "low", "normal", or "high"
volatility_forecastobject or nullGARCH volatility forecast. See Volatility Forecast Object below

OI Object

FieldTypeDescription
currentnumberCurrent open interest in USD
at_capbooleanWhether the asset is at Hyperliquid's OI cap
utilization_pctnumberOI as percentage of estimated cap

Stress Array

Each entry in the stress array represents a historical scenario:

FieldTypeDescription
scenariostringScenario identifier
descriptionstringHuman-readable description of the scenario
pnl_pctnumberEstimated PnL as percentage of position
pnl_usdnumberEstimated PnL in USD
funding_cost_pctnumberProjected funding cost under the scenario
liquidity_cost_pctnumberEstimated liquidity/slippage cost under the scenario
liquidation_distance_pctnumberDistance to liquidation under the scenario
survivesbooleanWhether the position would survive the scenario

Portfolio Risk Object

Present only when the wallet has 2 or more open positions. Omitted from response otherwise.

FieldTypeDescription
portfolio_var_99_24hnumberPortfolio-level 99% VaR in USD, accounting for correlations
portfolio_es_99_24hnumberPortfolio-level Expected Shortfall at 99% in USD
position_countintegerNumber of open positions in the portfolio
monte_carloobject or nullPortfolio-level Monte Carlo simulation results (VaR, ES, marginal/component VaR, liquidation probability)
tail_dependencearray or nullCopula-based tail dependence between position pairs (lower/upper tail lambda, Pearson rho)

Portfolio Stress Object

Present only when the wallet has existing positions. Omitted from response otherwise.

FieldTypeDescription
scenariostringWorst-case scenario for the portfolio
total_pnl_usdnumberTotal portfolio PnL under the scenario
total_pnl_pctnumberTotal portfolio PnL as percentage
total_funding_cost_pctnumberCombined funding cost across all positions
account_survivesbooleanWhether the account would survive
positions_liquidatedintegerNumber of positions that would be liquidated

Fees Object

FieldTypeDescription
taker_fee_bpsnumberTaker fee rate in basis points
estimated_fee_usdnumberEstimated fee for this trade in USD
fee_pct_of_marginnumberFee as percentage of margin posted

Cost Analysis Object

FieldTypeDescription
total_entry_cost_bpsnumberTotal entry cost in basis points (slippage + impact + taker fee)
total_round_trip_cost_bpsnumberEstimated round-trip cost (entry + exit) in basis points
breakeven_move_pctnumberPrice movement percentage needed to break even after all costs, accounting for leverage
funding_drag_24h_pctnumberProjected 24-hour funding cost as percentage of margin. Negative means the agent receives funding
cost_scorenumberNormalized cost burden from 0.0 (negligible) to 1.0 (extremely expensive)

Sizing Object

Present when the engine can compute sizing guidance. Omitted in error responses.

FieldTypeDescription
max_safe_size_usdnumberLargest position size (USD) that keeps all risk metrics within safe thresholds
suggested_size_usdnumberRecommended position size with safety margin applied
size_limit_reasonstringThe binding constraint: "book_depth", "oi_capacity", "margin_headroom", or "market_impact"

Monte Carlo Object

Present when "monte_carlo": true is passed in the request body.

FieldTypeDescription
simulationsnumberNumber of Monte Carlo paths simulated
var_95number95% VaR from simulation (percentage)
var_99number99% VaR from simulation (percentage)
expected_shortfall_95numberExpected Shortfall at 95% from simulation
expected_shortfall_99numberExpected Shortfall at 99% from simulation
median_returnnumberMedian simulated return
worst_casenumberWorst-case simulated return
confidence_intervalarray[lower, upper] bounds of the 95% confidence interval

EVT Object

Tail risk estimates beyond standard VaR.

FieldTypeDescription
var_99_9number99.9% VaR estimate (percentage)
expected_shortfall_99_9number99.9% Expected Shortfall

Greeks Object

Position-level Greeks for sensitivity analysis.

FieldTypeDescription
deltanumberPrice sensitivity (dPnL / dPrice)
gammanumberSecond-order price sensitivity (dDelta / dPrice)
veganumberVolatility sensitivity (dPnL / dVol)
thetanumberTime decay (daily PnL erosion from funding and costs)
liquidation_gammanumberGamma-like measure of liquidation distance sensitivity to price moves

Regime Object

Current liquidity regime classification.

FieldTypeDescription
statestring"normal", "stressed", or "crisis"
confidencenumberConfidence in the regime classification (0.0 to 1.0)

Drawdown Object

Drawdown metrics and suggested stop-loss levels.

FieldTypeDescription
max_drawdown_pctnumberMaximum historical drawdown percentage for the asset
current_drawdown_pctnumberCurrent drawdown from recent peak
peak_equitynumberPeak equity value before drawdown
trough_equitynumberTrough equity value during drawdown
drawdown_duration_hoursnumberDuration of the current drawdown in hours
calmar_rationumberReturn-to-max-drawdown ratio
trailing_stop_distance_pctnumberATR-based trailing stop distance as percentage
suggested_stop_loss_pctnumberSuggested stop-loss percentage based on volatility and leverage

Portfolio Attribution Object

Marginal and component VaR decomposition across portfolio positions.

FieldTypeDescription
total_var_99numberTotal portfolio 99% VaR in USD
diversification_benefit_pctnumberPercentage reduction in VaR from diversification
positionsarrayPer-position attribution breakdown

Each entry in the positions array:

FieldTypeDescription
assetstringAsset ticker
marginal_varnumberMarginal VaR contribution in USD (change in portfolio VaR from adding this position)
component_varnumberComponent VaR in USD (position's share of total portfolio VaR)
component_var_pctnumberComponent VaR as percentage of total portfolio VaR

Meta Object

FieldTypeDescription
assetstringAsset ticker
mark_pricenumberCurrent mark price
max_leveragenumberMaximum allowed leverage for this asset
latency_msnumberServer-side processing time in milliseconds
request_idstring or nullUnique identifier for this request
errorstring or nullError message (present only in batch error responses)

Model Version Object

FieldTypeDescription
engine_versionstringSemantic version of the risk engine

Volatility Forecast Object

Volatility forecast at multiple horizons.

FieldTypeDescription
sigma_1hnumberForecasted 1-hour volatility (annualized)
sigma_4hnumberForecasted 4-hour volatility (annualized)
sigma_1dnumberForecasted 1-day volatility (annualized)
sigma_7dnumberForecasted 7-day volatility (annualized)
long_run_sigmanumberLong-run unconditional volatility