> ## 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 vào cơ sở)

> Tính toán lượng đầu ra dự kiến khi swap một lượng đầu vào cố định.
Hữu ích để hiển thị xem trước trước khi xây dựng giao dịch.




## OpenAPI

````yaml /vi/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: >
    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-in:
    get:
      tags:
        - Compute
      summary: Tính báo giá swap (đầu vào cơ sở)
      description: |
        Tính toán lượng đầu ra dự kiến khi swap một lượng đầu vào cố định.
        Hữu ích để hiển thị xem trước trước khi xây dựng giao dịch.
      operationId: computeSwapBaseIn
      parameters:
        - name: inputMint
          in: query
          required: true
          schema:
            type: string
          description: Địa chỉ mint của token đầu vào (khóa công khai được mã hóa base58).
          example: EPjFWdd5Au5WrWSNY8jk5oHE3TkM3TvhEhBNj9xtJzwQ
        - name: outputMint
          in: query
          required: true
          schema:
            type: string
          description: Địa chỉ mint của token đầu ra (khóa công khai được mã hóa base58).
          example: So11111111111111111111111111111111111111112
        - name: amount
          in: query
          required: true
          schema:
            type: string
          description: >-
            Lượng đầu vào tính bằng lamports (đơn vị nhỏ nhất của SPL token).
            Phải là một chuỗi số nguyên không âm.
          example: '1000000'
        - name: slippageBps
          in: query
          required: true
          schema:
            type: string
          description: >-
            Dung sai slippage tối đa tính bằng basis points (0–10000). 1 bps =
            0,01%.
          example: '50'
        - name: referrerBps
          in: query
          required: false
          schema:
            type: string
          description: >-
            Phí người giới thiệu tùy chọn tính bằng basis points (0–10000). Chỉ
            được sử dụng nếu bạn có quyền hạn người giới thiệu.
          example: '100'
        - name: txVersion
          in: query
          required: true
          schema:
            type: string
            enum:
              - V0
              - LEGACY
          description: >-
            Phiên bản giao dịch Solana. V0 sử dụng bảng tra cứu địa chỉ; LEGACY
            là định dạng truyền thống.
          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).'

````