Skip to content

fix(perps): enforce stale oracle gate on liquidation#138

Draft
rndrntwrk wants to merge 1 commit into
mainfrom
security/perps-stale-oracle-liquidation-gate
Draft

fix(perps): enforce stale oracle gate on liquidation#138
rndrntwrk wants to merge 1 commit into
mainfrom
security/perps-stale-oracle-liquidation-gate

Conversation

@rndrntwrk

Copy link
Copy Markdown
Collaborator

Summary

This PR fixes the stale-oracle liquidation bypass in the EVM perps engines. Liquidation now uses the same max-oracle-delay gate as normal perps oracle sync instead of entering a special liquidation context that allowed stale-but-still-oracle-readable prices.

Security invariant

A liquidation must not execute from an oracle price older than the market engine maxOracleDelay, even if the underlying SkillOracle has a longer max delay.

Changes

  • remove the liquidation-context stale-oracle bypass from AgentPerpEngine
  • remove the same bypass from AgentPerpEngineNative
  • add ERC20 and native regression tests proving stale oracle data blocks liquidation

Validation

  • bun install --frozen-lockfile: pass
  • git submodule update --init --recursive packages/evm-contracts/lib/solady: pass
  • FOUNDRY_LIBS=["../../node_modules","lib"] forge test --match-path test/perps/AgentPerpEngine.t.sol --match-test "test(OracleStalenessBlocksLiquidation|NativeOracleStalenessBlocksLiquidation)": 2 passed
  • FOUNDRY_LIBS=["../../node_modules","lib"] forge test --match-path test/perps/AgentPerpEngine.t.sol: 50 passed
  • FOUNDRY_LIBS=["../../node_modules","lib"] forge test --match-path test/perps/AgentPerpEngineFuzz.t.sol: 2 passed
  • FOUNDRY_LIBS=["../../node_modules","lib"] forge test --match-path test/adversarial/PmPerpsAdversarial.t.sol: 11 passed
  • git diff --check: pass

Notes

Draft until owner/security review is complete. This branch targets main as the effective PR path; the same commit will be replayed into enoomian staging separately for deployment testing.

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