Function cancelOrder

  • Cancels specified open order if the order is not fully filled. [IMPORTANT] Set ApprovalForAll before calling this function.

    Parameters

    • __namedParameters: {
          chainId: CHAIN_IDS;
          userAddress: `0x${string}`;
          id: string;
          options?: DefaultOptions & {
              gasLimit?: bigint;
              gasPriceLimit?: bigint;
          } & {
              useSubgraph?: boolean;
          };
      }
      • chainId: CHAIN_IDS
      • userAddress: `0x${string}`
      • id: string
      • Optional options?: DefaultOptions & {
            gasLimit?: bigint;
            gasPriceLimit?: bigint;
        } & {
            useSubgraph?: boolean;
        }

    Returns Promise<{
        transaction: Transaction;
        result: CurrencyFlow;
    }>

    Promise resolving to the transaction object representing the cancel action with the result of the order.

    Throws

    Throws an error if no open orders are found for the specified user.

    Example

    import { getOpenOrders, cancelOrders } from '@clober/v2-sdk'

    const openOrders = await getOpenOrders({
    chainId: 421614,
    userAddress:'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0'
    })
    const transaction = await cancelOrders({
    chainId: 421614,
    userAddress: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
    id: openOrders.map((order) => order.id)
    })