Skip to content

[contracts] happy-path fork tests set minSwapOut=0 — slippage invariant never validated #267

@obchain

Description

@obchain

Refs #53

File: contracts/test/CharonLiquidatorFork.t.sol, _params() function

Code:
return CharonLiquidator.LiquidationParams({
...
minSwapOut: 0
});

Problem:
All 5 market happy-path tests pass minSwapOut=0. This disables slippage protection entirely. The happy-path test does not validate that:

  1. A realistic minSwapOut (e.g., repayAmount * 99% / 100%) is honoured.
  2. The swap route is viable at the expected fee tier.
  3. The profit calculation holds when slippage is constrained.

The slippage-specific tests (test_fork_slippage_tooTight_reverts, test_fork_underRepayment_reverts) cover extreme cases but the normal operating regime — minSwapOut set to a reasonable floor — is untested.

PRD clause / invariant: CLAUDE.md: 'Off-chain gates (health factor, price freshness, profitability, gas ceiling, flash-loan liquidity) must all run before simulation.' The on-chain slippage guard is part of the profit protection layer. A happy path that bypasses it gives false confidence.

Impact:
Any regression that zeros out minSwapOut in the production Rust path (OpportunityQueue -> TxBuilder) would be invisible to the fork test suite.

Fix:
In _params(), compute a realistic minSwapOut:
minSwapOut: (m.repayAmount * 99) / 100

Add an assertion that the owner balance increase exceeds minSwapOut to verify the slippage floor was respected end-to-end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions