Add MEV Chain138 live smoke pack

This commit is contained in:
defiQUG
2026-04-14 07:32:01 -07:00
parent cabb6b6baa
commit 579a3bbe3a
4 changed files with 190 additions and 1 deletions

View File

@@ -0,0 +1,158 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
if [[ -f "${PROJECT_ROOT}/scripts/lib/load-project-env.sh" ]]; then
# shellcheck source=/dev/null
source "${PROJECT_ROOT}/scripts/lib/load-project-env.sh"
fi
require_command() {
command -v "$1" >/dev/null 2>&1 || {
printf '[fail] missing required command: %s\n' "$1" >&2
exit 1
}
}
require_command curl
require_command jq
require_command python3
BASE_URL="${MEV_BASE_URL:-https://mev.defi-oracle.io}"
CHAIN_ID="${MEV_CHAIN_ID:-138}"
API_KEY="${MEV_API_KEY:-${API_KEY:-}}"
RUN_NATIVE_DODO="${MEV_LIVE_SMOKE_RUN_NATIVE_DODO:-1}"
auth_args=()
if [[ -n "${API_KEY}" ]]; then
auth_args=(-H "X-API-Key: ${API_KEY}")
fi
pass_count=0
fail_count=0
pass() {
printf '[PASS] %s\n' "$*"
pass_count=$((pass_count + 1))
}
fail() {
printf '[FAIL] %s\n' "$*" >&2
fail_count=$((fail_count + 1))
}
check_url_ok() {
local label="$1"
local url="$2"
if curl -fsS "${auth_args[@]}" "$url" >/dev/null; then
pass "${label}"
else
fail "${label}"
fi
}
printf 'MEV Chain %s live smoke pack\n' "${CHAIN_ID}"
printf 'base=%s\n' "${BASE_URL}"
check_url_ok "public /api/health" "${BASE_URL}/api/health"
check_url_ok "public /api/stats/freshness" "${BASE_URL}/api/stats/freshness"
check_url_ok "public /api/stats/venue-coverage" "${BASE_URL}/api/stats/venue-coverage"
check_url_ok "public /api/tokens" "${BASE_URL}/api/tokens?chain_id=${CHAIN_ID}&limit=20"
freshness_json="$(curl -fsS "${auth_args[@]}" "${BASE_URL}/api/stats/freshness")"
if JSON_INPUT="${freshness_json}" python3 - "${CHAIN_ID}" <<'PY'
import json, os, sys
rows = json.loads(os.environ["JSON_INPUT"])
cid = int(sys.argv[1])
row = next((r for r in rows if int(r["chain_id"]) == cid), None)
assert row is not None
assert int(row["pools_with_recent_state"]) > 0
assert int(row["reserve_rows"]) > 0
assert int(row["latest_observed_block"]) > 0
PY
then
pass "freshness summary contains live Chain ${CHAIN_ID} state"
else
fail "freshness summary contains live Chain ${CHAIN_ID} state"
fi
coverage_json="$(curl -fsS "${auth_args[@]}" "${BASE_URL}/api/stats/venue-coverage")"
if JSON_INPUT="${coverage_json}" python3 - "${CHAIN_ID}" <<'PY'
import json, os, sys
rows = json.loads(os.environ["JSON_INPUT"])
cid = int(sys.argv[1])
chain_rows = [r for r in rows if int(r["chain_id"]) == cid]
assert chain_rows
assert any(int(r["pools_with_state"]) > 0 for r in chain_rows)
PY
then
pass "venue coverage contains active Chain ${CHAIN_ID} venues"
else
fail "venue coverage contains active Chain ${CHAIN_ID} venues"
fi
pools_json="$(curl -fsS "${auth_args[@]}" "${BASE_URL}/api/pools?chain_id=${CHAIN_ID}&limit=20")"
if JSON_INPUT="${pools_json}" python3 - "${CHAIN_ID}" <<'PY'
import json, os, sys
rows = json.loads(os.environ["JSON_INPUT"])
cid = int(sys.argv[1])
assert rows
assert any(int(r["chain_id"]) == cid for r in rows)
assert any(r.get("dex") == "dodo_pmm" for r in rows)
assert any(r.get("dex") == "dodo_d3mm" for r in rows)
assert any(
str(r.get("pool_id", "")).lower() == "0xc39b7d0f40838cbfb54649d327f49a6dac964062"
and str(r.get("token_a", "")).lower() == "0xf22258f57794cc8e06237084b353ab30fffa640b"
and str(r.get("token_b", "")).lower() == "0x71d6687f38b93ccad569fa6352c876eea967201b"
for r in rows
)
PY
then
pass "pools endpoint exposes canonical Chain ${CHAIN_ID} DODO metadata"
else
fail "pools endpoint exposes canonical Chain ${CHAIN_ID} DODO metadata"
fi
tokens_json="$(curl -fsS "${auth_args[@]}" "${BASE_URL}/api/tokens?chain_id=${CHAIN_ID}&limit=20")"
if JSON_INPUT="${tokens_json}" python3 - "${CHAIN_ID}" <<'PY'
import json, os, sys
rows = json.loads(os.environ["JSON_INPUT"])
cid = int(sys.argv[1])
symbols = {r.get("symbol") for r in rows if int(r.get("chain_id", 0)) == cid}
assert {"cUSDT", "cUSDC", "USDT", "USDC", "WETH10"}.issubset(symbols)
PY
then
pass "tokens endpoint exposes canonical Chain ${CHAIN_ID} symbols"
else
fail "tokens endpoint exposes canonical Chain ${CHAIN_ID} symbols"
fi
reserve_json="$(curl -fsS "${auth_args[@]}" "${BASE_URL}/api/reserve_state?chain_id=${CHAIN_ID}&limit=20")"
if JSON_INPUT="${reserve_json}" python3 - "${CHAIN_ID}" <<'PY'
import json, os, sys
rows = json.loads(os.environ["JSON_INPUT"])
cid = int(sys.argv[1])
assert rows
assert any(int(r["chain_id"]) == cid for r in rows)
assert any(str(r["reserve_a"]) not in ("0", "0x0") and str(r["reserve_b"]) not in ("0", "0x0") for r in rows)
PY
then
pass "reserve_state exposes nonzero Chain ${CHAIN_ID} liquidity rows"
else
fail "reserve_state exposes nonzero Chain ${CHAIN_ID} liquidity rows"
fi
if [[ "${RUN_NATIVE_DODO}" == "1" ]]; then
if bash "${PROJECT_ROOT}/scripts/verify/check-chain138-native-dodo-read-surfaces.sh"; then
pass "native Chain 138 DODO read surfaces"
else
fail "native Chain 138 DODO read surfaces"
fi
fi
printf '\nSummary: %s passed, %s failed\n' "${pass_count}" "${fail_count}"
if (( fail_count > 0 )); then
exit 1
fi