Add Chain138 native DODO verification tooling

This commit is contained in:
defiQUG
2026-04-14 07:13:22 -07:00
parent 367e98446a
commit ba71943c3f
7 changed files with 417 additions and 2 deletions

View File

@@ -0,0 +1,76 @@
#!/usr/bin/env bash
set -euo pipefail
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
REGISTRY_JSON="${PROJECT_ROOT}/config/smart-contracts-master.json"
DB_URL="${DB_URL:-postgresql://postgres:postgres@127.0.0.1:5434/mev}"
CHAIN_ID="${CHAIN_ID:-138}"
APPLY="${APPLY:-0}"
usage() {
cat <<'EOF'
Usage: sync-mev-chain138-token-symbols.sh [--db-url URL] [--chain-id ID] [--apply]
Builds a symbol map for the live Chain 138 MEV token set from canonical repo sources
and prints or applies UPDATE statements against the MEV Postgres database.
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--db-url)
DB_URL="$2"
shift 2
;;
--chain-id)
CHAIN_ID="$2"
shift 2
;;
--apply)
APPLY=1
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown arg: $1" >&2
usage >&2
exit 1
;;
esac
done
sql="$(
python3 - "$REGISTRY_JSON" "$CHAIN_ID" <<'PY'
import json, sys
from pathlib import Path
registry = json.loads(Path(sys.argv[1]).read_text())
chain_id = str(sys.argv[2])
contracts = registry["chains"][chain_id]["contracts"]
mapping = {
contracts["cUSDT"].lower(): "cUSDT",
contracts["cUSDC"].lower(): "cUSDC",
contracts["WETH10"].lower(): "WETH10",
"0x004b63a7b5b0e06f6bb6adb4a5f9f590bf3182d1": "USDT",
"0x798f6762bb40d6801a593459d08f890603d3979c": "USDC",
}
for address, symbol in mapping.items():
safe_symbol = symbol.replace("'", "''")
print(
f"UPDATE tokens SET symbol = '{safe_symbol}' "
f"WHERE chain_id = {chain_id} AND LOWER(token_id) = LOWER('{address}');"
)
PY
)"
if [[ "${APPLY}" != "1" ]]; then
printf '%s\n' "$sql"
exit 0
fi
psql "$DB_URL" -v ON_ERROR_STOP=1 -c "$sql"