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 | Adding Collateral |
| Increase Debt | prepareIncreaseDebt() | Borrow from pool | Debt Management |
| Decrease Debt | prepareDecreaseDebt() | Repay borrowed funds | Debt Management |
| Update Quota | prepareUpdateQuota() | Enable/adjust quota token exposure | Updating Quotas |
| Withdraw Collateral | prepareWithdrawCollateral() | Remove tokens from account | Withdrawing Collateral |
| Slippage Control | Manual encoding | Protect swaps from sandwich attacks | Controlling Slippage |
| External Calls | Manual encoding | Interact with Uniswap, Curve, etc. | Making External Calls |
| Enable/Disable Token | Manual encoding | Explicit collateral management | Enabling/Disabling Tokens |
| Price Updates | Manual encoding | Update Pyth/Redstone feeds | Updating Price Feeds |
| Check Params | Manual encoding | Optimize gas, set min health factor | Collateral Check Params |
| Revoke Allowances | Manual encoding | Security measure after suspicious activity | Revoke Allowances |
Page Structure
Each operation guide follows the same structure:
- Why - When you need this operation
- What - What it does and how it fits the system
- How - Working TypeScript code
- Gotchas - Common mistakes and edge cases
- 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/compareBalancesenableToken/disableTokenonDemandPriceUpdatesetFullCheckParamsrevokeAdapterAllowances
All manual encoding uses iCreditFacadeV300MulticallAbi from @gearbox-protocol/sdk.
Related
- Multicalls Overview - Basic patterns and complete example
- Credit Accounts - Account data and services
- Solidity Multicalls - On-chain implementation details