Files
proxmox/scripts/verify/audit-mainnet-dodo-standard-pool-readiness.sh
defiQUG dbd517b279 Sync workspace: config, docs, scripts, CI, operator rules, and submodule pointers.
- Update dbis_core, cross-chain-pmm-lps, explorer-monorepo, metamask-integration, pr-workspace/chains
- Omit embedded publish git dirs and empty placeholders from index

Made-with: Cursor
2026-04-12 06:12:20 -07:00

173 lines
7.3 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
# Audit the current mainnet DODO pool creation path and standard-surface readiness.
#
# Usage:
# bash scripts/verify/audit-mainnet-dodo-standard-pool-readiness.sh
#
# Requires:
# ETHEREUM_MAINNET_RPC
# DODO_PMM_INTEGRATION_MAINNET
#
# Optional env-backed pool refs:
# POOL_CWUSDT_USDC_MAINNET
# POOL_CWUSDC_USDC_MAINNET
# POOL_CWUSDT_USDT_MAINNET
# POOL_CWUSDC_USDT_MAINNET
# POOL_CWEURC_USDC_MAINNET
# POOL_CWGBPC_USDC_MAINNET
# POOL_CWAUDC_USDC_MAINNET
# POOL_CWCADC_USDC_MAINNET
# POOL_CWJPYC_USDC_MAINNET
# POOL_CWCHFC_USDC_MAINNET
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
STATUS_JSON="${REPO_ROOT}/cross-chain-pmm-lps/config/deployment-status.json"
source "${REPO_ROOT}/smom-dbis-138/scripts/load-env.sh" >/dev/null 2>&1
require_cmd() {
command -v "$1" >/dev/null 2>&1 || {
echo "[fail] missing required command: $1" >&2
exit 1
}
}
require_cmd cast
require_cmd bash
require_cmd timeout
require_cmd jq
RPC_URL="${ETHEREUM_MAINNET_RPC:-}"
INTEGRATION="${DODO_PMM_INTEGRATION_MAINNET:-}"
if [[ -z "$RPC_URL" || -z "$INTEGRATION" ]]; then
echo "[fail] ETHEREUM_MAINNET_RPC and DODO_PMM_INTEGRATION_MAINNET are required" >&2
exit 1
fi
if [[ ! -f "$STATUS_JSON" ]]; then
echo "[fail] missing $STATUS_JSON" >&2
exit 1
fi
code_size() {
local target="$1"
local code
code="$(timeout 20s cast code "$target" --rpc-url "$RPC_URL" 2>/dev/null || true)"
if [[ -z "$code" || "$code" == "0x" ]]; then
printf '0'
return
fi
printf '%d' $(( (${#code} - 2) / 2 ))
}
cast_call_quick() {
local target="$1"
local signature="$2"
shift 2
timeout 20s cast call "$target" "$signature" "$@" --rpc-url "$RPC_URL" 2>/dev/null || true
}
probe_quote() {
local pool="$1"
local selector="$2"
if timeout 20s cast call "$pool" "$selector" "$INTEGRATION" 1 --rpc-url "$RPC_URL" >/dev/null 2>&1; then
printf 'ok'
else
printf 'revert'
fi
}
read_mapping() {
local base_token="$1"
local quote_token="$2"
cast_call_quick "$INTEGRATION" 'pools(address,address)(address)' "$base_token" "$quote_token" | awk '{print $1}'
}
read_standard_surface() {
local pool="$1"
cast_call_quick "$INTEGRATION" 'hasStandardPoolSurface(address)(bool)' "$pool" | awk '{print $1}'
}
echo "=== Mainnet DODO Standard Pool Readiness Audit ==="
echo "rpc=$RPC_URL"
echo "integration=$INTEGRATION"
echo "integrationCodeSize=$(code_size "$INTEGRATION")"
factory="$(cast_call_quick "$INTEGRATION" 'dodoVendingMachine()(address)' | awk '{print $1}')"
approve="$(cast_call_quick "$INTEGRATION" 'dodoApprove()(address)' | awk '{print $1}')"
echo "dodoVendingMachine=${factory:-unknown}"
echo "dodoVendingMachineCodeSize=$(code_size "${factory:-0x0000000000000000000000000000000000000000}")"
echo "dodoApprove=${approve:-unknown}"
pairs=(
"cwusdt-usdc|cWUSDT|USDC|POOL_CWUSDT_USDC_MAINNET|${CWUSDT_MAINNET:-0xaF5017d0163ecb99D9B5D94e3b4D7b09Af44D8AE}|0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
"cwusdc-usdc|cWUSDC|USDC|POOL_CWUSDC_USDC_MAINNET|${CWUSDC_MAINNET:-0x2de5F116bFcE3d0f922d9C8351e0c5Fc24b9284a}|0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
"cwusdt-usdt|cWUSDT|USDT|POOL_CWUSDT_USDT_MAINNET|${CWUSDT_MAINNET:-0xaF5017d0163ecb99D9B5D94e3b4D7b09Af44D8AE}|0xdAC17F958D2ee523a2206206994597C13D831ec7"
"cwusdc-usdt|cWUSDC|USDT|POOL_CWUSDC_USDT_MAINNET|${CWUSDC_MAINNET:-0x2de5F116bFcE3d0f922d9C8351e0c5Fc24b9284a}|0xdAC17F958D2ee523a2206206994597C13D831ec7"
"cweurc-usdc|cWEURC|USDC|POOL_CWEURC_USDC_MAINNET|${CWEURC_MAINNET:-0xD4aEAa8cD3fB41Dc8437FaC7639B6d91B60A5e8d}|0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
"cwgbpc-usdc|cWGBPC|USDC|POOL_CWGBPC_USDC_MAINNET|${CWGBPC_MAINNET:-0xc074007dc0bfb384b1cf6426a56287ed23fe4d52}|0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
"cwaudc-usdc|cWAUDC|USDC|POOL_CWAUDC_USDC_MAINNET|${CWAUDC_MAINNET:-0x5020Db641B3Fc0dAbBc0c688C845bc4E3699f35F}|0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
"cwcadc-usdc|cWCADC|USDC|POOL_CWCADC_USDC_MAINNET|${CWCADC_MAINNET:-0x209FE32fe7B541751D190ae4e50cd005DcF8EDb4}|0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
"cwjpyc-usdc|cWJPYC|USDC|POOL_CWJPYC_USDC_MAINNET|${CWJPYC_MAINNET:-0x07EEd0D7dD40984e47B9D3a3bdded1c536435582}|0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
"cwchfc-usdc|cWCHFC|USDC|POOL_CWCHFC_USDC_MAINNET|${CWCHFC_MAINNET:-0x0F91C5E6Ddd46403746aAC970D05d70FFe404780}|0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
)
for row in "${pairs[@]}"; do
IFS='|' read -r pair base_symbol quote_symbol pool_env_key base_token quote_token <<<"$row"
echo
echo "[$pair]"
configured_pool="${!pool_env_key:-}"
status_pool="$(jq -r --arg b "$base_symbol" --arg q "$quote_symbol" '.chains["1"].pmmPools[]? | select(.base == $b and .quote == $q) | .poolAddress' "$STATUS_JSON" | head -n1)"
mapped_pool="$(read_mapping "$base_token" "$quote_token")"
effective_pool="${status_pool:-${configured_pool:-${mapped_pool:-}}}"
if [[ -z "${effective_pool}" || "${effective_pool}" == "0x0000000000000000000000000000000000000000" ]]; then
echo "configuredPool=${configured_pool:-<missing>}"
echo "statusPool=${status_pool:-<missing>}"
echo "mappedPool=${mapped_pool:-<missing>}"
echo "effectivePool=<missing>"
echo "note=no configured or integration-mapped pool address found"
continue
fi
base_token_onchain="$(cast_call_quick "$effective_pool" '_BASE_TOKEN_()(address)' | awk '{print $1}')"
quote_token_onchain="$(cast_call_quick "$effective_pool" '_QUOTE_TOKEN_()(address)' | awk '{print $1}')"
reserves="$(cast_call_quick "$effective_pool" 'getVaultReserve()(uint256,uint256)')"
base_reserve="$(printf '%s\n' "$reserves" | sed -n '1p' | awk '{print $1}')"
quote_reserve="$(printf '%s\n' "$reserves" | sed -n '2p' | awk '{print $1}')"
standard_surface="$(read_standard_surface "$effective_pool")"
query_base="$(probe_quote "$effective_pool" 'querySellBase(address,uint256)(uint256,uint256)')"
query_quote="$(probe_quote "$effective_pool" 'querySellQuote(address,uint256)(uint256,uint256)')"
surface_class="unknown"
if [[ "${standard_surface:-}" == "true" && "${query_base}" == "ok" && "${query_quote}" == "ok" ]]; then
surface_class="standard"
elif [[ "${query_base}" == "revert" || "${query_quote}" == "revert" ]]; then
surface_class="partial_or_nonstandard"
fi
echo "configuredPool=${configured_pool:-<missing>}"
echo "statusPool=${status_pool:-<missing>}"
echo "pool=${effective_pool}"
echo "mappedPool=${mapped_pool:-unknown}"
echo "mappingMatchesConfigured=$([[ -n "${configured_pool:-}" && "${mapped_pool:-}" == "${configured_pool}" ]] && printf 'yes' || printf 'no')"
echo "mappingMatchesEffective=$([[ "${mapped_pool:-}" == "${effective_pool}" ]] && printf 'yes' || printf 'no')"
echo "poolCodeSize=$(code_size "$effective_pool")"
echo "baseToken=$base_token_onchain"
echo "quoteToken=$quote_token_onchain"
echo "reserves=${base_reserve:-unknown}/${quote_reserve:-unknown}"
echo "querySellBase=$query_base"
echo "querySellQuote=$query_quote"
echo "integrationHasStandardSurface=${standard_surface:-false}"
echo "surfaceClass=${surface_class}"
done
echo
echo "Rollout notes:"
echo "- Replace pools whose query surface still reverts after liquidity with canonical factory-backed deployments."
echo "- After each replacement pool is seeded, call refreshPoolSurface(pool) on the integration and update env/config references."