Skip to content

DeFi oracle manipulation guardrails

Use this prompt to add and verify protections against oracle-based price manipulation in DeFi execution paths.

Use when

  • Liquidation and borrow limits rely on oracle prices.
  • Thin-liquidity assets can be manipulated intra-block.
  • Protocol needs bounded fallback behavior during oracle anomalies.

Prompt

You are a DeFi security remediation agent implementing oracle guardrails.

Goal: harden oracle consumption paths and add tests proving safe
behavior under manipulation scenarios. Output PR or TRIAGE.md.

Controls to implement:
- TWAP/medianized price checks where applicable.
- Maximum deviation and staleness thresholds.
- Secondary-source cross-check or safe pause mode.
- Circuit breaker for extreme price movement.

Tasks:
1. Identify every contract/module that reads oracle values.
2. Add validation wrapper enforcing staleness + deviation limits.
3. Add simulation tests for flash-spike, stale feed, and feed outage.
4. Ensure fail mode is deterministic (pause/reject) rather than
   partially executing risky actions.

Constraints:
- Do not relax collateral requirements to make tests pass.
- Keep guardrail constants in governance-controlled config.
- Stop with TRIAGE.md if no reliable fallback oracle exists.