Raindex SDK Documentation
    Preparing search index...

    Class RaindexOrder

    A single order representation within a given orderbook.

    RaindexOrder represents a trading order on a specific blockchain with its associated input and output vaults, metadata, and performance tracking capabilities. Each order is deployed on a specific orderbook contract and can be queried for volume and performance metrics over time.

    The order contains both the raw order data (bytes and hash) and structured access to its vaults, which define what tokens can be traded and their current balances.

    Index

    Properties

    active: boolean
    chainId: number
    id: `0x${string}`
    inputsList: RaindexVaultsList
    inputsOutputsList: RaindexVaultsList
    meta: undefined | `0x${string}`
    orderbook: `0x${string}`
    orderBytes: `0x${string}`
    orderHash: `0x${string}`
    outputsList: RaindexVaultsList
    owner: `0x${string}`
    rainlang: undefined | string
    timestampAdded: bigint
    tradesCount: number
    transaction: undefined | RaindexTransaction
    vaultsList: RaindexVaultsList

    Methods

    • Converts the order from RaindexOrder to an SgOrder type

      const sgOrder = await order.convertToSgOrder();
      // Do something with sgOrder

      Returns WasmEncodedResult<SgOrder>

      Order as SgOrder type

    • Returns void

    • Executes quotes directly from complete order objects without additional data fetching

      This function performs quote calculations using complete order data structures that typically come from previous subgraph queries. It generates quotes for all possible input/output token pairs within each order, providing comprehensive trading information without requiring additional network calls for order data.

      const result = await getOrderQuote();
      if (result.error) {
      console.error("Error:", result.error.readableMsg);
      return;
      }
      const quoteResponses = result.value;
      // Do something with the quoteResponses

      Parameters

      • OptionalblockNumber: null | bigint

        Optional specific block number for historical quotes (uses latest if None)

      • Optionalgas: null | string

        Optional gas limit as string for quote simulations (uses default if None)

      Returns Promise<WasmEncodedResult<RaindexOrderQuote[]>>

      List of batch quote responses with trading pair information

    • Generates ABI-encoded calldata for the removeOrder2() function on the orderbook contract

      Takes an existing order from the subgraph and creates the transaction calldata needed to remove it from the orderbook. The order must be active and owned by the caller.

      // Generate calldata for removing an order
      const result = await order.getRemoveCalldata();
      if (result.error) {
      console.error('Failed:', result.error.readableMsg);
      } else {
      const calldata = result.value;
      // Do something with the calldata
      }

      Returns WasmEncodedResult<`0x${string}`>

      ABI-encoded calldata ready for blockchain submission

    • Counts total trades for an order within a time range

      Efficiently counts the total number of trades executed by an order without fetching all trade details.

      const result = await order.getTradeCount();
      if (result.error) {
      console.error("Cannot count trades:", result.error.readableMsg);
      return;
      }
      const count = result.value;
      // Do something with the count

      Parameters

      • OptionalstartTimestamp: null | bigint

        Optional start time filter (Unix timestamp in seconds)

      • OptionalendTimestamp: null | bigint

        Optional end time filter (Unix timestamp in seconds)

      Returns Promise<WasmEncodedResult<number>>

      Total trade count as number

    • Fetches detailed information for a specific trade

      Retrieves complete information about a single trade including vault changes and transaction details.

      const result = await order.getTradeDetail("0x1234567890abcdef1234567890abcdef12345678");
      if (result.error) {
      console.error("Trade not found:", result.error.readableMsg);
      return;
      }
      const trade = result.value;
      // Do something with the trade

      Parameters

      • tradeId: `0x${string}`

        Unique trade identifier

      Returns Promise<WasmEncodedResult<RaindexTrade>>

      Complete trade information

    • Fetches trade history with optional time filtering

      Retrieves a chronological list of trades executed by an order within an optional time range.

      const result = await order.getTradesList();
      if (result.error) {
      console.error("Cannot fetch trades:", result.error.readableMsg);
      return;
      }
      const trades = result.value;
      // Do something with the trades

      Parameters

      • OptionalstartTimestamp: null | bigint

        Optional start time filter (Unix timestamp in seconds)

      • OptionalendTimestamp: null | bigint

        Optional end time filter (Unix timestamp in seconds)

      • Optionalpage: null | number

        Optional page number (defaults to 1)

      Returns Promise<WasmEncodedResult<RaindexTrade[]>>

      Array of trade records with complete details