Operations Reference

Detailed guides for encoding each multicall operation in Solidity.

For TypeScript/SDK implementation, see Multicalls.

Why This Section?

The main multicalls.md covers the fundamentals: MultiCall struct encoding, call order, and the diff pattern. This section goes deeper on each operation - when you need it, complete Solidity examples, and what can go wrong.

Quick Reference

Operation
Function
When to Use
Guide

Add Collateral

addCollateral

Deposit tokens to increase health factor

Increase Debt

increaseDebt

Borrow from pool

Decrease Debt

decreaseDebt

Repay borrowed funds

Update Quota

updateQuota

Enable/adjust quota token exposure

Withdraw Collateral

withdrawCollateral

Remove tokens from account

Slippage Control

storeExpectedBalances / compareBalances

Protect swaps from sandwich attacks

External Calls

Adapter-specific

Interact with Uniswap, Curve, etc.

Enable/Disable Token

enableToken / disableToken

Explicit collateral management

Price Updates

onDemandPriceUpdate

Update Pyth/Redstone feeds

Check Params

setFullCheckParams

Optimize gas, set min health factor

Revoke Allowances

revokeAdapterAllowances

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 Solidity code

  4. Gotchas - Common mistakes and edge cases

  5. See Also - Related operations and SDK reference

Core Encoding Pattern

All multicall operations use the same encoding pattern:

Call Order Requirements

Some operations have strict ordering rules:

  1. Price updates (onDemandPriceUpdate) - Must be first in the calls array

  2. Collateral check params (setFullCheckParams) - Should be early, affects final check

  3. External calls - Can be anywhere after price updates

  4. Slippage checks - storeExpectedBalances before swaps, compareBalances after

Import Patterns

Standard imports for multicall operations:

Last updated