{
  "openapi": "3.1.0",
  "info": {
    "title": "multi — the cross-platform perp DEX aggregator",
    "version": "0.1.0",
    "summary": "One order, quoted and routed across every major perp DEX.",
    "description": "multi aggregates the major perpetual DEXs (Hyperliquid, Aster, Lighter, Pacifica, Pear, Avantis) behind one order surface: aggregated market data, best-fill routing, pair trades, execution algos, one cross-venue portfolio, and cross-chain funding into venue margin. Public reads need no key; execution uses a scoped multi_sk_ agent key with a server-side risk policy."
  },
  "servers": [
    {
      "url": "https://multi-venym-labs.vercel.app/api"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    },
    {}
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "multi agent key: multi_sk_live_... (or send it as x-multi-key)"
      }
    },
    "schemas": {
      "Envelope": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {},
          "error": {
            "type": "string"
          },
          "timestamp": {
            "type": "integer"
          }
        }
      },
      "PlaceOrder": {
        "type": "object",
        "required": [
          "symbol",
          "side",
          "type",
          "quantity"
        ],
        "properties": {
          "symbol": {
            "type": "string",
            "example": "BTC"
          },
          "side": {
            "type": "string",
            "enum": [
              "BUY",
              "SELL"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "MARKET",
              "LIMIT",
              "STOP_MARKET",
              "STOP_LIMIT"
            ]
          },
          "quantity": {
            "type": "string",
            "example": "0.01"
          },
          "price": {
            "type": "string"
          },
          "triggerPrice": {
            "type": "string"
          },
          "reduceOnly": {
            "type": "boolean"
          },
          "preferredExchange": {
            "type": "string",
            "enum": [
              "hyperliquid",
              "aster",
              "lighter"
            ]
          }
        }
      },
      "BatchOrders": {
        "type": "object",
        "required": [
          "orders"
        ],
        "properties": {
          "orders": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/PlaceOrder"
            },
            "description": "Up to 10 orders, executed sequentially with per-order policy checks; one failure doesn't abort the rest."
          }
        }
      },
      "CreateStrategy": {
        "type": "object",
        "required": [
          "kind",
          "symbol",
          "side",
          "totalQuantity",
          "sliceCount"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "twap",
              "scaled"
            ]
          },
          "symbol": {
            "type": "string",
            "example": "BTC"
          },
          "side": {
            "type": "string",
            "enum": [
              "BUY",
              "SELL"
            ]
          },
          "totalQuantity": {
            "type": "string",
            "example": "0.1"
          },
          "sliceCount": {
            "type": "integer",
            "minimum": 2,
            "maximum": 50
          },
          "intervalMs": {
            "type": "integer",
            "minimum": 5000,
            "maximum": 3600000,
            "description": "TWAP only: ms between timed market slices."
          },
          "priceLow": {
            "type": "string",
            "description": "Scaled only: ladder bottom."
          },
          "priceHigh": {
            "type": "string",
            "description": "Scaled only: ladder top."
          },
          "reduceOnly": {
            "type": "boolean"
          },
          "preferredExchange": {
            "type": "string",
            "enum": [
              "hyperliquid",
              "aster",
              "lighter"
            ]
          }
        }
      },
      "OpenPair": {
        "type": "object",
        "required": [
          "longSymbol",
          "shortSymbol",
          "notionalUsd",
          "leverage"
        ],
        "properties": {
          "longSymbol": {
            "type": "string",
            "example": "ETH"
          },
          "shortSymbol": {
            "type": "string",
            "example": "BTC"
          },
          "notionalUsd": {
            "type": "number",
            "example": 1000
          },
          "leverage": {
            "type": "number",
            "example": 3
          },
          "slippage": {
            "type": "number"
          },
          "venue": {
            "type": "string",
            "enum": [
              "lighter",
              "hyperliquid"
            ]
          }
        }
      },
      "SwapQuote": {
        "type": "object",
        "required": [
          "fromChain",
          "toChain",
          "fromToken",
          "toToken",
          "fromAmount"
        ],
        "properties": {
          "fromChain": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "integer"
              }
            ]
          },
          "toChain": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "integer"
              }
            ]
          },
          "fromToken": {
            "type": "string"
          },
          "toToken": {
            "type": "string"
          },
          "fromAmount": {
            "type": "string",
            "description": "Amount in the smallest unit (wei/lamports)."
          },
          "fromAddress": {
            "type": "string"
          },
          "toAddress": {
            "type": "string"
          }
        }
      }
    }
  },
  "paths": {
    "/token-pairs": {
      "get": {
        "operationId": "getMarkets",
        "summary": "List tradable markets",
        "security": [
          {}
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/aggregated/book": {
      "get": {
        "operationId": "getOrderbook",
        "summary": "Aggregated orderbook",
        "security": [
          {}
        ],
        "parameters": [
          {
            "name": "symbol",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/aggregated/candles": {
      "get": {
        "operationId": "getCandles",
        "summary": "Aggregated OHLCV candles (raw array)",
        "security": [
          {}
        ],
        "parameters": [
          {
            "name": "symbol",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "interval",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/aggregated/routing": {
      "get": {
        "operationId": "getRouting",
        "summary": "Routing recommendation",
        "security": [
          {}
        ],
        "parameters": [
          {
            "name": "symbol",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "side",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "BUY",
                "SELL"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/trades/{symbol}": {
      "get": {
        "operationId": "getTrades",
        "summary": "Recent trades",
        "security": [
          {}
        ],
        "parameters": [
          {
            "name": "symbol",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/positions": {
      "get": {
        "operationId": "getPositions",
        "summary": "Open positions",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/balances": {
      "get": {
        "operationId": "getBalances",
        "summary": "Balances",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/orders": {
      "get": {
        "operationId": "getOrders",
        "summary": "Open orders",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "operationId": "placeOrder",
        "summary": "Place a smart-routed perp order",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlaceOrder"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/orders/{venue}/{orderId}": {
      "delete": {
        "operationId": "cancelOrder",
        "summary": "Cancel an order",
        "parameters": [
          {
            "name": "venue",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/orders/batch": {
      "post": {
        "operationId": "placeBatchOrders",
        "summary": "Place up to 10 orders in one call",
        "description": "Sequential, per-order policy checks. Returns { results[], total, succeeded, failed }.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchOrders"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/portfolio": {
      "get": {
        "operationId": "getPortfolio",
        "summary": "One-call cross-venue portfolio",
        "description": "Normalized positions[] with PnL/funding/liquidation risk, pairPositions[], summary, byVenue[], bySymbol[], errors.",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/positions/open": {
      "post": {
        "operationId": "openPosition",
        "summary": "Open a position",
        "description": "Optional takeProfitPrice / stopLossPrice place reduce-only TP (limit) / SL (stop-market) orders after the entry fills; the response gains bracket { takeProfit?, stopLoss?, errors }.",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/positions/close": {
      "post": {
        "operationId": "closePosition",
        "summary": "Close a position",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/strategies": {
      "post": {
        "operationId": "createStrategy",
        "summary": "Create an execution strategy (TWAP or scaled ladder)",
        "description": "TWAP runs timed market slices server-side; scaled places a ladder of limit orders immediately. Full strategy notional is policy-checked/reserved up-front.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateStrategy"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "get": {
        "operationId": "listStrategies",
        "summary": "List strategies",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/strategies/{id}": {
      "get": {
        "operationId": "getStrategy",
        "summary": "Fetch one strategy",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "delete": {
        "operationId": "cancelStrategy",
        "summary": "Cancel a strategy",
        "description": "Stops future TWAP slices; resting scaled rungs must be canceled via DELETE /agent/orders/{venue}/{orderId}.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/pair/open": {
      "post": {
        "operationId": "openPair",
        "summary": "Open a long/short pair trade",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenPair"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/pair/{id}/close": {
      "post": {
        "operationId": "closePair",
        "summary": "Close a pair position",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/swap/quote": {
      "post": {
        "operationId": "swapQuote",
        "summary": "Quote a cross-chain swap",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SwapQuote"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/swap/prepare": {
      "post": {
        "operationId": "swapPrepare",
        "summary": "Prepare an unsigned swap",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/swap/execute": {
      "post": {
        "operationId": "swapExecute",
        "summary": "Execute a swap headlessly",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/agent/keys": {
      "post": {
        "operationId": "createKey",
        "summary": "Mint an agent key (owner JWT)",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "get": {
        "operationId": "listKeys",
        "summary": "List agent keys (owner JWT)",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  }
}