Skip to content

Add script for monitoring pools for #222

Open
AndriiDiachuk wants to merge 3 commits intomainfrom
andron/script-for-monitoring-pools-for-alp-fyv
Open

Add script for monitoring pools for #222
AndriiDiachuk wants to merge 3 commits intomainfrom
andron/script-for-monitoring-pools-for-alp-fyv

Conversation

@AndriiDiachuk
Copy link
Collaborator

@AndriiDiachuk AndriiDiachuk commented Mar 19, 2026

Summary

Adds get_pool_liquidity.cdc - a read-only Cadence script that reports liquidity status for a configurable list of Uniswap V3 pools deployed on Flow EVM.

This script is consumed by the fcm-observer
monitoring service, which calls it on a periodic basis to expose Prometheus metrics
for pool health alerting.

For each pool the script performs three dry EVM calls:

  1. factory.getPool(tokenA, tokenB, fee) — resolves the pool contract address
  2. pool.liquidity() — checks whether there is any current in-range liquidity
  3. tokenA/tokenB.balanceOf(pool) — reads actual token reserves held by the pool

Token balances are scaled to 8 decimal places (UFix64) using
FlowEVMBridgeUtils.uint256ToUFix64 with floor rounding for tokens with more than
8 decimals.

If any call fails (e.g. pool not yet deployed, RPC error), the pool entry is still
returned with balanceA=0, balanceB=0, hasLiquidity=false so the caller always
receives a complete response and metrics are never absent.

Metrics exposed by fcm-observer (context)

Metric Description
fcm_pool_token_balance{pool, token} Token reserve balance (UFix64 units)
fcm_pool_has_liquidity{pool} 1.0 = in-range liquidity present, 0.0 = empty

Related PR: https://github.com/onflow/fcm-observer/pull/111

@AndriiDiachuk AndriiDiachuk requested a review from a team as a code owner March 19, 2026 13:21
@AndriiDiachuk AndriiDiachuk self-assigned this Mar 23, 2026
@vishalchangrani
Copy link
Contributor

@AndriiDiachuk can you please post sample input and output of the script?

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.

2 participants