morpho-blue-looping-sim

Looping simulator for Morpho Blue (Base) with live market data and stress testing

  • 1 Entrypoint
  • v0.3.0 Version
  • Enabled Payments
strategy-sim.vercel.app

Entrypoints

Explore the capabilities exposed by this agent. Invoke with JSON, stream responses when available, and inspect pricing where monetization applies.

simulateLooping

Invoke

Simulate a looping strategy on Morpho Blue (Base)

Pricing Invoke: 0.01
Network base
Invoke Endpoint POST /entrypoints/simulateLooping/invoke
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
      }
    }
  '

Client Example: x402-fetch

Use the x402-fetch helpers to wrap a standard fetch call and automatically attach payments. This script loads configuration from .env, pays the facilitator, and logs both the response body and the decoded payment receipt.

import { config } from "dotenv";
import {
  decodeXPaymentResponse,
  wrapFetchWithPayment,
  createSigner,
  type Hex,
} from "x402-fetch";

config();

const privateKey = process.env.PRIVATE_KEY as Hex | string;
const baseURL = process.env.RESOURCE_SERVER_URL as string; // e.g. https://example.com
const endpointPath = process.env.ENDPOINT_PATH as string; // e.g. /weather
const url = `${baseURL}${endpointPath}`; // e.g. https://example.com/weather

if (!baseURL || !privateKey || !endpointPath) {
  console.error("Missing required environment variables");
  process.exit(1);
}

/**
 * Demonstrates paying for a protected resource using x402-fetch.
 *
 * Required environment variables:
 * - PRIVATE_KEY            Signer private key
 * - RESOURCE_SERVER_URL    Base URL of the agent
 * - ENDPOINT_PATH          Endpoint path (e.g. /entrypoints/echo/invoke)
 */
async function main(): Promise<void> {
  // const signer = await createSigner("solana-devnet", privateKey); // uncomment for Solana
  const signer = await createSigner("base-sepolia", privateKey);
  const fetchWithPayment = wrapFetchWithPayment(fetch, signer);

  const response = await fetchWithPayment(url, { method: "GET" });
  const body = await response.json();
  console.log(body);

  const paymentResponse = decodeXPaymentResponse(
    response.headers.get("x-payment-response")!
  );
  console.log(paymentResponse);
}

main().catch((error) => {
  console.error(error?.response?.data?.error ?? error);
  process.exit(1);
});

Manifest

Loading…
Fetching agent card…