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

# Post api swap

> POST building swap calldata for 8dx aggregation smart contract



## OpenAPI

````yaml /openapi.yaml post /api/{blockchain}/swap
openapi: 3.1.0
info:
  title: swap-8dx
  description: ''
  license:
    name: ''
  version: 0.1.0
servers:
  - url: https://swap.ggp.gg
  - url: https://8dx.io
security: []
tags:
  - name: swap
    description: Swap API endpoints
  - name: approve
    description: Approve (Permit) API endpoints
  - name: explorer
    description: Explorer API endpoints
  - name: order
    description: Limit Order API endpoints
  - name: healthcheck
    description: Health Check API endpoints
paths:
  /api/{blockchain}/swap:
    post:
      tags:
        - swap
      description: POST building swap calldata for 8dx aggregation smart contract
      operationId: create_swap
      parameters:
        - name: blockchain
          in: path
          required: true
          schema:
            type: string
            enum:
              - ethereum
              - bsc
              - arbitrum
      requestBody:
        description: Params for building swap calldata
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SwapBody'
        required: true
      responses:
        '201':
          description: Built swap calldata for 8dx aggregation smart contract
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwapResponse'
        '400':
          description: Bad request error from HTTP server
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                BadRequest:
                  summary: Bad request
                  value:
                    code: 400
                    error: string
        '404':
          description: Not found error from HTTP server
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                NotFound:
                  summary: Not found
                  value:
                    code: 404
                    error: string
        '408':
          description: Request timeout error from HTTP server
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                RequestTimeout:
                  summary: Request timeout
                  value:
                    code: 408
                    error: string
        '500':
          description: Internal server error from HTTP server
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                Internal:
                  summary: Internal
                  value:
                    code: 500
                    error: string
components:
  schemas:
    SwapBody:
      type: object
      required:
        - path
        - dstAddress
      properties:
        apiKey:
          type:
            - string
            - 'null'
        deadline:
          type:
            - integer
            - 'null'
          format: int64
          description: Deadline in seconds, default 3600 seconds (1 hour)
          minimum: 0
        dstAddress:
          type: string
          description: Destination/taker wallet or contract
        fromAddress:
          type:
            - string
            - 'null'
          description: Source wallet or contract
        path:
          $ref: '#/components/schemas/InputPath'
          description: Quote path
        permit:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/PermitSwapBody'
              description: Permit2 data with EIP-2612 signature, if exist
        skipSimulation:
          type:
            - boolean
            - 'null'
          description: Whether to skip simulation
        slippageBps:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            Custom slippage in bps, default using totalPriceImpact from the
            quote
          minimum: 0
        usePermit:
          type:
            - boolean
            - 'null'
          description: Whether to use permit
    SwapResponse:
      type: object
      required:
        - data
        - to
        - value
        - minReturnAmountOut
      properties:
        computeUnits:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
        data:
          type: string
          description: Calldata to send to the aggregator contract
        minReturnAmountOut:
          type: string
        to:
          type: string
          description: >-
            Aggregator contract address - recipient of the transaction
            (transaction `to`)
        tokenApprovalAddress:
          type:
            - string
            - 'null'
          description: >-
            Address that the user must approve for ERC20 spending

            (null for native-token swaps; equals `to` for non-permit ERC20
            swaps;

            equals Permit2 address when `use_permit = true`)
        value:
          type: string
          description: Native value (msg.value) attached to the transaction, in wei
    ErrorResponse:
      type: object
      required:
        - error
        - code
      properties:
        code:
          type: integer
          format: int32
          minimum: 0
        error:
          type: string
    InputPath:
      allOf:
        - $ref: '#/components/schemas/InputOptimalRoute'
        - type: object
          required:
            - addressTokenIn
            - addressTokenOut
            - amountIn
          properties:
            addressTokenIn:
              type: string
              description: Source token contract address (ERC20 or native token)
            addressTokenOut:
              type: string
              description: Destination token contract address (ERC20 or native token)
            amountIn:
              type: string
              description: >-
                Amount of source token to swap (in token's smallest unit, e.g.,
                wei for ETH)
    PermitSwapBody:
      type: object
      required:
        - data
        - signature
      properties:
        data:
          type: object
        signature:
          type: string
    InputOptimalRoute:
      type: object
      required:
        - steps
        - totalAmountOut
        - totalPriceImpact
      properties:
        steps:
          type: array
          items:
            type: array
            items:
              $ref: '#/components/schemas/InputPathStep'
        totalAmountOut:
          type: string
          description: >-
            Expected amount of destination token to receive (in token's smallest
            unit, e.g., wei for ETH)
        totalPriceImpact:
          type: integer
          format: int32
          description: Price impact of the quote in bps
          minimum: 0
    InputPathStep:
      allOf:
        - $ref: '#/components/schemas/Action'
        - type: object
          required:
            - tokenIn
            - tokenOut
            - percentBps
          properties:
            percentBps:
              type: integer
              format: int32
              description: Percentage of the input allocated to this route in bps
              minimum: 0
            tokenIn:
              type: string
              description: In step token contract address
            tokenOut:
              type: string
              description: Out of step token contract address
    Action:
      oneOf:
        - type: object
          required:
            - exchanger
          properties:
            exchanger:
              $ref: '#/components/schemas/ExchangerData'
        - type: object
          required:
            - wrap
          properties:
            wrap:
              $ref: '#/components/schemas/WrapData'
    ExchangerData:
      type: object
      required:
        - name
        - address
        - poolType
        - fee
      properties:
        address:
          type: string
          description: Pool contract address of the pool
        fee:
          type: integer
          format: int32
          description: Fee of the pool in bps
          minimum: 0
        name:
          type: string
          description: Name of the pool
        poolType:
          $ref: '#/components/schemas/PoolType'
          description: Type of the pool
    WrapData:
      type: object
      required:
        - isWrap
        - wrapperType
        - name
      properties:
        isWrap:
          type: boolean
          description: Whether the action is a wrap
        name:
          type: string
          description: Name of the wrap token
        wrapperType:
          $ref: '#/components/schemas/WrappedType'
          description: Type of the wrap token
    PoolType:
      type: string
      enum:
        - UniswapV2
        - UniswapV3
        - UniswapV4
        - SushiSwapV2
        - PancakeSwapV2
        - PancakeSwapV3
        - CurveStable
        - CurveCrypto
        - CurveNG
        - CurveMeta
        - BalancerV2
        - BalancerV3
        - FluidT1
        - FluidLite
    WrappedType:
      type: string
      enum:
        - WETH
        - LidoWstETH
        - RocketPoolRETH
        - FraxSfrxETH
        - Custom

````