> ## 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.

# Tính báo giá swap (đầu ra cơ sở)

> Tính toán lượng đầu vào cần thiết để đạt được lượng đầu ra mong muốn.
Hữu ích cho những swap nơi bạn biết đầu ra mục tiêu.




## OpenAPI

````yaml /vi/api-reference/openapi/route-api-v2.yaml get /compute/swap-base-out
openapi: 3.0.3
info:
  title: Raydium Transaction API (Route V2)
  version: 1.0.0
  description: >
    Công cụ xây dựng giao dịch swap phía máy chủ cho Solana. API này tạo ra giao
    dịch swap được tuần tự hóa mà không yêu cầu client chạy kết nối RPC hoặc SDK
    Raydium đầy đủ.


    Các phản hồi tuân theo định dạng phong bì tiêu chuẩn:

    - **Thành công**: `{ id: string, success: true, data: {...} }`

    - **Lỗi**: `{ 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: Các endpoint chỉ đọc để tính toán báo giá swap (không xây dựng giao dịch).
  - name: Transaction
    description: Xây dựng giao dịch swap được tuần tự hóa sẵn sàng ký và phát sóng.
paths:
  /compute/swap-base-out:
    get:
      tags:
        - Compute
      summary: Tính báo giá swap (đầu ra cơ sở)
      description: |
        Tính toán lượng đầu vào cần thiết để đạt được lượng đầu ra mong muốn.
        Hữu ích cho những swap nơi bạn biết đầu ra mục tiêu.
      operationId: computeSwapBaseOut
      parameters:
        - name: inputMint
          in: query
          required: true
          schema:
            type: string
          description: Địa chỉ mint của token đầu vào.
          example: EPjFWdd5Au5WrWSNY8jk5oHE3TkM3TvhEhBNj9xtJzwQ
        - name: outputMint
          in: query
          required: true
          schema:
            type: string
          description: Địa chỉ mint của token đầu ra.
          example: So11111111111111111111111111111111111111112
        - name: amount
          in: query
          required: true
          schema:
            type: string
          description: Lượng đầu ra mong muốn tính bằng đơn vị nhỏ nhất (lamports).
          example: '5000000'
        - name: slippageBps
          in: query
          required: true
          schema:
            type: string
          description: Dung sai slippage tối đa tính bằng basis points (0–10000).
          example: '50'
        - name: txVersion
          in: query
          required: true
          schema:
            type: string
            enum:
              - V0
              - LEGACY
          description: Phiên bản giao dịch Solana.
          example: V0
      responses:
        '200':
          description: Báo giá swap được tính toán thành công.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComputeSwapResponse'
        '400':
          description: Tham số đầu vào không hợp lệ.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ComputeSwapResponse:
      type: object
      properties:
        id:
          type: string
          description: Mã định danh yêu cầu duy nhất (UUID).
          example: 550e8400-e29b-41d4-a716-446655440000
        success:
          type: boolean
          description: Liệu tính toán có thành công hay không.
          example: true
        version:
          type: string
          description: Phiên bản phản hồi API.
          example: V1
        data:
          type: object
          description: Kết quả tính toán swap.
          properties:
            inputAmount:
              type: string
              description: Lượng đầu vào tính bằng đơn vị nhỏ nhất.
            outputAmount:
              type: string
              description: Lượng đầu ra dự kiến (tính đến slippage).
            priceImpact:
              type: string
              description: 'Phần trăm tác động giá (ví dụ: "0,5" cho 0,5%).'
            routes:
              type: array
              description: Mảng các tuyến swap và pool được sử dụng.
              items:
                type: object
    ErrorResponse:
      type: object
      properties:
        id:
          type: string
          description: Mã định danh yêu cầu duy nhất.
        success:
          type: boolean
          example: false
        version:
          type: string
          example: V1
        msg:
          type: string
          description: 'Mã tin nhắn lỗi (ví dụ: REQ_SLIPPAGE_BPS_ERROR, REQ_WALLET_ERROR).'

````