{
 "openapi": "3.1.0",
 "info": {
  "title": "BTB Finance API",
  "version": "1.0.0",
  "description": "Live DeFi data and transaction building for agents and apps: liquidity pools with risk grades across many chains, token safety, wallet LP positions, a registry of 50 protocols with official contract addresses, any contract's ABI, reads, and unsigned transactions (swaps, LP deposits, any contract call) with dry runs.\n\nNothing here signs or sends: build endpoints return unsigned transactions for your own wallet to sign. Not financial advice.\n\nNo key needed for 20 calls a minute per IP. A free key (POST /keys) gives 120. Send it as `Authorization: Bearer <key>` or `X-API-Key`.\n\nThe same tools are available over MCP at https://btb.finance/api/mcp.",
  "contact": {
   "url": "https://btb.finance/agents/docs"
  }
 },
 "servers": [
  {
   "url": "https://btb.finance/api/v1"
  }
 ],
 "security": [
  {},
  {
   "bearer": []
  },
  {
   "apiKey": []
  }
 ],
 "tags": [
  {
   "name": "Pools"
  },
  {
   "name": "Tokens"
  },
  {
   "name": "Wallets"
  },
  {
   "name": "Protocols"
  },
  {
   "name": "Contracts"
  },
  {
   "name": "Build"
  },
  {
   "name": "Tools",
   "description": "Every connector tool by name: POST its arguments as JSON."
  },
  {
   "name": "Keys"
  }
 ],
 "paths": {
  "/pools": {
   "get": {
    "operationId": "top_pools",
    "summary": "Top liquidity pools, ranked by APR, TVL, volume or fees, with risk grades.",
    "description": "Rank live liquidity pools by APR, TVL, 24h volume or 24h fees, filtered by chain, risk grade, TVL and stable pairs. Returns each pool with its risk grade and a btb.finance link.",
    "tags": [
     "Pools"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "chain",
      "in": "query",
      "required": false,
      "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
      "schema": {
       "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
       "type": "string"
      }
     },
     {
      "name": "maxRisk",
      "in": "query",
      "required": false,
      "description": "Worst risk grade to include (A safest). Default: all.",
      "schema": {
       "description": "Worst risk grade to include (A safest). Default: all.",
       "type": "string",
       "enum": [
        "A",
        "B",
        "C",
        "D",
        "E"
       ]
      }
     },
     {
      "name": "minTvlUsd",
      "in": "query",
      "required": false,
      "description": "Minimum TVL in USD. Default 100000.",
      "schema": {
       "description": "Minimum TVL in USD. Default 100000.",
       "type": "number",
       "minimum": 0
      }
     },
     {
      "name": "stableOnly",
      "in": "query",
      "required": false,
      "description": "Only pairs of two stablecoins.",
      "schema": {
       "description": "Only pairs of two stablecoins.",
       "type": "boolean"
      }
     },
     {
      "name": "sortBy",
      "in": "query",
      "required": false,
      "description": "Default apr.",
      "schema": {
       "description": "Default apr.",
       "type": "string",
       "enum": [
        "apr",
        "tvl",
        "volume",
        "fees"
       ]
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "Default 10.",
      "schema": {
       "description": "Default 10.",
       "type": "integer",
       "minimum": 1,
       "maximum": 50
      }
     }
    ]
   }
  },
  "/pools/search": {
   "get": {
    "operationId": "search_pools",
    "summary": "Find pools by token symbol, pair or address.",
    "description": "Find pools by token symbols (\"ETH USDC\"), a token address, or a DEX name (\"aerodrome\"). Sorted by TVL.",
    "tags": [
     "Pools"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 1
      }
     },
     {
      "name": "chain",
      "in": "query",
      "required": false,
      "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
      "schema": {
       "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
       "type": "string"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "Default 10.",
      "schema": {
       "description": "Default 10.",
       "type": "integer",
       "minimum": 1,
       "maximum": 50
      }
     }
    ]
   }
  },
  "/pools/best": {
   "get": {
    "operationId": "best_pools_for",
    "summary": "Best pools for an amount in USD and a risk limit.",
    "description": "The highest-APR pools that can take a position of this size without it being more than 2 % of the pool (TVL at least 50× the amount).",
    "tags": [
     "Pools"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "amountUsd",
      "in": "query",
      "required": true,
      "schema": {
       "type": "number",
       "exclusiveMinimum": 0
      }
     },
     {
      "name": "chain",
      "in": "query",
      "required": false,
      "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
      "schema": {
       "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
       "type": "string"
      }
     },
     {
      "name": "maxRisk",
      "in": "query",
      "required": false,
      "description": "Worst risk grade to include (A safest). Default: all.",
      "schema": {
       "description": "Worst risk grade to include (A safest). Default: all.",
       "type": "string",
       "enum": [
        "A",
        "B",
        "C",
        "D",
        "E"
       ]
      }
     },
     {
      "name": "stableOnly",
      "in": "query",
      "required": false,
      "schema": {
       "type": "boolean"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "Default 5.",
      "schema": {
       "description": "Default 5.",
       "type": "integer",
       "minimum": 1,
       "maximum": 20
      }
     }
    ]
   }
  },
  "/pools/compare": {
   "get": {
    "operationId": "compare_pools",
    "summary": "Compare 2 to 6 pools side by side (pools=base:0x…,ethereum:0x…).",
    "description": "Compare 2 to 6 pools side by side (APR, TVL, fees, risk with reasons, stable or not) and say which leads on each measure.",
    "tags": [
     "Pools"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "pools",
      "in": "query",
      "required": true,
      "description": "Pool keys, e.g. [\"base:0x…\", \"ethereum:0x…\"].",
      "schema": {
       "minItems": 2,
       "maxItems": 6,
       "type": "array",
       "items": {
        "type": "string"
       },
       "description": "Pool keys, e.g. [\"base:0x…\", \"ethereum:0x…\"]."
      },
      "style": "form",
      "explode": false
     }
    ]
   }
  },
  "/pools/{chain}/{pool}": {
   "get": {
    "operationId": "pool_details_by_path",
    "summary": "One pool in full: APRs, measured range APR, TVL, volume, fees, risk and tokens.",
    "description": "Everything about one pool: TVL, APRs (measured range APR, base, rewards), volume, fees, in-range share, result against holding, both tokens' safety scans, the risk grade with each deduction, and the btb.finance link.",
    "tags": [
     "Pools"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "chain",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Chain of the pool (not needed when pool is a key like \"base:0x…\")."
     },
     {
      "name": "pool",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "The pool: its key from another tool (\"base:0x…\") or its address / Uniswap V4 pool id."
     }
    ]
   }
  },
  "/pools/{chain}/{pool}/earnings": {
   "get": {
    "operationId": "estimate_lp_earnings_by_path",
    "summary": "Estimated earnings for an amount over some days.",
    "description": "What an amount in one pool might earn over a number of days, from its APR and from its last 24 hours of fees, with the caveats.",
    "tags": [
     "Pools"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "chain",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Chain of the pool (not needed when pool is a key like \"base:0x…\")."
     },
     {
      "name": "pool",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "The pool: its key from another tool (\"base:0x…\") or its address / Uniswap V4 pool id."
     },
     {
      "name": "amountUsd",
      "in": "query",
      "required": true,
      "schema": {
       "type": "number",
       "exclusiveMinimum": 0
      }
     },
     {
      "name": "days",
      "in": "query",
      "required": false,
      "description": "Default 30.",
      "schema": {
       "description": "Default 30.",
       "type": "integer",
       "minimum": 1,
       "maximum": 3650
      }
     }
    ]
   }
  },
  "/pools/{chain}/{pool}/link": {
   "get": {
    "operationId": "add_liquidity_link_by_path",
    "summary": "A btb.finance link where a person adds liquidity to this pool with their own wallet.",
    "description": "A btb.finance link that opens the Add-liquidity flow for a pool, where the user picks the amount and range and signs in their own wallet. Says whether the app can add to this pool directly.",
    "tags": [
     "Pools"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "chain",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Chain of the pool (not needed when pool is a key like \"base:0x…\")."
     },
     {
      "name": "pool",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "The pool: its key from another tool (\"base:0x…\") or its address / Uniswap V4 pool id."
     },
     {
      "name": "amountUsd",
      "in": "query",
      "required": false,
      "description": "For the estimate shown with the link.",
      "schema": {
       "description": "For the estimate shown with the link.",
       "type": "number",
       "exclusiveMinimum": 0
      }
     }
    ]
   }
  },
  "/plan": {
   "get": {
    "operationId": "lp_plan",
    "summary": "An LP plan: an amount in USD spread over several pools.",
    "description": "Split an amount across several pools on different pairs (at most one pool per pair, no more than 2 % of any pool), within a risk limit, with expected yearly earnings and the cost of auto-management. A starting point for the user to review, not advice.",
    "tags": [
     "Pools"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "amountUsd",
      "in": "query",
      "required": true,
      "schema": {
       "type": "number",
       "exclusiveMinimum": 0
      }
     },
     {
      "name": "chain",
      "in": "query",
      "required": false,
      "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
      "schema": {
       "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
       "type": "string"
      }
     },
     {
      "name": "maxRisk",
      "in": "query",
      "required": false,
      "description": "Worst risk grade to include. Default B.",
      "schema": {
       "description": "Worst risk grade to include. Default B.",
       "type": "string",
       "enum": [
        "A",
        "B",
        "C",
        "D",
        "E"
       ]
      }
     },
     {
      "name": "stableOnly",
      "in": "query",
      "required": false,
      "schema": {
       "type": "boolean"
      }
     },
     {
      "name": "pools",
      "in": "query",
      "required": false,
      "description": "How many pools to spread across. Default 3.",
      "schema": {
       "description": "How many pools to spread across. Default 3.",
       "type": "integer",
       "minimum": 1,
       "maximum": 8
      }
     }
    ]
   }
  },
  "/chains": {
   "get": {
    "operationId": "chain_summary_all",
    "summary": "Every chain BTB tracks, with pool counts, TVL and median APRs.",
    "description": "Per chain: pool count, total TVL, median APR and TVL-weighted APR (all pools, and stable pairs only).",
    "tags": [
     "Pools"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "chain",
      "in": "query",
      "required": false,
      "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
      "schema": {
       "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
       "type": "string"
      }
     }
    ]
   }
  },
  "/chains/{chain}": {
   "get": {
    "operationId": "chain_summary_by_path",
    "summary": "One chain: pool counts, TVL, median APRs and its top DEXes.",
    "description": "Per chain: pool count, total TVL, median APR and TVL-weighted APR (all pools, and stable pairs only).",
    "tags": [
     "Pools"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "chain",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains."
     }
    ]
   }
  },
  "/tokens/{chain}/{token}/safety": {
   "get": {
    "operationId": "token_safety_by_path",
    "summary": "Token safety grade: honeypot, taxes, proxy, owner powers, locked liquidity.",
    "description": "The newest btb.finance safety scan of a token (score 0-100, honeypot, taxes, owner powers), if one ran in the last 24 hours, else a link to run one.",
    "tags": [
     "Tokens"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "chain",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Chain name or id."
     },
     {
      "name": "token",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Token address."
     }
    ]
   }
  },
  "/tokens/find": {
   "get": {
    "operationId": "find_token",
    "summary": "A token's contract address on a chain by symbol or name (q=USDC&chain=base).",
    "description": "A token's contract address on one chain, by symbol, name or address, with decimals and USD price: first the swap catalog btb.finance uses (verified tokens first), then any token trading on a DEX (most liquid first). Use it before quoting, swapping or reading a balance; never write a token address from memory. \"ETH\" is the native coin.",
    "tags": [
     "Tokens"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "required": true,
      "description": "Symbol, name or address, e.g. \"USDC\", \"ezETH\", \"PONS\".",
      "schema": {
       "type": "string",
       "description": "Symbol, name or address, e.g. \"USDC\", \"ezETH\", \"PONS\"."
      }
     },
     {
      "name": "chain",
      "in": "query",
      "required": false,
      "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit to search every main chain at once.",
      "schema": {
       "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit to search every main chain at once.",
       "type": "string"
      }
     }
    ]
   }
  },
  "/quote": {
   "get": {
    "operationId": "quote_swap",
    "summary": "Live swap quote after the BTB fee, in USD, with a thin-pool warning (chain, tokenIn, tokenOut, amount).",
    "description": "A live quote at the best KyberSwap route, after the 1% BTB fee: what an amount of one token gets of another, both sides in USD, rate, price impact, gas, and a warning when the pool is thin for the size. Read-only; use build_swap to get the transactions, or give the swapLink to a person.",
    "tags": [
     "Tokens"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "chain",
      "in": "query",
      "required": true,
      "description": "Chain name or id.",
      "schema": {
       "type": "string",
       "description": "Chain name or id."
      }
     },
     {
      "name": "tokenIn",
      "in": "query",
      "required": true,
      "description": "Token sold: address from find_token, or \"ETH\" for the native coin.",
      "schema": {
       "type": "string",
       "description": "Token sold: address from find_token, or \"ETH\" for the native coin."
      }
     },
     {
      "name": "tokenOut",
      "in": "query",
      "required": true,
      "description": "Token bought: address, or \"ETH\".",
      "schema": {
       "type": "string",
       "description": "Token bought: address, or \"ETH\"."
      }
     },
     {
      "name": "amount",
      "in": "query",
      "required": true,
      "description": "Amount of tokenIn in whole units, e.g. \"1\" or \"0.25\".",
      "schema": {
       "type": "string",
       "pattern": "^\\d+(\\.\\d+)?$",
       "description": "Amount of tokenIn in whole units, e.g. \"1\" or \"0.25\"."
      }
     }
    ]
   }
  },
  "/wallets/{address}/overview": {
   "get": {
    "operationId": "wallet_overview_by_path",
    "summary": "Net worth, warnings and opportunities for a wallet, with the build calls to act on each.",
    "description": "Start here when someone asks about their portfolio (EVM or Solana address). One call: net worth across BTB's protocols (about 36 chains), liquidity pools and the wallet's own tokens, each counted once; warnings that need attention (Aave health factor low, pools out of range); and opportunities (idle stablecoins earning nothing, vaults well below the best rate on their chain), each with the yearly gain (on 7-day average rates, only into markets big enough to take the amount) and the exact build tool calls to act. Includes a one-line headline to show the person. Public on-chain data, read-only. Takes about 5 to 25 seconds.",
    "tags": [
     "Wallets"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "address",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "An EVM address (0x...) or a Solana address."
     },
     {
      "name": "idleMinUsd",
      "in": "query",
      "required": false,
      "description": "Smallest idle stablecoin balance worth suggesting a move for. Default 5.",
      "schema": {
       "description": "Smallest idle stablecoin balance worth suggesting a move for. Default 5.",
       "type": "number",
       "minimum": 0
      }
     }
    ]
   }
  },
  "/wallets/{address}/portfolio": {
   "get": {
    "operationId": "wallet_portfolio_by_path",
    "summary": "Everything a wallet holds in the protocols BTB supports, on about 36 chains, grouped by protocol with USD values.",
    "description": "What a wallet holds across the protocols BTB supports, on every EVM chain they run on (about 36), or on Solana for a Solana address (SOL, tokens, Jupiter, Meteora, STKESOL, Pump coins and Pump creator fees to claim): Aave supplied and borrowed with the health factor, Morpho and other vault shares with the underlying, liquid staking and restaking (Lido, Rocket Pool, Renzo, Origin, StakeStone), Ethena, Sky, Usual, Maple, Falcon, Inverse, Olympus and more, stablecoins and protocol tokens. Grouped by protocol with USD values, totals by kind, and which chains were scanned. LP positions are in wallet_positions. Public on-chain data, read-only; cached a minute.",
    "tags": [
     "Wallets"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "address",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "An EVM address (0x...) or a Solana address."
     },
     {
      "name": "chains",
      "in": "query",
      "required": false,
      "description": "Optional comma-separated chains to limit the scan, e.g. \"base,ethereum\". Default: every chain.",
      "schema": {
       "description": "Optional comma-separated chains to limit the scan, e.g. \"base,ethereum\". Default: every chain.",
       "type": "string"
      }
     }
    ]
   }
  },
  "/wallets/{address}/tokens": {
   "get": {
    "operationId": "wallet_tokens_by_path",
    "summary": "Token balances a wallet holds on every main chain, with USD values; search finds one token.",
    "description": "The tokens a wallet holds, read from chain now, on Ethereum, Base, BNB Chain, Arbitrum, Optimism, Polygon, Unichain and Robinhood Chain (or one chain), with USD values, newest-listed tokens included. Pass search (a symbol, name or address) to find one token across chains, e.g. before \"sell all my X\". Public data, read-only. Takes up to about 15 seconds.",
    "tags": [
     "Wallets"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "address",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "The wallet address."
     },
     {
      "name": "chain",
      "in": "query",
      "required": false,
      "description": "Only this chain (faster).",
      "schema": {
       "description": "Only this chain (faster).",
       "type": "string"
      }
     },
     {
      "name": "search",
      "in": "query",
      "required": false,
      "description": "Only this token: symbol, name or address.",
      "schema": {
       "description": "Only this token: symbol, name or address.",
       "type": "string"
      }
     },
     {
      "name": "minUsd",
      "in": "query",
      "required": false,
      "description": "Hide holdings worth less than this. Default 0.",
      "schema": {
       "description": "Hide holdings worth less than this. Default 0.",
       "type": "number",
       "minimum": 0
      }
     }
    ]
   }
  },
  "/yield": {
   "get": {
    "operationId": "compare_yield",
    "summary": "Every way to earn on a token ranked side by side: lending, vaults, savings, staking, stable LPs (token=USDC&chain=base).",
    "description": "Every place to earn on a token, side by side, from BTB's own index: lending (Aave V3 read from its contracts, Compound, Fluid, Euler, Spark, Moonwell, Venus), Morpho vaults (only listed ones, with address and curator), savings, ETH staking and stable-pair liquidity pools. Ranked by base yield, with rewards apart, 1-day/7-day/30-day rates, a stability flag, TVL, the contract to deposit into and the tool that builds the deposit. Prefer it over lending_rates.",
    "tags": [
     "Tokens"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "token",
      "in": "query",
      "required": true,
      "description": "Symbol or address, e.g. \"USDC\", \"ETH\" (includes staking), \"WBTC\".",
      "schema": {
       "type": "string",
       "description": "Symbol or address, e.g. \"USDC\", \"ETH\" (includes staking), \"WBTC\"."
      }
     },
     {
      "name": "chain",
      "in": "query",
      "required": false,
      "description": "Chain name or id. Omit for all chains.",
      "schema": {
       "description": "Chain name or id. Omit for all chains.",
       "type": "string"
      }
     },
     {
      "name": "kinds",
      "in": "query",
      "required": false,
      "description": "Only these kinds. \"lp\" also includes pools with a volatile partner.",
      "schema": {
       "description": "Only these kinds. \"lp\" also includes pools with a volatile partner.",
       "type": "array",
       "items": {
        "type": "string",
        "enum": [
         "lend",
         "vault",
         "savings",
         "stake",
         "lp"
        ]
       }
      },
      "style": "form",
      "explode": false
     },
     {
      "name": "minTvlUsd",
      "in": "query",
      "required": false,
      "description": "Default 1000000.",
      "schema": {
       "description": "Default 1000000.",
       "type": "number",
       "minimum": 0
      }
     },
     {
      "name": "stableOnly",
      "in": "query",
      "required": false,
      "description": "Only rates that held steady.",
      "schema": {
       "description": "Only rates that held steady.",
       "type": "boolean"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "Default 15.",
      "schema": {
       "description": "Default 15.",
       "type": "integer",
       "minimum": 1,
       "maximum": 50
      }
     }
    ]
   }
  },
  "/lending": {
   "get": {
    "operationId": "lending_rates",
    "summary": "Live lending and savings APYs (Aave, Compound, Morpho, Spark…) by token and chain.",
    "description": "Live supply APYs for lending a token on Aave, Compound, Morpho, Spark, Euler, Fluid, Moonwell, Venus and more, per chain, best first, with TVL and the 30-day average. Filter by token (symbol or address, \"stable\" for all stablecoins), chain and protocol. Use it for \"where do I earn most on my USDC\" and before suggesting any lending; never guess a rate.",
    "tags": [
     "Tokens"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "token",
      "in": "query",
      "required": false,
      "description": "Symbol or address, e.g. \"USDC\", \"ETH\", or \"stable\".",
      "schema": {
       "description": "Symbol or address, e.g. \"USDC\", \"ETH\", or \"stable\".",
       "type": "string"
      }
     },
     {
      "name": "chain",
      "in": "query",
      "required": false,
      "description": "Chain name or id. Omit for all chains.",
      "schema": {
       "description": "Chain name or id. Omit for all chains.",
       "type": "string"
      }
     },
     {
      "name": "protocol",
      "in": "query",
      "required": false,
      "description": "e.g. \"aave\", \"morpho\", \"compound\".",
      "schema": {
       "description": "e.g. \"aave\", \"morpho\", \"compound\".",
       "type": "string"
      }
     },
     {
      "name": "minTvlUsd",
      "in": "query",
      "required": false,
      "description": "Skip smaller markets. Default 1000000.",
      "schema": {
       "description": "Skip smaller markets. Default 1000000.",
       "type": "number",
       "minimum": 0
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "Default 15.",
      "schema": {
       "description": "Default 15.",
       "type": "integer",
       "minimum": 1,
       "maximum": 50
      }
     }
    ]
   }
  },
  "/staking": {
   "get": {
    "operationId": "staking_rates",
    "summary": "ETH staking yields per liquid-staking token (stETH, weETH, rETH, cbETH...).",
    "description": "What ETH earns staked through each liquid-staking token (Lido stETH/wstETH, ether.fi weETH, Rocket Pool rETH, Coinbase cbETH, Binance wBETH, Kelp, Renzo...), best first, with TVL and the 30-day average. Use it for \"where do I get the best staking APR\" and to add the staking yield to pools that hold these tokens.",
    "tags": [
     "Tokens"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "token",
      "in": "query",
      "required": false,
      "description": "Only this token or protocol, e.g. \"wstETH\", \"rETH\", \"lido\".",
      "schema": {
       "description": "Only this token or protocol, e.g. \"wstETH\", \"rETH\", \"lido\".",
       "type": "string"
      }
     }
    ]
   }
  },
  "/tokens/{chain}/{token}/quick-check": {
   "get": {
    "operationId": "quick_token_check_by_path",
    "summary": "Free basic token safety check (honeypot, taxes, owner powers).",
    "description": "A free basic safety check of any token (GoPlus): honeypot, buy and sell tax, owner can mint or change balances, blacklist, pausable transfers, proxy, verified source, holders. Use it when token_safety has no recent scan; it is not as deep as a btb.finance scan.",
    "tags": [
     "Tokens"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "chain",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Chain name or id."
     },
     {
      "name": "token",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Token address."
     }
    ]
   }
  },
  "/tx/{chain}/{hash}": {
   "get": {
    "operationId": "tx_status_by_path",
    "summary": "Whether a transaction confirmed, its fee, and the tokens that moved.",
    "description": "Whether a transaction confirmed or failed, its fee, and the tokens that moved in and out of the sending wallet. Use it after a person signs (they can paste the hash, or the sign page shows it).",
    "tags": [
     "Wallets"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "chain",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Chain name or id."
     },
     {
      "name": "hash",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Transaction hash."
     }
    ]
   }
  },
  "/wallets/{address}/positions": {
   "get": {
    "operationId": "wallet_positions_by_path",
    "summary": "Every LP position a wallet holds, with value, range and unclaimed fees.",
    "description": "Every LP position a wallet holds on Ethereum, Base, BNB Chain, Robinhood Chain and Arc (Uniswap V3/V4, PancakeSwap, Aerodrome, Aero, Giga, Ramses, UP, SushiSwap, Alandale), including the ones in its BTB smart wallets: pair, amounts, USD value, in range or not, price range, uncollected fees, staking, auto-management, and PnL when available. Public on-chain data, read-only. Takes up to about 20 seconds.",
    "tags": [
     "Wallets"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "address",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "The wallet address."
     },
     {
      "name": "chain",
      "in": "query",
      "required": false,
      "description": "Only this chain (faster). Omit for all five.",
      "schema": {
       "description": "Only this chain (faster). Omit for all five.",
       "type": "string"
      }
     }
    ]
   }
  },
  "/wallets/{address}/auto-manage": {
   "get": {
    "operationId": "auto_manage_status_by_path",
    "summary": "Positions BTB auto-manages for this wallet.",
    "description": "The LP positions a wallet has under BTB auto-management (automatic range resets and fee compounding): status, last in-range check, rebalances, costs and BTB balance. Read-only, public data.",
    "tags": [
     "Wallets"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "address",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "The owner wallet address."
     }
    ]
   }
  },
  "/auto-manage/setup": {
   "get": {
    "operationId": "auto_manage_setup",
    "summary": "How to turn on BTB auto-management, with the link.",
    "description": "How BTB auto-management works, what it costs on each chain, and the link where the user turns it on for a position with their own wallet.",
    "tags": [
     "Wallets"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "chain",
      "in": "query",
      "required": false,
      "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
      "schema": {
       "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
       "type": "string"
      }
     }
    ]
   }
  },
  "/protocols": {
   "get": {
    "operationId": "list_protocols",
    "summary": "Protocols in the BTB registry, by category, chain or text.",
    "description": "DeFi protocols BTB has researched for agents (stablecoin issuers, DEXes, lending, staking, prediction markets, perps…), filterable by category, chain or text: name, category, chains, how agents access it (on-chain or API) and how many contracts and APIs are recorded.",
    "tags": [
     "Protocols"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "category",
      "in": "query",
      "required": false,
      "description": "e.g. \"Liquid Staking\", \"Dexs\", \"Lending\", \"Stablecoin\".",
      "schema": {
       "description": "e.g. \"Liquid Staking\", \"Dexs\", \"Lending\", \"Stablecoin\".",
       "type": "string"
      }
     },
     {
      "name": "chain",
      "in": "query",
      "required": false,
      "description": "Only protocols on this chain, e.g. \"base\", \"ethereum\", \"solana\".",
      "schema": {
       "description": "Only protocols on this chain, e.g. \"base\", \"ethereum\", \"solana\".",
       "type": "string"
      }
     },
     {
      "name": "search",
      "in": "query",
      "required": false,
      "description": "Text in the name or description.",
      "schema": {
       "description": "Text in the name or description.",
       "type": "string"
      }
     }
    ]
   }
  },
  "/protocols/{protocol}": {
   "get": {
    "operationId": "get_protocol_by_path",
    "summary": "One protocol: official contracts per chain, key functions, APIs and risks.",
    "description": "One protocol from the BTB registry: its official contract addresses per chain (each with the official page it came from), the functions an agent would call, off-chain APIs, supported actions and risks. Then use get_abi / read_contract / build_tx on its contracts.",
    "tags": [
     "Protocols"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "protocol",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Name or slug, e.g. \"lido\", \"uniswap\", \"maple-finance\"."
     },
     {
      "name": "chain",
      "in": "query",
      "required": false,
      "description": "Only contracts on this chain.",
      "schema": {
       "description": "Only contracts on this chain.",
       "type": "string"
      }
     }
    ]
   }
  },
  "/contracts/{chain}/{address}/abi": {
   "get": {
    "operationId": "get_abi_by_path",
    "summary": "What any contract can do: functions, inputs, outputs and warning flags.",
    "description": "What any contract can do: its functions with signatures, inputs, outputs, read or write, and warning flags (admin-likely, arbitrary-call). From verified source on Sourcify, or decoded from the deployed bytecode when unverified; proxies are followed to their implementation. Works on any chain BTB has an RPC for.",
    "tags": [
     "Contracts"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "chain",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Chain name or id, e.g. \"ethereum\", \"base\", \"arbitrum\", \"bnb\", 8453."
     },
     {
      "name": "address",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "The contract address."
     },
     {
      "name": "kind",
      "in": "query",
      "required": false,
      "description": "Only read or only write functions. Default all.",
      "schema": {
       "description": "Only read or only write functions. Default all.",
       "type": "string",
       "enum": [
        "read",
        "write",
        "all"
       ]
      }
     },
     {
      "name": "search",
      "in": "query",
      "required": false,
      "description": "Only functions whose signature contains this text, e.g. \"borrow\".",
      "schema": {
       "description": "Only functions whose signature contains this text, e.g. \"borrow\".",
       "type": "string"
      }
     },
     {
      "name": "full",
      "in": "query",
      "required": false,
      "description": "Also return the raw ABI JSON. Default false.",
      "schema": {
       "description": "Also return the raw ABI JSON. Default false.",
       "type": "boolean"
      }
     }
    ]
   }
  },
  "/contracts/{chain}/{address}/read": {
   "post": {
    "operationId": "read_contract_by_path",
    "summary": "Call a read function on any contract. Body: {\"function\": \"balanceOf\", \"args\": [\"0x…\"]}.",
    "description": "Call a read (view/pure) function on any contract and get the decoded result: balances, prices, positions, settings. Free, nothing is sent.",
    "tags": [
     "Contracts"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "function": {
          "type": "string",
          "description": "Function name (e.g. \"balanceOf\"), full signature for overloads (\"supply(address,uint256,address,uint16)\") or 4-byte selector."
         },
         "args": {
          "default": [],
          "description": "Arguments in order. Integers as strings in base units (\"5000000000\" for 5,000 USDC), addresses as 0x strings, tuples as objects or arrays, \"max\" for the largest uint.",
          "type": "array",
          "items": {}
         }
        },
        "required": [
         "function"
        ]
       }
      }
     }
    },
    "parameters": [
     {
      "name": "chain",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Chain name or id, e.g. \"ethereum\", \"base\", \"arbitrum\", \"bnb\", 8453."
     },
     {
      "name": "address",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "The contract address."
     }
    ]
   }
  },
  "/build/swap": {
   "post": {
    "operationId": "build_swap",
    "summary": "Unsigned swap transactions (approval if needed, then the swap) with a quote and a dry run.",
    "description": "A swap ready to sign: the best KyberSwap price on that chain, an exact-amount approval if needed, then the swap, with the quote, price impact, BTB fee, a safety grade for the token bought and a dry run. For a person, give them the signLink (opens btb.finance with the steps to sign in their wallet); an agent with its own wallet can sign the transactions itself. Use this, not just quote_swap, whenever someone wants to swap.",
    "tags": [
     "Build"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"arbitrum\", 8453."
         },
         "tokenIn": {
          "type": "string",
          "description": "Token to sell: its address, or \"ETH\" for the chain's native coin."
         },
         "tokenOut": {
          "type": "string",
          "description": "Token to buy: its address, or \"ETH\" for the native coin."
         },
         "amount": {
          "type": "string",
          "pattern": "^(\\d+(\\.\\d+)?|max)$",
          "description": "Amount of tokenIn in whole units, e.g. \"250\" or \"0.5\", or \"max\" for the wallet's whole balance of a token (not the native coin, which also pays gas)."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that signs and pays."
         },
         "recipient": {
          "description": "Who receives tokenOut. Default: wallet.",
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$"
         },
         "slippageBps": {
          "description": "Slippage tolerance in bps. Default 50 (0.5%).",
          "type": "integer",
          "minimum": 1,
          "maximum": 3000
         }
        },
        "required": [
         "chain",
         "tokenIn",
         "tokenOut",
         "amount",
         "wallet"
        ]
       }
      }
     }
    },
    "parameters": []
   }
  },
  "/build/liquidity": {
   "post": {
    "operationId": "build_add_liquidity",
    "summary": "Unsigned transactions to open a concentrated-liquidity position, with a dry run.",
    "description": "For agents with their own wallet: the unsigned transactions to open a concentrated-liquidity position in a pool (exact-amount approvals if needed, then the mint), sized from an amount of one of its tokens, with the matching amount of the other token, the range, wallet balances and a dry run. Works for Uniswap V3, PancakeSwap V3, Aerodrome Slipstream and the V3 forks btb.finance supports; other pools return a link. Nothing is signed or sent.",
    "tags": [
     "Build"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "description": "Chain of the pool (not needed when pool is a key like \"base:0x…\").",
          "type": "string"
         },
         "pool": {
          "type": "string",
          "description": "The pool: its key from another tool (\"base:0x…\") or its address / Uniswap V4 pool id."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that signs, pays and receives the position."
         },
         "token": {
          "type": "string",
          "description": "Which of the pool's two tokens `amount` is in: its address or symbol (wrapped symbol for ETH, e.g. WETH)."
         },
         "amount": {
          "type": "string",
          "pattern": "^\\d+(\\.\\d+)?$",
          "description": "Amount of that token in whole units. The other token's amount is computed for the range."
         },
         "rangePct": {
          "description": "Half-width of the range around the price in %, e.g. 5 for ±5 %. null = full range. Default 5.",
          "anyOf": [
           {
            "type": "number",
            "exclusiveMinimum": 0,
            "maximum": 500
           },
           {
            "type": "null"
           }
          ]
         },
         "slippageBps": {
          "description": "Slippage tolerance in bps. Default 50 (500 on Robinhood Chain).",
          "type": "integer",
          "minimum": 1,
          "maximum": 3000
         }
        },
        "required": [
         "pool",
         "wallet",
         "token",
         "amount"
        ]
       }
      }
     }
    },
    "parameters": []
   }
  },
  "/build/lend": {
   "post": {
    "operationId": "build_lend",
    "summary": "Lend a token on Aave V3: the approval only if needed, then the supply, with the live rate, health factor and a signLink.",
    "description": "Lend a token on Aave V3, or Aave V4 with protocol \"aave-v4\" (the Core markets on ethereum and avalanche): the exact approval only if needed, then the supply, as ONE signLink for the person, with the live supply APY, what the amount earns a year, the wallet's health factor (V3) and a dry run. Use this, not build_tx, for Aave deposits.",
    "tags": [
     "Build"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id: ethereum, base, arbitrum, optimism, polygon, avalanche, bnb."
         },
         "token": {
          "type": "string",
          "description": "Symbol or address, e.g. \"USDC\", \"WETH\". Aave takes the wrapped coin, not native ETH."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that lends and signs."
         },
         "amount": {
          "type": "string",
          "pattern": "^(\\d+(\\.\\d+)?|max)$",
          "description": "Whole units, e.g. \"10\", or \"max\" for the whole balance."
         },
         "protocol": {
          "description": "Default aave-v3. aave-v4 lends in Aave V4's Core market (ethereum, avalanche).",
          "type": "string",
          "enum": [
           "aave-v3",
           "aave-v4"
          ]
         }
        },
        "required": [
         "chain",
         "token",
         "wallet",
         "amount"
        ]
       }
      }
     }
    },
    "parameters": []
   }
  },
  "/build/withdraw": {
   "post": {
    "operationId": "build_withdraw",
    "summary": "Withdraw a lent token from Aave V3 (\"max\" for all), with what is withdrawable now and a signLink.",
    "description": "Take a lent token back from Aave V3, as a signLink for the person: how much is supplied, how much can be withdrawn right now, the health factor (if the wallet borrows) and a dry run. amount \"max\" takes everything including interest.",
    "tags": [
     "Build"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id: ethereum, base, arbitrum, optimism, polygon, avalanche, bnb."
         },
         "token": {
          "type": "string",
          "description": "Symbol or address, e.g. \"USDC\", \"WETH\". Aave takes the wrapped coin, not native ETH."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that lends and signs."
         },
         "amount": {
          "type": "string",
          "pattern": "^(\\d+(\\.\\d+)?|max)$",
          "description": "Whole units, or \"max\" for all of it."
         }
        },
        "required": [
         "chain",
         "token",
         "wallet",
         "amount"
        ]
       }
      }
     }
    },
    "parameters": []
   }
  },
  "/build/zap": {
   "post": {
    "operationId": "build_zap_liquidity",
    "summary": "Add liquidity from one token: swap the right share, then open the position, as one signLink.",
    "description": "Open a concentrated-liquidity position using only ONE of the pool's tokens: swaps the right share into the other token at the best price, then deposits both for the chosen range, as ONE signLink (swap, approvals, deposit). A small safety margin of the other token is left in the wallet. Same pools as build_add_liquidity (Uniswap V3, PancakeSwap V3, Aerodrome Slipstream and the V3 forks btb.finance supports).",
    "tags": [
     "Build"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "description": "Chain of the pool (not needed when pool is a key like \"base:0x…\").",
          "type": "string"
         },
         "pool": {
          "type": "string",
          "description": "The pool: its key from another tool (\"base:0x…\") or its address / Uniswap V4 pool id."
         },
         "token": {
          "type": "string",
          "description": "The one token you have: the pool token's symbol or address (wrapped symbol for ETH, e.g. WETH)."
         },
         "amount": {
          "type": "string",
          "pattern": "^\\d+(\\.\\d+)?$",
          "description": "How much of it to put in, in whole units."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that signs."
         },
         "rangePct": {
          "description": "Half-width of the range in %, e.g. 5. null = full range. Default 5.",
          "anyOf": [
           {
            "type": "number",
            "exclusiveMinimum": 0,
            "maximum": 500
           },
           {
            "type": "null"
           }
          ]
         },
         "slippageBps": {
          "type": "integer",
          "minimum": 1,
          "maximum": 3000
         }
        },
        "required": [
         "pool",
         "token",
         "amount",
         "wallet"
        ]
       }
      }
     }
    },
    "parameters": []
   }
  },
  "/sign/status": {
   "post": {
    "operationId": "sign_status",
    "summary": "Which steps of a signLink the person signed, each checked on chain. Body: {\"signLink\": \"https://btb.finance/sign#…\"}.",
    "description": "After giving a person a btb.finance/sign link: which steps they have signed and whether each confirmed on chain, with the hashes and the tokens that moved. Each reported hash is checked on chain (sent from the link's wallet, to the step's contract). Call it when they say they are done, instead of asking for hashes.",
    "tags": [
     "Build"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "signLink": {
          "type": "string",
          "description": "The signLink a build tool returned."
         }
        },
        "required": [
         "signLink"
        ]
       }
      }
     }
    },
    "parameters": []
   }
  },
  "/build/vault-deposit": {
   "post": {
    "operationId": "build_vault_deposit",
    "summary": "Deposit into a Morpho vault (ERC-4626): exact approval if needed, then the deposit, as one signLink.",
    "description": "Deposit into a Morpho vault (V1 or V2, any ERC-4626 vault Morpho knows): the exact approval only if needed, then the deposit, as ONE signLink, with the shares you get and a dry run. Fast: no contract lookup. Get the vault address from compare_yield.",
    "tags": [
     "Build"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id."
         },
         "vault": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The vault address, from compare_yield."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that signs."
         },
         "amount": {
          "type": "string",
          "pattern": "^(\\d+(\\.\\d+)?|max)$",
          "description": "Whole units of the vault's token, or \"max\" for the whole balance."
         }
        },
        "required": [
         "chain",
         "vault",
         "wallet",
         "amount"
        ]
       }
      }
     }
    },
    "parameters": []
   }
  },
  "/build/vault-withdraw": {
   "post": {
    "operationId": "build_vault_withdraw",
    "summary": "Withdraw from a Morpho vault (\"max\" redeems everything), as a signLink.",
    "description": "Take tokens back from a Morpho vault (V1 or V2): an amount, or \"max\" to redeem every share including interest, as a signLink, with what the position is worth, what can be withdrawn right now and a dry run.",
    "tags": [
     "Build"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id."
         },
         "vault": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The vault address, from compare_yield."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that signs."
         },
         "amount": {
          "type": "string",
          "pattern": "^(\\d+(\\.\\d+)?|max)$",
          "description": "Whole units of the token, or \"max\" for everything."
         }
        },
        "required": [
         "chain",
         "vault",
         "wallet",
         "amount"
        ]
       }
      }
     }
    },
    "parameters": []
   }
  },
  "/build/bridge": {
   "post": {
    "operationId": "build_bridge",
    "summary": "Sell a token on one chain, receive any token on another (LI.FI), as one signLink.",
    "description": "Sell a token on one chain and receive any token on another chain (e.g. USDC on Base to ETH on Ethereum), through LI.FI's best bridge and DEX route: an exact approval if needed, then the bridge transaction, as ONE signLink, with what arrives (and the minimum), fees, gas, the estimated time and a dry run. Tokens arrive in the same wallet. Use find_token for each token on its own chain first.",
    "tags": [
     "Build"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "fromChain": {
          "type": "string",
          "description": "Chain the tokens leave, e.g. \"base\"."
         },
         "toChain": {
          "type": "string",
          "description": "Chain they arrive on, e.g. \"ethereum\"."
         },
         "tokenIn": {
          "type": "string",
          "description": "\"ETH\" for the native coin, or the token address on fromChain."
         },
         "tokenOut": {
          "type": "string",
          "description": "\"ETH\" for the native coin, or the token address on toChain."
         },
         "amount": {
          "type": "string",
          "pattern": "^(\\d+(\\.\\d+)?|max)$",
          "description": "Whole units of tokenIn, or \"max\" for the whole balance of a token."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that signs; it also receives on the other chain."
         }
        },
        "required": [
         "fromChain",
         "toChain",
         "tokenIn",
         "tokenOut",
         "amount",
         "wallet"
        ]
       }
      }
     }
    },
    "parameters": []
   }
  },
  "/bridge/status/{hash}": {
   "get": {
    "operationId": "bridge_status_by_path",
    "summary": "Whether a cross-chain transfer arrived, with the receiving transaction.",
    "description": "Whether a cross-chain transfer (from build_bridge or any LI.FI route) arrived: pending, done with the receiving transaction and amount, or failed. Give the source transaction hash (sign_status shows it).",
    "tags": [
     "Build"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "hash",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Source chain transaction hash."
     },
     {
      "name": "fromChain",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "toChain",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      }
     }
    ]
   }
  },
  "/build/tx": {
   "post": {
    "operationId": "build_tx",
    "summary": "Encode any contract function into an unsigned transaction, with a dry run and warnings.",
    "description": "Turn contract calls into transactions to sign, with a dry run and warnings. When an action needs an approval first (lend on Aave, stake, deposit), pass steps: [approve on the token, then the action] in ONE call so the person gets ONE signLink for both; never build them as separate calls. Single call: address and function. Details: encode any write function of any contract into an unsigned transaction, with a dry run from the wallet, a gas estimate and warnings (unverified ABI, admin-only, arbitrary calls, proxies, unlimited approvals). Prefer build_swap and build_add_liquidity where they apply: they add the protocol math and approvals. Nothing is signed or sent.",
    "tags": [
     "Build"
    ],
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id, e.g. \"ethereum\", \"base\", \"arbitrum\", \"bnb\", 8453."
         },
         "address": {
          "description": "The contract to call (one call). For several calls in order, use steps instead.",
          "type": "string"
         },
         "function": {
          "type": "string",
          "description": "Function name (e.g. \"balanceOf\"), full signature for overloads (\"supply(address,uint256,address,uint16)\") or 4-byte selector."
         },
         "args": {
          "default": [],
          "description": "Arguments in order. Integers as strings in base units (\"5000000000\" for 5,000 USDC), addresses as 0x strings, tuples as objects or arrays, \"max\" for the largest uint.",
          "type": "array",
          "items": {}
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that will sign and send."
         },
         "valueEth": {
          "description": "Native coin to send with the call, in whole units (payable functions only).",
          "type": "string",
          "pattern": "^\\d+(\\.\\d+)?$"
         },
         "steps": {
          "description": "Several calls signed in order, e.g. [approve on the token, supply on the pool]: one signLink for all. Use instead of address/function.",
          "minItems": 1,
          "maxItems": 6,
          "type": "array",
          "items": {
           "type": "object",
           "properties": {
            "address": {
             "type": "string",
             "description": "The contract to call."
            },
            "function": {
             "type": "string",
             "description": "Function name (e.g. \"balanceOf\"), full signature for overloads (\"supply(address,uint256,address,uint16)\") or 4-byte selector."
            },
            "args": {
             "default": [],
             "description": "Arguments in order. Integers as strings in base units (\"5000000000\" for 5,000 USDC), addresses as 0x strings, tuples as objects or arrays, \"max\" for the largest uint.",
             "type": "array",
             "items": {}
            },
            "valueEth": {
             "type": "string",
             "pattern": "^\\d+(\\.\\d+)?$"
            }
           },
           "required": [
            "address",
            "function"
           ]
          }
         },
         "title": {
          "description": "What the steps do, shown on the sign page, e.g. \"Lend 10 USDC on Aave\".",
          "type": "string",
          "maxLength": 80
         }
        },
        "required": [
         "chain",
         "wallet"
        ]
       }
      }
     }
    },
    "parameters": []
   }
  },
  "/tools/top_pools": {
   "post": {
    "operationId": "top_pools",
    "summary": "Top liquidity pools",
    "description": "Rank live liquidity pools by APR, TVL, 24h volume or 24h fees, filtered by chain, risk grade, TVL and stable pairs. Returns each pool with its risk grade and a btb.finance link.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
          "type": "string"
         },
         "maxRisk": {
          "description": "Worst risk grade to include (A safest). Default: all.",
          "type": "string",
          "enum": [
           "A",
           "B",
           "C",
           "D",
           "E"
          ]
         },
         "minTvlUsd": {
          "description": "Minimum TVL in USD. Default 100000.",
          "type": "number",
          "minimum": 0
         },
         "stableOnly": {
          "description": "Only pairs of two stablecoins.",
          "type": "boolean"
         },
         "sortBy": {
          "description": "Default apr.",
          "type": "string",
          "enum": [
           "apr",
           "tvl",
           "volume",
           "fees"
          ]
         },
         "limit": {
          "description": "Default 10.",
          "type": "integer",
          "minimum": 1,
          "maximum": 50
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/search_pools": {
   "post": {
    "operationId": "search_pools",
    "summary": "Search pools",
    "description": "Find pools by token symbols (\"ETH USDC\"), a token address, or a DEX name (\"aerodrome\"). Sorted by TVL.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "query": {
          "type": "string",
          "minLength": 1
         },
         "chain": {
          "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
          "type": "string"
         },
         "limit": {
          "description": "Default 10.",
          "type": "integer",
          "minimum": 1,
          "maximum": 50
         }
        },
        "required": [
         "query"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/pool_details": {
   "post": {
    "operationId": "pool_details",
    "summary": "Pool details and risk",
    "description": "Everything about one pool: TVL, APRs (measured range APR, base, rewards), volume, fees, in-range share, result against holding, both tokens' safety scans, the risk grade with each deduction, and the btb.finance link.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "description": "Chain of the pool (not needed when pool is a key like \"base:0x…\").",
          "type": "string"
         },
         "pool": {
          "type": "string",
          "description": "The pool: its key from another tool (\"base:0x…\") or its address / Uniswap V4 pool id."
         }
        },
        "required": [
         "pool"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/compare_pools": {
   "post": {
    "operationId": "compare_pools",
    "summary": "Compare pools",
    "description": "Compare 2 to 6 pools side by side (APR, TVL, fees, risk with reasons, stable or not) and say which leads on each measure.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "pools": {
          "minItems": 2,
          "maxItems": 6,
          "type": "array",
          "items": {
           "type": "string"
          },
          "description": "Pool keys, e.g. [\"base:0x…\", \"ethereum:0x…\"]."
         }
        },
        "required": [
         "pools"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/best_pools_for": {
   "post": {
    "operationId": "best_pools_for",
    "summary": "Best pools for an amount",
    "description": "The highest-APR pools that can take a position of this size without it being more than 2 % of the pool (TVL at least 50× the amount).",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "amountUsd": {
          "type": "number",
          "exclusiveMinimum": 0
         },
         "chain": {
          "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
          "type": "string"
         },
         "maxRisk": {
          "description": "Worst risk grade to include (A safest). Default: all.",
          "type": "string",
          "enum": [
           "A",
           "B",
           "C",
           "D",
           "E"
          ]
         },
         "stableOnly": {
          "type": "boolean"
         },
         "limit": {
          "description": "Default 5.",
          "type": "integer",
          "minimum": 1,
          "maximum": 20
         }
        },
        "required": [
         "amountUsd"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/chain_summary": {
   "post": {
    "operationId": "chain_summary",
    "summary": "Chain summary",
    "description": "Per chain: pool count, total TVL, median APR and TVL-weighted APR (all pools, and stable pairs only).",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/estimate_lp_earnings": {
   "post": {
    "operationId": "estimate_lp_earnings",
    "summary": "Estimate LP earnings",
    "description": "What an amount in one pool might earn over a number of days, from its APR and from its last 24 hours of fees, with the caveats.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "description": "Chain of the pool (not needed when pool is a key like \"base:0x…\").",
          "type": "string"
         },
         "pool": {
          "type": "string",
          "description": "The pool: its key from another tool (\"base:0x…\") or its address / Uniswap V4 pool id."
         },
         "amountUsd": {
          "type": "number",
          "exclusiveMinimum": 0
         },
         "days": {
          "description": "Default 30.",
          "type": "integer",
          "minimum": 1,
          "maximum": 3650
         }
        },
        "required": [
         "pool",
         "amountUsd"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/token_safety": {
   "post": {
    "operationId": "token_safety",
    "summary": "Token safety",
    "description": "The newest btb.finance safety scan of a token (score 0-100, honeypot, taxes, owner powers), if one ran in the last 24 hours, else a link to run one.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id."
         },
         "token": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "Token address."
         }
        },
        "required": [
         "chain",
         "token"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/lp_plan": {
   "post": {
    "operationId": "lp_plan",
    "summary": "Plan an LP portfolio",
    "description": "Split an amount across several pools on different pairs (at most one pool per pair, no more than 2 % of any pool), within a risk limit, with expected yearly earnings and the cost of auto-management. A starting point for the user to review, not advice.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "amountUsd": {
          "type": "number",
          "exclusiveMinimum": 0
         },
         "chain": {
          "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
          "type": "string"
         },
         "maxRisk": {
          "description": "Worst risk grade to include. Default B.",
          "type": "string",
          "enum": [
           "A",
           "B",
           "C",
           "D",
           "E"
          ]
         },
         "stableOnly": {
          "type": "boolean"
         },
         "pools": {
          "description": "How many pools to spread across. Default 3.",
          "type": "integer",
          "minimum": 1,
          "maximum": 8
         }
        },
        "required": [
         "amountUsd"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/add_liquidity_link": {
   "post": {
    "operationId": "add_liquidity_link",
    "summary": "Add liquidity (link to sign)",
    "description": "A btb.finance link that opens the Add-liquidity flow for a pool, where the user picks the amount and range and signs in their own wallet. Says whether the app can add to this pool directly.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "description": "Chain of the pool (not needed when pool is a key like \"base:0x…\").",
          "type": "string"
         },
         "pool": {
          "type": "string",
          "description": "The pool: its key from another tool (\"base:0x…\") or its address / Uniswap V4 pool id."
         },
         "amountUsd": {
          "description": "For the estimate shown with the link.",
          "type": "number",
          "exclusiveMinimum": 0
         }
        },
        "required": [
         "pool"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/wallet_positions": {
   "post": {
    "operationId": "wallet_positions",
    "summary": "Wallet LP positions",
    "description": "Every LP position a wallet holds on Ethereum, Base, BNB Chain, Robinhood Chain and Arc (Uniswap V3/V4, PancakeSwap, Aerodrome, Aero, Giga, Ramses, UP, SushiSwap, Alandale), including the ones in its BTB smart wallets: pair, amounts, USD value, in range or not, price range, uncollected fees, staking, auto-management, and PnL when available. Public on-chain data, read-only. Takes up to about 20 seconds.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "address": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet address."
         },
         "chain": {
          "description": "Only this chain (faster). Omit for all five.",
          "type": "string"
         }
        },
        "required": [
         "address"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/auto_manage_status": {
   "post": {
    "operationId": "auto_manage_status",
    "summary": "Auto-managed positions",
    "description": "The LP positions a wallet has under BTB auto-management (automatic range resets and fee compounding): status, last in-range check, rebalances, costs and BTB balance. Read-only, public data.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "address": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The owner wallet address."
         }
        },
        "required": [
         "address"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/auto_manage_setup": {
   "post": {
    "operationId": "auto_manage_setup",
    "summary": "Turn on auto-management",
    "description": "How BTB auto-management works, what it costs on each chain, and the link where the user turns it on for a position with their own wallet.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit for all chains.",
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/find_token": {
   "post": {
    "operationId": "find_token",
    "summary": "Find a token address",
    "description": "A token's contract address on one chain, by symbol, name or address, with decimals and USD price: first the swap catalog btb.finance uses (verified tokens first), then any token trading on a DEX (most liquid first). Use it before quoting, swapping or reading a balance; never write a token address from memory. \"ETH\" is the native coin.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "query": {
          "type": "string",
          "description": "Symbol, name or address, e.g. \"USDC\", \"ezETH\", \"PONS\"."
         },
         "chain": {
          "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"robinhood\", 8453. Omit to search every main chain at once.",
          "type": "string"
         }
        },
        "required": [
         "query"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/quote_swap": {
   "post": {
    "operationId": "quote_swap",
    "summary": "Swap quote",
    "description": "A live quote at the best KyberSwap route, after the 1% BTB fee: what an amount of one token gets of another, both sides in USD, rate, price impact, gas, and a warning when the pool is thin for the size. Read-only; use build_swap to get the transactions, or give the swapLink to a person.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id."
         },
         "tokenIn": {
          "type": "string",
          "description": "Token sold: address from find_token, or \"ETH\" for the native coin."
         },
         "tokenOut": {
          "type": "string",
          "description": "Token bought: address, or \"ETH\"."
         },
         "amount": {
          "type": "string",
          "pattern": "^\\d+(\\.\\d+)?$",
          "description": "Amount of tokenIn in whole units, e.g. \"1\" or \"0.25\"."
         }
        },
        "required": [
         "chain",
         "tokenIn",
         "tokenOut",
         "amount"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/token_balance": {
   "post": {
    "operationId": "token_balance",
    "summary": "One token balance",
    "description": "One wallet's balance of one token on one chain, in a single read (well under a second): token is \"native\" for the gas coin, a symbol (USDC, WETH, BTB) or a contract address. With the USD value when the price is known.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$"
         },
         "chain": {
          "type": "string",
          "description": "Chain name or id, e.g. base, ethereum, 42161."
         },
         "token": {
          "type": "string",
          "description": "\"native\", a symbol or a contract address."
         }
        },
        "required": [
         "wallet",
         "chain",
         "token"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/wallet_tokens": {
   "post": {
    "operationId": "wallet_tokens",
    "summary": "Wallet token balances",
    "description": "The tokens a wallet holds, read from chain now, on Ethereum, Base, BNB Chain, Arbitrum, Optimism, Polygon, Unichain and Robinhood Chain (or one chain), with USD values, newest-listed tokens included. Pass search (a symbol, name or address) to find one token across chains, e.g. before \"sell all my X\". Public data, read-only. Takes up to about 15 seconds.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet address."
         },
         "chain": {
          "description": "Only this chain (faster).",
          "type": "string"
         },
         "search": {
          "description": "Only this token: symbol, name or address.",
          "type": "string"
         },
         "minUsd": {
          "description": "Hide holdings worth less than this. Default 0.",
          "type": "number",
          "minimum": 0
         }
        },
        "required": [
         "wallet"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/lending_rates": {
   "post": {
    "operationId": "lending_rates",
    "summary": "Lending and savings rates",
    "description": "Live supply APYs for lending a token on Aave, Compound, Morpho, Spark, Euler, Fluid, Moonwell, Venus and more, per chain, best first, with TVL and the 30-day average. Filter by token (symbol or address, \"stable\" for all stablecoins), chain and protocol. Use it for \"where do I earn most on my USDC\" and before suggesting any lending; never guess a rate.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "token": {
          "description": "Symbol or address, e.g. \"USDC\", \"ETH\", or \"stable\".",
          "type": "string"
         },
         "chain": {
          "description": "Chain name or id. Omit for all chains.",
          "type": "string"
         },
         "protocol": {
          "description": "e.g. \"aave\", \"morpho\", \"compound\".",
          "type": "string"
         },
         "minTvlUsd": {
          "description": "Skip smaller markets. Default 1000000.",
          "type": "number",
          "minimum": 0
         },
         "limit": {
          "description": "Default 15.",
          "type": "integer",
          "minimum": 1,
          "maximum": 50
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/tx_status": {
   "post": {
    "operationId": "tx_status",
    "summary": "Transaction status",
    "description": "Whether a transaction confirmed or failed, its fee, and the tokens that moved in and out of the sending wallet. Use it after a person signs (they can paste the hash, or the sign page shows it).",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id."
         },
         "hash": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{64}$",
          "description": "Transaction hash."
         }
        },
        "required": [
         "chain",
         "hash"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/build_lend": {
   "post": {
    "operationId": "build_lend",
    "summary": "Lend on Aave (ready to sign)",
    "description": "Lend a token on Aave V3, or Aave V4 with protocol \"aave-v4\" (the Core markets on ethereum and avalanche): the exact approval only if needed, then the supply, as ONE signLink for the person, with the live supply APY, what the amount earns a year, the wallet's health factor (V3) and a dry run. Use this, not build_tx, for Aave deposits.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id: ethereum, base, arbitrum, optimism, polygon, avalanche, bnb."
         },
         "token": {
          "type": "string",
          "description": "Symbol or address, e.g. \"USDC\", \"WETH\". Aave takes the wrapped coin, not native ETH."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that lends and signs."
         },
         "amount": {
          "type": "string",
          "pattern": "^(\\d+(\\.\\d+)?|max)$",
          "description": "Whole units, e.g. \"10\", or \"max\" for the whole balance."
         },
         "protocol": {
          "description": "Default aave-v3. aave-v4 lends in Aave V4's Core market (ethereum, avalanche).",
          "type": "string",
          "enum": [
           "aave-v3",
           "aave-v4"
          ]
         }
        },
        "required": [
         "chain",
         "token",
         "wallet",
         "amount"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/build_withdraw": {
   "post": {
    "operationId": "build_withdraw",
    "summary": "Withdraw from Aave (ready to sign)",
    "description": "Take a lent token back from Aave V3, as a signLink for the person: how much is supplied, how much can be withdrawn right now, the health factor (if the wallet borrows) and a dry run. amount \"max\" takes everything including interest.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id: ethereum, base, arbitrum, optimism, polygon, avalanche, bnb."
         },
         "token": {
          "type": "string",
          "description": "Symbol or address, e.g. \"USDC\", \"WETH\". Aave takes the wrapped coin, not native ETH."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that lends and signs."
         },
         "amount": {
          "type": "string",
          "pattern": "^(\\d+(\\.\\d+)?|max)$",
          "description": "Whole units, or \"max\" for all of it."
         }
        },
        "required": [
         "chain",
         "token",
         "wallet",
         "amount"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/staking_rates": {
   "post": {
    "operationId": "staking_rates",
    "summary": "ETH staking rates",
    "description": "What ETH earns staked through each liquid-staking token (Lido stETH/wstETH, ether.fi weETH, Rocket Pool rETH, Coinbase cbETH, Binance wBETH, Kelp, Renzo...), best first, with TVL and the 30-day average. Use it for \"where do I get the best staking APR\" and to add the staking yield to pools that hold these tokens.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "token": {
          "description": "Only this token or protocol, e.g. \"wstETH\", \"rETH\", \"lido\".",
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/quick_token_check": {
   "post": {
    "operationId": "quick_token_check",
    "summary": "Free token check",
    "description": "A free basic safety check of any token (GoPlus): honeypot, buy and sell tax, owner can mint or change balances, blacklist, pausable transfers, proxy, verified source, holders. Use it when token_safety has no recent scan; it is not as deep as a btb.finance scan.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id."
         },
         "token": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "Token address."
         }
        },
        "required": [
         "chain",
         "token"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/build_zap_liquidity": {
   "post": {
    "operationId": "build_zap_liquidity",
    "summary": "Add liquidity from one token (ready to sign)",
    "description": "Open a concentrated-liquidity position using only ONE of the pool's tokens: swaps the right share into the other token at the best price, then deposits both for the chosen range, as ONE signLink (swap, approvals, deposit). A small safety margin of the other token is left in the wallet. Same pools as build_add_liquidity (Uniswap V3, PancakeSwap V3, Aerodrome Slipstream and the V3 forks btb.finance supports).",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "description": "Chain of the pool (not needed when pool is a key like \"base:0x…\").",
          "type": "string"
         },
         "pool": {
          "type": "string",
          "description": "The pool: its key from another tool (\"base:0x…\") or its address / Uniswap V4 pool id."
         },
         "token": {
          "type": "string",
          "description": "The one token you have: the pool token's symbol or address (wrapped symbol for ETH, e.g. WETH)."
         },
         "amount": {
          "type": "string",
          "pattern": "^\\d+(\\.\\d+)?$",
          "description": "How much of it to put in, in whole units."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that signs."
         },
         "rangePct": {
          "description": "Half-width of the range in %, e.g. 5. null = full range. Default 5.",
          "anyOf": [
           {
            "type": "number",
            "exclusiveMinimum": 0,
            "maximum": 500
           },
           {
            "type": "null"
           }
          ]
         },
         "slippageBps": {
          "type": "integer",
          "minimum": 1,
          "maximum": 3000
         }
        },
        "required": [
         "pool",
         "token",
         "amount",
         "wallet"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/sign_status": {
   "post": {
    "operationId": "sign_status",
    "summary": "What was signed from a sign link",
    "description": "After giving a person a btb.finance/sign link: which steps they have signed and whether each confirmed on chain, with the hashes and the tokens that moved. Each reported hash is checked on chain (sent from the link's wallet, to the step's contract). Call it when they say they are done, instead of asking for hashes.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "signLink": {
          "type": "string",
          "description": "The signLink a build tool returned."
         }
        },
        "required": [
         "signLink"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/compare_yield": {
   "post": {
    "operationId": "compare_yield",
    "summary": "Compare every way to earn on a token",
    "description": "Every place to earn on a token, side by side, from BTB's own index: lending (Aave V3 read from its contracts, Compound, Fluid, Euler, Spark, Moonwell, Venus), Morpho vaults (only listed ones, with address and curator), savings, ETH staking and stable-pair liquidity pools. Ranked by base yield, with rewards apart, 1-day/7-day/30-day rates, a stability flag, TVL, the contract to deposit into and the tool that builds the deposit. Prefer it over lending_rates.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "token": {
          "type": "string",
          "description": "Symbol or address, e.g. \"USDC\", \"ETH\" (includes staking), \"WBTC\"."
         },
         "chain": {
          "description": "Chain name or id. Omit for all chains.",
          "type": "string"
         },
         "kinds": {
          "description": "Only these kinds. \"lp\" also includes pools with a volatile partner.",
          "type": "array",
          "items": {
           "type": "string",
           "enum": [
            "lend",
            "vault",
            "savings",
            "stake",
            "lp"
           ]
          }
         },
         "minTvlUsd": {
          "description": "Default 1000000.",
          "type": "number",
          "minimum": 0
         },
         "stableOnly": {
          "description": "Only rates that held steady.",
          "type": "boolean"
         },
         "limit": {
          "description": "Default 15.",
          "type": "integer",
          "minimum": 1,
          "maximum": 50
         }
        },
        "required": [
         "token"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/build_pump_claim": {
   "post": {
    "operationId": "build_pump_claim",
    "summary": "Claim Pump creator fees (ready to sign)",
    "description": "For a Pump coin creator's Solana wallet: one unsigned transaction that claims every creator fee waiting for it, from the bonding curve and from PumpSwap (unwrapped to SOL), with the amount, a dry run on Solana, and the transaction to sign. Free: BTB takes no fee on claims. The transaction expires about a minute after it is built. wallet_portfolio shows the fees before claiming.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "wallet": {
          "type": "string",
          "pattern": "^[1-9A-HJ-NP-Za-km-z]{32,44}$",
          "description": "The creator's Solana address."
         }
        },
        "required": [
         "wallet"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/build_pump_launch": {
   "post": {
    "operationId": "build_pump_launch",
    "summary": "Launch a Pump coin (ready to sign)",
    "description": "Launch a new coin on Pump (Solana) from the creator's wallet: one transaction that creates the coin, sets the creator-fee split (BTB keeps a share of creator fees on coins launched through BTB; the creator gets the rest), and optionally makes the creator's first buy in the same transaction so nobody can buy before them. Returns the new mint address, the split, a dry run on Solana and the transaction, already signed by the new coin's mint key; the creator's wallet signs as fee payer and must send it within about a minute without changing the blockhash. Send the coin's picture (imageUrl or imageBase64), description and optional links, and BTB pins them to IPFS; or pass metadataUri if you host it yourself. No picture to send (for example one drawn in the chat, which a tool call cannot carry)? Leave it out and BTB makes a simple logo from the ticker. Cost: about 0.02 to 0.03 SOL plus the first buy. Most new coins lose almost all their value.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "wallet": {
          "type": "string",
          "pattern": "^[1-9A-HJ-NP-Za-km-z]{32,44}$",
          "description": "The creator's Solana address: pays, signs and receives the creator's fee share."
         },
         "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 32,
          "description": "Coin name, up to 32 characters."
         },
         "symbol": {
          "type": "string",
          "minLength": 1,
          "maxLength": 10,
          "description": "Ticker, up to 10 characters, without the $."
         },
         "description": {
          "description": "What the coin is about, shown on Pump.",
          "type": "string",
          "maxLength": 500
         },
         "imageUrl": {
          "description": "https or ipfs link to the coin's picture.",
          "type": "string"
         },
         "imageBase64": {
          "description": "Or the picture itself: PNG, JPEG, GIF or WebP, up to 1000 KB, base64 (a data: URL works).",
          "type": "string",
          "maxLength": 1400000
         },
         "twitter": {
          "description": "Optional https link.",
          "type": "string"
         },
         "telegram": {
          "description": "Optional https link.",
          "type": "string"
         },
         "website": {
          "description": "Optional https link.",
          "type": "string"
         },
         "metadataUri": {
          "description": "Only if you host the metadata JSON yourself (https or ipfs). Otherwise leave it out and BTB pins it from the fields above.",
          "type": "string",
          "maxLength": 200
         },
         "devBuySol": {
          "description": "SOL to spend on the creator's first buy, in the same transaction. Default 0.",
          "type": "number",
          "minimum": 0,
          "maximum": 85
         }
        },
        "required": [
         "wallet",
         "name",
         "symbol"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/build_token_launch": {
   "post": {
    "operationId": "build_token_launch",
    "summary": "Launch a coin on an EVM launchpad (ready to sign)",
    "description": "Launch a new coin from the creator's wallet on an EVM launchpad, with BTB's share of fees built in where the launchpad allows it. launchpad: clanker (Base, BNB Chain, Robinhood Chain or Monad; Uniswap v4 pool with a 1-10% buy/sell tax; BTB is the integrator and keeps a share of the creator's part of the tax; claim with build_launch_claim), zora (Base; 1% pool fee, creator 0.5% of each trade, BTB 0.2% as platform referrer, paid automatically), pons (Robinhood Chain bonding curve, 0.0005 ETH launch fee, optional extra creator tax up to 10%; Pons pays creator fees to one address so BTB takes no share; optional first buy in the same transaction), flap (BNB Chain bonding curve tax token, 1-10% tax paid to the creator; BTB is the commission receiver; optional first buy). Send the picture (imageUrl or imageBase64), description and links; BTB pins them. No picture to send (for example one drawn in the chat, which a tool call cannot carry)? Leave both out and BTB makes a simple logo from the ticker. Returns the coin address, the fee split, a dry run, the transaction and a sign link. Pump on Solana is build_pump_launch. Most new coins lose almost all their value.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The creator's EVM address: pays, signs and receives the creator's fees."
         },
         "launchpad": {
          "type": "string",
          "enum": [
           "clanker",
           "zora",
           "pons",
           "flap"
          ]
         },
         "chain": {
          "description": "Clanker only: base (default), bsc, robinhood or monad. The others have one chain each.",
          "type": "string"
         },
         "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 32
         },
         "symbol": {
          "type": "string",
          "minLength": 1,
          "maxLength": 10,
          "description": "Ticker without the $."
         },
         "description": {
          "type": "string",
          "maxLength": 500
         },
         "imageUrl": {
          "description": "https or ipfs link to the coin's picture.",
          "type": "string"
         },
         "imageBase64": {
          "description": "Or the picture itself: PNG, JPEG, GIF or WebP, up to 1000 KB, base64.",
          "type": "string",
          "maxLength": 1400000
         },
         "twitter": {
          "type": "string"
         },
         "telegram": {
          "type": "string"
         },
         "website": {
          "type": "string"
         },
         "taxPct": {
          "description": "clanker and flap: buy/sell tax in percent, 1 to 10 (default 3). pons: extra creator tax, 0 to 10 (default 0). Ignored for zora.",
          "type": "number",
          "minimum": 0,
          "maximum": 10
         },
         "devBuy": {
          "description": "pons and flap: native coin (ETH or BNB) for the creator's first buy in the same transaction. Default 0.",
          "type": "number",
          "minimum": 0,
          "maximum": 10
         }
        },
        "required": [
         "wallet",
         "launchpad",
         "name",
         "symbol"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/build_btb": {
   "post": {
    "operationId": "build_btb",
    "summary": "BTB Bears, BTBB, wrapping and FLIP (ready to sign)",
    "description": "BTB's own products on Ethereum, each as a sign link with a dry run. Bears: bear_status (Bears held and staked, BTBB waiting, mint price), bear_mint (count; ETH price read live; 1,000 XP per Bear on btb.finance), bear_stake (all Bears in the wallet or count; approval included once), bear_unstake (count), bear_claim (BTBB rewards: every BTBB transfer pays 1% to staked Bears). Tokens: btbb_wrap and btbb_unwrap (BTB to BTBB 1:1 and back), wrap and unwrap (BTB into the token used in BTB's pools, 1 to 1,000,000, and back; trades of it pay 1% into the Friday pot), flip_up (USDC into FLIP) and flip_down (FLIP into USDC).",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$"
         },
         "action": {
          "type": "string",
          "enum": [
           "bear_status",
           "bear_mint",
           "bear_stake",
           "bear_unstake",
           "bear_claim",
           "btbb_wrap",
           "btbb_unwrap",
           "wrap",
           "unwrap",
           "flip_up",
           "flip_down"
          ]
         },
         "count": {
          "description": "Bears to mint, stake or unstake. Stake defaults to all in the wallet; unstake to all staked.",
          "type": "integer",
          "minimum": 1,
          "maximum": 200
         },
         "amount": {
          "description": "Whole units for wrap, unwrap and flip actions (BTB, BTBB, pool token, USDC or FLIP).",
          "type": "string",
          "pattern": "^\\d+(\\.\\d+)?$"
         }
        },
        "required": [
         "wallet",
         "action"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/build_launch_claim": {
   "post": {
    "operationId": "build_launch_claim",
    "summary": "Claim launchpad creator fees (ready to sign)",
    "description": "Find a creator's unclaimed fees on Clanker (Base, BNB Chain, Robinhood Chain, Monad) and Pons (Robinhood Chain) and build the claim transactions, one per chain, each with a dry run. Zora and Flap pay creators automatically. Claiming through BTB is free. Pump on Solana is build_pump_claim.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$"
         }
        },
        "required": [
         "wallet"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/wallet_overview": {
   "post": {
    "operationId": "wallet_overview",
    "summary": "Where a wallet stands, and what to do",
    "description": "Start here when someone asks about their portfolio (EVM or Solana address). One call: net worth across BTB's protocols (about 36 chains), liquidity pools and the wallet's own tokens, each counted once; warnings that need attention (Aave health factor low, pools out of range); and opportunities (idle stablecoins earning nothing, vaults well below the best rate on their chain), each with the yearly gain (on 7-day average rates, only into markets big enough to take the amount) and the exact build tool calls to act. Includes a one-line headline to show the person. Public on-chain data, read-only. Takes about 5 to 25 seconds.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "wallet": {
          "type": "string",
          "pattern": "^(0x[0-9a-fA-F]{40}|[1-9A-HJ-NP-Za-km-z]{32,44})$",
          "description": "An EVM address (0x...) or a Solana address."
         },
         "idleMinUsd": {
          "description": "Smallest idle stablecoin balance worth suggesting a move for. Default 5.",
          "type": "number",
          "minimum": 0
         }
        },
        "required": [
         "wallet"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/wallet_portfolio": {
   "post": {
    "operationId": "wallet_portfolio",
    "summary": "Everything a wallet holds in DeFi",
    "description": "What a wallet holds across the protocols BTB supports, on every EVM chain they run on (about 36), or on Solana for a Solana address (SOL, tokens, Jupiter, Meteora, STKESOL, Pump coins and Pump creator fees to claim): Aave supplied and borrowed with the health factor, Morpho and other vault shares with the underlying, liquid staking and restaking (Lido, Rocket Pool, Renzo, Origin, StakeStone), Ethena, Sky, Usual, Maple, Falcon, Inverse, Olympus and more, stablecoins and protocol tokens. Grouped by protocol with USD values, totals by kind, and which chains were scanned. LP positions are in wallet_positions. Public on-chain data, read-only; cached a minute.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "wallet": {
          "type": "string",
          "pattern": "^(0x[0-9a-fA-F]{40}|[1-9A-HJ-NP-Za-km-z]{32,44})$",
          "description": "An EVM address (0x...) or a Solana address."
         },
         "chains": {
          "description": "Optional comma-separated chains to limit the scan, e.g. \"base,ethereum\". Default: every chain.",
          "type": "string"
         }
        },
        "required": [
         "wallet"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/build_bridge": {
   "post": {
    "operationId": "build_bridge",
    "summary": "Swap across chains (ready to sign)",
    "description": "Sell a token on one chain and receive any token on another chain (e.g. USDC on Base to ETH on Ethereum), through LI.FI's best bridge and DEX route: an exact approval if needed, then the bridge transaction, as ONE signLink, with what arrives (and the minimum), fees, gas, the estimated time and a dry run. Tokens arrive in the same wallet. Use find_token for each token on its own chain first.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "fromChain": {
          "type": "string",
          "description": "Chain the tokens leave, e.g. \"base\"."
         },
         "toChain": {
          "type": "string",
          "description": "Chain they arrive on, e.g. \"ethereum\"."
         },
         "tokenIn": {
          "type": "string",
          "description": "\"ETH\" for the native coin, or the token address on fromChain."
         },
         "tokenOut": {
          "type": "string",
          "description": "\"ETH\" for the native coin, or the token address on toChain."
         },
         "amount": {
          "type": "string",
          "pattern": "^(\\d+(\\.\\d+)?|max)$",
          "description": "Whole units of tokenIn, or \"max\" for the whole balance of a token."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that signs; it also receives on the other chain."
         }
        },
        "required": [
         "fromChain",
         "toChain",
         "tokenIn",
         "tokenOut",
         "amount",
         "wallet"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/bridge_status": {
   "post": {
    "operationId": "bridge_status",
    "summary": "Cross-chain transfer status",
    "description": "Whether a cross-chain transfer (from build_bridge or any LI.FI route) arrived: pending, done with the receiving transaction and amount, or failed. Give the source transaction hash (sign_status shows it).",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "hash": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{64}$",
          "description": "Source chain transaction hash."
         },
         "fromChain": {
          "type": "string"
         },
         "toChain": {
          "type": "string"
         }
        },
        "required": [
         "hash"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/build_vault_deposit": {
   "post": {
    "operationId": "build_vault_deposit",
    "summary": "Deposit into a vault (ready to sign)",
    "description": "Deposit into a Morpho vault (V1 or V2, any ERC-4626 vault Morpho knows): the exact approval only if needed, then the deposit, as ONE signLink, with the shares you get and a dry run. Fast: no contract lookup. Get the vault address from compare_yield.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id."
         },
         "vault": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The vault address, from compare_yield."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that signs."
         },
         "amount": {
          "type": "string",
          "pattern": "^(\\d+(\\.\\d+)?|max)$",
          "description": "Whole units of the vault's token, or \"max\" for the whole balance."
         }
        },
        "required": [
         "chain",
         "vault",
         "wallet",
         "amount"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/build_vault_withdraw": {
   "post": {
    "operationId": "build_vault_withdraw",
    "summary": "Withdraw from a vault (ready to sign)",
    "description": "Take tokens back from a Morpho vault (V1 or V2): an amount, or \"max\" to redeem every share including interest, as a signLink, with what the position is worth, what can be withdrawn right now and a dry run.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id."
         },
         "vault": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The vault address, from compare_yield."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that signs."
         },
         "amount": {
          "type": "string",
          "pattern": "^(\\d+(\\.\\d+)?|max)$",
          "description": "Whole units of the token, or \"max\" for everything."
         }
        },
        "required": [
         "chain",
         "vault",
         "wallet",
         "amount"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/build_swap": {
   "post": {
    "operationId": "build_swap",
    "summary": "Build a swap (unsigned)",
    "description": "A swap ready to sign: the best KyberSwap price on that chain, an exact-amount approval if needed, then the swap, with the quote, price impact, BTB fee, a safety grade for the token bought and a dry run. For a person, give them the signLink (opens btb.finance with the steps to sign in their wallet); an agent with its own wallet can sign the transactions itself. Use this, not just quote_swap, whenever someone wants to swap.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id, e.g. \"base\", \"ethereum\", \"bnb\", \"arbitrum\", 8453."
         },
         "tokenIn": {
          "type": "string",
          "description": "Token to sell: its address, or \"ETH\" for the chain's native coin."
         },
         "tokenOut": {
          "type": "string",
          "description": "Token to buy: its address, or \"ETH\" for the native coin."
         },
         "amount": {
          "type": "string",
          "pattern": "^(\\d+(\\.\\d+)?|max)$",
          "description": "Amount of tokenIn in whole units, e.g. \"250\" or \"0.5\", or \"max\" for the wallet's whole balance of a token (not the native coin, which also pays gas)."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that signs and pays."
         },
         "recipient": {
          "description": "Who receives tokenOut. Default: wallet.",
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$"
         },
         "slippageBps": {
          "description": "Slippage tolerance in bps. Default 50 (0.5%).",
          "type": "integer",
          "minimum": 1,
          "maximum": 3000
         }
        },
        "required": [
         "chain",
         "tokenIn",
         "tokenOut",
         "amount",
         "wallet"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/build_add_liquidity": {
   "post": {
    "operationId": "build_add_liquidity",
    "summary": "Build an LP deposit (unsigned)",
    "description": "For agents with their own wallet: the unsigned transactions to open a concentrated-liquidity position in a pool (exact-amount approvals if needed, then the mint), sized from an amount of one of its tokens, with the matching amount of the other token, the range, wallet balances and a dry run. Works for Uniswap V3, PancakeSwap V3, Aerodrome Slipstream and the V3 forks btb.finance supports; other pools return a link. Nothing is signed or sent.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "description": "Chain of the pool (not needed when pool is a key like \"base:0x…\").",
          "type": "string"
         },
         "pool": {
          "type": "string",
          "description": "The pool: its key from another tool (\"base:0x…\") or its address / Uniswap V4 pool id."
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that signs, pays and receives the position."
         },
         "token": {
          "type": "string",
          "description": "Which of the pool's two tokens `amount` is in: its address or symbol (wrapped symbol for ETH, e.g. WETH)."
         },
         "amount": {
          "type": "string",
          "pattern": "^\\d+(\\.\\d+)?$",
          "description": "Amount of that token in whole units. The other token's amount is computed for the range."
         },
         "rangePct": {
          "description": "Half-width of the range around the price in %, e.g. 5 for ±5 %. null = full range. Default 5.",
          "anyOf": [
           {
            "type": "number",
            "exclusiveMinimum": 0,
            "maximum": 500
           },
           {
            "type": "null"
           }
          ]
         },
         "slippageBps": {
          "description": "Slippage tolerance in bps. Default 50 (500 on Robinhood Chain).",
          "type": "integer",
          "minimum": 1,
          "maximum": 3000
         }
        },
        "required": [
         "pool",
         "wallet",
         "token",
         "amount"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/get_abi": {
   "post": {
    "operationId": "get_abi",
    "summary": "Contract functions (ABI)",
    "description": "What any contract can do: its functions with signatures, inputs, outputs, read or write, and warning flags (admin-likely, arbitrary-call). From verified source on Sourcify, or decoded from the deployed bytecode when unverified; proxies are followed to their implementation. Works on any chain BTB has an RPC for.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id, e.g. \"ethereum\", \"base\", \"arbitrum\", \"bnb\", 8453."
         },
         "address": {
          "type": "string",
          "description": "The contract address."
         },
         "kind": {
          "description": "Only read or only write functions. Default all.",
          "type": "string",
          "enum": [
           "read",
           "write",
           "all"
          ]
         },
         "search": {
          "description": "Only functions whose signature contains this text, e.g. \"borrow\".",
          "type": "string"
         },
         "full": {
          "description": "Also return the raw ABI JSON. Default false.",
          "type": "boolean"
         }
        },
        "required": [
         "chain",
         "address"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/read_contract": {
   "post": {
    "operationId": "read_contract",
    "summary": "Read a contract",
    "description": "Call a read (view/pure) function on any contract and get the decoded result: balances, prices, positions, settings. Free, nothing is sent.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id, e.g. \"ethereum\", \"base\", \"arbitrum\", \"bnb\", 8453."
         },
         "address": {
          "type": "string",
          "description": "The contract address."
         },
         "function": {
          "type": "string",
          "description": "Function name (e.g. \"balanceOf\"), full signature for overloads (\"supply(address,uint256,address,uint16)\") or 4-byte selector."
         },
         "args": {
          "default": [],
          "description": "Arguments in order. Integers as strings in base units (\"5000000000\" for 5,000 USDC), addresses as 0x strings, tuples as objects or arrays, \"max\" for the largest uint.",
          "type": "array",
          "items": {}
         }
        },
        "required": [
         "chain",
         "address",
         "function"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/build_tx": {
   "post": {
    "operationId": "build_tx",
    "summary": "Build any contract call (unsigned)",
    "description": "Turn contract calls into transactions to sign, with a dry run and warnings. When an action needs an approval first (lend on Aave, stake, deposit), pass steps: [approve on the token, then the action] in ONE call so the person gets ONE signLink for both; never build them as separate calls. Single call: address and function. Details: encode any write function of any contract into an unsigned transaction, with a dry run from the wallet, a gas estimate and warnings (unverified ABI, admin-only, arbitrary calls, proxies, unlimited approvals). Prefer build_swap and build_add_liquidity where they apply: they add the protocol math and approvals. Nothing is signed or sent.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "chain": {
          "type": "string",
          "description": "Chain name or id, e.g. \"ethereum\", \"base\", \"arbitrum\", \"bnb\", 8453."
         },
         "address": {
          "description": "The contract to call (one call). For several calls in order, use steps instead.",
          "type": "string"
         },
         "function": {
          "type": "string",
          "description": "Function name (e.g. \"balanceOf\"), full signature for overloads (\"supply(address,uint256,address,uint16)\") or 4-byte selector."
         },
         "args": {
          "default": [],
          "description": "Arguments in order. Integers as strings in base units (\"5000000000\" for 5,000 USDC), addresses as 0x strings, tuples as objects or arrays, \"max\" for the largest uint.",
          "type": "array",
          "items": {}
         },
         "wallet": {
          "type": "string",
          "pattern": "^0x[0-9a-fA-F]{40}$",
          "description": "The wallet that will sign and send."
         },
         "valueEth": {
          "description": "Native coin to send with the call, in whole units (payable functions only).",
          "type": "string",
          "pattern": "^\\d+(\\.\\d+)?$"
         },
         "steps": {
          "description": "Several calls signed in order, e.g. [approve on the token, supply on the pool]: one signLink for all. Use instead of address/function.",
          "minItems": 1,
          "maxItems": 6,
          "type": "array",
          "items": {
           "type": "object",
           "properties": {
            "address": {
             "type": "string",
             "description": "The contract to call."
            },
            "function": {
             "type": "string",
             "description": "Function name (e.g. \"balanceOf\"), full signature for overloads (\"supply(address,uint256,address,uint16)\") or 4-byte selector."
            },
            "args": {
             "default": [],
             "description": "Arguments in order. Integers as strings in base units (\"5000000000\" for 5,000 USDC), addresses as 0x strings, tuples as objects or arrays, \"max\" for the largest uint.",
             "type": "array",
             "items": {}
            },
            "valueEth": {
             "type": "string",
             "pattern": "^\\d+(\\.\\d+)?$"
            }
           },
           "required": [
            "address",
            "function"
           ]
          }
         },
         "title": {
          "description": "What the steps do, shown on the sign page, e.g. \"Lend 10 USDC on Aave\".",
          "type": "string",
          "maxLength": 80
         }
        },
        "required": [
         "chain",
         "wallet"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/list_protocols": {
   "post": {
    "operationId": "list_protocols",
    "summary": "Protocols in the BTB registry",
    "description": "DeFi protocols BTB has researched for agents (stablecoin issuers, DEXes, lending, staking, prediction markets, perps…), filterable by category, chain or text: name, category, chains, how agents access it (on-chain or API) and how many contracts and APIs are recorded.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "category": {
          "description": "e.g. \"Liquid Staking\", \"Dexs\", \"Lending\", \"Stablecoin\".",
          "type": "string"
         },
         "chain": {
          "description": "Only protocols on this chain, e.g. \"base\", \"ethereum\", \"solana\".",
          "type": "string"
         },
         "search": {
          "description": "Text in the name or description.",
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/tools/get_protocol": {
   "post": {
    "operationId": "get_protocol",
    "summary": "Protocol contracts, functions and APIs",
    "description": "One protocol from the BTB registry: its official contract addresses per chain (each with the official page it came from), the functions an agent would call, off-chain APIs, supported actions and risks. Then use get_abi / read_contract / build_tx on its contracts.",
    "tags": [
     "Tools"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "protocol": {
          "type": "string",
          "description": "Name or slug, e.g. \"lido\", \"uniswap\", \"maple-finance\"."
         },
         "chain": {
          "description": "Only contracts on this chain.",
          "type": "string"
         }
        },
        "required": [
         "protocol"
        ]
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The result, as JSON.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "400": {
      "description": "Bad arguments or the tool could not answer; `error.message` says why.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found (pool, protocol, function).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/keys": {
   "post": {
    "operationId": "create_api_key",
    "tags": [
     "Keys"
    ],
    "summary": "Get a free API key (120 calls a minute instead of 20). Shown once: store it.",
    "security": [],
    "requestBody": {
     "required": false,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "name": {
          "type": "string",
          "description": "Your app or agent."
         },
         "contact": {
          "type": "string",
          "description": "Optional email or URL."
         }
        }
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The new key.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit reached. Wait until `X-RateLimit-Reset` (unix seconds), or use a key for a higher limit.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/keys/me": {
   "get": {
    "operationId": "api_key_usage",
    "tags": [
     "Keys"
    ],
    "summary": "Usage and limit of the key you send.",
    "responses": {
     "200": {
      "description": "Key info."
     },
     "401": {
      "description": "The API key is unknown or turned off.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer"
   },
   "apiKey": {
    "type": "apiKey",
    "in": "header",
    "name": "X-API-Key"
   }
  },
  "schemas": {
   "Error": {
    "type": "object",
    "properties": {
     "error": {
      "type": "object",
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       }
      },
      "required": [
       "code",
       "message"
      ]
     }
    }
   }
  }
 }
}