diff --git a/scripts/bootstrap-common.sh b/scripts/bootstrap-common.sh index 3e42594..cd8b52b 100755 --- a/scripts/bootstrap-common.sh +++ b/scripts/bootstrap-common.sh @@ -113,6 +113,18 @@ call_recenter() { recenter_pk="$TXNBOT_PRIVATE_KEY" recenter_addr="$TXNBOT_ADDRESS" fi + + # If the deploy script already bootstrapped VWAP (cumulativeVolume > 0), positions + # are in place at the post-seed-buy tick. Calling recenter() now would fail with + # "amplitude not reached" because currentTick == anchorCenterTick. Skip it. + local cumvol + cumvol="$(cast call --rpc-url "$ANVIL_RPC" \ + "$LIQUIDITY_MANAGER" "cumulativeVolume()(uint256)" 2>/dev/null || echo "0")" + if [[ "$cumvol" != "0" && -n "$cumvol" ]]; then + bootstrap_log "VWAP already bootstrapped by deploy script (cumulativeVolume=$cumvol) -- skipping initial recenter" + return 0 + fi + bootstrap_log "Calling recenter() via $recenter_addr" cast send --rpc-url "$ANVIL_RPC" --private-key "$recenter_pk" \ "$LIQUIDITY_MANAGER" "recenter()" >>"$LOG_FILE" 2>&1