DocumentationOpen App

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

OperationSDK HelperWhen to UseGuide
Add CollateralprepareAddCollateral()Deposit tokens to increase health factorAdding Collateral
Increase DebtprepareIncreaseDebt()Borrow from poolDebt Management
Decrease DebtprepareDecreaseDebt()Repay borrowed fundsDebt Management
Update QuotaprepareUpdateQuota()Enable/adjust quota token exposureUpdating Quotas
Withdraw CollateralprepareWithdrawCollateral()Remove tokens from accountWithdrawing Collateral
Slippage ControlManual encodingProtect swaps from sandwich attacksControlling Slippage
External CallsManual encodingInteract with Uniswap, Curve, etc.Making External Calls
Enable/Disable TokenManual encodingExplicit collateral managementEnabling/Disabling Tokens
Price UpdatesManual encodingUpdate Pyth/Redstone feedsUpdating Price Feeds
Check ParamsManual encodingOptimize gas, set min health factorCollateral Check Params
Revoke AllowancesManual encodingSecurity measure after suspicious activityRevoke Allowances

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.