Files
proxmox/scripts/economics/refresh-strategy-from-live.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

46 lines
1.2 KiB
Bash
Executable File

#!/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] <strategy.json>
# --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] <strategy.json>}"
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 $?