Support Aave wrapper in MEV deploy helper
This commit is contained in:
@@ -9,6 +9,7 @@ OUTPUT_DEFAULT="$ROOT/reports/status/mev_execution_deploy_$(date +%Y%m%d_%H%M%S)
|
||||
RPC_URL="${RPC_URL:-}"
|
||||
PRIVATE_KEY="${PRIVATE_KEY:-}"
|
||||
FLASH_LOAN_PROVIDER="${FLASH_LOAN_PROVIDER:-}"
|
||||
AAVE_POOL="${AAVE_POOL:-}"
|
||||
TREASURY="${TREASURY:-}"
|
||||
EXECUTOR_OWNER="${EXECUTOR_OWNER:-}"
|
||||
PAUSE_ON_DEPLOY="${PAUSE_ON_DEPLOY:-1}"
|
||||
@@ -28,7 +29,8 @@ updated afterward.
|
||||
Required env or options:
|
||||
RPC_URL Target chain RPC URL
|
||||
PRIVATE_KEY Deployer private key
|
||||
FLASH_LOAN_PROVIDER Non-zero provider address compatible with the executor
|
||||
FLASH_LOAN_PROVIDER Non-zero generic provider address compatible with the executor
|
||||
AAVE_POOL Aave V3 pool address; deploys the wrapper and uses it as provider
|
||||
|
||||
Optional env or options:
|
||||
TREASURY Treasury address; defaults to deployer in Foundry script
|
||||
@@ -41,6 +43,7 @@ Options:
|
||||
--rpc-url URL
|
||||
--private-key KEY
|
||||
--flash-loan-provider ADDRESS
|
||||
--aave-pool ADDRESS
|
||||
--treasury ADDRESS
|
||||
--executor-owner ADDRESS
|
||||
--pause-on-deploy BOOL
|
||||
@@ -65,6 +68,10 @@ while [[ $# -gt 0 ]]; do
|
||||
FLASH_LOAN_PROVIDER="$2"
|
||||
shift 2
|
||||
;;
|
||||
--aave-pool)
|
||||
AAVE_POOL="$2"
|
||||
shift 2
|
||||
;;
|
||||
--treasury)
|
||||
TREASURY="$2"
|
||||
shift 2
|
||||
@@ -123,8 +130,8 @@ if [[ -z "$PRIVATE_KEY" && "$DRY_RUN" -eq 0 ]]; then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ -z "$FLASH_LOAN_PROVIDER" ]]; then
|
||||
echo "FLASH_LOAN_PROVIDER is required and must be non-zero" >&2
|
||||
if [[ -z "$FLASH_LOAN_PROVIDER" && -z "$AAVE_POOL" ]]; then
|
||||
echo "Either FLASH_LOAN_PROVIDER or AAVE_POOL is required" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
@@ -148,7 +155,8 @@ contracts: $CONTRACTS_DIR
|
||||
config target: $CONFIG_PATH
|
||||
output artifact: $OUTPUT_PATH
|
||||
chain id: $CHAIN_ID
|
||||
flash loan provider: $FLASH_LOAN_PROVIDER
|
||||
flash loan provider: ${FLASH_LOAN_PROVIDER:-"(derived from AAVE_POOL wrapper if set)"}
|
||||
aave pool: ${AAVE_POOL:-"(not used)"}
|
||||
treasury: ${TREASURY:-"(defaults to deployer)"}
|
||||
executor owner: ${EXECUTOR_OWNER:-"(deployer remains owner)"}
|
||||
pause on deploy: $PAUSE_ON_DEPLOY
|
||||
@@ -159,7 +167,12 @@ EOF
|
||||
if [[ "$DRY_RUN" -eq 1 ]]; then
|
||||
echo ""
|
||||
echo "Planned forge command:"
|
||||
printf 'cd %q && FLASH_LOAN_PROVIDER=%q ' "$CONTRACTS_DIR" "$FLASH_LOAN_PROVIDER"
|
||||
printf 'cd %q && ' "$CONTRACTS_DIR"
|
||||
if [[ -n "$AAVE_POOL" ]]; then
|
||||
printf 'AAVE_POOL=%q ' "$AAVE_POOL"
|
||||
else
|
||||
printf 'FLASH_LOAN_PROVIDER=%q ' "$FLASH_LOAN_PROVIDER"
|
||||
fi
|
||||
if [[ -n "$TREASURY" ]]; then
|
||||
printf 'TREASURY=%q ' "$TREASURY"
|
||||
fi
|
||||
@@ -173,7 +186,11 @@ fi
|
||||
|
||||
(
|
||||
cd "$CONTRACTS_DIR"
|
||||
export FLASH_LOAN_PROVIDER
|
||||
if [[ -n "$AAVE_POOL" ]]; then
|
||||
export AAVE_POOL
|
||||
else
|
||||
export FLASH_LOAN_PROVIDER
|
||||
fi
|
||||
export PAUSE_ON_DEPLOY
|
||||
if [[ -n "$TREASURY" ]]; then
|
||||
export TREASURY
|
||||
@@ -191,19 +208,30 @@ fi
|
||||
|
||||
EXECUTOR_CONTRACT="$(jq -r '.transactions[] | select(.contractName=="ArbitrageExecutor") | .contractAddress' "$BROADCAST_PATH" | tail -1)"
|
||||
UNISWAP_V2_ADAPTER="$(jq -r '.transactions[] | select(.contractName=="UniswapV2Adapter") | .contractAddress' "$BROADCAST_PATH" | tail -1)"
|
||||
AAVE_WRAPPER="$(jq -r '.transactions[] | select(.contractName=="AaveV3FlashLoanProviderAdapter") | .contractAddress' "$BROADCAST_PATH" | tail -1)"
|
||||
|
||||
if [[ -z "$EXECUTOR_CONTRACT" || "$EXECUTOR_CONTRACT" == "null" || -z "$UNISWAP_V2_ADAPTER" || "$UNISWAP_V2_ADAPTER" == "null" ]]; then
|
||||
echo "Could not extract deployed contract addresses from broadcast artifact" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$AAVE_WRAPPER" == "null" ]]; then
|
||||
AAVE_WRAPPER=""
|
||||
fi
|
||||
|
||||
if [[ -n "$AAVE_POOL" ]]; then
|
||||
EFFECTIVE_PROVIDER="$AAVE_WRAPPER"
|
||||
else
|
||||
EFFECTIVE_PROVIDER="$FLASH_LOAN_PROVIDER"
|
||||
fi
|
||||
|
||||
ONCHAIN_OWNER="$(cast call "$EXECUTOR_CONTRACT" "owner()(address)" --rpc-url "$RPC_URL" 2>/dev/null || true)"
|
||||
ONCHAIN_PENDING_OWNER="$(cast call "$EXECUTOR_CONTRACT" "pendingOwner()(address)" --rpc-url "$RPC_URL" 2>/dev/null || true)"
|
||||
ONCHAIN_PAUSED="$(cast call "$EXECUTOR_CONTRACT" "paused()(bool)" --rpc-url "$RPC_URL" 2>/dev/null || true)"
|
||||
ONCHAIN_PROVIDER="$(cast call "$EXECUTOR_CONTRACT" "flashLoanProvider()(address)" --rpc-url "$RPC_URL" 2>/dev/null || true)"
|
||||
ONCHAIN_TREASURY="$(cast call "$EXECUTOR_CONTRACT" "treasury()(address)" --rpc-url "$RPC_URL" 2>/dev/null || true)"
|
||||
|
||||
python3 - "$OUTPUT_PATH" "$CONFIG_PATH" "$BROADCAST_PATH" "$CHAIN_ID" "$EXECUTOR_CONTRACT" "$UNISWAP_V2_ADAPTER" "$FLASH_LOAN_PROVIDER" "$TREASURY" "$DEPLOYER_ADDRESS" "$EXECUTOR_OWNER" "$PAUSE_ON_DEPLOY" "$ONCHAIN_OWNER" "$ONCHAIN_PENDING_OWNER" "$ONCHAIN_PAUSED" "$ONCHAIN_PROVIDER" "$ONCHAIN_TREASURY" <<'PY'
|
||||
python3 - "$OUTPUT_PATH" "$CONFIG_PATH" "$BROADCAST_PATH" "$CHAIN_ID" "$EXECUTOR_CONTRACT" "$UNISWAP_V2_ADAPTER" "$EFFECTIVE_PROVIDER" "$TREASURY" "$DEPLOYER_ADDRESS" "$EXECUTOR_OWNER" "$PAUSE_ON_DEPLOY" "$ONCHAIN_OWNER" "$ONCHAIN_PENDING_OWNER" "$ONCHAIN_PAUSED" "$ONCHAIN_PROVIDER" "$ONCHAIN_TREASURY" "$AAVE_POOL" "$AAVE_WRAPPER" <<'PY'
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -224,6 +252,8 @@ onchain_pending_owner = sys.argv[13] or None
|
||||
onchain_paused = sys.argv[14] or None
|
||||
onchain_provider = sys.argv[15] or None
|
||||
onchain_treasury = sys.argv[16] or None
|
||||
aave_pool = sys.argv[17] or None
|
||||
aave_wrapper = sys.argv[18] or None
|
||||
|
||||
artifact = {
|
||||
"chain_id": chain_id,
|
||||
@@ -236,6 +266,8 @@ artifact = {
|
||||
"deployer_address": deployer_address,
|
||||
"requested_executor_owner": executor_owner,
|
||||
"pause_on_deploy": pause_on_deploy,
|
||||
"aave_pool": aave_pool,
|
||||
"aave_wrapper": aave_wrapper,
|
||||
"onchain": {
|
||||
"owner": onchain_owner,
|
||||
"pending_owner": onchain_pending_owner,
|
||||
@@ -255,9 +287,13 @@ print("")
|
||||
print("next config values:")
|
||||
print(f'chains.{chain_id}.execution.executor_contract = "{executor_contract}"')
|
||||
print(f'chains.{chain_id}.execution.flash_loan_provider = "{flash_loan_provider}"')
|
||||
if aave_pool:
|
||||
print(f'# Aave pool behind wrapper: {aave_pool}')
|
||||
print("")
|
||||
print("next operator checks:")
|
||||
print(f"- verify code exists at {executor_contract}")
|
||||
if aave_wrapper:
|
||||
print(f"- verify code exists at provider wrapper {aave_wrapper}")
|
||||
print(f"- verify owner(): {onchain_owner}")
|
||||
if onchain_pending_owner and onchain_pending_owner.lower() != "0x0000000000000000000000000000000000000000":
|
||||
print(f"- pendingOwner() is set to {onchain_pending_owner}; that address must call acceptOwnership()")
|
||||
|
||||
Reference in New Issue
Block a user