THORChain Swap API

The Swap API from THORChain — 1 operation(s) for swap.

OpenAPI Specification

thorchain-swap-api-openapi.yml Raw ↑
openapi: 3.0.0
info:
  title: Thornode Auth Swap API
  version: 3.19.1
  contact:
    email: devs@thorchain.org
  description: Thornode REST API.
tags:
- name: Swap
paths:
  /thorchain/queue/swap/details/{tx_id}:
    parameters:
    - $ref: '#/components/parameters/queryHeight'
    - name: tx_id
      in: path
      required: true
      description: Transaction ID of the swap
      schema:
        type: string
    get:
      description: Returns detailed information about a specific swap including its state.
      operationId: swapDetails
      tags:
      - Swap
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SwapDetailsResponse'
        404:
          description: Swap not found
components:
  schemas:
    SwapState:
      type: object
      description: State tracking for swap execution
      properties:
        interval:
          type: integer
          format: int64
          description: the interval for streaming swaps
        quantity:
          type: integer
          format: int64
          description: the number of swaps to execute
        ttl:
          type: integer
          format: int64
          description: time to live
        count:
          type: integer
          format: int64
          description: number of swaps executed
        last_height:
          type: integer
          format: int64
          description: last height when a swap was executed
        deposit:
          type: string
          description: total deposit amount
        withdrawn:
          type: string
          description: amount withdrawn
        in:
          type: string
          description: total amount swapped in
        out:
          type: string
          description: total amount swapped out
        failed_swaps:
          type: array
          items:
            type: integer
            format: int64
          description: list of failed swap indices
        failed_swap_reasons:
          type: array
          items:
            type: string
          description: reasons for failed swaps
    Tx:
      type: object
      required:
      - coins
      - gas
      properties:
        id:
          type: string
          example: CF524818D42B63D25BBA0CCC4909F127CAA645C0F9CD07324F2824CC151A64C7
        chain:
          type: string
          example: BTC
        from_address:
          type: string
          example: bcrt1q0s4mg25tu6termrk8egltfyme4q7sg3h8kkydt
        to_address:
          type: string
          example: bcrt1qf3s7q037eancht7sg0aj995dht25rwrnqsf45e
        coins:
          type: array
          items:
            $ref: '#/components/schemas/Coin'
        gas:
          type: array
          items:
            $ref: '#/components/schemas/Coin'
        memo:
          type: string
          example: ADD:BTC.BTC:thor1zupk5lmc84r2dh738a9g3zscavannjy3nzplwt
    MsgSwap:
      type: object
      required:
      - tx
      - target_asset
      - trade_target
      - affiliate_basis_points
      properties:
        tx:
          $ref: '#/components/schemas/Tx'
        target_asset:
          type: string
          example: ETH.ETH
          description: the asset to be swapped to
        destination:
          type: string
          example: '0x66fb1cd65b97fa40457b90b7d1ca6b92cb64b32b'
          description: the destination address to receive the swap output
        trade_target:
          type: string
          description: the minimum amount of output asset to receive (else cancelling and refunding the swap)
        affiliate_address:
          type: string
          example: thor1f3s7q037eancht7sg0aj995dht25rwrnu4ats5
          description: the affiliate address which will receive any affiliate fee
        affiliate_basis_points:
          type: string
          description: the affiliate fee in basis points
        signer:
          type: string
          description: the signer (sender) of the transaction
        aggregator:
          type: string
          description: the contract address if an aggregator is specified for a non-THORChain SwapOut
        aggregator_target_address:
          type: string
          description: the desired output asset of the aggregator SwapOut
        aggregator_target_limit:
          type: string
          description: the minimum amount of SwapOut asset to receive (else cancelling the SwapOut and receiving THORChain's output)
        swap_type:
          type: string
          description: market if immediately completed or refunded, limit if held until fulfillable
        stream_quantity:
          type: integer
          format: int64
          description: number of swaps to execute in a streaming swap
        stream_interval:
          type: integer
          format: int64
          description: the interval (in blocks) to execute the streaming swap
        initial_block_height:
          type: integer
          format: int64
          description: the initial block height when the streaming swap was first queued
        state:
          $ref: '#/components/schemas/SwapState'
        version:
          type: string
          description: the version of the swap (v1 or v2)
        index:
          type: integer
          format: int32
          description: the index of the swap in the batch
    Coin:
      type: object
      required:
      - asset
      - amount
      properties:
        asset:
          type: string
          example: BTC.BTC
        amount:
          type: string
          example: '100000'
        decimals:
          type: integer
          format: int64
          example: 6
    SwapDetailsResponse:
      type: object
      properties:
        swap:
          $ref: '#/components/schemas/MsgSwap'
        status:
          type: string
          description: Current status of the swap
          example: queued
        queue_type:
          type: string
          description: Type of queue the swap is in
          example: advanced
  parameters:
    queryHeight:
      name: height
      in: query
      description: optional block height, defaults to current tip
      required: false
      schema:
        type: integer
        format: int64
        minimum: 0