Skip to content

Conversation

@0xIcarus
Copy link

@0xIcarus 0xIcarus commented Nov 4, 2025

Description

GGP balance alert bot that monitors the GGP balance via the Movement indexer and sends alerts when the balance falls below a dynamically computed threshold.

Running the bot requires some env variables to be set:

Required env vars

export REST_URL="https://testnet.movementnetwork.xyz/v1"
export INDEXER_GRAPHQL_URL="https://indexer.testnet.movementnetwork.xyz/v1/graphql"
export BASE_PER_VALIDATOR=1000000000
export RUNWAY_EPOCHS=2
export SAFETY_BPS=500
export SLACK_WEBHOOK_URL=<slack-webhook-url>

Optional env vars

export POLL_SECS=60
export RUST_LOG=info

Run

cargo run -p ggp-balance-alert-bot --release

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Other (specify) : Independent monitoring crate

How Has This Been Tested?

All unit tests in threshold.rs passing.

Key Areas to Review

  1. Threshold calculation: crates/ggp-balance-alert-bot/src/threshold.rs
  2. Validator count: crates/ggp-balance-alert-bot/src/sources/rest.rs
  3. Indexer query: crates/ggp-balance-alert-bot/src/sources/indexer.rs

Checklist

  • I have read and followed the CONTRIBUTING doc
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I identified and added all stakeholders and component owners affected by this change as reviewers
  • I tested both happy and unhappy path of the functionality
  • I have made corresponding changes to the documentation

@0xIcarus 0xIcarus requested review from 0xmovses and musitdev November 4, 2025 17:59
@0xmovses 0xmovses marked this pull request as ready for review November 5, 2025 17:46
Copy link

@musitdev musitdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly, I don't see why you:

  • add the _ on all these files
  • you use the indexer to get the balance

The indexer usage is to get withdraw events to verify after each even, but you decide to pool which is fine so I don't see why you use it for the balance.

For the alert, you should start a health check entry point that the sre team can plug with pager duty. This is a basic example .

),
ident_str!("abort_bridge_transfer").to_owned(),
vec![],
vec![bcs::to_bytes(&bridge_transfer_id).unwrap()],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable is used, why you precede with an _ ? And more generally, why you do that for all the other var?


/// Query current coin balance (AptosCoin) for an owner address via GraphQL indexer.
/// Tries `current_coin_balances` first; if unavailable, falls back to latest row from `coin_balances`.
pub async fn get_latest_apt_balance(&self, owner: &str) -> anyhow::Result<Option<u64>> {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you don't use the RPC to get the balance, it's easier and doesn't add a dependency to the indexer?
You've implemented the call.

impl RestClient {
pub fn new(base: String) -> Self { Self { base, http: reqwest::Client::new() } }

pub async fn get_apt_balance(&self, account: &str) -> anyhow::Result<u64> {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't use this call.

indexer: &IndexerClient,
sinks: &[Arc<dyn AlertSink>],
) -> anyhow::Result<()> {
let balance = indexer.get_latest_apt_balance(ggp_address).await?.unwrap_or(0);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a view function to get the ggp balance:

public fun get_balance<CoinType>(): u64 acquires GovernedGasPool

I think it's the best way to get the ggp balance. If the ggp treasury change, this call will still return the right balance.

@@ -0,0 +1,65 @@
use serde::Deserialize;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where this code is used.

pub num_validators_hint: u64,
}

pub fn compute_dynamic_low_threshold(p: Option<ThresholdParams>) -> u64 {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same in the move contract, explain the threshold function ins the comment. We need to understand why the threshold is calculated like that.

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.

3 participants