> ## 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}/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: 입력 토큰 Mint 주소
        outputMint:
          type: string
          description: 출력 토큰 Mint 주소
      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

````