Skip to content

fix(H6): relax emergency de-risk bound under oracle degradation - #15

Merged
jayeshy14 merged 1 commit into
mainfrom
fix/h6-emergency-degraded-bound
Jul 18, 2026
Merged

jayeshy14 merged 1 commit into
mainfrom
fix/h6-emergency-degraded-bound

Conversation

@jayeshy14

Copy link
Copy Markdown
Owner

Audit finding H6 (High)

De-risk swaps anchor minOut to OracleHub.ethUsdWad() x (1 - bound). When the feed is stale the hub serves the last-good snapshot (above market during a fast fall), and at the tight 150bps emergency bound the swap can't fill on either fee tier, so rebalance() reverts, bricking the permissionless de-risk during exactly the crash it must run.

Fix

The vault already holds healthSource. For an Emergency trigger while the oracle is degraded, it uses a wider 1000bps bound (EMERGENCY_DEGRADED_SLIPPAGE_BPS) so the de-risk executes instead of reverting; normal emergencies keep the tight 150bps MEV protection. Executing at a wider bound during a genuine feed outage beats not de-risking. A swap can still revert if no venue fills within the widened bound, which is the market genuinely gapping past a fair exit (the >1/m case). The overstated "never blocked" invariant comment is corrected to match.

Tests

  • test_h6_emergencyDeRiskNotBrickedByStaleOracle: oracle stale + 3% execution cost on both tiers (exceeds 150bps, within 1000bps) -> emergency de-risk still executes and defends the floor.
  • test_h6_tightBoundStillProtectsWhenHealthy: same 3% cost with a healthy oracle -> the tight bound rejects the fill (MEV protection preserved).

Independent of the other fix PRs; branches off main. Suite 116 -> 118.

Audit H6: every de-risk swap anchors minOut to OracleHub.ethUsdWad() x
(1 - bound). When the Chainlink feed is stale the hub serves the
last-good snapshot, which during a fast fall is above market; at the
tight 150bps emergency bound the swap then can't fill on either tier
and rebalance() reverts, bricking the permissionless de-risk during
the exact crash it must run.

Fix: the vault checks oracle health (it already holds healthSource) and,
for an Emergency trigger while degraded, uses a wider 1000bps bound so
the de-risk executes rather than reverting. Normal-condition emergencies
keep the tight 150bps MEV protection. A swap can still revert if no
venue fills within the widened bound, which is the market genuinely
gapping past a fair exit (the >1/m case). Corrected the overstated
'never blocked' invariant comment. Regression tests: emergency de-risk
survives a stale oracle + 3% execution cost; the tight bound still
rejects the same fill when healthy. 116 -> 118.
@jayeshy14
jayeshy14 merged commit 6430925 into main Jul 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant