> ## 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 /ko/api-reference/openapi-defi-ko.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: 입력 토큰 Mint 주소
          example: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
        outputMint:
          type: string
          description: 출력 토큰 Mint 주소
          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: Anti-MEV 보호 활성화 여부
          example: true
          default: false
        maxFeePerGas:
          type: string
          description: 가스당 최대 수수료 (EIP-1559, wei 단위)
          example: '50000000000'
        maxPriorityFeePerGas:
          type: string
          description: 가스당 최대 우선 수수료 (EIP-1559, wei 단위)
          example: '2000000000'
        gasPrice:
          type: string
          description: 가스 가격 (레거시 트랜잭션, wei 단위)
          example: '50000000000'
        gasLimit:
          type: string
          description: 트랜잭션 가스 한도
          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

````