{
  "openapi": "3.1.0",
  "info": {
    "title": "Perp2AI agent API",
    "version": "1.0.0",
    "description": "Perpetual markets on AI agents' x402 revenue. Read any agent's income history, market data and ENS records, find market makers, and register a permissionless <label>.perp2ai.eth name by signing one EIP-712 message. Amounts are decimal strings. No API key; CORS is open.\n\nExample for a funded wallet A on research.perp2ai.eth. Replace A with your address. Deposit once. One balance backs every market. Amounts and prices are USDC base units (1000000 = $1). Size is WAD (1000000000000000000 = one day of the agent's revenue).\n\n1. POST /api/v1/tx/deposit {\"amount\":\"100000000\",\"from\":\"A\"}. Sign and broadcast each item in transactions in order, waiting for a successful receipt each time. Approval is included when needed.\n2. POST /api/v1/orders/quote {\"market\":\"research.perp2ai.eth\",\"side\":\"long\",\"usd\":\"10000000\",\"taker\":\"A\"}. Alternatively supply a positive size instead of usd. The service pays the makers and simulates the trade from A. A rejected trade returns HTTP 409 with a reason. Inspect quote and signature, then sign and send transaction. A short uses side \"short\".\n3. GET /api/v1/accounts/A. Read collateral, equity, initialMargin, maintenanceMargin, available and withdrawable for the whole account. Find the position in markets for its signed size, entry, mark, unrealizedPnl, signed fundingAccrued, requirements and trigger. leverageWad is position notional divided by account equity scaled by 1e18. estimatedLiquidationPrice is an estimate in margin-price units where account equity reaches maintenance with other positions unchanged, or null if there is no positive threshold.\n4. POST /api/v1/tx/tpsl {\"market\":\"research.perp2ai.eth\",\"takeProfit\":\"1100000000\",\"stopLoss\":\"900000000\",\"from\":\"A\"} for a long with a current mark of 1000000000. Adjust for the actual mark. Sign and send transaction. Use \"0\" to disable either leg. A keeper checks the mark and closes the full position at a signed quote price, which may differ from the trigger.\n5. GET /api/v1/markets/research.perp2ai.eth/funding. rateWad is the signed hourly fraction of the index scaled by 1e18. nextFundingTime uses Unix seconds. history contains up to 24 accruals within the last 8192 blocks, with the UTC epoch hour, signed premium and historical rateWad.\n6. POST /api/v1/orders/close {\"market\":\"research.perp2ai.eth\",\"taker\":\"A\"}. Sign and send transaction. Close and reduceOnly quotes use the observed position. If another fill or keeper changes it before broadcast, request a fresh quote.\n7. GET /api/v1/accounts/A again. POST /api/v1/tx/withdraw {\"amount\":\"99800000\"}, replacing the example amount with the amount you want, up to withdrawable. Sign and send transaction, then check walletUsdc and the markets list.\n\nEach transaction contains to, data, value (\"0\"), chainId and rpcUrl. Verify the network, destination and calldata with your wallet before signing. The API never needs your signing key."
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "paths": {
    "/api/v1/markets": {
      "get": {
        "summary": "All listed markets",
        "operationId": "listMarkets",
        "responses": {
          "200": {
            "description": "Markets with index, mark, funding and open interest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Markets"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/markets/{name}": {
      "get": {
        "summary": "One market with index and mark series, recent trades, makers and ENS records",
        "operationId": "getMarket",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "research.perp2ai.eth"
            },
            "description": "ENS name of the agent"
          }
        ],
        "responses": {
          "200": {
            "description": "Market detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/markets/{name}/history": {
      "get": {
        "summary": "Index reports, hourly funding and every trade",
        "operationId": "getMarketHistory",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "research.perp2ai.eth"
            },
            "description": "ENS name of the agent"
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "unix seconds"
          }
        ],
        "responses": {
          "200": {
            "description": "History",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/accounts/{address}": {
      "get": {
        "summary": "Wallet USDC, cross-margin balance, requirements and open positions",
        "operationId": "account",
        "parameters": [
          {
            "name": "address",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{40}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Account at one block",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "address": {
                      "type": "string",
                      "pattern": "^0x[0-9a-fA-F]{40}$"
                    },
                    "blockNumber": {
                      "type": "string",
                      "pattern": "^-?[0-9]+$"
                    },
                    "walletUsdc": {
                      "type": "string",
                      "description": "USDC in base units (6 decimals), as a decimal string"
                    },
                    "allowance": {
                      "type": "string",
                      "description": "USDC in base units (6 decimals), as a decimal string"
                    },
                    "collateral": {
                      "type": "string",
                      "description": "USDC in base units (6 decimals), as a decimal string"
                    },
                    "equity": {
                      "type": "string",
                      "description": "USDC in base units (6 decimals), as a decimal string"
                    },
                    "initialMargin": {
                      "type": "string",
                      "description": "USDC in base units (6 decimals), as a decimal string"
                    },
                    "maintenanceMargin": {
                      "type": "string",
                      "description": "USDC in base units (6 decimals), as a decimal string"
                    },
                    "available": {
                      "type": "string",
                      "description": "USDC in base units (6 decimals), as a decimal string"
                    },
                    "withdrawable": {
                      "type": "string",
                      "description": "USDC in base units (6 decimals), as a decimal string"
                    },
                    "markets": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "market": {
                            "type": "string",
                            "example": "research.perp2ai.eth"
                          },
                          "side": {
                            "enum": [
                              "long",
                              "short"
                            ]
                          },
                          "size": {
                            "type": "string",
                            "pattern": "^-?[0-9]+$"
                          },
                          "notional": {
                            "type": "string",
                            "description": "USDC in base units (6 decimals), as a decimal string"
                          },
                          "entry": {
                            "type": "string",
                            "description": "USDC in base units (6 decimals), as a decimal string"
                          },
                          "mark": {
                            "type": "string",
                            "description": "USDC in base units (6 decimals), as a decimal string"
                          },
                          "index": {
                            "type": "string",
                            "description": "USDC in base units (6 decimals), as a decimal string"
                          },
                          "unrealizedPnl": {
                            "type": "string",
                            "description": "USDC in base units (6 decimals), as a decimal string"
                          },
                          "initialMargin": {
                            "type": "string",
                            "description": "USDC in base units (6 decimals), as a decimal string"
                          },
                          "maintenanceMargin": {
                            "type": "string",
                            "description": "USDC in base units (6 decimals), as a decimal string"
                          },
                          "estimatedLiquidationPrice": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "leverageWad": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "liquidatable": {
                            "type": "boolean"
                          },
                          "fundingAccrued": {
                            "type": "string",
                            "description": "USDC in base units (6 decimals), as a decimal string"
                          },
                          "trigger": {
                            "type": "object",
                            "properties": {
                              "takeProfit": {
                                "type": "string",
                                "description": "USDC in base units (6 decimals), as a decimal string"
                              },
                              "stopLoss": {
                                "type": "string",
                                "description": "USDC in base units (6 decimals), as a decimal string"
                              }
                            },
                            "required": [
                              "takeProfit",
                              "stopLoss"
                            ]
                          }
                        },
                        "required": [
                          "market",
                          "side",
                          "size",
                          "notional",
                          "entry",
                          "mark",
                          "index",
                          "unrealizedPnl",
                          "initialMargin",
                          "maintenanceMargin",
                          "estimatedLiquidationPrice",
                          "leverageWad",
                          "liquidatable",
                          "fundingAccrued",
                          "trigger"
                        ]
                      }
                    }
                  },
                  "required": [
                    "address",
                    "blockNumber",
                    "walletUsdc",
                    "allowance",
                    "collateral",
                    "equity",
                    "initialMargin",
                    "maintenanceMargin",
                    "available",
                    "withdrawable",
                    "markets"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/markets/{name}/funding": {
      "get": {
        "summary": "Current hourly funding and recent accruals",
        "operationId": "funding",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "research.perp2ai.eth"
            },
            "description": "ENS name of the agent"
          }
        ],
        "responses": {
          "200": {
            "description": "Hourly rates in WAD, next funding in Unix seconds",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "market": {
                      "type": "string",
                      "example": "research.perp2ai.eth"
                    },
                    "rateWad": {
                      "type": "string",
                      "pattern": "^-?[0-9]+$"
                    },
                    "whoPays": {
                      "enum": [
                        "longs pay shorts",
                        "shorts pay longs",
                        "none"
                      ]
                    },
                    "nextFundingTime": {
                      "type": "string",
                      "pattern": "^-?[0-9]+$"
                    },
                    "history": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "hour": {
                            "type": "string",
                            "pattern": "^-?[0-9]+$"
                          },
                          "premium": {
                            "type": "string",
                            "description": "USDC in base units (6 decimals), as a decimal string"
                          },
                          "rateWad": {
                            "type": "string",
                            "pattern": "^-?[0-9]+$"
                          }
                        },
                        "required": [
                          "hour",
                          "premium",
                          "rateWad"
                        ]
                      }
                    }
                  },
                  "required": [
                    "market",
                    "rateWad",
                    "whoPays",
                    "nextFundingTime",
                    "history"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/markets/{name}/decisions": {
      "get": {
        "summary": "The AI trader's decision rounds for this market from its HCS topic: view, limits applied, fills, and trades waiting for approval",
        "operationId": "decisions",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "research.perp2ai.eth"
            },
            "description": "ENS name of the agent"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Decision rounds, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/approvals": {
      "get": {
        "summary": "Signed approvals waiting for a trader to pick up",
        "operationId": "listApprovals",
        "parameters": [
          {
            "name": "trader",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Approvals",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "approveTrade",
        "summary": "Hand in the approver's EIP-712 ApproveTrade signature for a trade the AI trader is holding",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "trader": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  },
                  "id": {
                    "type": "string"
                  },
                  "signature": {
                    "type": "string"
                  }
                },
                "required": [
                  "trader",
                  "id",
                  "signature"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Hand in the approver's EIP-712 ApproveTrade signature for a trade the AI trader is holding",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accepted": {
                      "type": "boolean"
                    },
                    "id": {
                      "type": "string"
                    },
                    "market": {
                      "type": "string",
                      "example": "research.perp2ai.eth"
                    },
                    "deltaUsd": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "accepted",
                    "id",
                    "market",
                    "deltaUsd"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/markets/{name}/positions": {
      "get": {
        "summary": "Open interest split into longs and shorts, and every open position",
        "operationId": "positions",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "research.perp2ai.eth"
            },
            "description": "ENS name of the agent"
          }
        ],
        "responses": {
          "200": {
            "description": "USDC amounts in 6 decimals at the current mark; sizes in WAD units of the index",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "market": {
                      "type": "string",
                      "example": "research.perp2ai.eth"
                    },
                    "mark": {
                      "type": "string",
                      "description": "USDC in base units (6 decimals), as a decimal string"
                    },
                    "index": {
                      "type": "string",
                      "description": "USDC in base units (6 decimals), as a decimal string"
                    },
                    "openInterest": {
                      "type": "object",
                      "properties": {
                        "size": {
                          "type": "string",
                          "pattern": "^-?[0-9]+$"
                        },
                        "notional": {
                          "type": "string",
                          "description": "USDC in base units (6 decimals), as a decimal string"
                        },
                        "cap": {
                          "type": "string",
                          "description": "USDC in base units (6 decimals), as a decimal string"
                        },
                        "used": {
                          "type": "number",
                          "description": "share of the cap in use, 0 to 1"
                        },
                        "long": {
                          "type": "object",
                          "properties": {
                            "positions": {
                              "type": "string",
                              "pattern": "^-?[0-9]+$"
                            },
                            "notional": {
                              "type": "string",
                              "description": "USDC in base units (6 decimals), as a decimal string"
                            }
                          },
                          "required": [
                            "positions",
                            "notional"
                          ]
                        },
                        "short": {
                          "type": "object",
                          "properties": {
                            "positions": {
                              "type": "string",
                              "pattern": "^-?[0-9]+$"
                            },
                            "notional": {
                              "type": "string",
                              "description": "USDC in base units (6 decimals), as a decimal string"
                            }
                          },
                          "required": [
                            "positions",
                            "notional"
                          ]
                        }
                      },
                      "required": [
                        "size",
                        "notional",
                        "cap",
                        "used",
                        "long",
                        "short"
                      ]
                    },
                    "positions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "address": {
                            "type": "string",
                            "pattern": "^0x[0-9a-fA-F]{40}$"
                          },
                          "name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "side": {
                            "enum": [
                              "long",
                              "short"
                            ]
                          },
                          "size": {
                            "type": "string",
                            "pattern": "^-?[0-9]+$"
                          },
                          "notional": {
                            "type": "string",
                            "description": "USDC in base units (6 decimals), as a decimal string"
                          },
                          "entry": {
                            "type": "string",
                            "description": "USDC in base units (6 decimals), as a decimal string"
                          },
                          "unrealizedPnl": {
                            "type": "string",
                            "description": "USDC in base units (6 decimals), as a decimal string"
                          }
                        },
                        "required": [
                          "address",
                          "name",
                          "side",
                          "size",
                          "notional",
                          "entry",
                          "unrealizedPnl"
                        ]
                      }
                    }
                  },
                  "required": [
                    "market",
                    "mark",
                    "index",
                    "openInterest",
                    "positions"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/orders/quote": {
      "post": {
        "operationId": "quote",
        "summary": "Buy signed quotes and simulate the best trade. A rejected trade returns HTTP 409.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "market",
                  "side",
                  "taker"
                ],
                "oneOf": [
                  {
                    "required": [
                      "size"
                    ]
                  },
                  {
                    "required": [
                      "usd"
                    ]
                  }
                ],
                "properties": {
                  "market": {
                    "type": "string",
                    "example": "research.perp2ai.eth"
                  },
                  "side": {
                    "enum": [
                      "long",
                      "short"
                    ]
                  },
                  "size": {
                    "type": "string",
                    "pattern": "^-?[0-9]+$"
                  },
                  "usd": {
                    "type": "string",
                    "description": "USDC in base units (6 decimals), as a decimal string"
                  },
                  "taker": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  },
                  "reduceOnly": {
                    "type": "boolean",
                    "description": "Check at quote time that this size only reduces the current position."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Buy signed quotes and simulate the best trade. A rejected trade returns HTTP 409.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quote": {
                      "type": "object",
                      "properties": {
                        "market": {
                          "type": "string"
                        },
                        "maker": {
                          "type": "string",
                          "pattern": "^0x[0-9a-fA-F]{40}$"
                        },
                        "taker": {
                          "type": "string",
                          "pattern": "^0x[0-9a-fA-F]{40}$"
                        },
                        "size": {
                          "type": "string",
                          "pattern": "^-?[0-9]+$"
                        },
                        "price": {
                          "type": "string",
                          "description": "USDC in base units (6 decimals), as a decimal string"
                        },
                        "expiry": {
                          "type": "string",
                          "pattern": "^-?[0-9]+$"
                        },
                        "nonce": {
                          "type": "string",
                          "pattern": "^-?[0-9]+$"
                        }
                      },
                      "required": [
                        "market",
                        "maker",
                        "taker",
                        "size",
                        "price",
                        "expiry",
                        "nonce"
                      ]
                    },
                    "signature": {
                      "type": "string"
                    },
                    "transaction": {
                      "type": "object",
                      "properties": {
                        "to": {
                          "type": "string",
                          "pattern": "^0x[0-9a-fA-F]{40}$"
                        },
                        "data": {
                          "type": "string"
                        },
                        "value": {
                          "const": "0"
                        },
                        "chainId": {
                          "type": "integer"
                        },
                        "rpcUrl": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "to",
                        "data",
                        "value",
                        "chainId",
                        "rpcUrl"
                      ]
                    },
                    "failures": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "quotes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "quote": {
                            "type": "object",
                            "properties": {
                              "market": {
                                "type": "string"
                              },
                              "maker": {
                                "type": "string",
                                "pattern": "^0x[0-9a-fA-F]{40}$"
                              },
                              "taker": {
                                "type": "string",
                                "pattern": "^0x[0-9a-fA-F]{40}$"
                              },
                              "size": {
                                "type": "string",
                                "pattern": "^-?[0-9]+$"
                              },
                              "price": {
                                "type": "string",
                                "description": "USDC in base units (6 decimals), as a decimal string"
                              },
                              "expiry": {
                                "type": "string",
                                "pattern": "^-?[0-9]+$"
                              },
                              "nonce": {
                                "type": "string",
                                "pattern": "^-?[0-9]+$"
                              }
                            },
                            "required": [
                              "market",
                              "maker",
                              "taker",
                              "size",
                              "price",
                              "expiry",
                              "nonce"
                            ]
                          },
                          "signature": {
                            "type": "string"
                          },
                          "fee": {
                            "type": "string",
                            "description": "USDC in base units (6 decimals), as a decimal string"
                          },
                          "maker": {
                            "type": "object"
                          }
                        }
                      }
                    }
                  },
                  "required": [
                    "quote",
                    "signature",
                    "transaction",
                    "failures",
                    "quotes"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/orders/close": {
      "post": {
        "operationId": "close",
        "summary": "Quote the full opposite of the current position",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "market": {
                    "type": "string",
                    "example": "research.perp2ai.eth"
                  },
                  "taker": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  }
                },
                "required": [
                  "market",
                  "taker"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Quote the full opposite of the current position",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "quote": {
                      "type": "object",
                      "properties": {
                        "market": {
                          "type": "string"
                        },
                        "maker": {
                          "type": "string",
                          "pattern": "^0x[0-9a-fA-F]{40}$"
                        },
                        "taker": {
                          "type": "string",
                          "pattern": "^0x[0-9a-fA-F]{40}$"
                        },
                        "size": {
                          "type": "string",
                          "pattern": "^-?[0-9]+$"
                        },
                        "price": {
                          "type": "string",
                          "description": "USDC in base units (6 decimals), as a decimal string"
                        },
                        "expiry": {
                          "type": "string",
                          "pattern": "^-?[0-9]+$"
                        },
                        "nonce": {
                          "type": "string",
                          "pattern": "^-?[0-9]+$"
                        }
                      },
                      "required": [
                        "market",
                        "maker",
                        "taker",
                        "size",
                        "price",
                        "expiry",
                        "nonce"
                      ]
                    },
                    "signature": {
                      "type": "string"
                    },
                    "transaction": {
                      "type": "object",
                      "properties": {
                        "to": {
                          "type": "string",
                          "pattern": "^0x[0-9a-fA-F]{40}$"
                        },
                        "data": {
                          "type": "string"
                        },
                        "value": {
                          "const": "0"
                        },
                        "chainId": {
                          "type": "integer"
                        },
                        "rpcUrl": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "to",
                        "data",
                        "value",
                        "chainId",
                        "rpcUrl"
                      ]
                    },
                    "failures": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "quotes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "quote": {
                            "type": "object",
                            "properties": {
                              "market": {
                                "type": "string"
                              },
                              "maker": {
                                "type": "string",
                                "pattern": "^0x[0-9a-fA-F]{40}$"
                              },
                              "taker": {
                                "type": "string",
                                "pattern": "^0x[0-9a-fA-F]{40}$"
                              },
                              "size": {
                                "type": "string",
                                "pattern": "^-?[0-9]+$"
                              },
                              "price": {
                                "type": "string",
                                "description": "USDC in base units (6 decimals), as a decimal string"
                              },
                              "expiry": {
                                "type": "string",
                                "pattern": "^-?[0-9]+$"
                              },
                              "nonce": {
                                "type": "string",
                                "pattern": "^-?[0-9]+$"
                              }
                            },
                            "required": [
                              "market",
                              "maker",
                              "taker",
                              "size",
                              "price",
                              "expiry",
                              "nonce"
                            ]
                          },
                          "signature": {
                            "type": "string"
                          },
                          "fee": {
                            "type": "string",
                            "description": "USDC in base units (6 decimals), as a decimal string"
                          },
                          "maker": {
                            "type": "object"
                          }
                        }
                      }
                    }
                  },
                  "required": [
                    "quote",
                    "signature",
                    "transaction",
                    "failures",
                    "quotes"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tx/deposit": {
      "post": {
        "operationId": "deposit",
        "summary": "Build approval if needed, then deposit USDC for every market",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "amount": {
                    "type": "string",
                    "description": "USDC in base units (6 decimals), as a decimal string"
                  },
                  "from": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  }
                },
                "required": [
                  "amount",
                  "from"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Build approval if needed, then deposit USDC for every market",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transactions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "to": {
                            "type": "string",
                            "pattern": "^0x[0-9a-fA-F]{40}$"
                          },
                          "data": {
                            "type": "string"
                          },
                          "value": {
                            "const": "0"
                          },
                          "chainId": {
                            "type": "integer"
                          },
                          "rpcUrl": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "to",
                          "data",
                          "value",
                          "chainId",
                          "rpcUrl"
                        ]
                      }
                    }
                  },
                  "required": [
                    "transactions"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tx/withdraw": {
      "post": {
        "operationId": "withdraw",
        "summary": "Build a withdrawal",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "amount": {
                    "type": "string",
                    "description": "USDC in base units (6 decimals), as a decimal string"
                  }
                },
                "required": [
                  "amount"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Build a withdrawal",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transaction": {
                      "type": "object",
                      "properties": {
                        "to": {
                          "type": "string",
                          "pattern": "^0x[0-9a-fA-F]{40}$"
                        },
                        "data": {
                          "type": "string"
                        },
                        "value": {
                          "const": "0"
                        },
                        "chainId": {
                          "type": "integer"
                        },
                        "rpcUrl": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "to",
                        "data",
                        "value",
                        "chainId",
                        "rpcUrl"
                      ]
                    }
                  },
                  "required": [
                    "transaction"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tx/tpsl": {
      "post": {
        "operationId": "tpsl",
        "summary": "Set or clear mark-price triggers",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "market": {
                    "type": "string",
                    "example": "research.perp2ai.eth"
                  },
                  "takeProfit": {
                    "type": "string",
                    "description": "USDC in base units (6 decimals), as a decimal string"
                  },
                  "stopLoss": {
                    "type": "string",
                    "description": "USDC in base units (6 decimals), as a decimal string"
                  },
                  "from": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  }
                },
                "required": [
                  "market",
                  "takeProfit",
                  "stopLoss",
                  "from"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Set or clear mark-price triggers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transaction": {
                      "type": "object",
                      "properties": {
                        "to": {
                          "type": "string",
                          "pattern": "^0x[0-9a-fA-F]{40}$"
                        },
                        "data": {
                          "type": "string"
                        },
                        "value": {
                          "const": "0"
                        },
                        "chainId": {
                          "type": "integer"
                        },
                        "rpcUrl": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "to",
                        "data",
                        "value",
                        "chainId",
                        "rpcUrl"
                      ]
                    }
                  },
                  "required": [
                    "transaction"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/makers": {
      "get": {
        "summary": "Market makers, their x402 quote endpoints and whether their ENS address matches their signer",
        "operationId": "listMakers",
        "responses": {
          "200": {
            "description": "Makers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents": {
      "get": {
        "summary": "Every agent name issued by the registrar, newest first",
        "operationId": "listAgents",
        "responses": {
          "200": {
            "description": "Agents",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents/{name}": {
      "get": {
        "summary": "ENS records (ENSIP-26 agent-context and endpoints), ENSv2 details (own resolver, ENSIP-31 payment preference, ENSIP-28 accounts), earnings against AI costs, ERC-8004 identity, market and listing eligibility",
        "operationId": "getAgent",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "research.perp2ai.eth"
            },
            "description": "ENS name of the agent"
          }
        ],
        "responses": {
          "200": {
            "description": "Agent profile",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents/{name}/registration.json": {
      "get": {
        "summary": "ERC-8004 registration file (the agentURI): name, description, services and on-chain registrations",
        "operationId": "getRegistration",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "research.perp2ai.eth"
            },
            "description": "ENS name of the agent"
          }
        ],
        "responses": {
          "200": {
            "description": "ERC-8004 registration-v1 document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents/{name}/erc8004": {
      "post": {
        "operationId": "registerIdentity",
        "summary": "Build the ERC-8004 register transaction for the agent to send on Hedera",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "from": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  }
                },
                "required": [
                  "from"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Build the ERC-8004 register transaction for the agent to send on Hedera",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agentURI": {
                      "type": "string"
                    },
                    "transaction": {
                      "type": "object",
                      "properties": {
                        "to": {
                          "type": "string",
                          "pattern": "^0x[0-9a-fA-F]{40}$"
                        },
                        "data": {
                          "type": "string"
                        },
                        "value": {
                          "const": "0"
                        },
                        "chainId": {
                          "type": "integer"
                        },
                        "rpcUrl": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "to",
                        "data",
                        "value",
                        "chainId",
                        "rpcUrl"
                      ]
                    },
                    "next": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "agentURI",
                    "transaction",
                    "next"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents/{name}/reports/{sequence}": {
      "get": {
        "summary": "A signed indexer report from the Hedera Consensus Service topic; the feedbackURI of reputation entries",
        "operationId": "getReport",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "research.perp2ai.eth"
            },
            "description": "ENS name of the agent"
          },
          {
            "name": "sequence",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Signed report message",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/names/records/prepare": {
      "post": {
        "operationId": "prepareRecords",
        "summary": "Typed data to update records on a name you own. Pass registrationTx (or agentId) to write the ENSIP-25 link to your ERC-8004 identity, or texts",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string"
                  },
                  "owner": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  },
                  "registrationTx": {
                    "type": "string"
                  },
                  "agentId": {
                    "type": "string",
                    "pattern": "^-?[0-9]+$"
                  },
                  "texts": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  }
                },
                "required": [
                  "label",
                  "owner"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Typed data to update records on a name you own. Pass registrationTx (or agentId) to write the ENSIP-25 link to your ERC-8004 identity, or texts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "typedData": {
                      "type": "object"
                    },
                    "next": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "typedData",
                    "next"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/names/records": {
      "post": {
        "operationId": "updateRecords",
        "summary": "Submit the signed record update; the relayer pays the gas",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string"
                  },
                  "owner": {
                    "type": "string",
                    "pattern": "^0x[0-9a-fA-F]{40}$"
                  },
                  "registrationTx": {
                    "type": "string"
                  },
                  "agentId": {
                    "type": "string",
                    "pattern": "^-?[0-9]+$"
                  },
                  "texts": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "deadline": {
                    "type": "string",
                    "pattern": "^-?[0-9]+$"
                  },
                  "signature": {
                    "type": "string"
                  }
                },
                "required": [
                  "label",
                  "owner",
                  "deadline",
                  "signature"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Submit the signed record update; the relayer pays the gas",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "node": {
                      "type": "string"
                    },
                    "tx": {
                      "type": "string"
                    },
                    "chainId": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "node",
                    "tx",
                    "chainId"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents/{name}/revenue": {
      "get": {
        "summary": "The agent's income history from public payment records",
        "description": "Gross USDC received at the ENS payment address, bucketed. `index` is what the market settles on: outside revenue only, each payer capped at 10%.",
        "operationId": "getAgentRevenue",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "research.perp2ai.eth"
            },
            "description": "ENS name of the agent"
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 14,
              "maximum": 90
            }
          },
          {
            "name": "interval",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "hour",
                "day"
              ],
              "default": "day"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Revenue series",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Revenue"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents/{name}/payments": {
      "get": {
        "summary": "Individual payments into the agent, newest first",
        "operationId": "getAgentPayments",
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "research.perp2ai.eth"
            },
            "description": "ENS name of the agent"
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 7
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50,
              "maximum": 500
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payments",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/names/{label}": {
      "get": {
        "summary": "Whether <label>.perp2ai.eth is valid and free",
        "operationId": "getName",
        "parameters": [
          {
            "name": "label",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "my-agent"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Name status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/names/prepare": {
      "post": {
        "summary": "Build the EIP-712 registration request for the owner to sign",
        "operationId": "prepareName",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NameRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Typed data to sign with eth_signTypedData_v4",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/names": {
      "post": {
        "summary": "Register a signed name. The relayer pays gas; the signer owns the name.",
        "operationId": "registerName",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/NameRequest"
                  },
                  {
                    "type": "object",
                    "required": [
                      "addr",
                      "deadline",
                      "signature"
                    ],
                    "properties": {
                      "deadline": {
                        "type": "string"
                      },
                      "signature": {
                        "type": "string",
                        "pattern": "^0x[0-9a-fA-F]+$"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Registered: name, node and transaction",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },
      "NameRequest": {
        "type": "object",
        "required": [
          "label",
          "owner"
        ],
        "properties": {
          "label": {
            "type": "string",
            "pattern": "^[a-z0-9-]{3,63}$",
            "example": "my-agent"
          },
          "owner": {
            "type": "string",
            "description": "address that signs and will own the name"
          },
          "addr": {
            "type": "string",
            "description": "payment address (ETH and the ENSIP-11 coin type of the payment chain); defaults to owner"
          },
          "texts": {
            "type": "array",
            "maxItems": 12,
            "items": {
              "type": "object",
              "required": [
                "key",
                "value"
              ],
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            },
            "example": [
              {
                "key": "perp2ai.service",
                "value": "https://my-agent.example/v1/run"
              },
              {
                "key": "description",
                "value": "Summaries of any text"
              }
            ]
          }
        }
      },
      "Markets": {
        "type": "object",
        "properties": {
          "demo": {
            "type": "boolean"
          },
          "chainId": {
            "type": "integer"
          },
          "now": {
            "type": "integer"
          },
          "stats": {
            "type": "object",
            "properties": {
              "markets": {
                "type": "integer"
              },
              "indexRevenue": {
                "type": "string",
                "description": "USDC in base units (6 decimals), as a decimal string"
              },
              "openInterest": {
                "type": "string",
                "description": "USDC in base units (6 decimals), as a decimal string"
              }
            }
          },
          "markets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "index": {
                  "type": "string",
                  "description": "USDC in base units (6 decimals), as a decimal string"
                },
                "mark": {
                  "type": "string",
                  "description": "USDC in base units (6 decimals), as a decimal string"
                },
                "premium": {
                  "type": "number"
                },
                "fundingRate": {
                  "type": "number",
                  "description": "this hour, as a fraction of the index"
                },
                "oiNotional": {
                  "type": "string",
                  "description": "USDC in base units (6 decimals), as a decimal string"
                },
                "oiCap": {
                  "type": "string",
                  "description": "open-interest cap per side, USDC notional"
                },
                "oiUsed": {
                  "type": "number",
                  "description": "share of the open-interest cap in use"
                },
                "maxLeverage": {
                  "type": "number"
                },
                "payers": {
                  "type": "integer"
                }
              }
            }
          }
        }
      },
      "Revenue": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "paymentAddress": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "hedera-mirror-node",
              "usdc-transfer-logs"
            ]
          },
          "totals": {
            "type": "object",
            "properties": {
              "revenue": {
                "type": "string",
                "description": "USDC in base units (6 decimals), as a decimal string"
              },
              "payments": {
                "type": "integer"
              },
              "payers": {
                "type": "integer"
              },
              "trailing": {
                "type": "string",
                "description": "USDC in base units (6 decimals), as a decimal string"
              },
              "windowHours": {
                "type": "integer"
              }
            }
          },
          "index": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "revenue": {
                "type": "string",
                "description": "USDC in base units (6 decimals), as a decimal string"
              },
              "payers": {
                "type": "integer"
              },
              "updatedAt": {
                "type": "integer"
              }
            }
          },
          "series": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "t": {
                  "type": "integer"
                },
                "revenue": {
                  "type": "string",
                  "description": "USDC in base units (6 decimals), as a decimal string"
                },
                "payments": {
                  "type": "integer"
                },
                "payers": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    }
  }
}