Cambrian Calculate Liquidation Risk API

By Cambrian Network risk

GET /api/v1/perp-risk-engine

Perpetual Futures Liquidation Risk Engine

Overview

The /api/v1/perp-risk-engine endpoint calculates the probability that a leveraged cryptocurrency position will be liquidated within a specified time horizon. It uses Monte Carlo simulations driven by real historical price data from the Cambrian API, automatically determining lookback periods and simulation parameters based on the requested risk horizon. The response includes the liquidation price, volatility metrics, and full simulation visualization data.

Business Value

  • Risk Management: Quantify exact liquidation probabilities before entering leveraged positions to prevent unexpected losses
  • Position Sizing: Optimize leverage levels based on statistical risk assessments and personal risk tolerance
  • Market Intelligence: Understand volatility dynamics and price drift patterns for different tokens across various timeframes
  • Trading Strategy: Make data-driven decisions on entry points, stop losses, and position duration based on probabilistic outcomes
  • Capital Preservation: Avoid overleveraging by visualizing risk distributions and understanding sigma-based safety margins

Endpoint Details

URL:

https://risk.cambrian.network/api/v1/perp-risk-engine

Method: GET Authentication: Required via X-API-Key header, or pay per request with x402. The x402 option does not require an API key.

Query Parameters

Parameter Type Required Default Description
token_address string Yes - Solana token address for the asset being traded
entry_price float Yes - Entry price of the position in USD (must be greater than 0)
leverage float Yes - Leverage multiplier for the position (must be greater than 0, maximum 1000)
direction string Yes - Position direction: long or short
risk_horizon string Yes - Time horizon over which to assess liquidation risk: 1h, 1d, 1w, or 1mo

Response Field Descriptions

Response Field Type Description
status string Result status of the calculation, e.g. "success"
riskProbability float Probability (0.0–1.0) that the position will be liquidated within the risk horizon, derived from the fraction of Monte Carlo paths that breach the liquidation price
liquidationPrice float The price level at which the position would be liquidated, calculated from entry price, leverage, and direction
entryPrice float The entry price provided in the request, echoed back in the response
volatility float Annualized volatility of the token estimated from historical price data used in the simulation
drift float Estimated drift (mean return) of the token derived from historical price data
priceChangeNeeded float Fractional price move required to reach the liquidation price from the entry price (e.g. 0.1 means a 10% move)
sigmasAway float Number of standard deviations the liquidation price is from the current price, given the simulated volatility over the risk horizon
simulationDetails object Metadata about the Monte Carlo simulation run
simulationDetails.totalSimulations integer Total number of price paths simulated
simulationDetails.liquidatedPaths integer Number of simulated paths that reached the liquidation price
simulationDetails.dataPointsUsed integer Number of historical price data points used to calibrate the simulation
simulationDetails.dataInterval string Interval description of the historical data used
simulationDetails.riskHorizon string The risk horizon used for this simulation, echoing the request parameter
visualizationData object Data for rendering a probability distribution of simulated final prices
visualizationData.histogram.bins array[float] Price bin edges for the histogram of simulated final prices
visualizationData.histogram.counts array[integer] Number of simulated paths whose final price fell in each histogram bin
visualizationData.histogram.finalPrices array[float] Sampled final prices from individual simulation paths (subset for visualization)
visualizationData.liquidationThreshold float The liquidation price echoed into the visualization object for chart rendering
server string Server identifier string

Examples

1. Assessing 1-Day Liquidation Risk for a 10x Long Position

This example demonstrates calculating the liquidation risk for a 10x leveraged long position on a Solana token entered at $2,800 over a 1-day horizon. The response shows full simulation detail including visualization data.

curl -X GET "https://risk.cambrian.network/api/v1/perp-risk-engine?token_address=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&entry_price=2800&leverage=10&direction=long&risk_horizon=1d" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json"

Response:

