Refs #53
File: contracts/test/CharonLiquidatorFork.t.sol, _assertHappyPath()
Problem:
No gas snapshot is taken for executeLiquidation calls. Gas consumption is a profit-critical metric for a liquidation bot: a 50k gas increase per liquidation changes profit/loss calculation and may make marginal opportunities unprofitable. The fork test environment, with real Aave V3 state, is the most accurate place to baseline this.
Fix:
Add gas measurement to _assertHappyPath():
uint256 gasBefore = gasleft();
liquidator.executeLiquidation(_params(m));
uint256 gasUsed = gasBefore - gasleft();
emit log_named_uint(string.concat(m.name, " gas"), gasUsed);
For regression detection, integrate with forge snapshot:
forge snapshot --match-test test_fork
Add a .gas-snapshot file (gitignored or tracked) and fail CI when gas increases beyond a threshold using forge snapshot --check.
Refs #53
File: contracts/test/CharonLiquidatorFork.t.sol, _assertHappyPath()
Problem:
No gas snapshot is taken for executeLiquidation calls. Gas consumption is a profit-critical metric for a liquidation bot: a 50k gas increase per liquidation changes profit/loss calculation and may make marginal opportunities unprofitable. The fork test environment, with real Aave V3 state, is the most accurate place to baseline this.
Fix:
Add gas measurement to _assertHappyPath():
uint256 gasBefore = gasleft();
liquidator.executeLiquidation(_params(m));
uint256 gasUsed = gasBefore - gasleft();
emit log_named_uint(string.concat(m.name, " gas"), gasUsed);
For regression detection, integrate with forge snapshot:
forge snapshot --match-test test_fork
Add a .gas-snapshot file (gitignored or tracked) and fail CI when gas increases beyond a threshold using forge snapshot --check.