Multicalls

Build and execute multicalls using SDK service helpers.

For Solidity multicall encoding, see Multicalls.

Service Multicall Helpers

The SDK provides structured multicall builders via createCreditAccountService:

import { GearboxSDK, createCreditAccountService } from '@gearbox-protocol/sdk';

const sdk = await GearboxSDK.attach({ client, marketConfigurators: [] });
const service = createCreditAccountService(sdk, 310);

Available Service Methods

Method
Operation

prepareAddCollateral(token, amount)

Add collateral from wallet

prepareIncreaseDebt(amount)

Borrow from pool

prepareDecreaseDebt(amount)

Repay debt

prepareUpdateQuota(token, change, minQuota)

Adjust token quota

prepareWithdrawCollateral(token, amount, to)

Remove collateral

Detailed Operation Guides

For comprehensive documentation of each operation:

SDK Helper Operations:

Manual Encoding Operations:

Building a Multicall

Executing Multicalls

On Existing Account

Opening with Multicall

Combining SDK Helpers with Raw Encoding

For adapter calls or custom operations, combine SDK helpers with manual encoding:

Slippage Protection

Add slippage checks around external calls:

On-Demand Price Updates

If using pull-based oracles, add price updates first:

Getting Adapter Addresses

Retrieve adapter addresses from the Credit Manager:

Complete Example

Best Practices

  1. Always use slippage protection when performing swaps

  2. Price updates first if using pull-based oracles

  3. Set quotas for tokens you'll hold as collateral

  4. Approve collateral to Credit Manager (not Facade) before adding

For architectural background, see Multicall System.

Last updated