> ## 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}/route
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}/route:
    post:
      tags:
        - Dex
      summary: Dex - ルート
      description: 価格インパクトと手数料を考慮してトークンスワップの最適ルートを算出。最適パスと準備済みトランザクションを返します
      operationId: route
      parameters:
        - name: chain
          required: true
          in: path
          description: サポートされているネットワークに記載されているチェーン名
          schema:
            $ref: '#/components/schemas/ChainSymbol'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SwapRouteInput'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwapRouteResponse'
      security:
        - bearer: []
components:
  schemas:
    ChainSymbol:
      type: string
      enum:
        - sol
        - bsc
        - eth
    SwapRouteInput:
      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'
        amount:
          type: string
          description: スワップ数量。全残高の場合は "auto"、割合指定の場合は "50%" のように指定
          example: '1000000000'
        swapMode:
          type: string
          description: スワップ方向モード
          enum:
            - ExactIn
            - ExactOut
          example: ExactIn
        slippage:
          type: integer
          description: スリッページ許容率
          example: 5
          default: 5
          minimum: 0
          maximum: 100
          format: int64
        inputMint:
          type: string
          description: 入力トークンのミントアドレス
          example: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
        outputMint:
          type: string
          description: 出力トークンのミントアドレス
          example: Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB
        recipientAddress:
          type: string
          description: スワップの受取先ウォレットアドレス
          example: '0x0000000000000000000000000000000000000001'
        permit:
          type: string
          description: スワップ用の Permit データ
          example: 66c85d1637257e890e581f724f69f4d4fc17eee156c0619c4719ed0c66eed0e9
        deadline:
          type: integer
          description: スワップの有効期限タイムスタンプ
          example: 1716806400000
          format: int64
        tipFee:
          type: string
          description: トランザクション処理速度を上げるためのチップ手数料（SOL 単位）
          example: '1000000'
        isAntiMev:
          type: boolean
          description: アンチ MEV 保護を有効にするかどうか
          example: true
          default: false
        maxFeePerGas:
          type: string
          description: Gas 単位あたりの最大手数料（EIP-1559）（wei 単位）
          example: '50000000000'
        maxPriorityFeePerGas:
          type: string
          description: Gas 単位あたりの最大優先手数料（EIP-1559）（wei 単位）
          example: '2000000000'
        gasPrice:
          type: string
          description: Gas 価格（wei 単位、レガシートランザクション）
          example: '50000000000'
        gasLimit:
          type: string
          description: トランザクションの Gas Limit
          example: '300000'
      required:
        - dex
        - userAddress
        - amount
        - swapMode
        - slippage
    SwapRouteResponse:
      type: object
      properties:
        args:
          description: 元のスワップリクエストパラメータ
          allOf:
            - $ref: '#/components/schemas/SwapRouteInput'
        serializedTx:
          type: string
          description: Base64 エンコードされたトランザクション
          example: >-
            AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDRgYGpQEDAQIABQcICQoLDA0ODwAAAAAAAAAAAAAQERITFBUWFxgZGhscHR4fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
        routeInfo:
          type: object
          description: 詳細なルーティング情報
          example:
            inAmount: '1000000000'
            outAmount: '985000000'
            priceImpact: '0.15'
            route:
              - USDC
              - SOL
        elapsedTime:
          type: integer
          description: リクエスト処理にかかった時間（ミリ秒）
          example: 245
          format: int64
        recentBlockhash:
          type: string
          description: スワップトランザクションの最近のブロックハッシュ
          example: JE38e5sYDcpjcfuKA7Madpq8p3A4zc8UQuonCZDbn2yP
        lastValidBlockHeight:
          type: integer
          description: スワップトランザクションの最後の有効ブロック高
          example: 416681972
          format: int64
      required:
        - args
        - serializedTx
        - routeInfo
        - elapsedTime
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````