Open
Conversation
…dation - fork_multiple_positions_per_user.cdc covering three scenarios: - Multiple positions with distinct collateral types (FLOW, USDF, USDC, WETH, WBTC) and isolation guarantees between them - Cross-position effects through shared liquidity pools - Batch liquidation of 4 positions (2 full, 2 partial) in a single tx
…eates 100 positions across three collateral types (50 USDF, 45 USDC, 5 WBTC), crashes all collateral prices 40% simultaneously, and batch-liquidates all positions via MockDexSwapper in chunks of 10 to stay within computation limits.
…ion-per-user-scenarios-testing # Conflicts: # flow.json
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.
Note: Should be reviewed after #165, because some changes were taken from it.
Closes: #147
Multi-Position Per User Scenarios: Fork Tests & Supporting Infrastructure
cadence/tests/fork_multiple_positions_per_user.cdcRuns against mainnet at block 142528994 using real token holders and real token identifiers (FLOW, USDF, USDC, WETH, WBTC). Contains 4 tests:
testMultiplePositionsPerUser — Creates 5 positions with different collateral types, borrows varying amounts from each, and asserts that operations on one position do not affect the health factors of others (isolation guarantee).
testPositionInteractionsSharedLiquidity — Verifies cross-position effects through the shared FLOW liquidity pool: Position A's heavy borrowing reduces available liquidity for Position B, a subsequent repayment restores it, and a crash of Position A's collateral price has zero effect on Position B's health.
testBatchLiquidations — Creates 5 positions (USDF, WETH, USDC, WBTC, FLOW) with differentiated borrow levels, crashes 4 collateral prices, then executes a single-transaction batch liquidation: 2 full liquidations (WETH, USDF) and 2 partial liquidations (USDC, WBTC). The FLOW-collateral position, whose price is unchanged, remains untouched.
testMassUnhealthyLiquidations — System-wide stress test: 100 positions across 3 collateral types (50 USDF × 10 USDF, 45 USDC × 2 USDC, 5 WBTC × 0.00009 WBTC), two risk tiers (high/moderate) per stablecoin group, simultaneous 40% price crash across all three collateral types, then batch DEX liquidation of all 100 positions in chunks of 10 to stay within computation limits. Verifies all positions recover health and protocol FLOW reserve stays positive.
cadence/transactions/flow-alp/pool-management/batch_manual_liquidation.cdc— Liquidates multiple positions in one transaction using the caller's own debt tokens as repayment.cadence/transactions/flow-alp/pool-management/batch_liquidate_via_mock_dex.cdc— Liquidates multiple positions in one transaction sourcing repayment from a pre-configured MockDexSwapper.