Oracle Failure & Manipulation Testing#178
Draft
UlyanaAndrukhiv wants to merge 7 commits intoUlianaAndrukhiv/148-multiple-collateral-testingfrom
Draft
Conversation
…hub.com:onflow/FlowCreditMarket into UlianaAndrukhiv/149-oracle-failure-and-manipulation-testing
…hub.com:onflow/FlowCreditMarket into UlianaAndrukhiv/149-oracle-failure-and-manipulation-testing
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
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: #149
Note: this PR should be merged after
Description
Adds comprehensive test coverage for oracle failure modes, extreme price scenarios, and DEX/oracle price deviation circuit breaker to ensure the protocol maintains security when price data is compromised, unavailable, or manipulated.
Tests added (
fork_oracle_edge_cases_test.cdc)Price Feed Failures
test_oracle_nil_price— oracle returnsnilfor FLOW; any operation requiring pricing (health check) must revert due to force-unwrap panicInvalid Price Data
test_oracle_zero_price— oracle price set to0.0; position creation fails withPriceOracle must return a price greater than 0.0 if availablepostconditiontest_oracle_near_zero_price_extreme_health— FLOW price set to$0.00000001; health drops to near-zero (0.000000016), position becomes liquidatabletest_oracle_very_large_price_no_overflow— WETH price set toUFix64.max; verifies no overflow inUFix128math, health returnsCEILING_HEALTH, available balance unchangedDEX/Oracle Price Deviation & Circuit Breaker
test_dex_oracle_deviation_boundary_exact_threshold— boundary tests fordexOraclePriceDeviationInRangehelper at exactly 300 bps, 301 bps, both directions, and equal pricestest_dex_oracle_deviation_blocks_liquidation— DEX price deviates 16.7% from oracle; liquidation blocked withDEX/oracle price deviation too largetest_dex_oracle_within_threshold_liquidation_succeeds— DEX price within 3% of oracle; liquidation proceeds normallytest_governance_tightens_dex_deviation_threshold— governance tightens threshold from 300 bps to 100 bps; previously allowed 2.19% deviation now blockedExtreme Price Scenarios
test_flash_crash_triggers_liquidation— FLOW drops 50% ($1.00 → $0.50) in single block; health drops from 1.33 to 0.67, position becomes liquidatable, full liquidation flow executed and verifiedtest_flash_pump_increase_doubles_health— FLOW doubles ($1.00 → $2.00); health jumps from 1.6 to 3.2, user borrows at inflated price, price corrects back demonstrating pump-and-dump risk