Integration
Swapping and Aggregation
Javascript SDK
Get Status

Get Status

getStatus

Fetches the status of an ongoing swap based on the provided swapStatusRequest argument.

getStatus(
  swapStatusRequest: SwapStatusRequest,
  options?: RequestOptions
): Promise<SwapStatusResponse>

The SwapStatusRequest object includes the following arguments:

ParamDescriptionData type
id(required)

One of the following:

string

The response will include the following:

interface SwapFee {
  type: 'LIQUIDITY' | 'NETWORK' | 'INGRESS' | 'EGRESS' | 'BROKER';
  chain: Chain;
  asset: Asset;
  amount: string;
}
 
interface CommonStatusFields {
  srcChain: Chain;
  destChain: Chain;
  srcAsset: Asset;
  destAsset: Asset;
  destAddress: string | undefined;
  depositAddress: string | undefined;
  depositChannelBrokerCommissionBps: number | undefined;
  estimatedDepositChannelExpiryTime: number | undefined;
  expectedDepositAmount: string | undefined;
  isDepositChannelExpired: boolean;
  ccmDepositReceivedBlockIndex: string | undefined;
  ccmMetadata: {
      gasBudget: string;
      message: `0x${string}`;
  } | undefined;
  feesPaid: SwapFee[];
}
 
export type SwapStatusResponse = CommonStatusFields &
  (
    | {
        // we are waiting for the user to send funds
        state: 'AWAITING_DEPOSIT';
        depositAmount: string | undefined;
        depositTransactionConfirmations: number | undefined;
      }
    | {
        // funds have been received and the swap is being performed
        state: 'DEPOSIT_RECEIVED';
        depositAmount: string;
        depositReceivedAt: number;
        depositReceivedBlockIndex: string;
      }
    | {
        // funds have been swapped through the AMM and awaiting scheduling
        state: 'SWAP_EXECUTED';
        depositAmount: string;
        depositReceivedAt: number;
        depositReceivedBlockIndex: string;
        intermediateAmount: string | undefined;
        swapExecutedAt: number;
        swapExecutedBlockIndex: string;
      }
    | {
        // funds have been scheduled to be sent to the destination address
        state: 'EGRESS_SCHEDULED';
        depositAmount: string;
        depositReceivedAt: number;
        depositReceivedBlockIndex: string;
        intermediateAmount: string | undefined;
        swapExecutedAt: number;
        swapExecutedBlockIndex: string;
        egressAmount: string;
        egressScheduledAt: number;
        egressScheduledBlockIndex: string;
      }
    | {
        state:
          // a validator has been requested to send the funds
          | "BROADCAST_REQUESTED"
          // the transaction has been included in a block on the destination chain
          | "BROADCASTED";
        depositAmount: string;
        depositReceivedAt: number;
        depositReceivedBlockIndex: string;
        intermediateAmount: string | undefined;
        swapExecutedAt: number;
        swapExecutedBlockIndex: string;
        egressAmount: string;
        egressScheduledAt: number;
        egressScheduledBlockIndex: string;
        broadcastRequestedAt: number;
        broadcastRequestedBlockIndex: string;
      }
    | {
        // the transaction could not be successfully completed
        state: 'BROADCAST_ABORTED';
        depositAmount: string;
        depositReceivedAt: number;
        depositReceivedBlockIndex: string;
        intermediateAmount: string | undefined;
        swapExecutedAt: number;
        swapExecutedBlockIndex: string;
        egressAmount: string;
        egressScheduledAt: number;
        egressScheduledBlockIndex: string;
        broadcastRequestedAt: number;
        broadcastRequestedBlockIndex: string;
        broadcastAbortedAt: number;
        broadcastAbortedBlockIndex: string;
      }
    | {
        // the transaction has been confirmed beyond our safety margin
        state: 'COMPLETE';
        depositAmount: string;
        depositReceivedAt: number;
        depositReceivedBlockIndex: string;
        intermediateAmount: string | undefined;
        swapExecutedAt: number;
        swapExecutedBlockIndex: string;
        egressAmount: string;
        egressScheduledAt: number;
        egressScheduledBlockIndex: string;
        broadcastRequestedAt: number;
        broadcastRequestedBlockIndex: string;
        broadcastSucceededAt: number;
        broadcastSucceededBlockIndex: string;
      }
  );

Example

Here is an example using Request Deposit Address:

const swapStatusRequest = {
  id: "1234567890", // depositChannelId or transactionHash
};
 
console.log(await swapSDK.getStatus(swapStatusRequest));

Sample Response

{
  "broadcastAbortedBlockIndex": null,
  "broadcastRequestedAt": 1669907147201,
  "broadcastRequestedBlockIndex": "202-4",
  "broadcastSucceededAt": 1669907153201,
  "broadcastSucceededBlockIndex": "204-4",
  "depositAddress": "0x6Aa69332B63bB5b1d7Ca5355387EDd5624e181F2",
  "depositAmount": "1000000000000",
  "ccmMetadata": {
    "gasBudget": "100000000000",
    "message": "0x436861696e666c697020526f636b73"
  },
  "depositReceivedAt": 1669907135201,
  "depositReceivedBlockIndex": "100-3",
  "destAddress": "5F3sa2TJAWMqDhXG6jhV4N8ko9SxwGy8TpaNS1repo5EYjQX",
  "destAsset": "DOT",
  "destChain": "Polkadot",
  "egressAmount": "1000000000000000000",
  "egressScheduledAt": 1669907147201,
  "egressScheduledBlockIndex": "202-3",
  "expectedDepositAmount": "10000000000",
  "intermediateAmount": "20000000",
  "srcAsset": "ETH",
  "srcChain": "Ethereum",
  "state": "COMPLETE",
  "swapExecutedAt": 1669907141201,
  "swapExecutedBlockIndex": "200-3"
}

Lifecycle of a Swap


;