DocumentationOpen App

Account Operations

A reference of all operations available on credit accounts. Each operation can be included as a call within a multicall.

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 attacksSlippage & Safety
External CallsManual encodingInteract with Uniswap, Curve, etc.External Calls
Enable/Disable TokenManual encodingExplicit collateral managementToken Management
Price UpdatesManual encodingUpdate Pyth/Redstone feedsSlippage & Safety
Check ParamsManual encodingOptimize gas, set min health factorSlippage & Safety
Revoke AllowancesManual encodingSecurity measure after suspicious activityToken Management

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.

Page Structure

Each operation guide covers:

  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

Learn More