-
Notifications
You must be signed in to change notification settings - Fork 2
Integrate DEX into manual liquidation #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jordanschalm
wants to merge
11
commits into
jord/liquidation
Choose a base branch
from
jord/94-liquidation-integrate-dex
base: jord/liquidation
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+582
−19
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #???
Description
Extends #77
For contributor use:
masterbranchFiles changedin the Github PR explorer