simulateLooping
InvokeSimulate a looping strategy on Morpho Blue (Base)
Input Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"protocol": {
"type": "string",
"const": "morpho-blue"
},
"chain": {
"type": "string",
"const": "base"
},
"collateral": {
"type": "object",
"properties": {
"symbol": {
"type": "string",
"minLength": 1
},
"decimals": {
"type": "integer",
"minimum": 0,
"maximum": 36
},
"address": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$"
}
},
"required": [
"symbol",
"decimals"
],
"additionalProperties": false
},
"debt": {
"type": "object",
"properties": {
"symbol": {
"type": "string",
"minLength": 1
},
"decimals": {
"type": "integer",
"minimum": 0,
"maximum": 36
},
"address": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$"
}
},
"required": [
"symbol",
"decimals"
],
"additionalProperties": false
},
"start_capital": {
"type": "string",
"minLength": 1
},
"target_ltv": {
"type": "number",
"exclusiveMinimum": 0,
"maximum": 0.99
},
"loops": {
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
},
"price": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "number"
}
},
"swap_model": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "amm_xyk"
},
"fee_bps": {
"type": "number",
"minimum": 0
},
"pool": {
"type": "object",
"properties": {
"base_reserve": {
"type": "number",
"minimum": 0
},
"quote_reserve": {
"type": "number",
"minimum": 0
}
},
"required": [
"base_reserve",
"quote_reserve"
],
"additionalProperties": false
}
},
"required": [
"type",
"fee_bps",
"pool"
],
"additionalProperties": false
},
"oracle": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "chainlink"
},
"lag_seconds": {
"type": "number",
"minimum": 0
}
},
"required": [
"type",
"lag_seconds"
],
"additionalProperties": false
},
"rates": {
"type": "object",
"properties": {
"supply_apr": {
"type": "number"
},
"borrow_apr": {
"type": "number"
}
},
"additionalProperties": false
},
"horizon_days": {
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 365
},
"scenarios": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "price_jump"
},
"asset": {
"type": "string",
"minLength": 1
},
"shock_pct": {
"type": "number"
},
"at_day": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"type",
"asset",
"shock_pct",
"at_day"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "rates_shift"
},
"borrow_apr_delta_bps": {
"type": "number"
}
},
"required": [
"type",
"borrow_apr_delta_bps"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "oracle_lag"
},
"lag_seconds": {
"type": "number",
"minimum": 0
}
},
"required": [
"type",
"lag_seconds"
],
"additionalProperties": false
}
]
}
},
"risk_limits": {
"type": "object",
"properties": {
"min_hf": {
"type": "number"
},
"max_leverage": {
"type": "number"
}
},
"additionalProperties": false
}
},
"required": [
"protocol",
"chain",
"collateral",
"debt",
"start_capital",
"target_ltv",
"loops"
],
"additionalProperties": false
}
Output Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"summary": {
"type": "object",
"properties": {
"loops_done": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"gross_leverage": {
"type": "number"
},
"net_apr": {
"type": "number"
},
"hf_now": {
"type": "number"
},
"liq_price": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "number"
}
},
"slip_cost_usd": {
"type": "number"
}
},
"required": [
"loops_done",
"gross_leverage",
"net_apr",
"hf_now",
"liq_price",
"slip_cost_usd"
],
"additionalProperties": false
},
"time_series": {
"type": "array",
"items": {
"type": "object",
"properties": {
"t": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"collateral": {
"type": "number"
},
"debt": {
"type": "number"
},
"equity": {
"type": "number"
},
"hf": {
"type": "number"
}
},
"required": [
"t",
"collateral",
"debt",
"equity",
"hf"
],
"additionalProperties": false
}
},
"stress": {
"type": "array",
"items": {
"type": "object",
"properties": {
"scenario": {
"type": "string",
"minLength": 1
},
"min_hf": {
"type": "number"
},
"liquidated": {
"type": "boolean"
},
"liq_loss_usd": {
"type": "number"
}
},
"required": [
"scenario",
"min_hf",
"liquidated"
],
"additionalProperties": false
}
},
"action_plan": {
"type": "array",
"items": {
"type": "object",
"properties": {
"borrow": {
"type": "object",
"properties": {
"asset": {
"type": "string",
"minLength": 1
},
"amount": {
"type": "number"
}
},
"required": [
"asset",
"amount"
],
"additionalProperties": false
},
"swap": {
"type": "object",
"properties": {
"from": {
"type": "string",
"minLength": 1
},
"to": {
"type": "string",
"minLength": 1
},
"amount_in": {
"type": "number"
},
"amount_out": {
"type": "number"
},
"route": {}
},
"required": [
"from",
"to",
"amount_in",
"amount_out"
],
"additionalProperties": false
},
"supply": {
"type": "object",
"properties": {
"asset": {
"type": "string",
"minLength": 1
},
"amount": {
"type": "number"
}
},
"required": [
"asset",
"amount"
],
"additionalProperties": false
}
},
"additionalProperties": false
}
},
"protocol_params_used": {
"type": "object",
"properties": {
"lltv": {
"type": "number"
},
"liquidation_incentive": {
"type": "number"
},
"close_factor": {
"type": "number"
},
"irm": {
"type": "string",
"minLength": 1
},
"oracle_type": {
"type": "string",
"minLength": 1
},
"version": {
"type": "string"
},
"oracle_address": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$"
},
"irm_address": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$"
},
"market_id": {
"type": "string"
},
"data_source": {
"type": "string",
"enum": [
"fixture",
"live"
]
},
"fetched_at": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"lltv",
"liquidation_incentive",
"close_factor",
"irm",
"oracle_type"
],
"additionalProperties": false
},
"receipt": {
"type": "object",
"properties": {
"payment": {},
"provenance_hash": {
"type": "string",
"minLength": 1
}
},
"required": [
"payment",
"provenance_hash"
],
"additionalProperties": false
},
"canExecute": {
"type": "boolean"
},
"reason": {
"type": "string"
}
},
"required": [
"summary",
"time_series",
"stress",
"action_plan",
"protocol_params_used",
"receipt"
],
"additionalProperties": false
}
Invoke with curl
curl -s -X POST \
'https://strategy-sim.vercel.app/entrypoints/simulateLooping/invoke' \
-H 'Content-Type: application/json' \
-d '
{
"input": {
"protocol": "morpho-blue",
"chain": "base",
"collateral": {
"symbol": "string",
"decimals": 0
},
"debt": {
"symbol": "string",
"decimals": 0
},
"start_capital": "string",
"target_ltv": 0.99,
"loops": 9007199254740991
}
}
'