Overview
The Gearbox SDK provides typed access to protocol state and operations. It wraps contract calls, handles encoding, and provides cached market data through a clean TypeScript interface.
Prerequisites
- Node.js 18+
- Basic familiarity with viem
- Understanding of async/await patterns
What the SDK Provides
| Component | Purpose |
|---|---|
GearboxSDK | Main entry point with attach() initialization |
marketRegister | Cached market data access |
addressProvider | Contract discovery wrapper |
| Plugins | Extended functionality (AccountsPlugin, AdaptersPlugin) |
| Services | Credit account operations and multicall helpers |
Guide Structure
- Setup — Installation, SDK initialization, basic configuration
- Reading Data — Market queries, account state, pool data
- Credit Accounts — Account operations via services
- Multicalls — Building and executing multicalls
When to Use the SDK
| Use Case | Recommended |
|---|---|
| Frontend applications | Yes |
| Analytics dashboards | Yes |
| Liquidation bots | Yes (or direct compressor calls) |
| Backend services | Yes |
| On-chain contracts | No (use Solidity Guide) |
The SDK handles ABI management, type conversions, and caching internally. For on-chain integrations or gas-optimized bot implementations, consider the Solidity Guide.
Architecture Understanding
For conceptual background on how Gearbox works:
- Credit Suite Architecture — How Credit Managers, Facades, and Configurators work together
- Pool Architecture — Lending pools and ERC-4626 compliance
- Multicall System — How multicalls execute and validate
Detailed Guides
Multicall Operations
Complete reference for each multicall operation with TypeScript examples:
| Operation | Description |
|---|---|
| Adding Collateral | Transfer tokens to credit account |
| Debt Management | Borrow and repay |
| Updating Quotas | Manage collateral quotas |
| Withdrawing Collateral | Remove tokens from account |
| Controlling Slippage | Protect against price movement |
| Making External Calls | Interact with DeFi protocols |
| Enabling/Disabling Tokens | Manage active collateral |
| Updating Price Feeds | On-demand oracle updates |
| Collateral Check Params | Optimize health checks |
| Revoke Allowances | Security cleanup |
See Multicalls Overview for building and executing multicalls.
Use Case Guides
Application-specific guides for common development scenarios:
| Building | Guide | Focus |
|---|---|---|
| Web UI / Dashboard | Frontend Applications | Data display, real-time updates |
| Analytics / Indexer | Backend Services | Historical data, event indexing |
| Liquidation Bot | Liquidation Bots | Monitoring, Router execution |