From e20b4517fda4a7c1254598f8f84fe137a0dc97a4 Mon Sep 17 00:00:00 2001 From: johba Date: Sun, 5 Apr 2026 17:21:41 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20fix:=20protocol=20activity=20statistics?= =?UTF-8?q?=20stay=20zero=20=E2=80=94=20ponder=20watches=20wrong=20contrac?= =?UTF-8?q?t=20addresses=20(#4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Add LM_ADDRESS and POOL_ADDRESS to ponder .env.local (bootstrap.sh) 2. Discover pool address from Uniswap factory during bootstrap (bootstrap-common.sh) 3. Make ring buffer block threshold configurable via MINIMUM_BLOCKS_FOR_RINGBUFFER env var, set to 0 for local dev so early events populate the ring buffer Co-Authored-By: Claude Opus 4.6 (1M context) --- containers/bootstrap.sh | 3 +++ scripts/bootstrap-common.sh | 12 ++++++++++++ services/ponder/src/helpers/stats.ts | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/containers/bootstrap.sh b/containers/bootstrap.sh index 1952593..299bf4e 100755 --- a/containers/bootstrap.sh +++ b/containers/bootstrap.sh @@ -104,6 +104,9 @@ write_ponder_env() { PONDER_NETWORK=$NETWORK_NAME KRAIKEN_ADDRESS=$KRAIKEN STAKE_ADDRESS=$STAKE +LM_ADDRESS=$LIQUIDITY_MANAGER +POOL_ADDRESS=$POOL_ADDRESS +MINIMUM_BLOCKS_FOR_RINGBUFFER=0 START_BLOCK=$DEPLOY_BLOCK PONDER_RPC_URL_${NETWORK_NAME}=$ANVIL_RPC DATABASE_URL=postgresql://ponder:ponder_local@postgres:5432/ponder_local diff --git a/scripts/bootstrap-common.sh b/scripts/bootstrap-common.sh index 2c6182b..dc8ab54 100755 --- a/scripts/bootstrap-common.sh +++ b/scripts/bootstrap-common.sh @@ -102,6 +102,18 @@ extract_addresses() { bootstrap_log "LiquidityManager address missing" exit 1 fi + + # Discover Uniswap pool address from factory + detect_swap_router + local factory + factory=$(cast call --rpc-url "$ANVIL_RPC" "$SWAP_ROUTER" "factory()(address)" 2>/dev/null) || factory="" + if [[ -n "$factory" && "$factory" != "0x" ]]; then + POOL_ADDRESS=$(cast call --rpc-url "$ANVIL_RPC" "$factory" "getPool(address,address,uint24)(address)" "$WETH" "$KRAIKEN" 10000 2>/dev/null) || POOL_ADDRESS="" + fi + if [[ -z "$POOL_ADDRESS" || "$POOL_ADDRESS" == "0x0000000000000000000000000000000000000000" ]]; then + bootstrap_log "Warning: could not discover pool address" + POOL_ADDRESS="" + fi } write_contracts_env() { diff --git a/services/ponder/src/helpers/stats.ts b/services/ponder/src/helpers/stats.ts index 7d9bff9..b226a0d 100644 --- a/services/ponder/src/helpers/stats.ts +++ b/services/ponder/src/helpers/stats.ts @@ -7,7 +7,7 @@ export type StatsContext = HandlerArgs extends { context: infer C } ? C : never; type StatsEvent = HandlerArgs extends { event: infer E } ? E : never; export const RING_BUFFER_SEGMENTS = 4; // ethReserve, minted, burned, holderCount -export const MINIMUM_BLOCKS_FOR_RINGBUFFER = 100; +export const MINIMUM_BLOCKS_FOR_RINGBUFFER = parseInt(process.env.MINIMUM_BLOCKS_FOR_RINGBUFFER || '100'); // Get deploy block from environment (set by bootstrap) const DEPLOY_BLOCK = BigInt(process.env.START_BLOCK || '0'); -- 2.49.1