DocumentationOpen App

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

ComponentPurpose
GearboxSDKMain entry point with attach() initialization
marketRegisterCached market data access
addressProviderContract discovery wrapper
PluginsExtended functionality (AccountsPlugin, AdaptersPlugin)
ServicesCredit account operations and multicall helpers

Guide Structure

  1. Setup — Installation, SDK initialization, basic configuration
  2. Reading Data — Market queries, account state, pool data
  3. Credit Accounts — Account operations via services
  4. Multicalls — Building and executing multicalls

When to Use the SDK

Use CaseRecommended
Frontend applicationsYes
Analytics dashboardsYes
Liquidation botsYes (or direct compressor calls)
Backend servicesYes
On-chain contractsNo (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:


Detailed Guides

Multicall Operations

Complete reference for each multicall operation with TypeScript examples:

OperationDescription
Adding CollateralTransfer tokens to credit account
Debt ManagementBorrow and repay
Updating QuotasManage collateral quotas
Withdrawing CollateralRemove tokens from account
Controlling SlippageProtect against price movement
Making External CallsInteract with DeFi protocols
Enabling/Disabling TokensManage active collateral
Updating Price FeedsOn-demand oracle updates
Collateral Check ParamsOptimize health checks
Revoke AllowancesSecurity cleanup

See Multicalls Overview for building and executing multicalls.

Use Case Guides

Application-specific guides for common development scenarios:

BuildingGuideFocus
Web UI / DashboardFrontend ApplicationsData display, real-time updates
Analytics / IndexerBackend ServicesHistorical data, event indexing
Liquidation BotLiquidation BotsMonitoring, Router execution