Fetches orders that were added in a specific transaction
Retrieves all orders created within a single blockchain transaction, useful for tracking order deployment.
const result = await client.getAddOrdersForTransaction(1, "0x1234567890abcdef1234567890abcdef12345678");
if (result.error) {
console.error("Cannot fetch added orders:", result.error.readableMsg);
return;
}
const orders = result.value;
// Do something with orders
Chain ID for the network
Orderbook contract address
Transaction hash
Array of orders added in the transaction
Retrieves all accounts from the orderbook YAML configuration
Returns a map of account configurations where the keys are account names
and the values are AccountCfg objects containing account details.
const result = client.getAllAccounts();
if (result.error) {
console.error("Error getting accounts:", result.error.readableMsg);
return;
}
const accounts = result.value;
for (const [name, account] of accounts) {
console.log(`Account name: ${name}, Address: ${account.address}`);
}
Returns the list of accounts from the orderbook YAML configuration.
Retrieves all available networks with their configurations
Returns a comprehensive map of all network configurations available in the orderbook YAML. Each entry contains detailed network information including RPC endpoints and chain-specific settings.
const result = client.getAllNetworks();
if (result.error) {
console.error("Error getting networks:", result.error.readableMsg);
return;
}
const networks = result.value;
for (const [key, config] of networks) {
console.log(`Network key: ${key}, Chain ID: ${config.chainId}`);
}
Returns a map of all available networks with their configurations. Keys are network names, values are NetworkCfg objects.
Fetches all unique tokens that exist in vaults.
Retrieves all unique ERC20 tokens that have associated vaults by querying all vaults and extracting their token information, removing duplicates.
const result = await client.getAllVaultTokens();
if (result.error) {
console.error("Error fetching tokens:", result.error.readableMsg);
return;
}
const tokens = result.value;
console.log(`Found ${tokens.length} unique tokens`);
console.log(`Token ${tokens[0].name} in ${tokens[0].chainId}`);
OptionalchainIds: null | ChainIdsSpecific networks to query (optional)
Array of raindex vault token instances
Retrieves network configuration for a specific chain ID
Finds and returns the network configuration that matches the provided chain ID. This is useful when you need to access network-specific settings like RPC URLs.
const result = client.getNetworkByChainId(1); // Ethereum mainnet
if (result.error) {
console.error("Network not found:", result.error.readableMsg);
return;
}
const networkConfig = result.value;
console.log(`Found network: ${networkConfig}`);
The blockchain network ID to retrieve the configuration for
Returns the configuration for a specific network identified by its chain ID
Retrieves orderbook configuration by contract address
Finds and returns the orderbook configuration that matches the provided contract address. This allows you to access orderbook-specific settings including subgraph endpoints, network information, and other details.
const result = client.getOrderbookByAddress("0x1234567890123456789012345678901234567890");
if (result.error) {
console.error("Orderbook not found:", result.error.readableMsg);
return;
}
const orderbookConfig = result.value;
console.log(`Found orderbook ${orderbookConfig}`);
The address of the orderbook to retrieve the configuration for
Returns the configuration for a specific orderbook identified by its address
Retrieves a specific order by its hash from a particular blockchain network
Fetches complete order details including all vault information, metadata, and performance tracking capabilities for a specific order identified by its hash.
const result = await client.getOrderByHash(
137, // Polygon network
"0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
);
if (result.error) {
console.error("Error fetching order:", result.error.readableMsg);
return;
}
const order = result.value;
// Do something with order
The blockchain network ID where the order exists
Orderbook contract address
The unique hash identifier of the order
Complete order details with vault and metadata information
Queries orders with filtering and pagination across configured networks
Retrieves a list of orders from the specified network or all configured networks, with support for filtering by owner, status, and order hash. Results are paginated for efficient data retrieval.
const result = await client.getOrders(
137, // Polygon network
{
owners: ["0x1234567890abcdef1234567890abcdef12345678"],
active: true
},
1
);
if (result.error) {
console.error("Error fetching orders:", result.error.readableMsg);
return;
}
const orders = result.value;
// Do something with orders
OptionalchainIds: null | ChainIdsSpecific blockchain network to query (optional, queries all networks if not specified)
Optionalfilters: null | GetOrdersFiltersFiltering criteria including owners, active status, and order hash (optional)
Optionalpage: null | numberPage number for pagination (optional, defaults to 1)
Array of raindex order instances
Fetches orders that were removed in a specific transaction
Retrieves all orders cancelled or removed within a single blockchain transaction.
const result = await client.getRemoveOrdersForTransaction(1, "0x1234567890abcdef1234567890abcdef12345678");
if (result.error) {
console.error("Cannot fetch removed orders:", result.error.readableMsg);
return;
}
const orders = result.value;
// Do something with orders
Chain ID for the network
Orderbook contract address
Transaction hash
Array of orders removed in the transaction
Fetches transaction details for a given transaction hash
Retrieves basic transaction information including sender, block number, and timestamp.
const result = await client.getTransaction(
"0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
);
if (result.error) {
console.error("Transaction not found:", result.error.readableMsg);
return;
}
const transaction = result.value;
// Do something with the transaction
Orderbook contract address
Transaction hash
Transaction details
Retrieves a list of unique chain IDs from all configured networks
Extracts and returns all unique blockchain network chain IDs that are available in the current orderbook configuration.
const result = client.getUniqueChainIds();
if (result.error) {
console.error("Error getting chain IDs:", result.error.readableMsg);
return;
}
const chainIds = result.value;
console.log("Available chains:", chainIds);
Returns a list of unique chain IDs from all available networks.
Fetches detailed information for a specific vault
Retrieves complete vault information including token details, balance, etc.
const result = await client.getVault(
137, // Polygon network
"0x1234567890abcdef1234567890abcdef12345678"
);
if (result.error) {
console.error("Vault not found:", result.error.readableMsg);
return;
}
const vault = result.value;
// Do something with the vault
Chain ID of the network the vault is on
Orderbook contract address
Unique vault identifier
Complete vault information
Fetches vault data from multiple subgraphs across different networks
Queries multiple subgraphs simultaneously to retrieve vault information across different networks.
const result = await client.getVaults(
{
owners: ["0x1234567890abcdef1234567890abcdef12345678"],
hide_zero_balance: true
},
);
if (result.error) {
console.error("Error fetching vaults:", result.error.readableMsg);
return;
}
const vaults = result.value;
// Do something with the vaults
OptionalchainIds: null | ChainIdsSpecific networks to query (optional)
Optionalfilters: null | GetVaultsFiltersOptional filtering options including owners and hide_zero_balance
Optionalpage: null | numberOptional page number (defaults to 1)
Array of raindex vault instances
Checks if Sentry error tracking is enabled in the YAML configuration
Returns true if Sentry is enabled, otherwise returns false.
const isEnabled = client.isSentryEnabled();
if (isEnabled.error) {
console.error("Error checking Sentry status:", isEnabled.error.readableMsg);
return;
}
console.log("Is Sentry enabled?", isEnabled.value);
Returns whether Sentry is enabled in the YAML configuration.
JavaScript function to execute local database queries
Full settings YAML string used by the client runner
OptionalstatusCallback: null | FunctionOptional callback invoked with the current local DB status
StaticnewConstructor that creates and returns RaindexClient instance directly
// Single YAML file
const result = await RaindexClient.new([yamlConfig]);
if (result.error) {
console.error("Init failed:", result.error.readableMsg);
return;
}
const client = result.value;
// Multiple YAML files (for modular configuration)
const result = await RaindexClient.new([networksYaml, orderbooksYaml, tokensYaml]);
List of YAML configuration strings. The YAML files must match the orderbook yaml spec
Optionalvalidate: null | booleanInitialized client instance for further operations
RaindexClient provides a simplified interface for querying orderbook data across multiple networks with automatic configuration management.
This client abstracts away complex network-specific configurations by parsing YAML configuration files that define networks, tokens, orderbooks, and subgraph endpoints. It enables querying orderbook data either from specific chains or across all configured networks with automatic fallback mechanisms.
The client handles:
Examples