aftermath-ts-sdk - v3.3.3
    Preparing search index...

    The LimitOrders class manages creation, cancellation, and querying of limit orders on the Aftermath platform. Limit orders allow you to buy or sell at a specified price, giving more control over your trades compared to market execution.

    const afSdk = await Aftermath.create({ network: "MAINNET" });

    const limitOrders = afSdk.LimitOrders();

    Hierarchy (View Summary)

    Index
    config: CallerConfig

    The mutable configuration used for subsequent requests.

    constants: { gasAmount: bigint } = ...

    Static configuration constants, including a default gas amount for limit order transactions (50 SUI).

    Type Declaration

    • gasAmount: bigint

      The default gas budget for limit-order transactions, in MIST. 50_000_000n equals 0.05 SUI.

    • Sends a signed request to cancel one or more limit orders.

      Sign the exact string returned by UserData.createTermsAndConditionsMessage() as a personal message over its UTF-8 bytes. Send those signed bytes and the signature in inputs. The order IDs are sent in orderObjectIds; the deprecated per-action message from cancelLimitOrdersMessageToSign is not the current credential.

      Parameters

      Returns Promise<boolean>

      The backend cancellation result. false is a valid response.

      AftermathTransportError when the API request or response fails.

      const success = await limitOrders.cancelLimitOrder({
      walletAddress: "0x<address>",
      bytes: "0x<signed_bytes>",
      signature: "0x<signature>",
      });
    • Builds the legacy per-action message for canceling limit orders.

      This method performs no network I/O. The current cancellation endpoint authenticates with the canonical terms message instead. Put the order IDs in cancelLimitOrder's orderObjectIds field.

      Parameters

      • inputs: { orderIds: string[] }

        Object with orderIds, an array of order object IDs to cancel.

      Returns { action: string; order_object_ids: string[] }

      { action: "CANCEL_LIMIT_ORDERS", order_object_ids: inputs.orderIds }.

      af-fe no longer accepts this per-action message. Sign UserData.createTermsAndConditionsMessage and pass orderObjectIds in the cancelLimitOrder body instead.

    • Fetches the user's active limit orders from the Aftermath API.

      The bytes and signature fields authenticate the request. They are the signed terms-message credential, not a transaction or a limit-order cancellation payload.

      Parameters

      Returns Promise<LimitOrderObject[]>

      A promise resolving to an array of LimitOrderObject, representing the active orders.

      AftermathTransportError when the API request or response fails.

      const activeOrders = await limitOrders.getActiveLimitOrders({
      walletAddress: "0x<address>",
      bytes: "0x<signed_bytes>",
      signature: "0x<signature>"
      });
    • Requests a limit-order creation transaction from the Aftermath API. The returned Transaction is not signed or executed.

      Parameters

      Returns Promise<Transaction>

      A parsed Transaction with the wallet address set as its sender.

      AftermathTransportError when the API request, response decoding, or transaction parsing fails.

      const tx = await limitOrders.getCreateLimitOrderTx({
      walletAddress: "0x<address>",
      allocateCoinType: "0x<coin>",
      allocateCoinAmount: BigInt(1000),
      buyCoinType: "0x<other_coin>",
      expiryDurationMs: 3600000, // 1 hour
      outputToInputExchangeRate: 0.5,
      });
      // sign and execute the transaction
    • Fetches the minimum allowable limit-order size in USD.

      Returns Promise<number | undefined>

      A promise resolving to a number (USD value) or undefined if not configured.

      AftermathTransportError when the API request or response fails.

      const minSize = await limitOrders.getMinOrderSizeUsd();
      console.log("Minimum order size in USD:", minSize);
    • Fetches the user's past limit orders from the Aftermath API, including completed, canceled, expired, and failed orders.

      Parameters

      • inputs: { walletAddress: string }

        An object containing the walletAddress.

      Returns Promise<LimitOrderObject[]>

      A promise resolving to an array of LimitOrderObject representing past orders.

      AftermathTransportError when the API request or response fails.

      const pastOrders = await limitOrders.getPastLimitOrders({
      walletAddress: "0x<address>",
      });
    • Returns the canonical Aftermath API host for a Sui network.

      To target a custom or local host, pass baseUrl in CallerConfig to the constructor instead.

      Parameters

      • network: SuiNetwork

        The Sui network whose host to return.

      Returns string

      The network's HTTPS or local HTTP API host.