{
  "openapi": "3.1.0",
  "info": {
    "title": "Tape Finance Solver & Meta-Aggregator API",
    "description": "Production-grade quoter, convex routing engine, and swap calldata generator for Tape Finance on Robinhood Chain Mainnet (Chain ID 4663). Integrated with verified TapeRouter v2.4 (0x8c3C624617A91ebbd404202Dfbc89B2471Ef0439) and Safe 2-of-3 Multisig Governance (0xAe5183f6b766719F18a3B3Bd01D6bCEfA5BacBE3).",
    "version": "2.4.0",
    "contact": {
      "name": "Tape Finance Engineering",
      "url": "https://github.com/dd5-code/TapeFinance",
      "x": "https://x.com/tapefinancerwa",
      "email": "hello@tapefinance.io"
    }
  },
  "servers": [
    {
      "url": "https://solver.tapefinance.io",
      "description": "Production Solver & Meta-Aggregator Gateway"
    },
    {
      "url": "https://tapefinance.io",
      "description": "Production Web Domain"
    },
    {
      "url": "http://localhost:3000",
      "description": "Local Development Server"
    }
  ],
  "paths": {
    "/v1/quote": {
      "get": {
        "summary": "Fetch real-time convex route quote (Meta-Aggregator standard)",
        "description": "Calculates optimal split across verified DEX pools on Robinhood Chain, signs an EIP-712 Quote attestation, and generates transaction calldata targeting TapeRouter v2.4 (0x8c3C624617A91ebbd404202Dfbc89B2471Ef0439).\n",
        "parameters": [
          {
            "name": "fromToken",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Input token symbol (e.g., USDG, NVDA, ETH) or contract address (0x...)"
          },
          {
            "name": "tokenIn",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Alias for fromToken"
          },
          {
            "name": "toToken",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Output token symbol or contract address"
          },
          {
            "name": "tokenOut",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Alias for toToken"
          },
          {
            "name": "fromAmount",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Exact raw input amount in integer base units (wei)"
          },
          {
            "name": "amountIn",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Alias for fromAmount"
          },
          {
            "name": "slippageBps",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 50
            },
            "description": "Maximum allowed slippage in basis points (e.g., 50 = 0.50%)"
          },
          {
            "name": "caller",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The msg.sender that will execute TapeRouter.swap() (user EOA or aggregator router)"
          },
          {
            "name": "userAddress",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Alias for caller"
          },
          {
            "name": "recipient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Output token recipient address (defaults to caller)"
          },
          {
            "name": "partnerTreasury",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional partner treasury for 50/50 fee sharing (defaults to address(0))"
          },
          {
            "name": "referrer",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Alias for partnerTreasury"
          },
          {
            "name": "chainId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 4663
            },
            "description": "Robinhood Chain network ID"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful quote and signed calldata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters or unsupported token"
          },
          "404": {
            "description": "No valid route found across DEX venues"
          },
          "500": {
            "description": "Internal quoter error"
          }
        }
      },
      "post": {
        "summary": "Fetch real-time convex route quote (JSON body)",
        "description": "Equivalent to GET /v1/quote with JSON body payload.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful quote and signed calldata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters"
          },
          "404": {
            "description": "No valid route found"
          },
          "500": {
            "description": "Internal server error"
          }
        }
      }
    },
    "/v1/swap": {
      "post": {
        "summary": "Generate executable swap transaction calldata",
        "description": "Returns signed EIP-712 attestation and full ABI-encoded calldata for TapeRouter.swap(SwapParams).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Complete executable swap transaction payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters"
          },
          "404": {
            "description": "No route available"
          },
          "500": {
            "description": "Internal execution error"
          }
        }
      },
      "get": {
        "summary": "Generate executable swap transaction calldata (Query params)",
        "parameters": [
          {
            "$ref": "#/paths/~1v1~1quote/get/parameters/0"
          },
          {
            "$ref": "#/paths/~1v1~1quote/get/parameters/1"
          },
          {
            "$ref": "#/paths/~1v1~1quote/get/parameters/2"
          },
          {
            "$ref": "#/paths/~1v1~1quote/get/parameters/3"
          },
          {
            "$ref": "#/paths/~1v1~1quote/get/parameters/4"
          },
          {
            "$ref": "#/paths/~1v1~1quote/get/parameters/5"
          },
          {
            "$ref": "#/paths/~1v1~1quote/get/parameters/6"
          },
          {
            "$ref": "#/paths/~1v1~1quote/get/parameters/7"
          },
          {
            "$ref": "#/paths/~1v1~1quote/get/parameters/8"
          },
          {
            "$ref": "#/paths/~1v1~1quote/get/parameters/9"
          },
          {
            "$ref": "#/paths/~1v1~1quote/get/parameters/10"
          },
          {
            "$ref": "#/paths/~1v1~1quote/get/parameters/11"
          },
          {
            "$ref": "#/paths/~1v1~1quote/get/parameters/12"
          }
        ],
        "responses": {
          "200": {
            "description": "Executable swap response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tokens": {
      "get": {
        "summary": "Token list discovery (Uniswap standard format)",
        "description": "Returns a Uniswap-compatible token list JSON for all verified Robinhood Chain RWA tokens and native/wrapped pairs.",
        "parameters": [
          {
            "name": "chainId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 4663
            },
            "description": "Robinhood Chain network ID"
          }
        ],
        "responses": {
          "200": {
            "description": "Uniswap Token List JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UniswapTokenList"
                }
              }
            }
          }
        }
      }
    },
    "/v1/health": {
      "get": {
        "summary": "Health check and quote signer status",
        "description": "Queries live RPC block height, on-chain router contract, and verifies quoteSigner matches the local private key signer.",
        "responses": {
          "200": {
            "description": "Service health report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          },
          "503": {
            "description": "RPC disconnected or quote signer mismatch"
          }
        }
      }
    },
    "/v1/basket-quote": {
      "post": {
        "summary": "1-Click Multi-Stock Portfolio Basket Swaps",
        "description": "Quotes multiple target stocks from a single input currency (e.g. USDG -> NVDA + TSLA + AAPL).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BasketQuoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful basket quote"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "QuoteRequest": {
        "type": "object",
        "required": [
          "tokenIn",
          "tokenOut",
          "amountIn"
        ],
        "properties": {
          "tokenIn": {
            "type": "string",
            "description": "Input token symbol or 0x contract address",
            "example": "USDG"
          },
          "fromToken": {
            "type": "string",
            "description": "Alias for tokenIn"
          },
          "tokenOut": {
            "type": "string",
            "description": "Output token symbol or 0x contract address",
            "example": "NVDA"
          },
          "toToken": {
            "type": "string",
            "description": "Alias for tokenOut"
          },
          "amountIn": {
            "type": "string",
            "description": "Raw integer input amount in base units (wei)",
            "example": "25000000"
          },
          "fromAmount": {
            "type": "string",
            "description": "Alias for amountIn"
          },
          "caller": {
            "type": "string",
            "description": "Address of the msg.sender that will execute the swap",
            "example": "0xc4fdfB0a8E6bB67Ff80AFF5De7DEF3EB40ef175b"
          },
          "userAddress": {
            "type": "string",
            "description": "Alias for caller"
          },
          "recipient": {
            "type": "string",
            "description": "Recipient of the swapped output tokens",
            "example": "0xc4fdfB0a8E6bB67Ff80AFF5De7DEF3EB40ef175b"
          },
          "partnerTreasury": {
            "type": "string",
            "description": "Optional pre-approved partner treasury address for 50/50 fee share",
            "example": "0x0000000000000000000000000000000000000000"
          },
          "slippageBps": {
            "type": "integer",
            "description": "Slippage tolerance in basis points (50 = 0.5%)",
            "default": 50,
            "example": 50
          }
        }
      },
      "QuoteResponse": {
        "type": "object",
        "properties": {
          "fromToken": {
            "type": "string",
            "example": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"
          },
          "toToken": {
            "type": "string",
            "example": "0xd0601CE157Db5bdC3162BbaC2a2C8aF5320D9EEC"
          },
          "fromAmount": {
            "type": "string",
            "example": "25000000"
          },
          "toAmount": {
            "type": "string",
            "example": "194622897754864136"
          },
          "expectedOut": {
            "type": "string",
            "example": "194622897754864136"
          },
          "minBaselineOut": {
            "type": "string",
            "example": "194233651959354407"
          },
          "minUserOut": {
            "type": "string",
            "example": "193262483699557635"
          },
          "estimatedGas": {
            "type": "string",
            "example": "165000"
          },
          "priceImpactPct": {
            "type": "number",
            "example": 0.02
          },
          "routeSummary": {
            "type": "string",
            "example": "Uniswap v3 (5 bps) 100%"
          },
          "routeBreakdown": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RouteAllocation"
            }
          },
          "tx": {
            "$ref": "#/components/schemas/MetaAggregatorTx"
          },
          "caller": {
            "type": "string",
            "example": "0xc4fdfB0a8E6bB67Ff80AFF5De7DEF3EB40ef175b"
          },
          "recipient": {
            "type": "string",
            "example": "0xc4fdfB0a8E6bB67Ff80AFF5De7DEF3EB40ef175b"
          },
          "wrapRequired": {
            "type": "boolean",
            "example": false
          },
          "unwrapRequired": {
            "type": "boolean",
            "example": false
          },
          "nonce": {
            "type": "string",
            "example": "173214567890123456"
          },
          "deadline": {
            "type": "string",
            "example": "1732145768"
          },
          "quoteSignature": {
            "type": "string",
            "example": "0x3f5b..."
          },
          "routeSplit": {
            "type": "string",
            "example": "Uniswap v3 (5 bps) 100%"
          },
          "baselineOut": {
            "type": "string"
          },
          "grossSurplus": {
            "type": "string"
          },
          "totalFee": {
            "type": "string"
          },
          "partnerFee": {
            "type": "string"
          },
          "tapeFee": {
            "type": "string"
          },
          "grossSavingsBps": {
            "type": "number"
          },
          "executionTimeMs": {
            "type": "number"
          }
        }
      },
      "RouteAllocation": {
        "type": "object",
        "properties": {
          "venue": {
            "type": "string",
            "example": "Uniswap v3"
          },
          "fee": {
            "type": "integer",
            "example": 500
          },
          "poolAddress": {
            "type": "string",
            "example": "0x1234..."
          },
          "percent": {
            "type": "number",
            "example": 100
          },
          "inputAmount": {
            "type": "string",
            "example": "25000000"
          },
          "expectedOutput": {
            "type": "string",
            "example": "194622897754864136"
          }
        }
      },
      "MetaAggregatorTx": {
        "type": "object",
        "properties": {
          "to": {
            "type": "string",
            "example": "0xD6fa5A0340140754Cc981415f76af1f4bfD20b3D"
          },
          "data": {
            "type": "string",
            "example": "0x9c31405a..."
          },
          "value": {
            "type": "string",
            "example": "0"
          }
        }
      },
      "UniswapTokenList": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "example": "Tape Finance Robinhood Chain Token List"
          },
          "timestamp": {
            "type": "string"
          },
          "version": {
            "type": "object",
            "properties": {
              "major": {
                "type": "integer"
              },
              "minor": {
                "type": "integer"
              },
              "patch": {
                "type": "integer"
              }
            }
          },
          "keywords": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tokens": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TokenEntry"
            }
          }
        }
      },
      "TokenEntry": {
        "type": "object",
        "properties": {
          "chainId": {
            "type": "integer",
            "example": 4663
          },
          "address": {
            "type": "string",
            "example": "0xd0601CE157Db5bdC3162BbaC2a2C8aF5320D9EEC"
          },
          "name": {
            "type": "string",
            "example": "NVIDIA Corp"
          },
          "symbol": {
            "type": "string",
            "example": "NVDA"
          },
          "decimals": {
            "type": "integer",
            "example": 18
          },
          "logoURI": {
            "type": "string",
            "example": "https://assets.coingecko.com/coins/images/279/small/nvidia.png"
          }
        }
      },
      "HealthResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "ok"
          },
          "chainId": {
            "type": "integer",
            "example": 4663
          },
          "rpcConnected": {
            "type": "boolean",
            "example": true
          },
          "blockNumber": {
            "type": "string",
            "example": "1234567"
          },
          "quoteSigner": {
            "type": "string",
            "example": "0xcF2d1e8b2747D83f57a3090EA71c61373870dD14"
          },
          "onChainQuoteSigner": {
            "type": "string",
            "example": "0xcF2d1e8b2747D83f57a3090EA71c61373870dD14"
          },
          "quoteSignerVerified": {
            "type": "boolean",
            "example": true
          },
          "routerAddress": {
            "type": "string",
            "example": "0xD6fa5A0340140754Cc981415f76af1f4bfD20b3D"
          },
          "timestamp": {
            "type": "string"
          },
          "uptimeSeconds": {
            "type": "number"
          }
        }
      },
      "BasketQuoteRequest": {
        "type": "object",
        "required": [
          "fromToken",
          "amountIn",
          "allocations"
        ],
        "properties": {
          "fromToken": {
            "type": "string",
            "example": "USDG"
          },
          "amountIn": {
            "type": "string",
            "example": "100000000"
          },
          "allocations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "tokenOut": {
                  "type": "string"
                },
                "weightBps": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    }
  }
}