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

Topic
Description

Credit Accounts

Contract discovery, CreditFacade, CreditManager interactions

Multicall Encoding

Build and execute multicalls in Solidity

Pool Operations

Deposit, 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

When to Use Solidity Integration

Use Case
Recommended

On-chain protocol integration

Yes

Building adapters

Yes

Composable strategies

Yes

Backend services

No (use SDK Guide)

Frontend applications

No (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:

Operation
Description

Transfer tokens to credit account

Borrow and repay

Manage collateral quotas

Remove tokens from account

Protect against price movement

Interact with DeFi protocols via adapters

Manage active collateral

On-demand oracle updates (Pyth, Redstone)

Optimize health checks with hints

Security cleanup

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

Use Case Guides

Integration-specific guides for common development scenarios:

Building
Guide
Focus

New DeFi Adapter

AbstractAdapter, security patterns, diff functions

Strategy Contract

Multicall building, access control, automation

Core Extensions

Extending core contracts, advanced customizations

Liquidation Contract

On-chain liquidation, flash loans, keeper integration

Last updated