> ## Documentation Index
> Fetch the complete documentation index at: https://docs.raydium.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 计算 swap 报价（固定输入）

> 计算固定输入数量时的预期输出数量。
适用于在构建交易前显示预览。




## OpenAPI

````yaml /zh/api-reference/openapi/route-api-v2.yaml get /compute/swap-base-in
openapi: 3.0.3
info:
  title: Raydium Transaction API（Route V2）
  version: 1.0.0
  description: >
    服务端 swap 交易构建器，适用于 Solana。此 API 生成序列化的 swap 交易，无需客户端运行 RPC 连接或完整的 Raydium
    SDK。


    响应遵循标准信封格式：

    - **成功**：`{ id: string, success: true, data: {...} }`

    - **错误**：`{ id: string, success: false, msg: string }`
  contact:
    name: Raydium
    url: https://raydium.io
servers:
  - url: https://transaction-v1.raydium.io
    description: Mainnet
  - url: https://transaction-v1-devnet.raydium.io
    description: Devnet
security: []
tags:
  - name: Compute
    description: 用于 swap 报价计算的只读端点（不构建交易）。
  - name: Transaction
    description: 构建序列化的 swap 交易，可直接签名并广播。
paths:
  /compute/swap-base-in:
    get:
      tags:
        - Compute
      summary: 计算 swap 报价（固定输入）
      description: |
        计算固定输入数量时的预期输出数量。
        适用于在构建交易前显示预览。
      operationId: computeSwapBaseIn
      parameters:
        - name: inputMint
          in: query
          required: true
          schema:
            type: string
          description: 输入代币的 mint 地址（base58 编码的公钥）。
          example: EPjFWdd5Au5WrWSNY8jk5oHE3TkM3TvhEhBNj9xtJzwQ
        - name: outputMint
          in: query
          required: true
          schema:
            type: string
          description: 输出代币的 mint 地址（base58 编码的公钥）。
          example: So11111111111111111111111111111111111111112
        - name: amount
          in: query
          required: true
          schema:
            type: string
          description: 以 lamports 为单位的输入数量（SPL 代币最小单位），必须为非负整数字符串。
          example: '1000000'
        - name: slippageBps
          in: query
          required: true
          schema:
            type: string
          description: 最大滑点容忍度，以基点表示（0–10000）。1 bps = 0.01%。
          example: '50'
        - name: referrerBps
          in: query
          required: false
          schema:
            type: string
          description: 可选的推荐人费用，以基点表示（0–10000）。仅在拥有推荐人权限时生效。
          example: '100'
        - name: txVersion
          in: query
          required: true
          schema:
            type: string
            enum:
              - V0
              - LEGACY
          description: Solana 交易版本。V0 使用地址查找表；LEGACY 为传统格式。
          example: V0
      responses:
        '200':
          description: Swap 报价计算成功。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComputeSwapResponse'
        '400':
          description: 输入参数无效。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ComputeSwapResponse:
      type: object
      properties:
        id:
          type: string
          description: 唯一请求标识符（UUID）。
          example: 550e8400-e29b-41d4-a716-446655440000
        success:
          type: boolean
          description: 计算是否成功。
          example: true
        version:
          type: string
          description: API 响应版本。
          example: V1
        data:
          type: object
          description: Swap 计算结果。
          properties:
            inputAmount:
              type: string
              description: 以最小单位表示的输入数量。
            outputAmount:
              type: string
              description: 预期输出数量（已考虑滑点）。
            priceImpact:
              type: string
              description: 价格影响百分比（例如，"0.5" 表示 0.5%）。
            routes:
              type: array
              description: 所使用的 swap 路由和流动性池数组。
              items:
                type: object
    ErrorResponse:
      type: object
      properties:
        id:
          type: string
          description: 请求的唯一标识符。
        success:
          type: boolean
          example: false
        version:
          type: string
          example: V1
        msg:
          type: string
          description: 错误信息码（例如 REQ_SLIPPAGE_BPS_ERROR、REQ_WALLET_ERROR）。

````