Operations Reference

Detailed guides for each multicall operation in TypeScript.

For Solidity multicall encoding, see Multicalls.

Why This Section?

The main multicalls.md covers the basics: SDK service helpers, combining with raw encoding, and a complete example. This section goes deeper on each operation - when you need it, complete examples, and what can go wrong.

Quick Reference

Operation
SDK Helper
When to Use
Guide

Add Collateral

prepareAddCollateral()

Deposit tokens to increase health factor

Increase Debt

prepareIncreaseDebt()

Borrow from pool

Decrease Debt

prepareDecreaseDebt()

Repay borrowed funds

Update Quota

prepareUpdateQuota()

Enable/adjust quota token exposure

Withdraw Collateral

prepareWithdrawCollateral()

Remove tokens from account

Slippage Control

Manual encoding

Protect swaps from sandwich attacks

External Calls

Manual encoding

Interact with Uniswap, Curve, etc.

Enable/Disable Token

Manual encoding

Explicit collateral management

Price Updates

Manual encoding

Update Pyth/Redstone feeds

Check Params

Manual encoding

Optimize gas, set min health factor

Revoke Allowances

Manual encoding

Security measure after suspicious activity

Page Structure

Each operation guide follows the same structure:

  1. Why - When you need this operation

  2. What - What it does and how it fits the system

  3. How - Working TypeScript code

  4. Gotchas - Common mistakes and edge cases

  5. See Also - Related operations and Solidity reference

SDK Helpers vs Manual Encoding

Five operations have SDK helpers via createCreditAccountService:

  • prepareAddCollateral(token, amount)

  • prepareIncreaseDebt(amount)

  • prepareDecreaseDebt(amount)

  • prepareUpdateQuota(token, change, minQuota)

  • prepareWithdrawCollateral(token, amount, to)

Six operations require manual encoding with viem's encodeFunctionData:

  • storeExpectedBalances / compareBalances

  • enableToken / disableToken

  • onDemandPriceUpdate

  • setFullCheckParams

  • revokeAdapterAllowances

All manual encoding uses iCreditFacadeV300MulticallAbi from @gearbox-protocol/sdk.

Last updated