This guide explains the current watchdog behavior using the on-chain debt repay rescue path.
The watchdog acts as a planner/submission bot:
- Reads loan health factor (HF).
- If HF is below
triggerHF, computes required debt repay amount. - Calls the on-chain rescue contract in one transaction.
- Contract atomically repays debt using stablecoins (e.g. USDC/USDT) from the wallet and enforces post-HF safety.
The repay token is determined from the loan's borrowed asset (e.g. USDC for an Aave USDC borrow, or the loanToken for a Morpho market).
- Rescue is atomic (
rescue(...)), so either full success or full revert. - Contract checks resulting HF and reverts if it is below
minResultingHF. - For Morpho Blue, preview/guard math accounts for accrued borrow interest and Morpho's virtual-share conversion.
Watchdog config fields:
enabled(defaultfalse)dryRun(defaulttrue)triggerHF(default1.65)targetHF(default1.9)minResultingHF(default1.85)cooldownMs(default1800000)maxRepayAmount(default500) — denominated in the debt token (e.g. 500 USDC)deadlineSeconds(default300)rescueContract(required for Aave rescue whenenabled=true)morphoRescueContract(required for Morpho rescue whenenabled=true)maxGasGwei(default50)
Note:
rescueContractis the persisted config field for the Aave rescue contract./api/watchdog/statusexposes this asaaveRescueContractto make the protocol explicit.
Validation rules:
targetHF > triggerHFminResultingHF > triggerHFminResultingHF <= targetHFrescueContractmust be a valid address when setmorphoRescueContractmust be a valid address when set- At least one of
rescueContractormorphoRescueContractmust be configured when watchdog is enabled
Environment overrides:
WATCHDOG_TRIGGER_HFWATCHDOG_TARGET_HFWATCHDOG_MIN_RESULTING_HFWATCHDOG_MAX_REPAY_AMOUNT(WATCHDOG_MAX_TOP_UP_AMOUNTandWATCHDOG_MAX_TOP_UP_WBTCstill work as legacy fallbacks)WATCHDOG_MORPHO_RESCUE_CONTRACT
Live mode requires:
WATCHDOG_EXECUTOR_PRIVATE_KEYset on server (WATCHDOG_PRIVATE_KEYstill works as a fallback alias)- executor address is authorized by the rescue contract
- monitored wallet has debt token balance (e.g. USDC)
- monitored wallet has approved
rescueContractto pull the debt token
Live mode additionally requires:
morphoRescueContractconfigured (separate contract from the Aave rescue)- executor address is authorized by the Morpho rescue contract
- monitored wallet has loan token balance (e.g. USDC)
- monitored wallet has approved
morphoRescueContractto pull the loan token
Dry run:
- Computes amount and projected HF.
- Sends notifications and logs.
- No transaction submission.
Live:
- Enforces gas and ETH checks.
- Submits exactly one
rescue(...)tx. - Logs tx hash and applies cooldown.
GET /api/watchdog/status: returns summary + recent action log- Status summary fields include
aaveRescueContractandmorphoRescueContract - Recent action entries include
protocol,repayAmount, andrepayAssetSymbol GET /api/config: includes watchdog sectionPUT /api/config: updates watchdog fields/watchdog: shows watchdog status and recent actions
- Missing/invalid
rescueContractormorphoRescueContract - Cooldown active
- No usable debt token (balance/allowance/max cap)
- Projected HF cannot reach
minResultingHF - Gas above
maxGasGwei - Insufficient ETH for gas
- Missing executor authorization
- Start with
dryRun=true. - Configure
rescueContract(Aave) and/ormorphoRescueContract(Morpho) and verify addresses. - Pre-approve debt/loan tokens from monitored wallet to rescue contract(s).
- Keep
maxRepayAmountsmall during rollout. - Monitor Telegram alerts and
/api/watchdog/statusfor recent repay activity.