Skip to content

Bot stuck: native gas reserve depleted, never refilled #76

@TaprootFreak

Description

@TaprootFreak

What happened

DEV bot (svJUSD/WCBTC on Citrea Mainnet) failed two consecutive rebalances on 2026-04-29 with INSUFFICIENT_FUNDS during the mint step. Wallet 0x7008…3c8AB:

Asset Balance
native cBTC 0.0000048 (need ≥0.0001 per gasReserve)
WCBTC (token) 0.000508
svJUSD 32.1
JUSD 0

Two bands (536, 537) got dissolved but no replacement bands were minted. Bot is now at 5 bands = MIN_OPERATIONAL_BANDS, with consecutiveErrors: 2. One more failure → emergency stop.

Log excerpt

[04:39:35] WARN: mint: retrying after error
  error: insufficient funds for gas * price + value:
         have   7202812749668
         want  17149632000000
[05:05:53] ERROR: Rebalance error
  operation: executeBandRebalance
  consecutiveErrors: 2

Root cause

gasReserve (config/pools.dev.yaml: 100000000000000 wei = 0.0001 cBTC) is only honored at startup by TokenWrapper.wrapNative (src/chain/token-wrapper.ts). It is never re-checked during operation.

After each rebalance, the dissolved band returns WCBTC (the wrapped token), not native cBTC. There is no logic that unwraps WCBTC back to native to top up the gas reserve. Over many rebalances, the initial gas allowance gets spent and the bot dies silently.

Fix idea

Before each rebalance (and/or on a periodic timer):

  1. Read native cBTC balance
  2. If < gasReserve, unwrap gasReserve - currentBalance worth of WCBTC via WCBTC.withdraw()
  3. Only then proceed with the swap/mint

Should also surface "low gas" as a notification well before the bot grinds to a halt.

Workaround

Send native cBTC directly to the wallet, or manually call WCBTC.withdraw() to unwrap.

Severity

P0 — bot is one failed tx away from emergency stop, holds dissolved band assets in wallet, and the price has drifted into a position that won't auto-correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions