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

# DEX - スワップ

> 入力トークン、出力トークン、数量、スリッページを含むスワップパラメータ



## OpenAPI

````yaml /jp/api-reference/openapi-defi-jp.yaml POST /v2/dex/{chain}/swap
openapi: 3.1.0
info:
  title: Defi Service API
  description: Defi Service API ⚡️
  version: '1.0'
  contact:
    name: AI
    url: https://github.com/chainstream-io/defi-service
    email: ai@sx.ai
servers:
  - url: https://api.chainstream.io
    description: Production
security: []
tags:
  - name: Endpoints
    description: ''
paths:
  /v2/dex/{chain}/swap:
    post:
      tags:
        - Dex
      summary: Dex - スワップ
      description: 入力トークン、出力トークン、数量、スリッページを含むスワップパラメータ
      operationId: swap
      parameters:
        - name: chain
          required: true
          in: path
          description: サポートされているネットワークに記載されているチェーン名
          schema:
            $ref: '#/components/schemas/ChainSymbol'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SwapInput'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwapReply'
      security:
        - bearer: []
components:
  schemas:
    ChainSymbol:
      type: string
      enum:
        - sol
        - bsc
        - eth
    SwapInput:
      type: object
      properties:
        dex:
          type: string
          description: 取引用の DEX 識別子
          example: jupiter
          enum:
            - jupiter
            - kyberswap
            - raydium
            - pumpfun
            - moonshot
            - candy
            - launchpad
        userAddress:
          type: string
          description: トランザクションを開始するウォレットの公開鍵
          example: oQPnhXAbLbMuKHESaGrbXT17CyvWCpLyERSJA9HCYd7
          minLength: 8
          maxLength: 64
        priorityFee:
          type: string
          description: トランザクション処理速度を上げるための優先手数料（SOL 単位）
          example: '1000'
        poolAddress:
          type: string
          description: DEX プールアドレス
          example: 58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2
        amount:
          type: string
          description: スワップ数量。全残高の場合は "auto"、割合指定の場合は "50%" のように指定
          example: '1000000000'
        swapMode:
          type: string
          description: スワップ方向モード
          enum:
            - ExactIn
            - ExactOut
          example: ExactIn
        slippage:
          type: integer
          description: スリッページ許容率
          example: 10
          default: 10
          minimum: 0
          maximum: 100
          format: int64
        inputMint:
          type: string
          description: 入力トークンのミントアドレス
        outputMint:
          type: string
          description: 出力トークンのミントアドレス
      required:
        - dex
        - userAddress
        - amount
        - swapMode
        - slippage
    SwapReply:
      type: object
      properties:
        serializedTx:
          type: string
          description: Base64 エンコードされたトランザクション
          example: >-
            AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDRgYGpQEDAQIABQcICQoLDA0ODwAAAAAAAAAAAAAQERITFBUWFxgZGhscHR4fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
        elapsedTime:
          type: integer
          description: リクエスト処理にかかった時間（ミリ秒）
          example: 245
          format: int64
      required:
        - serializedTx
        - elapsedTime
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````