Skip to content

Multiple Collateral Types & Cross-Asset Operations Testing #148

@UlyanaAndrukhiv

Description

@UlyanaAndrukhiv

Context

Implement comprehensive test coverage for positions using multiple collateral types simultaneously, cross-asset borrowing scenarios, complex multi-hop conversion workflows, and multi-asset liquidation mechanics to ensure the protocol handles diverse asset combinations correctly.

Current tests primarily use FLOW and MOET with limited cross-asset scenarios. Production will involve complex positions with multiple collateral types and cross-asset borrowing. Health calculations become significantly more complex with multiple assets.

Missing Test Coverage

  • Multi-Collateral Position Management

    • Single position with FLOW + USDC + WETH collateral
    • Health calculation across different asset types
    • Weighted collateral factors
    • Correlation between collateral assets
  • Cross-Asset Borrowing

    • Deposit FLOW, borrow USDC
    • Deposit USDC, borrow WETH
    • Deposit wrapped ETH, end with wrapped BTC
    • Complex swap paths through protocol
  • Collateral Conversion

    • User starts with 1000 FLOW
    • Protocol workflow results in 0.5 WETH
    • Multi-hop conversions through DEX integrations
    • Slippage and price impact validation
  • Multi-Asset Liquidations

    • Position with 3 collateral types, 2 debt types
    • Liquidator selects which collateral to seize
    • Partial liquidation prioritization
    • Gas optimization for multi-asset operations
  • Asset Price Correlation

    • FLOW and USDC prices move independently
    • Health factor changes with uncorrelated price moves
    • Rebalancing with multiple changing prices

Recommended Tests

Test: Deposit 1000 FLOW → Borrow 500 USDC → Health calculation
Test: Position with FLOW+USDC collateral, borrow WETH
Test: Convert 1000 FLOW to 0.5 wrapped ETH via protocol
Test: Liquidate position with 3 collateral types, 2 debt types
Test: FLOW price +10%, USDC price -5%, calculate net health change
Test: User deposits FLOW, borrows MOET, swaps to USDC, repays with WETH

Complex Workflow Test

// Test: Multi-Asset Complex Workflow
// 1. User deposits 1000 FLOW (collateral)
// 2. User deposits 500 USDC (collateral)
// 3. User borrows 300 MOET (debt)
// 4. FLOW price drops 20%
// 5. Position becomes undercollateralized
// 6. Auto-rebalance pulls WETH from topUpSource
// 7. Validate final position: FLOW + USDC + WETH collateral, MOET debt
// 8. Health factor restored to target

Supported Token Matrix Test

// For each pair of (Collateral Type, Borrow Type):
// - FLOW → MOET
// - FLOW → USDC
// - FLOW → WETH
// - USDC → MOET
// - USDC → FLOW
// - USDC → WETH
// - WETH → MOET
// - WETH → FLOW
// - WETH → USDC
//
// Validate:
// 1. Deposit succeeds
// 2. Borrow succeeds
// 3. Health calculated correctly
// 4. Interest accrues properly
// 5. Repayment works
// 6. Withdrawal works

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions