DocumentationOpen App

Overview

Integrate directly with Gearbox contracts from your Solidity code. This guide covers on-chain integration patterns for smart contract developers.

Prerequisites

  • Solidity 0.8.x experience
  • Familiarity with interface-based contract interaction
  • Understanding of ERC-20 and common DeFi patterns

What You'll Learn

TopicDescription
Credit AccountsContract discovery, CreditFacade, CreditManager interactions
Multicall EncodingBuild and execute multicalls in Solidity
Pool OperationsDeposit, withdraw, and read pool state

Guide Structure

  1. Credit Accounts - Contract discovery, ICreditFacadeV3, ICreditManagerV3 interfaces
  2. Multicalls - MultiCall struct encoding, adapter calls
  3. Pool Operations - IPoolV3 deposit/withdraw, ERC-4626 functions

Note: Contract discovery patterns (AddressProvider, ContractsRegister) are covered in the Credit Accounts guide.

Key Interfaces

Solidity
// Core interfaces you'll use import {IAddressProviderV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IAddressProviderV3.sol"; import {ICreditFacadeV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditFacadeV3.sol"; import {ICreditManagerV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditManagerV3.sol"; import {IPoolV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IPoolV3.sol";

When to Use Solidity Integration

Use CaseRecommended
On-chain protocol integrationYes
Building adaptersYes
Composable strategiesYes
Backend servicesNo (use SDK Guide)
Frontend applicationsNo (use SDK Guide)

For TypeScript/JavaScript applications, see the SDK Guide.

Architecture Understanding

For conceptual background on how Gearbox works:


Detailed Guides

Multicall Operations

Complete reference for each multicall operation with Solidity 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 via adapters
Enabling/Disabling TokensManage active collateral
Updating Price FeedsOn-demand oracle updates (Pyth, Redstone)
Collateral Check ParamsOptimize health checks with hints
Revoke AllowancesSecurity cleanup

See Multicalls Overview for the diff pattern and complete encoding examples.

Use Case Guides

Integration-specific guides for common development scenarios:

BuildingGuideFocus
New DeFi AdapterAdapter DevelopmentAbstractAdapter, security patterns, diff functions
Strategy ContractProtocol IntegrationMulticall building, access control, automation
Core ExtensionsCore ExtensionExtending core contracts, advanced customizations
Liquidation ContractLiquidation BotsOn-chain liquidation, flash loans, keeper integration