{
  "status": "success",
  "riskProbability": 0.0,
  "liquidationPrice": 2519.8038627038927,
  "entryPrice": 2800.0,
  "volatility": 0.04471483870290695,
  "drift": 0.0046871436434241945,
  "priceChangeNeeded": 0.10007004903432402,
  "sigmasAway": 42.756177990007,
  "simulationDetails": {
    "totalSimulations": 10000,
    "liquidatedPaths": 0,
    "dataPointsUsed": 672,
    "dataInterval": "variable",
    "riskHorizon": "1d"
  },
  "visualizationData": {
    "histogram": {
      "bins": [
        2773.64208984375,
        2774.728271484375,
        2775.814453125,
        2776.900634765625,
        2777.986572265625,
        2779.07275390625,
        2780.158935546875,
        2781.2451171875,
        2782.331298828125,
        2783.41748046875,
        2784.503662109375,
        2785.589599609375,
        2786.67578125,
        2787.761962890625,
        2788.84814453125,
        2789.934326171875,
        2791.0205078125,
        2792.106689453125,
        2793.192626953125,
        2794.27880859375,
        2795.364990234375,
        2796.451171875,
        2797.537353515625,
        2798.62353515625,
        2799.709716796875,
        2800.7958984375,
        2801.8818359375,
        2802.968017578125,
        2804.05419921875,
        2805.140380859375,
        2806.2265625,
        2807.312744140625,
        2808.39892578125,
        2809.48486328125,
        2810.571044921875,
        2811.6572265625,
        2812.743408203125,
        2813.82958984375,
        2814.915771484375,
        2816.001953125,
        2817.087890625,
        2818.174072265625,
        2819.26025390625,
        2820.346435546875,
        2821.4326171875,
        2822.518798828125,
        2823.60498046875,
        2824.69091796875,
        2825.777099609375,
        2826.86328125,
        2827.949462890625
      ],
      "counts": [
        1,
        2,
        0,
        2,
        3,
        6,
        12,
        18,
        22,
        31,
        40,
        63,
        91,
        136,
        203,
        256,
        272,
        356,
        418,
        465,
        547,
        612,
        605,
        706,
        706,
        633,
        594,
        544,
        518,
        444,
        380,
        315,
        271,
        207,
        146,
        122,
        76,
        64,
        36,
        32,
        15,
        13,
        3,
        5,
        3,
        1,
        2,
        1,
        0,
        2
      ],
      "finalPrices": [
        2799.4658203125,
        2803.881103515625,
        2806.348876953125,
        2794.480224609375,
        2803.92919921875,
        2808.342041015625,
        2803.807373046875,
        2790.15185546875,
        2816.1240234375,
        2798.91845703125,
        2797.903076171875,
        2805.513916015625,
        2799.43505859375,
        2807.7529296875,
        2788.0556640625,
        2798.332763671875,
        2789.1767578125,
        2808.652587890625,
        2797.6416015625,
        2797.4306640625,
        2798.137939453125,
        2814.751708984375,
        2803.7353515625,
        2805.10986328125,
        2796.893310546875,
        2798.747802734375,
        2788.417236328125,
        2795.597412109375,
        2805.0498046875,
        2799.2841796875,
        2813.820556640625,
        2801.70654296875,
        2814.02978515625,
        2807.15576171875,
        2794.78564453125,
        2794.779052734375,
        2805.014892578125,
        2796.5146484375,
        2805.484375,
        2801.365966796875,
        2803.28466796875,
        2799.417724609375,
        2810.862060546875,
        2789.42138671875,
        2795.488037109375,
        2798.221923828125,
        2798.527587890625,
        2807.329833984375,
        2798.551513671875,
        2807.391357421875,
        2795.156005859375,
        2799.668701171875,
        2795.583984375,
        2809.681640625,
        2808.9501953125,
        2791.172607421875,
        2795.986328125,
        2806.1455078125,
        2797.2705078125,
        2785.044677734375,
        2806.759521484375,
        2805.087158203125,
        2801.697265625,
        2794.5283203125,
        2800.906494140625,
        2794.752197265625,
        2790.408447265625,
        2797.903076171875,
        2797.6640625,
        2795.221435546875,
        2798.208740234375,
        2793.193359375,
        2798.00732421875,
        2799.847412109375,
        2800.566162109375,
        2800.477783203125,
        2785.69970703125,
        2792.783447265625,
        2799.519287109375,
        2810.08349609375,
        2796.485107421875,
        2794.83740234375,
        2796.838623046875,
        2805.824462890625,
        2790.451171875,
        2800.368408203125,
        2801.384521484375,
        2791.326904296875,
        2800.726318359375,
        2805.516845703125,
        2795.1240234375,
        2799.921142578125,
        2796.9921875,
        2805.120849609375,
        2804.4306640625,
        2791.625,
        2803.2314453125,
        2816.30224609375,
        2790.50439453125,
        2799.508544921875,
        2798.622314453125,
        2802.287841796875,
        2798.04833984375,
        2805.721435546875,
        2801.836181640625,
        2802.05810546875,
        2799.281494140625,
        2785.243896484375,
        2808.338134765625,
        2801.643798828125,
        2800.45361328125,
        2811.070068359375,
        2794.547119140625,
        2792.5048828125,
        2803.692626953125,
        2806.968505859375,
        2809.531494140625,
        2803.15771484375,
        2806.284423828125,
        2795.534423828125,
        2807.071533203125,
        2807.886962890625,
        2812.634765625,
        2805.712158203125,
        2795.470458984375,
        2794.10888671875,
        2803.315673828125,
        2802.867919921875,
        2806.041015625,
        2800.858642578125,
        2799.983642578125,
        2796.610595703125,
        2806.091796875,
        2795.873291015625,
        2800.620849609375,
        2799.393798828125,
        2796.374755859375,
        2797.21337890625,
        2800.6982421875,
        2799.7822265625,
        2802.456298828125,
        2783.1318359375,
        2801.579833984375,
        2796.227783203125,
        2810.856689453125,
        2805.00830078125,
        2797.11328125,
        2807.302001953125,
        2800.1064453125,
        2807.614990234375,
        2792.45703125,
        2798.03515625,
        2809.511474609375,
        2803.7392578125,
        2791.98974609375,
        2796.642578125,
        2805.782958984375,
        2799.081298828125,
        2801.945556640625,
        2789.894775390625,
        2805.667724609375,
        2797.482666015625,
        2807.333984375,
        2790.8662109375,
        2801.14306640625,
        2811.584716796875,
        2788.44921875,
        2793.9033203125,
        2809.9052734375,
        2807.0595703125,
        2792.70458984375,
        2797.35205078125,
        2789.569091796875,
        2808.146484375,
        2805.159423828125,
        2797.12646484375,
        2799.3642578125,
        2796.585205078125,
        2800.9677734375,
        2795.29736328125,
        2801.122802734375,
        2794.21240234375,
        2794.035400390625,
        2804.482666015625,
        2807.01806640625,
        2803.18310546875,
        2807.958984375,
        2789.4306640625,
        2803.188720703125,
        2804.92138671875,
        2813.01416015625,
        2801.26025390625,
        2801.56103515625,
        2792.602294921875,
        2792.44775390625,
        2793.385498046875,
        2791.48388671875,
        2803.84619140625,
        2793.31591796875,
        2782.545166015625,
        2801.496826171875,
        2811.614013671875,
        2792.439697265625,
        2810.359619140625,
        2797.46142578125,
        2806.98583984375,
        2796.575927734375,
        2794.828125,
        2810.05419921875,
        2803.140625,
        2797.91748046875,
        2787.929443359375,
        2791.888671875,
        2798.3740234375,
        2804.343505859375,
        2797.91748046875,
        2795.47607421875,
        2795.619873046875,
        2805.9970703125,
        2799.0654296875,
        2799.328369140625,
        2797.76025390625,
        2792.89404296875,
        2807.724853515625,
        2803.825927734375,
        2797.686767578125,
        2804.98681640625,
        2803.6416015625,
        2801.515625,
        2793.8740234375,
        2799.45361328125,
        2807.36181640625,
        2783.38525390625,
        2794.68408203125,
        2799.186767578125,
        2817.019775390625,
        2797.62548828125,
        2799.157470703125,
        2797.166748046875,
        2794.664306640625,
        2794.52294921875,
        2789.337646484375,
        2801.55810546875,
        2798.58203125,
        2802.82666015625,
        2792.113525390625,
        2793.280029296875,
        2808.750732421875,
        2793.14697265625,
        2805.330810546875,
        2799.230712890625,
        2801.26708984375,
        2791.184326171875,
        2794.564208984375,
        2795.217529296875,
        2807.730224609375,
        2797.792236328125,
        2797.42138671875,
        2801.344482421875,
        2798.03125,
        2804.93994140625,
        2806.27001953125,
        2799.32568359375,
        2790.101318359375,
        2798.145751953125,
        2787.697021484375,
        2790.235595703125,
        2805.729248046875,
        2797.222412109375,
        2799.76220703125,
        2802.493408203125,
        2795.978515625,
        2802.61376953125,
        2804.887939453125,
        2800.087890625,
        2804.0322265625,
        2805.918212890625,
        2804.628662109375,
        2797.866943359375,
        2799.05322265625,
        2799.181640625,
        2803.99853515625,
        2796.427734375,
        2800.298583984375,
        2793.310791015625,
        2799.66748046875,
        2805.875244140625,
        2792.514404296875,
        2800.712890625,
        2795.947998046875,
        2805.352294921875,
        2794.484375,
        2796.1025390625,
        2805.533935546875,
        2807.3056640625,
        2792.8046875,
        2795.33203125,
        2806.8134765625,
        2798.143310546875,
        2802.681884765625,
        2797.141357421875,
        2808.20166015625,
        2802.126220703125,
        2800.1640625,
        2808.630126953125,
        2797.43212890625,
        2799.3642578125,
        2794.3603515625,
        2805.034912109375,
        2802.078125,
        2799.257568359375,
        2794.680419921875,
        2792.833984375,
        2802.060791015625,
        2794.077880859375,
        2801.384521484375,
        2810.68115234375,
        2796.10400390625,
        2806.572509765625,
        2800.12255859375,
        2802.666015625,
        2799.353759765625,
        2811.52734375,
        2809.42578125,
        2800.0009765625,
        2802.152587890625,
        2803.473388671875,
        2801.008056640625,
        2802.734130859375,
        2796.142822265625,
        2799.00390625,
        2792.5634765625,
        2797.8056640625,
        2812.975341796875,
        2803.72216796875,
        2796.0146484375,
        2799.416259765625,
        2807.719482421875,
        2803.703125,
        2786.379638671875,
        2796.453125,
        2808.86865234375,
        2805.59033203125,
        2790.004150390625,
        2790.553466796875,
        2797.212158203125,
        2807.79052734375,
        2794.075439453125,
        2798.502197265625,
        2809.3505859375,
        2803.28466796875,
        2800.109130859375,
        2803.872802734375,
        2798.39013671875,
        2793.788818359375,
        2798.80908203125,
        2799.624755859375,
        2798.17919921875,
        2808.222900390625,
        2805.719970703125,
        2795.525390625,
        2800.070556640625,
        2800.294921875,
        2796.594482421875,
        2792.619384765625,
        2791.9619140625,
        2793.318603515625,
        2801.360595703125,
        2800.55126953125,
        2794.56689453125,
        2800.317626953125,
        2788.328369140625,
        2808.478515625,
        2804.125732421875,
        2801.240478515625,
        2794.40966796875,
        2786.1513671875,
        2811.113037109375,
        2802.2197265625,
        2804.296875,
        2796.737060546875,
        2808.60595703125,
        2805.6171875,
        2801.182861328125,
        2786.97216796875,
        2801.81494140625,
        2784.88818359375,
        2800.6767578125,
        2809.19384765625,
        2803.72216796875,
        2798.272705078125,
        2799.7314453125,
        2804.5908203125,
        2786.239013671875,
        2812.71923828125,
        2793.453125,
        2793.126953125,
        2795.583984375,
        2799.68603515625,
        2802.197021484375,
        2797.89892578125,
        2809.966796875,
        2810.466796875,
        2803.518798828125,
        2807.153076171875,
        2804.61376953125,
        2795.877197265625,
        2800.94384765625,
        2798.399169921875,
        2800.081298828125,
        2796.190673828125,
        2795.713134765625,
        2809.51416015625,
        2803.021484375,
        2804.784912109375,
        2792.578125,
        2789.570556640625,
        2796.38232421875,
        2810.2431640625,
        2792.269287109375,
        2806.5390625,
        2800.669921875,
        2792.118896484375,
        2797.3251953125,
        2804.252685546875,
        2797.45751953125,
        2799.53662109375,
        2807.2255859375,
        2810.998779296875,
        2799.41357421875,
        2801.452880859375,
        2795.1865234375,
        2811.40234375,
        2804.3408203125,
        2789.74462890625,
        2788.673828125,
        2805.064453125,
        2805.27197265625,
        2799.577880859375,
        2806.652587890625,
        2788.287109375,
        2803.518798828125,
        2797.00390625,
        2799.858154296875,
        2798.87841796875,
        2797.025390625,
        2809.419189453125,
        2788.715087890625,
        2799.528564453125,
        2812.79150390625,
        2792.442138671875,
        2806.8603515625,
        2801.400634765625,
        2799.759521484375,
        2813.278564453125,
        2797.150634765625,
        2799.7275390625,
        2798.95458984375,
        2799.58447265625,
        2802.80224609375,
        2808.5576171875,
        2812.18017578125,
        2804.1416015625,
        2805.19580078125,
        2792.82568359375,
        2795.358642578125,
        2799.428466796875,
        2800.268310546875,
        2797.13720703125,
        2795.149169921875,
        2805.1904296875,
        2791.4931640625,
        2808.72119140625,
        2801.4501953125,
        2805.23828125,
        2800.002197265625,
        2799.54052734375,
        2804.801025390625,
        2793.8046875,
        2802.600341796875,
        2804.936279296875,
        2802.373291015625,
        2810.095703125,
        2800.325439453125,
        2803.223388671875,
        2788.985107421875,
        2800.3564453125,
        2798.278076171875,
        2805.602294921875,
        2791.380126953125,
        2801.9443359375,
        2802.30908203125,
        2804.271728515625,
        2801.011962890625,
        2801.770751953125,
        2810.93310546875,
        2790.4111328125,
        2809.09619140625,
        2796.093017578125,
        2810.462646484375,
        2803.307373046875,
        2790.127685546875,
        2791.82861328125,
        2793.0205078125,
        2804.746337890625,
        2799.544677734375,
        2789.75,
        2812.559326171875,
        2790.744140625,
        2792.6953125,
        2791.5263671875,
        2809.08544921875,
        2795.243896484375,
        2799.7421875,
        2803.942626953125,
        2796.17578125,
        2799.696533203125,
        2793.38134765625,
        2805.274658203125,
        2803.99853515625,
        2804.7568359375,
        2793.2041015625,
        2798.675537109375,
        2804.42236328125,
        2808.096923828125,
        2802.761962890625,
        2809.541015625,
        2791.135009765625,
        2792.73388671875,
        2789.66357421875,
        2790.338134765625,
        2800.145263671875,
        2784.861328125,
        2803.4892578125,
        2794.80029296875,
        2802.933349609375,
        2803.978759765625,
        2807.89892578125,
        2802.766357421875,
        2796.65185546875,
        2796.10400390625,
        2804.0107421875,
        2800.350830078125,
        2804.720703125,
        2804.58984375,
        2806.112060546875,
        2796.1748046875,
        2798.8759765625,
        2802.08740234375,
        2803.254150390625,
        2800.815673828125,
        2811.10205078125,
        2795.07470703125,
        2785.002197265625,
        2794.6962890625,
        2797.454833984375,
        2804.42529296875,
        2798.351318359375,
        2801.057373046875,
        2806.265869140625,
        2792.583740234375,
        2795.6279296875,
        2804.041259765625,
        2811.427978515625,
        2811.445068359375,
        2803.703125,
        2799.90771484375,
        2799.899658203125,
        2781.96826171875,
        2796.16796875,
        2801.12548828125,
        2809.574462890625,
        2790.409912109375,
        2799.868896484375,
        2805.076416015625,
        2803.630859375,
        2783.958740234375,
        2806.19775390625,
        2806.043701171875,
        2792.9326171875,
        2800.869140625,
        2802.537841796875,
        2809.38818359375,
        2799.527099609375,
        2802.39990234375,
        2795.491943359375,
        2810.828857421875,
        2804.817138671875,
        2808.16943359375,
        2809.19921875,
        2801.5302734375,
        2799.544677734375,
        2803.628173828125,
        2802.510986328125,
        2810.685302734375,
        2798.36328125,
        2789.365478515625,
        2803.906494140625,
        2813.89013671875,
        2797.502685546875,
        2799.18798828125,
        2806.798583984375,
        2798.260498046875,
        2802.54296875,
        2798.019287109375,
        2812.19482421875,
        2798.2392578125,
        2805.550048828125,
        2802.465576171875,
        2801.3955078125,
        2799.42578125,
        2810.998779296875,
        2807.1455078125,
        2790.417724609375,
        2799.922119140625,
        2811.027099609375,
        2801.211181640625,
        2794.456298828125,
        2799.083984375,
        2801.102783203125,
        2793.7861328125,
        2793.503662109375,
        2788.65283203125,
        2782.156494140625,
        2801.656005859375,
        2804.435791015625,
        2803.937255859375,
        2787.975830078125,
        2796.311767578125,
        2803.3662109375,
        2789.163330078125,
        2793.00048828125,
        2791.18701171875,
        2803.1669921875,
        2802.56591796875,
        2797.1533203125,
        2786.58056640625,
        2802.764892578125,
        2811.265380859375,
        2805.9208984375,
        2788.861572265625,
        2801.514404296875,
        2796.207763671875,
        2796.67724609375,
        2795.864013671875,
        2793.59716796875,
        2804.94677734375,
        2795.67431640625,
        2800.5244140625,
        2792.607421875,
        2809.52880859375,
        2800.476318359375,
        2797.193359375,
        2810.776123046875,
        2795.7958984375,
        2808.6552734375,
        2796.11328125,
        2798.5087890625,
        2792.386474609375,
        2809.847900390625,
        2794.119140625,
        2788.922607421875,
        2794.185791015625,
        2793.541015625,
        2807.024658203125,
        2802.830322265625,
        2810.836669921875,
        2790.38330078125,
        2785.202880859375,
        2795.5185546875,
        2807.39013671875,
        2796.1318359375,
        2795.0947265625,
        2802.008544921875,
        2797.956298828125,
        2799.6044921875,
        2807.758544921875,
        2805.659912109375,
        2786.822265625,
        2806.061279296875,
        2796.966552734375,
        2799.031982421875,
        2806.73583984375,
        2787.8095703125,
        2805.61962890625,
        2798.03515625,
        2798.890380859375,
        2801.232177734375,
        2822.189208984375,
        2805.052734375,
        2807.574951171875,
        2800.512451171875,
        2800.576416015625,
        2808.304443359375,
        2800.865234375,
        2793.00439453125,
        2808.859130859375,
        2796.758544921875,
        2791.048583984375,
        2801.299072265625,
        2807.1640625,
        2797.101318359375,
        2799.743408203125,
        2797.21728515625,
        2809.167236328125,
        2790.51904296875,
        2803.88232421875,
        2792.73388671875,
        2803.743408203125,
        2807.552001953125,
        2806.90966796875,
        2797.7724609375,
        2797.2587890625,
        2792.839111328125,
        2802.5029296875,
        2791.0087890625,
        2794.107421875,
        2800.154541015625,
        2804.3876953125,
        2795.60791015625,
        2788.374755859375,
        2797.41357421875,
        2803.082763671875,
        2800.321533203125,
        2798.3232421875,
        2794.797607421875,
        2806.64990234375,
        2795.1826171875,
        2808.208251953125,
        2792.80322265625,
        2791.506591796875,
        2798.31005859375,
        2794.6923828125,
        2787.724853515625,
        2807.171875,
        2792.896484375,
        2808.61669921875,
        2801.5849609375,
        2803.90771484375,
        2793.205322265625,
        2796.4638671875,
        2790.962158203125,
        2806.261962890625,
        2806.611328125,
        2799.349609375,
        2791.795166015625,
        2803.5546875,
        2798.94921875,
        2797.68408203125,
        2805.963623046875,
        2807.999267578125,
        2802.222412109375,
        2803.368896484375,
        2803.83154296875,
        2808.139892578125,
        2795.9052734375,
        2794.3857421875,
        2790.685302734375,
        2812.2509765625,
        2790.742431640625,
        2806.0009765625,
        2807.391357421875,
        2803.6162109375,
        2790.570556640625,
        2795.135986328125,
        2809.44189453125,
        2793.168212890625,
        2806.35693359375,
        2801.112060546875,
        2802.012451171875,
        2797.91650390625,
        2797.4228515625,
        2798.1591796875,
        2812.662841796875,
        2801.16162109375,
        2804.718017578125,
        2795.9052734375,
        2801.021240234375,
        2802.490966796875,
        2797.266845703125,
        2791.707275390625,
        2804.92822265625,
        2804.8935546875,
        2792.478271484375,
        2799.925048828125,
        2798.694091796875,
        2805.88720703125,
        2805.9755859375,
        2811.295166015625,
        2798.873046875,
        2802.867919921875,
        2806.2900390625,
        2801.7373046875,
        2789.97900390625,
        2792.5341796875,
        2796.70263671875,
        2800.063720703125,
        2808.071533203125,
        2806.079833984375,
        2790.939453125,
        2802.8876953125,
        2810.765869140625,
        2801.460693359375,
        2801.480712890625,
        2793.636962890625,
        2806.677978515625,
        2792.88720703125,
        2796.757080078125,
        2795.638671875,
        2799.939697265625,
        2789.3125,
        2806.542724609375,
        2810.01123046875,
        2788.527587890625,
        2794.23388671875,
        2802.1474609375,
        2811.36083984375,
        2788.930908203125,
        2800.9638671875,
        2809.374755859375,
        2802.728759765625,
        2802.413330078125,
        2792.357177734375,
        2802.564453125,
        2790.972900390625,
        2792.9326171875,
        2799.232177734375,
        2805.666748046875,
        2798.183349609375,
        2786.201416015625,
        2791.16845703125,
        2789.474609375,
        2801.025146484375,
        2790.56298828125,
        2785.1337890625,
        2792.135986328125,
        2798.281982421875,
        2810.15576171875,
        2798.349853515625,
        2806.66455078125,
        2798.1337890625,
        2806.44384765625,
        2800.84765625,
        2814.251220703125,
        2796.341064453125,
        2805.812255859375,
        2798.636962890625,
        2802.616455078125,
        2797.336181640625,
        2810.68359375,
        2790.174072265625,
        2806.050537109375,
        2805.140869140625,
        2807.677978515625,
        2791.406494140625,
        2797.030517578125,
        2797.0439453125,
        2816.689208984375,
        2799.509765625,
        2802.6044921875,
        2801.697265625,
        2792.063232421875,
        2818.550048828125,
        2799.348388671875,
        2789.712646484375,
        2800.71142578125,
        2795.442626953125,
        2801.315185546875,
        2798.3232421875,
        2799.77294921875,
        2806.15478515625,
        2799.181640625,
        2792.562255859375,
        2799.707275390625,
        2793.771728515625,
        2787.833740234375,
        2803.315673828125,
        2800.981201171875,
        2801.702880859375,
        2795.747802734375,
        2799.6845703125,
        2808.865966796875,
        2809.541015625,
        2798.43408203125,
        2806.66455078125,
        2802.4267578125,
        2791.353271484375,
        2804.81298828125,
        2794.25244140625,
        2805.043212890625,
        2804.57373046875,
        2800.29345703125,
        2797.423828125,
        2802.921142578125,
        2798.013671875,
        2808.202880859375,
        2810.945068359375,
        2797.73779296875,
        2794.527099609375,
        2815.381103515625,
        2797.030517578125,
        2790.542724609375,
        2796.439697265625,
        2800.690185546875,
        2795.404052734375,
        2793.21875,
        2799.888916015625,
        2794.852294921875,
        2797.389404296875,
        2796.56787109375,
        2801.31787109375,
        2791.85400390625,
        2808.69189453125,
        2798.2939453125,
        2805.76025390625,
        2790.767822265625,
        2806.168212890625,
        2801.487548828125,
        2794.560302734375,
        2797.662841796875,
        2808.884521484375,
        2806.0302734375,
        2797.384033203125,
        2803.41845703125,
        2784.920166015625,
        2796.671875,
        2787.797607421875,
        2789.856689453125,
        2791.684814453125,
        2796.649169921875,
        2799.008056640625,
        2799.77294921875,
        2811.480224609375,
        2788.0078125,
        2790.085205078125,
        2804.33837890625,
        2795.221435546875,
        2799.994384765625,
        2792.57275390625,
        2799.983642578125,
        2793.85546875,
        2799.228271484375,
        2792.65966796875,
        2800.54296875,
        2811.9482421875,
        2806.072021484375,
        2805.729248046875,
        2802.33984375,
        2804.541748046875,
        2808.25244140625,
        2794.313720703125,
        2800.550048828125,
        2802.993408203125,
        2796.223876953125,
        2800.84912109375,
        2809.05859375,
        2801.072021484375,
        2789.48779296875,
        2804.2060546875,
        2799.516357421875,
        2801.3125,
        2803.82763671875,
        2805.934326171875,
        2801.2509765625,
        2790.9423828125,
        2793.001708984375,
        2799.441650390625,
        2799.90625,
        2798.108642578125,
        2800.5458984375,
        2824.033447265625,
        2796.495849609375,
        2797.86572265625,
        2788.519775390625,
        2804.51904296875,
        2788.57568359375,
        2809.552978515625,
        2801.2001953125,
        2802.947998046875,
        2799.0439453125,
        2795.58251953125,
        2790.00146484375,
        2812.75,
        2797.94580078125,
        2811.84228515625,
        2799.487060546875,
        2808.652587890625,
        2797.263916015625,
        2802.46142578125,
        2786.256103515625,
        2816.96044921875,
        2794.677490234375,
        2793.8046875,
        2796.694580078125,
        2799.285400390625,
        2798.342041015625,
        2802.283935546875,
        2799.22021484375,
        2806.35009765625,
        2800.914306640625
      ]
    },
    "liquidationThreshold": 2519.8038627038927
  },
  "server": "Python FastAPI"
}

