Skip to content

Conversation

@jordanschalm
Copy link
Member

@jordanschalm jordanschalm commented Jan 16, 2026

Closes: #???

Description

Extends #77


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the standards mentioned here.
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

jordanschalm and others added 11 commits January 16, 2026 09:46
(no errors in IDE, but tests failing (can't find FCM in this scope) on
this commit)
state is stored in smart contract, struct with reference to contract
acts as mock object from FCM's perspective
Un-comment the DEX price validation logic to ensure liquidators provide competitive prices and prevent oracle manipulation. Add test infrastructure with MockDexSwapper transaction and helpers to configure DEX prices that stay synchronized with oracle prices during liquidation tests.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement 5 test functions covering DEX pricing validation logic:
- testManualLiquidation_dexOraclePriceDivergence: Tests price divergence thresholds with 3 sub-cases (within/exceeds/above oracle)
- testManualLiquidation_increaseHealthBelowTarget: Tests partial liquidation improving health without reaching target
- testManualLiquidation_liquidateToTarget: Tests liquidation bringing health to exactly 1.05 target
- testManualLiquidation_liquidatorOfferWorseThanDex: Tests rejection when liquidator offers worse price than DEX
- testManualLiquidation_combinedEdgeCase: Tests divergence check precedence over competitive offers

All 18 tests in liquidation_phase1_test.cdc now pass.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Refactor testManualLiquidation_dexOraclePriceDivergence into:
- testManualLiquidation_dexOraclePriceDivergence_withinThreshold: Tests successful liquidation when divergence is within 3% threshold
- testManualLiquidation_dexOraclePriceDivergence_exceedsThreshold: Tests two failure cases when divergence exceeds threshold (DEX below and above oracle)

This improves test clarity by separating success and failure scenarios into distinct test functions. All 19 tests pass.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Refactor testManualLiquidation_dexOraclePriceDivergence_exceedsThreshold into:
- testManualLiquidation_dexOraclePriceDivergence_dexBelowOracle: Tests failure when DEX price is below oracle (6.06% divergence)
- testManualLiquidation_dexOraclePriceDivergence_dexAboveOracle: Tests failure when DEX price is above oracle (5.71% divergence)

This provides better test isolation with one assertion per test function. All 20 tests pass.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.

2 participants