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

One of the following:

string

The response will include the following:

interface CommonStatusFields {
  srcChain: Chain;
  destChain: Chain;
  srcAsset: Asset;
  destAsset: Asset;
  destAddress: string;
  depositAddress: string;
  expectedDepositAmount: string;
}
 
export type SwapStatusResponse = CommonStatusFields &
  (
    | { state: "AWAITING_DEPOSIT" }
    | {
        state: "DEPOSIT_RECEIVED";
        depositAmount: string;
        depositReceivedAt: number;
        depositReceivedBlockIndex: string;
      }
    | {
        state: "SWAP_EXECUTED";
        depositAmount: string;
        depositReceivedAt: number;
        depositReceivedBlockIndex: string;
        intermediateAmount: string | undefined;
        swapExecutedAt: number;
        swapExecutedBlockIndex: string;
      }
    | {
        state: "EGRESS_SCHEDULED";
        depositAmount: string;
        depositReceivedAt: number;
        depositReceivedBlockIndex: string;
        intermediateAmount: string | undefined;
        swapExecutedAt: number;
        swapExecutedBlockIndex: string;
        egressAmount: string;
        egressScheduledAt: number;
        egressScheduledBlockIndex: string;
      }
    | {
        state: "BROADCAST_REQUESTED";
        depositAmount: string;
        depositReceivedAt: number;
        depositReceivedBlockIndex: string;
        intermediateAmount: string | undefined;
        swapExecutedAt: number;
        swapExecutedBlockIndex: string;
        egressAmount: string;
        egressScheduledAt: number;
        egressScheduledBlockIndex: string;
        broadcastRequestedAt: number;
        broadcastRequestedBlockIndex: string;
      }
    | {
        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;
      }
    | {
        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",
  "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"
}
;