The response shows riskProbability: 0.0 meaning zero of the 10,000 simulated price paths reached the liquidation price of $2,519.80 within the 1-day horizon. The position is approximately 42.76 standard deviations away from liquidation, indicating negligible short-term risk at 10x leverage given the token's measured volatility of ~4.5%.

2. Evaluating a Short Position

This example shows the same endpoint call structure for evaluating a short position. Replace direction=short in the query parameters to assess downside risk for short positions.

curl -X GET "https://risk.cambrian.network/api/v1/perp-risk-engine?token_address=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&entry_price=2800&leverage=10&direction=short&risk_horizon=1d" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json"

For a short position, the liquidation price will be above the entry price. The sigmasAway and riskProbability fields reflect the probability that the price rises enough to trigger liquidation within the chosen horizon.

x402 Payment Option

This endpoint supports pay-per-use access via the x402 payment protocol (v2) - pay $0.05 USDC per request using blockchain micropayments. No API key required.

Quick Start (TypeScript)

npm install @x402/fetch @x402/evm viem
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { wrapFetchWithPayment } from "@x402/fetch";
import { privateKeyToAccount } from "viem/accounts";

const signer = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`);
const client = new x402Client();
client.register("eip155:*", new ExactEvmScheme(signer));

const fetchWithPayment = wrapFetchWithPayment(fetch, client);
const response = await fetchWithPayment("https://x402.cambrian.network/api/v1/perp-risk-engine?token_address=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&entry_price=2800&leverage=10&direction=long&risk_horizon=1d");
const data = await response.json();

Quick Start (Python)

pip install "x402[httpx]"
import asyncio
import os
from eth_account import Account
from x402 import x402Client
from x402.http.clients import x402HttpxClient
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact.register import register_exact_evm_client

async def main():
    client = x402Client()
    account = Account.from_key(os.getenv("EVM_PRIVATE_KEY"))
    register_exact_evm_client(client, EthAccountSigner(account))

    async with x402HttpxClient(client) as http:
        response = await http.get("https://x402.cambrian.network/api/v1/perp-risk-engine?token_address=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&entry_price=2800&leverage=10&direction=long&risk_horizon=1d")
        print(response.json())

asyncio.run(main())

Payment Flow

  1. Send a normal request to the endpoint without an API key.
  2. Server returns 402 Payment Required with payment details.
  3. The x402 SDK signs a payment authorization with your wallet.
  4. The SDK resubmits the request with the signed payment.
  5. Server verifies payment and returns the API response.

The x402 SDK handles steps 2-5 automatically.

Network: Base (chain ID 8453) | Currency: USDC | Price: $0.05 per request