Pool Operations

Interact with Gearbox pools directly from Solidity. Pools are ERC-4626 compliant vaults.

For SDK data reading, see Reading Data.

IPoolV3

import {IPoolV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IPoolV3.sol";

IPoolV3 pool = IPoolV3(poolAddress);

ERC-4626 Standard Functions

Gearbox pools implement the full ERC-4626 tokenized vault standard:

Deposit

Deposit underlying assets and receive diesel tokens (shares):

function deposit(uint256 assets, address receiver) external returns (uint256 shares);

Example:

// Approve underlying first
IERC20(underlying).approve(address(pool), assets);

// Deposit and receive shares
uint256 shares = pool.deposit(assets, msg.sender);

// Preview how many shares you'd receive
uint256 expectedShares = pool.previewDeposit(assets);

Deposit with Referral

Track referrals on-chain:

Example:

Mint

Mint exact shares, depositing required assets:

Example:

Withdraw

Withdraw exact assets, burning required shares:

Example:

Redeem

Burn exact shares, receiving assets:

Example:

Gearbox Extensions

Diesel Rate (Share Price)

Interest Rates

Liquidity State

Underlying Asset

Maximum Operations

Credit Manager Interaction

Only whitelisted Credit Managers can borrow. Regular users cannot call these:

Quota Keeper

Interest Rate Model

Complete Example

For architectural background, see Pool Architecture.

Last updated