# Get Swap Status

## Details

Follow up the progress of a swap. 

You can do this either via a Deposit Channel or via the Swap id. Both are received from [Starting a Swap](https://docs.chainflip-broker.io/features/start-swap/).

A [deposit channel](https://docs.chainflip-broker.io/reference/glossary/#deposit-channel) is defined in the glossary.

Additionally, you can also get the status via the transaction hash of the deposit transaction.

A swap can have any of the following statuses:

* `waiting`
* `receiving`
* `swapping`
* `sending`
* `sent`
* `completed`
* `failed`

## API Endpoint

* [`/status-by-deposit-channel`](https://chainflip-broker.io/docs/ui/index.html#tag/Status/operation/getStatusByDepositChannel) - View status of a swap by deposit channel.
* [`/status-by-id`](https://chainflip-broker.io/docs/ui/index.html#tag/Status/operation/getStatusById) - View status of a swap by swap id.
* [`/status-by-transaction-hash`](https://chainflip-broker.io/docs/ui/index.html#tag/Status/operation/getStatusByTransactionHash) - View status of a swap by transaction hash. For a Polkadot Assethub deposit, pass either the `<block>-<extrinsicIndex>` reference shown in `deposit.transactionReference` or the 0x extrinsic hash your wallet shows; the extrinsic hash matches shortly after the deposit is witnessed. On every chain, a `0x` transaction hash matches in any letter case.

## Error Responses

When a status lookup returns HTTP `404` because the swap is unknown or its status is pending, the response is an [RFC 7807](https://www.rfc-editor.org/rfc/rfc7807) problem details object carrying a stable, machine-readable `code` next to the human-readable `detail`. Branch on the `code`, never on the `detail` text. `swap_pending` means the swap exists but its status is not available yet — poll again shortly. `swap_unknown` means no swap is recorded under your API key for that lookup key — usually a wrong key, but on a deposit transaction hash it can clear once the deposit has been witnessed on-chain, so retry with backoff and stop at your own deadline.

Other error responses, including input validation (`400`), invalid-partner (`401`), and unclassified failures (`500`), can omit `code`. Treat `code` as optional and fall back to the HTTP status when it is absent.

See [Error Codes](https://docs.chainflip-broker.io/features/error-codes/) for the full list and the handling rules.

```json
{
    "type": "https://tools.ietf.org/html/rfc9110#section-15.5.5",
    "title": "Not Found",
    "status": 404,
    "detail": "Swap '42' exists but its status is not available yet; poll again later.",
    "traceId": "00-2f0c3d9b1a5e4c7d8e9f0a1b2c3d4e5f-1a2b3c4d5e6f7a8b-00",
    "code": "swap_pending"
}
```

## Example - Status By Id

> **Tip**
>
> Want to test first? Change the API base URL to `https://perseverance.chainflip-broker.io`. The [Testing](https://docs.chainflip-broker.io/environments/testing/) environment swaps testnet assets with no real value.
>
> Swap the API key in the examples for your own [production API key](https://chainflip-broker.io/register). Testing requires a separate [testnet API key](https://perseverance.chainflip-broker.io/register).

Replace the lookup placeholders before running: use the BaaS swap id, or the `issuedBlock`/`network`/`channelId` tuple returned by your own [Starting a Swap](https://docs.chainflip-broker.io/features/start-swap/) call, or your actual deposit transaction hash — under the same API key and in the same environment you query. The identifiers in the example responses below are testnet captures; they do not match a swap made with a freshly registered key.

```bash
curl --location 'https://chainflip-broker.io/status-by-id?apiKey=87517a91d5f34dbabfc1e410946a3a3c&swapId=YOUR_SWAP_ID'
```

*Example response captured on the testing environment; response shape is identical on production. These values are illustrative, not output from the production request above.*

```json
{
  "id": 1,
  "status": {
    "state": "completed",
    "swapId": "1092",
    "sourceAsset": "usdc.eth",
    "destinationAsset": "usdc.arb",
    "destinationAddress": "0xdc009de550099fb68a85214dd41ed94eb9c99ca6",
    "depositChannel": {
      "id": "1288957-Ethereum-16",
      "createdAt": 1718109153304,
      "createdAtDate": "2024-06-11T12:32:33.304+00:00",
      "brokerCommissionBps": 5,
      "depositAddress": "0xa773bc9df8811ef0678094d9c2e6c5476b811f52",
      "sourceChainExpiryBlock": "6086102",
      "estimatedExpiryTime": 1718115318000,
      "estimatedExpiryDate": "2024-06-11T14:15:18+00:00",
      "isExpired": true,
      "openedThroughBackend": false,
      "affiliateBrokers": [
        {
          "account": "cFMTcq3p1C4Yhpw7NPn88Jdzj6ryVD8cTGPBuVMR4U6tFVdQb",
          "commissionBps": 10
        }
      ]
    },
    "estimatedDurationSeconds": 102.26,
    "sourceChainRequiredBlockConfirmations": 7,
    "fees": [
      {
        "type": "broker",
        "asset": "usdc.eth",
        "amountNative": "69148",
        "amount": 0.069148
      },
      {
        "type": "ingress",
        "asset": "usdc.eth",
        "amountNative": "3901634",
        "amount": 3.901634
      },
      {
        "type": "network",
        "asset": "usdc.eth",
        "amountNative": "46098",
        "amount": 0.046098
      },
      {
        "type": "egress",
        "asset": "usdc.arb",
        "amountNative": "711833",
        "amount": 0.711833
      },
      {
        "type": "liquidity",
        "asset": "usdc.eth",
        "amountNative": "46029",
        "amount": 0.046029
      }
    ],
    "deposit": {
      "amountNative": "50000000",
      "amount": 50,
      "witnessedAt": 1718109630000,
      "witnessedAtDate": "2024-06-11T12:40:30+00:00",
      "witnessedBlockIndex": "1289039-756"
    },
    "swap": {
      "originalInputAmountNative": "46029218",
      "originalInputAmount": 46.029218,
      "remainingInputAmountNative": "0",
      "remainingInputAmount": 0,
      "swappedInputAmountNative": "46029218",
      "swappedInputAmount": 46.029218,
      "swappedIntermediateAmountNative": "0",
      "swappedIntermediateAmount": 0,
      "swappedOutputAmountNative": "33973505",
      "swappedOutputAmount": 33.973505,
      "regular": {
        "inputAmountNative": "46029218",
        "inputAmount": 46.029218,
        "outputAmountNative": "33973505",
        "outputAmount": 33.973505,
        "scheduledAt": 1718109630000,
        "scheduledAtDate": "2024-06-11T12:40:30+00:00",
        "scheduledBlockIndex": "1289039-756",
        "executedAt": 1718109642000,
        "executedAtDate": "2024-06-11T12:40:42+00:00",
        "executedBlockIndex": "1289041-840",
        "retryCount": 0
      }
    },
    "swapEgress": {
      "amountNative": "33261672",
      "amount": 33.261672,
      "scheduledAt": 1718109642000,
      "scheduledAtDate": "2024-06-11T12:40:42+00:00",
      "scheduledBlockIndex": "1289041-841",
      "transactionReference": "0xa1a059961bbea44eafa3371d84e573f79e19be2b3216a4efd851a40d8ffc5338",
      "witnessedAt": 1718109780000,
      "witnessedBlockIndex": "1289064-591"
    }
  }
}
```

## Example - Status By Deposit Channel

```bash
curl --location 'https://chainflip-broker.io/status-by-deposit-channel?apiKey=87517a91d5f34dbabfc1e410946a3a3c&issuedBlock=YOUR_ISSUED_BLOCK&network=YOUR_NETWORK&channelId=YOUR_CHANNEL_ID'
```

*Example response captured on the testing environment; response shape is identical on production. These values are illustrative, not output from the production request above.*

```json
{
  "id": 1,
  "status": {
    "state": "completed",
    "swapId": "1092",
    "sourceAsset": "usdc.eth",
    "destinationAsset": "usdc.arb",
    "destinationAddress": "0xdc009de550099fb68a85214dd41ed94eb9c99ca6",
    "depositChannel": {
      "id": "1288957-Ethereum-16",
      "createdAt": 1718109153304,
      "createdAtDate": "2024-06-11T12:32:33.304+00:00",
      "brokerCommissionBps": 5,
      "depositAddress": "0xa773bc9df8811ef0678094d9c2e6c5476b811f52",
      "sourceChainExpiryBlock": "6086102",
      "estimatedExpiryTime": 1718115318000,
      "estimatedExpiryDate": "2024-06-11T14:15:18+00:00",
      "isExpired": true,
      "openedThroughBackend": false,
      "affiliateBrokers": [
        {
          "account": "cFMTcq3p1C4Yhpw7NPn88Jdzj6ryVD8cTGPBuVMR4U6tFVdQb",
          "commissionBps": 10
        }
      ]
    },
    "estimatedDurationSeconds": 102.26,
    "sourceChainRequiredBlockConfirmations": 7,
    "fees": [
      {
        "type": "broker",
        "asset": "usdc.eth",
        "amountNative": "69148",
        "amount": 0.069148
      },
      {
        "type": "ingress",
        "asset": "usdc.eth",
        "amountNative": "3901634",
        "amount": 3.901634
      },
      {
        "type": "network",
        "asset": "usdc.eth",
        "amountNative": "46098",
        "amount": 0.046098
      },
      {
        "type": "egress",
        "asset": "usdc.arb",
        "amountNative": "711833",
        "amount": 0.711833
      },
      {
        "type": "liquidity",
        "asset": "usdc.eth",
        "amountNative": "46029",
        "amount": 0.046029
      }
    ],
    "deposit": {
      "amountNative": "50000000",
      "amount": 50,
      "witnessedAt": 1718109630000,
      "witnessedAtDate": "2024-06-11T12:40:30+00:00",
      "witnessedBlockIndex": "1289039-756"
    },
    "swap": {
      "originalInputAmountNative": "46029218",
      "originalInputAmount": 46.029218,
      "remainingInputAmountNative": "0",
      "remainingInputAmount": 0,
      "swappedInputAmountNative": "46029218",
      "swappedInputAmount": 46.029218,
      "swappedIntermediateAmountNative": "0",
      "swappedIntermediateAmount": 0,
      "swappedOutputAmountNative": "33973505",
      "swappedOutputAmount": 33.973505,
      "regular": {
        "inputAmountNative": "46029218",
        "inputAmount": 46.029218,
        "outputAmountNative": "33973505",
        "outputAmount": 33.973505,
        "scheduledAt": 1718109630000,
        "scheduledAtDate": "2024-06-11T12:40:30+00:00",
        "scheduledBlockIndex": "1289039-756",
        "executedAt": 1718109642000,
        "executedAtDate": "2024-06-11T12:40:42+00:00",
        "executedBlockIndex": "1289041-840",
        "retryCount": 0
      }
    },
    "swapEgress": {
      "amountNative": "33261672",
      "amount": 33.261672,
      "scheduledAt": 1718109642000,
      "scheduledAtDate": "2024-06-11T12:40:42+00:00",
      "scheduledBlockIndex": "1289041-841",
      "transactionReference": "0xa1a059961bbea44eafa3371d84e573f79e19be2b3216a4efd851a40d8ffc5338",
      "witnessedAt": 1718109780000,
      "witnessedBlockIndex": "1289064-591"
    }
  }
}
```

## Example - Status By Transaction Hash

```bash
curl --location 'https://chainflip-broker.io/status-by-transaction-hash?apiKey=87517a91d5f34dbabfc1e410946a3a3c&transactionHash=YOUR_DEPOSIT_TRANSACTION_HASH'
```

*Example response captured on the testing environment; response shape is identical on production. These values are illustrative, not output from the production request above.*

```json
{
    "id": 214,
    "status": {
        "state": "completed",
        "swapId": "2194",
        "sourceAsset": "eth.eth",
        "destinationAsset": "dot.hub",
        "destinationAddress": "1BzDB5n2rfSJwvuCW9deKY9XnUyys8Gy44SoX8tRNDCFBhx",
        "depositChannel": {
            "id": "2294832-Ethereum-12",
            "createdAt": 1724242789342,
            "createdAtDate": "2024-08-21T12:19:49.342+00:00",
            "brokerCommissionBps": 5,
            "depositAddress": "0xdc91b85ebd6e2618a38fc97eb241231fe0d811ae",
            "sourceChainExpiryBlock": "6543609",
            "estimatedExpiryTime": 1724248962000,
            "estimatedExpiryDate": "2024-08-21T14:02:42+00:00",
            "isExpired": true,
            "openedThroughBackend": false,
            "affiliateBrokers": [
                {
                    "account": "cFMTcq3p1C4Yhpw7NPn88Jdzj6ryVD8cTGPBuVMR4U6tFVdQb",
                    "commissionBps": 10
                }
            ]
        },
        "estimatedDurationSeconds": 108,
        "sourceChainRequiredBlockConfirmations": 7,
        "fees": [
            {
                "type": "broker",
                "asset": "eth.eth",
                "amountNative": "11574402976725",
                "amount": 0.000011574402976725
            },
            {
                "type": "ingress",
                "asset": "eth.eth",
                "amountNative": "2283731348850000",
                "amount": 0.00228373134885
            },
            {
                "type": "network",
                "asset": "usdc.eth",
                "amountNative": "78319",
                "amount": 0.078319
            },
            {
                "type": "liquidity",
                "asset": "usdc.eth",
                "amountNative": "1564",
                "amount": 0.001564
            },
            {
                "type": "egress",
                "asset": "dot.hub",
                "amountNative": "197450000",
                "amount": 0.019745
            },
            {
                "type": "liquidity",
                "asset": "eth.eth",
                "amountNative": "3852347124087",
                "amount": 0.000003852347124087
            }
        ],
        "deposit": {
            "amountNative": "10000000000000000",
            "amount": 0.01,
            "transactionReference": "0xd15c8b27a8cbb6ed098227d6fd07812ca0bfc207e8986175e772984da43a7c95",
            "witnessedAt": 1724242890000,
            "witnessedAtDate": "2024-08-21T12:21:30+00:00",
            "witnessedBlockIndex": "2294851-900"
        },
        "swap": {
            "originalInputAmountNative": "7704694248173275",
            "originalInputAmount": 0.007704694248173275,
            "remainingInputAmountNative": "0",
            "remainingInputAmount": 0,
            "swappedInputAmountNative": "7704694248173275",
            "swappedInputAmount": 0.007704694248173275,
            "swappedIntermediateAmountNative": "78240741",
            "swappedIntermediateAmount": 78.240741,
            "swappedOutputAmountNative": "89499099997",
            "swappedOutputAmount": 8.9499099997,
            "regular": {
                "inputAmountNative": "7704694248173275",
                "inputAmount": 0.007704694248173275,
                "intermediateAmountNative": "78240741",
                "intermediateAmount": 78.240741,
                "outputAmountNative": "89499099997",
                "outputAmount": 8.9499099997,
                "scheduledAt": 1724242890000,
                "scheduledAtDate": "2024-08-21T12:21:30+00:00",
                "scheduledBlockIndex": "2294851-900",
                "executedAt": 1724242902001,
                "executedAtDate": "2024-08-21T12:21:42.001+00:00",
                "executedBlockIndex": "2294853-751",
                "retryCount": 0
            }
        },
        "swapEgress": {
            "amountNative": "89301649997",
            "amount": 8.9301649997,
            "scheduledAt": 1724242902001,
            "scheduledAtDate": "2024-08-21T12:21:42.001+00:00",
            "scheduledBlockIndex": "2294853-752",
            "transactionReference": "5141384-2",
            "witnessedAt": 1724243052000,
            "witnessedBlockIndex": "2294877-573"
        }
    }
}
```
