Deploy scripts (DeployLocal.sol and DeployBase.sol) now execute a seed buy + double-recenter sequence before handing control to users: 1. Temporarily grant deployer recenterAccess (via self as feeDestination) 2. Fund LM with a small amount and call recenter() -> places thin positions 3. SeedSwapper executes a small buy, generating a non-zero WETH fee 4. Second recenter() hits the cumulativeVolume==0 bootstrap path with ethFee>0 -> _recordVolumeAndPrice fires -> cumulativeVolume>0 5. Revoke recenterAccess and restore the real feeDestination After deployment, cumulativeVolume>0, so the bootstrap path is unreachable by external users and cannot be front-run by an attacker inflating the initial VWAP anchor with a whale buy. Also adds: - tools/deploy-optimizer.sh: verification step checks cumulativeVolume>0 after a fresh local deployment - test_vwapBootstrappedBySeedTrade() in VWAPFloorProtection.t.sol: confirms the deploy sequence (recenter + buy + recenter) leaves cumulativeVolume>0 and getVWAP()>0 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b456bc75fd
commit
c05b20d640
4 changed files with 278 additions and 20 deletions
|
|
@ -237,6 +237,33 @@ PYEOF
|
|||
fail "Could not determine OPTIMIZER_PROXY from fresh deployment. Set OPTIMIZER_PROXY manually."
|
||||
fi
|
||||
info "Fresh stack deployed. Optimizer proxy: $OPTIMIZER_PROXY"
|
||||
|
||||
# Verify that the seed trade bootstrapped VWAP during deployment.
|
||||
# DeployLocal.sol runs a first recenter + seed buy + second recenter so that
|
||||
# cumulativeVolume>0 before any user can interact with the protocol.
|
||||
LM_ADDR=""
|
||||
if [ -f "$BROADCAST_JSON" ]; then
|
||||
LM_ADDR="$(python3 - "$BROADCAST_JSON" <<'PYEOF'
|
||||
import json, sys
|
||||
with open(sys.argv[1]) as f:
|
||||
data = json.load(f)
|
||||
for tx in data.get('transactions', []):
|
||||
if (tx.get('contractName') or '').lower() == 'liquiditymanager':
|
||||
print(tx.get('contractAddress', ''))
|
||||
break
|
||||
PYEOF
|
||||
)"
|
||||
fi
|
||||
if [ -n "$LM_ADDR" ]; then
|
||||
CUMVOL_HEX="$(cast call "$LM_ADDR" "cumulativeVolume()(uint256)" \
|
||||
--rpc-url "$RPC_URL" 2>/dev/null || echo "0x0")"
|
||||
CUMVOL="$(decode_uint "$CUMVOL_HEX")"
|
||||
if [ "$CUMVOL" -gt 0 ]; then
|
||||
success "VWAP bootstrapped: LiquidityManager.cumulativeVolume=$CUMVOL"
|
||||
else
|
||||
fail "VWAP not bootstrapped: cumulativeVolume=0 — seed trade may have failed"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue