Skip to content

[test] Foundry fork tests for CharonLiquidator (all Venus markets + slippage edge cases) #23

@obchain

Description

@obchain

Context

Before a single mainnet tx, the liquidator contract must pass fork tests against real BSC state. Fork tests pin a block number, fork the chain in-memory, and execute the full flow with real reserves — the closest we get to mainnet without spending gas.

Scope

  • contracts/test/CharonLiquidator.t.sol
  • Fork setup: pin a block number where a known Venus position is liquidatable
  • Happy path: full liquidation, assert profit > 0, assert flash-loan repaid in full
  • Slippage path: force a bad minAmountOut, assert tx reverts (no state change)
  • Authorization: call executeLiquidation from non-owner, assert revert
  • Multi-market: parameterize test to run across top-5 Venus vTokens (BNB, USDT, USDC, BTCB, ETH)
  • Foundry forge snapshot to lock gas costs

Acceptance criteria

  • forge test --fork-url <bsc-rpc> passes all tests
  • Gas snapshot committed (.gas-snapshot) and checked in CI
  • Slippage failure mode covered by an explicit test
  • Owner-only gate covered by an explicit test
  • Tests run in < 60 seconds locally against a reachable BSC RPC

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions