Skip to content

feat(maple): add pool cash balance and withdrawal queue depth monitoring#172

Open
spalen0 wants to merge 3 commits intomainfrom
maple
Open

feat(maple): add pool cash balance and withdrawal queue depth monitoring#172
spalen0 wants to merge 3 commits intomainfrom
maple

Conversation

@spalen0
Copy link
Collaborator

@spalen0 spalen0 commented Mar 15, 2026

Summary

  • Adds check_pool_liquidity() function that queries USDC balance of pool contract, locked liquidity, and withdrawal queue depth in a single batched call
  • Alerts on four conditions: low cash balance (<$1M), low cash ratio (<0.5% of TVL), high queue depth (>50 pending requests), and locked liquidity exceeding available cash (critical)
  • Reuses existing WithdrawalManagerQueue ABI which already includes lockedLiquidity() and queue() functions

Test plan

  • Verify batched calls decode correctly (especially queue() returning two uint128 values)
  • Confirm alerts fire with current on-chain state (~$280K cash, 0.016% ratio)
  • Verify no duplicate alerts when both cash balance and cash ratio thresholds are breached (uses elif)
  • Run python maple/main.py against mainnet to validate end-to-end

Closes #171

🤖 Generated with Claude Code

spalen0 and others added 3 commits March 15, 2026 10:15
Adds check_pool_liquidity() that monitors:
- Pool cash balance (USDC in pool contract) with $1M threshold
- Cash ratio (cash/TVL) with 0.5% threshold
- Withdrawal queue depth via queue() with 50 request threshold
- Locked liquidity vs available cash (critical alert)

All calls are batched for efficiency and reuse existing ABIs.

Closes #171

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@spalen0 spalen0 marked this pull request as ready for review March 17, 2026 19:16
@spalen0
Copy link
Collaborator Author

spalen0 commented Mar 17, 2026

cash reserves are low:

[2026-03-17 20:15:40,866] INFO maple: Strategy allocations — Aave: $156.17M, Sky: $600.32M | Withdrawal queue: $133.40K (liquid: $756.49M)
[2026-03-17 20:15:41,053] INFO maple: Pool liquidity — Cash: $133.41K (0.007% of TVL), Locked: $0.00, Queue depth: 1 pending
[2026-03-17 20:15:41,053] DEBUG utils.telegram: Sending telegram message:
⚠️ *Maple syrupUSDC Low Pool Cash*
💵 Cash: $133.41K (threshold: $1.00M)
📊 Cash ratio: 0.007% of $1.79B TVL
🔗 [syrupUSDC Pool](https://etherscan.io/address/0x80ac24aA929eaF5013f6436cdA2a7ba190f5Cc0b)

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.

Maple: add cash balance and withdrawal queue depth monitoring

1 participant