SDK Namespaces
The SDK vNext organizes its API into purpose-built namespaces. Each namespace groups related methods so you can discover, analyze, and execute without navigating raw contract state.
Namespace Reference
| Namespace | Purpose |
|---|---|
sdk.chains | Multi-chain configuration — list supported chains, resolve RPC endpoints, check chain health |
sdk.opportunities | Unified discovery surface — search across all opportunity types (pools, strategies, markets) in one call |
sdk.pools | Pool-specific queries — list pools, get detail, check utilization, interest rates, and available liquidity |
sdk.strategies | Strategy-specific queries — list strategies, get detail, inspect adapters and leverage ranges |
sdk.markets | X-interface style markets — unified market view combining supply and borrow sides, useful for P2P and intent flows |
sdk.tokens | Token profiles and market data — prices, metadata, risk parameters, and enrichment info |
sdk.curators | Curator profiles and reputation — who manages which Credit Managers, track record, parameters |
sdk.history | Metric history time series — APY over time, utilization, TVL, and other historical data points |
sdk.events | Parameter changes and governance — feed of configuration updates, rate changes, and governance actions |
sdk.positions | Position lifecycle — deposit, open, adjust, close, and monitor Credit Account positions |
sdk.trades | Quote and routing — get swap quotes, compare routes, preview trade outcomes |
sdk.transactions | Final execution — submit prepared transactions, track confirmation, handle MEV protection |
Runtime Modes
The SDK operates in one of two runtime modes depending on backend availability:
Core-Only — works without a backend connection. Supports chain reads, transaction building, simulation, execution, and current position status. Limited for history, profiles, APY enrichment, and snapshots.
Enriched — available when the Gearbox backend is configured and healthy. Adds opportunity surfaces, historical data, curator/token profiles, points and APY enrichment, and fast bootstrap via startFromCache.
import { GearboxSDK } from "@gearbox-protocol/sdk/official"; // Enriched mode (default) — uses backend at api.gearbox.fi const sdk = new GearboxSDK(); // Core-only mode — no backend dependency const sdk = new GearboxSDK({ backend: false });
Loading Modes
Two loading strategies control how aggressively the SDK fetches state:
Lazy (default) — no heavy state load on startup. Each query fetches only what it needs. Best for frontend screens, agent queries, and partial usage.
Full-State — loads broad chain state upfront. Best for dense workflows, advanced analysis, and fast repeated navigation after the initial bootstrap.
// Lazy loading (default) await sdk.loadState({ mode: "lazy" }); // Full-state loading await sdk.loadState({ mode: "full-state" });
Both modes coexist — you can start lazy and switch to full-state later if your workflow demands it.
Learn More
- Getting Started — TypeScript SDK — installation and bootstrap
- Opportunities — discover yield across all types
- Lender (Pools) — pool queries and deposits
- Positions (Strategies) — open and manage leveraged positions