Add optional Cosmos/Engine-X/act-runner templates, CWUSDC/EI-matrix tooling, non-EVM route planner in multi-chain-execution (tests passing), token list and extraction updates, and documentation (MetaMask matrix, GRU/CWUSDC packets). Ignore institutional evidence tarballs/sha256 under reports/status. Validated with: bash scripts/verify/run-all-validation.sh --skip-genesis Co-authored-by: Cursor <cursoragent@cursor.com>
75 lines
3.1 KiB
Bash
Executable File
75 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Chunked continuation of send-cwusdc-ei-matrix-targeted.sh using the full topup TSV.
|
|
# Uses ei-matrix-cwusdc-targeted-last-idx.txt: next index is last+1 (TSV line last+2).
|
|
# Chooses chunk size from current ETH and gas price (never exceeds --max-chunk).
|
|
# Stops when TSV exhausted, chunk size < 1, or the targeted script exits non-zero.
|
|
set -euo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
cd "$PROJECT_ROOT"
|
|
|
|
MAX_CHUNK="${EI_MATRIX_TARGETED_MAX_CHUNK:-500}"
|
|
TSV="${EI_MATRIX_TARGETED_TSV:-${PROJECT_ROOT}/reports/status/ei-matrix-cwusdc-topup-amounts.tsv}"
|
|
LAST_FILE="${PROJECT_ROOT}/reports/status/ei-matrix-cwusdc-targeted-last-idx.txt"
|
|
LOG="${EI_MATRIX_TARGETED_CHUNK_LOG:-${PROJECT_ROOT}/reports/status/ei-matrix-cwusdc-targeted-chunked.log}"
|
|
|
|
# shellcheck disable=SC1091
|
|
source "$PROJECT_ROOT/scripts/lib/load-project-env.sh"
|
|
|
|
[[ -f "$TSV" ]] || { echo "Missing TSV: $TSV" >&2; exit 1; }
|
|
[[ -f "$LAST_FILE" ]] || { echo "Missing progress file: $LAST_FILE" >&2; exit 1; }
|
|
|
|
command -v cast &>/dev/null || { echo "cast required" >&2; exit 1; }
|
|
|
|
RPC="${ETHEREUM_MAINNET_RPC:-${RPC_URL_1:-}}"
|
|
[[ -n "$RPC" ]] || { echo "ETHEREUM_MAINNET_RPC or RPC_URL_1 required" >&2; exit 1; }
|
|
[[ -n "${PRIVATE_KEY:-}" ]] || { echo "PRIVATE_KEY required" >&2; exit 1; }
|
|
|
|
D=$(cast wallet address --private-key "$PRIVATE_KEY")
|
|
TOTAL_LINES=$(wc -l <"$TSV" | tr -d ' ')
|
|
|
|
exec >>"$LOG" 2>&1
|
|
echo "======== $(date -Is) chunked targeted cWUSDC start signer=$D max_chunk=$MAX_CHUNK tsv=$TSV"
|
|
|
|
while true; do
|
|
LAST=$(tr -d '[:space:]' <"$LAST_FILE" || echo "-1")
|
|
START=$((LAST + 2))
|
|
REM=$((TOTAL_LINES - START + 1))
|
|
if [[ "$REM" -le 0 ]]; then
|
|
echo "======== $(date -Is) COMPLETE: all indices done (last_idx=$LAST lines=$TOTAL_LINES)"
|
|
exit 0
|
|
fi
|
|
|
|
ETH_WEI=$(cast balance "$D" --rpc-url "$RPC" | awk '{print $1}')
|
|
GP=$(cast gas-price --rpc-url "$RPC" | awk '{print $1}' | head -1)
|
|
CHUNK=$(python3 -c "
|
|
eth = int('${ETH_WEI}')
|
|
gp = int('${GP}')
|
|
rem = int('${REM}')
|
|
mx = int('${MAX_CHUNK}')
|
|
# ~72k gas per ERC-20 transfer + 20% headroom on fee
|
|
cost = max(1, 72000 * gp * 12 // 10)
|
|
# spend at most 85% of ETH on this chunk
|
|
n = eth * 85 // 100 // cost
|
|
chunk = max(0, min(n, rem, mx))
|
|
print(chunk)
|
|
")
|
|
|
|
if [[ "$CHUNK" -lt 1 ]]; then
|
|
echo "======== $(date -Is) STOP: not enough ETH for one transfer (rem=$REM wei=$ETH_WEI gp=$GP). Top up and re-run."
|
|
exit 2
|
|
fi
|
|
|
|
echo "-------- $(date -Is) last=$LAST start_line=$START chunk=$CHUNK rem=$REM eth_wei=$ETH_WEI gp=$GP"
|
|
|
|
# Avoid tail|head under pipefail (SIGPIPE → exit 141).
|
|
_end=$((START + CHUNK - 1))
|
|
sed -n "${START},${_end}p" "$TSV" >"${PROJECT_ROOT}/reports/status/ei-matrix-cwusdc-chunk.tsv"
|
|
awk '{print $1}' "${PROJECT_ROOT}/reports/status/ei-matrix-cwusdc-chunk.tsv" >"${PROJECT_ROOT}/reports/status/ei-matrix-cwusdc-chunk.idx"
|
|
|
|
EI_MATRIX_SKIP_GAS_CHECK=1 \
|
|
"$SCRIPT_DIR/send-cwusdc-ei-matrix-targeted.sh" \
|
|
--amounts-tsv "${PROJECT_ROOT}/reports/status/ei-matrix-cwusdc-chunk.tsv" \
|
|
--indices-file "${PROJECT_ROOT}/reports/status/ei-matrix-cwusdc-chunk.idx"
|
|
done
|