Files
27-combi/TEST_CHECKLIST.md
2026-02-09 21:51:30 -08:00

4.9 KiB

Test Checklist for DeFi Collateral Simulation

Pre-Generation Checklist

  • Python script syntax verified (no compilation errors)
  • xlsxwriter installed (pip install xlsxwriter)
  • Python 3.7+ available

Generation

Run:

python generate_defi_simulation.py

Expected output:

Generating DeFi_Collateral_Simulation.xlsx...
✅ Successfully generated DeFi_Collateral_Simulation.xlsx
   - Assets sheet: 4 assets
   - Summary sheet: Portfolio totals and HF
   - Simulation sheet: 11 rounds (0-10)
   - Redeploy sheet: Advanced asset-level redeploy
   - Help sheet: Test cases and documentation

Verification Tests

Test 1: Baseline (Round 0)

  1. Open DeFi_Collateral_Simulation.xlsx
  2. Go to Assets sheet
  3. Verify default values:
    • ETH: 10 @ $2,000 = $20,000
    • wBTC: 1 @ $60,000 = $60,000
    • stETH: 0 @ $2,000 = $0
    • USDC: 5,000 @ $1 = $5,000
  4. All assets should have in Collateral ON/OFF
  5. Go to Summary sheet
  6. Verify:
    • Total Collateral Value = $85,000
    • Total Max Borrowable = $20,0000.80 + $60,0000.70 + $00.75 + $5,0000.90 = $16,000 + $42,000 + $0 + $4,500 = $62,500
    • Borrowed (input) = $25,000 (default)
    • Portfolio LTV = $25,000 / $85,000 = 0.2941 (29.41%)
    • Health Factor = $62,500 / $25,000 = 2.50
    • Status = Safe
  7. Go to Simulation sheet, Round 0
  8. Verify Round 0 matches Summary sheet values

Test 2: Swap Only (Round 1)

  1. In Simulation sheet, Round 1
  2. Enter Swap Volatile → Stable = $4,000
  3. Leave Repay Amount = 0
  4. Verify:
    • Borrowed_1 = $25,000 (unchanged, no repay)
    • New Collateral Value_1 = $85,000 (same total, but mix changed)
    • Volatile assets (ETH, wBTC) should have reduced values pro-rata
    • USDC should have increased by $4,000
    • Max Borrow_1 should be recomputed from new asset mix
    • HF_1 should increase (more stable collateral = higher LTV = higher Max Borrow)

Test 3: Repay Only (Round 1)

  1. Reset Round 1: Set Swap = 0, Repay Amount = $3,000
  2. Verify:
    • Borrowed_1 = $25,000 - $3,000 = $22,000
    • New Collateral Value_1 = $85,000 (unchanged, no swap)
    • Max Borrow_1 = $62,500 (unchanged, no swap)
    • HF_1 = $62,500 / $22,000 = 2.84 (increased from 2.50)
    • Status = Safe

Test 4: Combined (Round 1)

  1. Set Repay Amount = $2,000, Swap = $3,000
  2. Verify:
    • Borrowed_1 = $25,000 - $2,000 = $23,000
    • New Collateral Value_1 = $85,000 (total unchanged, but mix changed)
    • Max Borrow_1 recomputed from new asset mix (should increase due to more stable)
    • HF_1 should be higher than Round 0
    • LTV_1 should be lower than Round 0

Test 5: Optimizer

  1. In Simulation sheet, set Optimization On/Off =
  2. Set Max Repay per Round = $3,000
  3. Set Max Swap per Round = $4,000
  4. If Round 0 HF < 2.0, check Round 1 Suggested Repay and Suggested Swap
  5. Verify suggestions are within caps
  6. Verify suggestions would bring HF_1 to approximately 2.0

Test 6: Zero Borrowed

  1. In Summary sheet, set Borrowed (input) = 0
  2. Verify:
    • HF = 999 (large number)
    • Status = Safe
  3. In Simulation sheet, verify Round 0 reflects this

Test 7: Conditional Formatting

  1. In Summary sheet, verify HF cell:
    • Green background if HF ≥ 2
    • Red background if HF < 2
  2. In Simulation sheet, verify HF column (G):
    • Green background for all rounds with HF ≥ 2
    • Red background for rounds with HF < 2

Test 8: Extensibility

  1. Edit generate_defi_simulation.py
  2. Add a new asset to DEFAULT_ASSETS:
    {'name': 'USDT', 'amount': 1000, 'price': 1, 'ltv': 0.90, 'liq_th': 0.92, 'is_stable': True}
    
  3. Regenerate workbook
  4. Verify new asset appears in all sheets
  5. Verify all formulas still work correctly

Known Limitations

  1. Advanced Redeploy Sheet: Currently a placeholder structure. Full integration with Simulation sheet swap logic would require additional formula work.

  2. Optimizer Heuristic: Uses simplified calculations. For production use, consider:

    • More sophisticated optimization algorithms
    • Consideration of gas costs
    • Multi-round optimization (not just single-round)
  3. Swap Price Impact: Currently assumes 1:1 value transfer. Real-world swaps have:

    • Price impact
    • Slippage
    • Fees
  4. Asset Amount Updates: The swap mechanics adjust values but don't automatically update the Amount column in Assets sheet. This is by design (helper block approach), but users should be aware.

Success Criteria

All test cases pass Formulas calculate correctly Conditional formatting works Named ranges are accessible Workbook opens without errors in Excel/LibreOffice Round 0 matches Summary sheet Per-round recomputation works (Max Borrow changes after swaps) Optimizer provides reasonable suggestions