Skip to content

Comments

Multi position per user scenarios testing#172

Open
mts1715 wants to merge 6 commits intomainfrom
taras/147-multi-position-per-user-scenarios-testing
Open

Multi position per user scenarios testing#172
mts1715 wants to merge 6 commits intomainfrom
taras/147-multi-position-per-user-scenarios-testing

Conversation

@mts1715
Copy link
Contributor

@mts1715 mts1715 commented Feb 19, 2026

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.cdc
Runs 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.

…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
@mts1715 mts1715 requested a review from a team as a code owner February 19, 2026 13:48
@mts1715 mts1715 self-assigned this Feb 20, 2026
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.

Multi-Position Scenarios Testing

1 participant