Skip to content

feat: sPOL contract metrics#57

Merged
minhd-vu merged 9 commits into
mainfrom
minhd-vu/sPOL
May 19, 2026
Merged

feat: sPOL contract metrics#57
minhd-vu merged 9 commits into
mainfrom
minhd-vu/sPOL

Conversation

@minhd-vu
Copy link
Copy Markdown
Collaborator

@minhd-vu minhd-vu commented Feb 12, 2026

Description

This PR adds comprehensive sPOL liquid staking monitoring for both L1 (Ethereum) and L2 (Polygon PoS).

Phase 1: SPOLController Global Metrics (L1)

Metric Description
spol_exchange_rate POL value per 1 sPOL (convertSPOLtoPOL)
spol_paused 1 if contract is paused
spol_global_withdraw_nonce Global withdrawal counter
spol_dpol_balance Total dPOL balance
spol_spol_balance Total sPOL supply
spol_total_validators Number of validators
spol_active_validators Number of active validators

Phase 2: Per-Validator Metrics (L1)

Metric Description
spol_validator_status Validator status (0=inactive, 1=active)
spol_validator_deposit_share Deposit share percentage
spol_validator_total_staked Total POL staked with validator
spol_validator_real_dpol_balance Real dPOL position via ValidatorShare.balanceOf
spol_validator_delegation_locked 1 if delegation is locked
spol_validator_liquid_rewards Pending rewards for restaking
spol_validator_share_exchange_rate ValidatorShare exchange rate (~1e29 for healthy validators)

Labels: network, provider, validator_id, validator_address

L2 Monitoring (Polygon PoS)

Account balance monitoring via existing account_balance metric:

  • spol-child (0xd1CD49A08AeF3Af93457aEc17C786C2b7F48eCd7) - sPOLChild contract
  • pol-bridger (0x71663898Df7470e3b64d52663Ff975895E9b06E8) - POL bridger account

DataDog Alerting (Computed from above metrics)

The following alerts can be configured in DataDog without code changes:

  • dPOL balance desync: abs(sum(spol_validator_real_dpol_balance) - spol_dpol_balance) > 0
  • dPOL/sPOL divergence: abs(delta(spol_dpol_balance) - delta(spol_spol_balance)) > threshold
  • Deposit shares != 100: sum(spol_validator_deposit_share) != 100
  • Large dPOL decrease: delta(spol_dpol_balance) < -10000
  • Validator concentration: max(spol_validator_total_staked) / spol_dpol_balance > 0.5
  • Withdrawal nonce burst: delta(spol_global_withdraw_nonce) > N

Files Added/Modified

  • contracts/ValidatorShare.abi.json - New ABI for ValidatorShare contract
  • contracts/ValidatorShare.go - Generated Go bindings
  • observer/rpc.go - Extended SPOLValidator and SPOLController structs, added new metrics
  • provider/rpc.go - Added contract calls for Phase 1 & Phase 2 metrics
  • config.yml - Documented spol_controller_address config option
  • metrics.md - Documented all new metrics

Configuration

providers:
  rpc:
    # L1 - Ethereum Mainnet
    - name: "Ethereum"
      url: "${ETH_RPC_URL}"
      label: "mainnet"
      contracts:
        spol_controller_address: "0xEaadA411F2600570796c341552b9869DA708a28B"

    # L2 - Polygon PoS
    - name: "Polygon Mainnet"
      url: "${POLYGON_RPC_URL}"
      label: "mainnet"
      accounts:
        - address: "0xd1CD49A08AeF3Af93457aEc17C786C2b7F48eCd7"
          tag: "spol-child"
        - address: "0x71663898Df7470e3b64d52663Ff975895E9b06E8"
          tag: "pol-bridger"

Jira / Linear Tickets

Testing

  • go run cmd/main.go
  • Verified all metrics via curl localhost:9090/metrics | grep spol_
  • Deployed

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 1, 2026

Resolved conflicts in:
- observer/topics/observabletopic_string.go (regenerated)
- provider/rpc.go (combined sPOLController and stakingEvents features)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@minhd-vu minhd-vu marked this pull request as ready for review May 19, 2026 06:28
minhd-vu and others added 3 commits May 19, 2026 02:30
Phase 1 - SPOLController global metrics:
- spol_exchange_rate: POL per 1 sPOL (convertSPOLtoPOL)
- spol_paused: contract paused state
- spol_global_withdraw_nonce: withdrawal counter

Phase 2 - Per-validator metrics via ValidatorShare contract:
- spol_validator_real_dpol_balance: actual dPOL position (balanceOf)
- spol_validator_delegation_locked: delegation state
- spol_validator_liquid_rewards: pending rewards
- spol_validator_share_exchange_rate: share exchange rate

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Fix ShareExchangeRate overflow by using big.Float instead of Uint64()
- Rename spol_validator_count to spol_total_validators
- Rename spol_active_validator_count to spol_active_validators
- Improve share exchange rate help text clarity

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@minhd-vu minhd-vu merged commit 96c272b into main May 19, 2026
5 of 6 checks passed
@minhd-vu minhd-vu deleted the minhd-vu/sPOL branch May 19, 2026 07:08
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.

1 participant