Reading Data

Query market state, pool data, and credit account information using the SDK.

For Solidity pool operations, see Pool Operations.

Market Data via marketRegister

The marketRegister provides cached access to all Gearbox markets:

import { GearboxSDK } from '@gearbox-protocol/sdk';

const sdk = await GearboxSDK.attach({ client, marketConfigurators: [] });

// All markets
const markets = sdk.marketRegister.markets;

// Find specific market
const market = sdk.marketRegister.findByPool(poolAddress);
// or
const market = sdk.marketRegister.findByCreditManager(cmAddress);

// Access market components
console.log(`Pool: ${market.pool.address}`);
console.log(`Available liquidity: ${market.pool.availableLiquidity}`);
console.log(`Diesel rate: ${market.pool.dieselRate}`);
console.log(`Supply rate: ${market.pool.supplyRate}`);
console.log(`Credit managers: ${market.creditManagers.length}`);

Pool State

Access pool data through the market object:

Credit Manager Data

Access credit manager configuration:

Real-Time Data via Compressors

The SDK caches data on initialization. For real-time data, use compressors directly:

Filtering Markets

Query markets by criteria:

Price Oracle Data

Access price information through the market:

Complete Example

Next Steps

For architectural background, see Pool Architecture.

Last updated