fix: correct solvency calculation for streaming swaps

Summary

  • Fixes double-counting bug in solvency calculation for streaming swaps
  • Streaming swap amounts were being counted twice: once in swap queue (full deposit) and again in pool balance (processed amounts)
  • This caused reported solvency to artificially decrease as streaming swaps processed

Root Cause

When a streaming swap processes sub-swaps:

  1. Each sub-swap adds to pool.BalanceAsset (the asset goes into the pool)
  2. But the swap queue still contained the full deposit amount
  3. Solvency calculation deducted both, causing double-counting

Fix

Modified calculateNetworkSolvency() to:

  • Check if swap queue item is a streaming swap (IsLegacyStreaming() or IsStreaming())
  • If streaming, fetch the StreamingSwap state and deduct only the remaining amount (deposit - in)
  • Non-streaming swaps continue to deduct full amount as before

Test plan

  • Added TestCalculateNetworkSolvencyWithStreamingSwaps with 4 test cases:
    • Non-streaming swap deducts full amount
    • Legacy streaming swap (V1) with partial progress deducts only remaining
    • Advanced streaming swap (V2) with partial progress deducts only remaining
    • Streaming swap with no progress deducts full amount
  • All 28 network manager tests pass
  • All 8 solvency tests pass

Merge request reports

Loading
Loading