DocumentationOpen App

Bot Execution

Bot Execution mode allows an agent to operate autonomously on-chain, but within strictly bounded permissions. The agent has its own address with explicit, revocable permissions granted per Credit Account.

How It Works

The Gearbox Bot System provides granular permission control:

  1. Account owner grants permissions — specific operations allowed for a specific bot on a specific account
  2. Agent executes via botMulticall — operations go through CreditFacade with permission checks
  3. Protocol enforces boundaries — any unpermitted operation reverts the transaction
  4. Solvency check still applies — bot multicalls undergo the same HF >= 1 check as user multicalls

Permission Bitmask

Each permission is a bit flag. The account owner composes a bitmask of allowed operations:

PermissionWhat the Bot Can Do
ADD_COLLATERALDeposit tokens into the account
INCREASE_DEBTBorrow more from the pool
DECREASE_DEBTRepay debt
WITHDRAW_COLLATERALRemove tokens from the account
UPDATE_QUOTAAdjust token quotas
EXTERNAL_CALLSCall DeFi protocols via adapters

An agent managing a yield strategy might need ADD_COLLATERAL | EXTERNAL_CALLS | UPDATE_QUOTA but explicitly not WITHDRAW_COLLATERAL — preventing it from removing funds.

Safety Model

  • Scoped — permissions are per (bot, creditManager, creditAccount) tuple. One bot's permissions on one account don't affect any other.
  • Revocable — the account owner can revoke at any time by setting permissions to 0
  • Immutable boundary — bots cannot modify their own permissions
  • DAO forbid list — the DAO can globally forbid a malicious bot address
  • Same solvency rules — bot operations undergo identical collateral checks

Monitoring Bot Activity

The agent (or a separate monitor) should track bot state:

TypeScript
const position = await sdk.accounts.getStatus({ chainId: "Mainnet", creditAccount: accountAddress, }); // Check active bots for (const bot of position.bots) { console.log(`Bot: ${bot.address}, permissions: ${bot.permissions}`); }

When to Use

ScenarioRecommendation
Automated rebalancingBot with EXTERNAL_CALLS + UPDATE_QUOTA
Liquidation protectionBot with ADD_COLLATERAL + DECREASE_DEBT
Full autonomyBot with all permissions (high trust required)
Withdrawal neededPrefer Human-in-the-Loop

Combining Both Modes

A common pattern: use Bot Execution for routine operations (rebalancing, quota adjustments) and Human-in-the-Loop for high-impact actions (opening new positions, withdrawals, strategy changes).

The agent runs autonomously within its bounded permissions, but when it needs to do something outside those bounds, it generates a preview URL for human approval.

Learn More