#!/usr/bin/env bash # Refresh strategy JSON with live path + gas fills (enrich), then evaluate economics. # Loads repo env when present (RPC_URL_138, etc.). Default dry-run (no file write). # # Usage: # bash scripts/economics/refresh-strategy-from-live.sh [--apply] # --apply Write enriched JSON back (same as economics-toolkit enrich --write) # set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" cd "$PROJECT_ROOT" if [[ -f "$PROJECT_ROOT/scripts/lib/load-project-env.sh" ]]; then # shellcheck source=/dev/null source "$PROJECT_ROOT/scripts/lib/load-project-env.sh" 2>/dev/null || true fi APPLY=0 ARGS=() for a in "$@"; do if [[ "$a" == "--apply" ]]; then APPLY=1 else ARGS+=("$a") fi done FILE="${ARGS[0]:?usage: refresh-strategy-from-live.sh [--apply] }" RPC="${RPC_URL_138:-https://rpc-http-pub.d-bis.org}" CLI="$PROJECT_ROOT/packages/economics-toolkit/dist/cli.js" if [[ ! -f "$CLI" ]]; then pnpm run economics:build fi ENRICH_FLAGS=(--file "$FILE" --rpc "$RPC") if [[ "$APPLY" -eq 1 ]]; then ENRICH_FLAGS+=(--write) fi node "$CLI" strategy enrich "${ENRICH_FLAGS[@]}" node "$CLI" strategy eval --file "$FILE" exit $?