ReadonlyactiveReadonlychainReadonlydotrainReadonlydotrainReadonlyidReadonlyinputsReadonlyinputsReadonlymetaReadonlyoracleReturns the signed context oracle URL if this order has oracle metadata.
ReadonlyorderbookReadonlyorderReadonlyorderReadonlyoutputsReadonlyownerReadonlyparsedReadonlyrainlangReadonlytimestampReadonlytradesReadonlytransactionReadonlyvaultsConverts the order from RaindexOrder to an SgOrder type
const sgOrder = await order.convertToSgOrder();
// Do something with sgOrder
Order as SgOrder type
Quote for the order pair
True if buying output token, false if selling input token
Amount as decimal string
Estimated spend/receive amounts and partial fill indicator
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
OptionalblockNumber: null | bigintOptional specific block number for historical quotes (uses latest if None)
OptionalchunkSize: null | numberOptional quote chunk size override (defaults to 16)
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
}
ABI-encoded calldata ready for blockchain submission
Generates calldata for IOrderBookV6.takeOrders4 targeting this specific order.
Unlike getTakeOrdersCalldata on RaindexClient which discovers orders from the subgraph,
this method generates calldata for taking this single known order that the user has already
selected. The method fetches a fresh quote at execution time using the provided pair indices.
This method includes preflight simulation to validate the transaction will succeed.
Parameters:
inputIndex: Index of the input token in the order's validInputs arrayoutputIndex: Index of the output token in the order's validOutputs arraytaker: Address of the account that will execute the takeOrders transactionmode: One of buyExact, buyUpTo, spendExact, or spendUpToamount: Target amount (output tokens for buy modes, input tokens for spend modes)priceCap: human-readable decimal string for max sell per 1 buyReturns calldata plus pricing info:
calldata: ABI-encoded bytes for takeOrders4.effectivePrice: expected blended sell per 1 buy from the simulation.prices: per-leg ratios (single entry for this order).expectedSell: simulated sell at current quotes.maxSellCap: worst-case on-chain spend cap.const res = await order.getTakeCalldata(
0, // inputIndex
0, // outputIndex
"0xTAKER...",
"buyUpTo",
"10",
"1.2",
);
if (res.error) {
console.error(res.error.readableMsg);
} else {
const { calldata, effectivePrice, expectedSell, maxSellCap, prices, orderbook } = res.value;
}
Index of the input token in the order's validInputs array
Index of the output token in the order's validOutputs array
Address of the taker account
Take orders mode: buyExact, buyUpTo, spendExact, or spendUpTo
Target amount as decimal string
Maximum price cap as decimal string
Encoded takeOrders4 calldata and price information for this order
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
OptionalstartTimestamp: null | bigintOptional start time filter (Unix timestamp in seconds)
OptionalendTimestamp: null | bigintOptional end time filter (Unix timestamp in seconds)
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
Unique trade identifier
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
OptionalstartTimestamp: null | bigintOptional start time filter (Unix timestamp in seconds)
OptionalendTimestamp: null | bigintOptional end time filter (Unix timestamp in seconds)
Optionalpage: null | numberOptional page number (defaults to 1)
Array of trade records with complete details
OptionalstartTimestamp: null | bigintUnix timestamp for the start of the query period (optional)
OptionalendTimestamp: null | bigintUnix timestamp for the end of the query period (optional)
Volume data for each vault over the specified period
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.