fix: chore: fetch and cache Uniswap V3 replay datasets for evolution backtesting (#883)

- Add fetch-datasets.sh wrapper that fetches HIGHER/WETH, DEGEN/WETH,
  and TOSHI/WETH 30-day event caches via fetch-events.ts; reads
  INFURA_API_KEY from env and fails with a helpful error if unset
- Update .gitignore from cache/ (whole dir) to cache/*.jsonl so the
  pattern is precise to the generated data files; cache/ is already
  covered by the repo-root .gitignore via its own cache/ rule

JSONL cache files are gitignored and must be generated locally by
running ./fetch-datasets.sh with INFURA_API_KEY set.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-16 15:50:19 +00:00
parent 8733d17062
commit fb83c70d23
2 changed files with 54 additions and 1 deletions

View file

@ -1,2 +1,2 @@
# Cache files generated by fetch-events.ts at runtime — do not commit
cache/
cache/*.jsonl

View file

@ -0,0 +1,53 @@
#!/usr/bin/env bash
# fetch-datasets.sh — Download and cache Uniswap V3 replay datasets for the
# evolution backtester. Re-running is safe: fetch-events.ts has resume support.
#
# Usage:
# INFURA_API_KEY=<key> ./fetch-datasets.sh
# # or export the variable beforehand:
# export INFURA_API_KEY=<key>
# ./fetch-datasets.sh
#
# Alternatively derive the key from BASE_RPC_URL:
# export INFURA_API_KEY=$(echo "$BASE_RPC_URL" | grep -oP '/v3/\K.*')
set -euo pipefail
: "${INFURA_API_KEY:?INFURA_API_KEY is required. Set it directly or derive from BASE_RPC_URL: export INFURA_API_KEY=\$(echo \"\$BASE_RPC_URL\" | grep -oP '/v3/\\K.*')}"
export INFURA_API_KEY
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
mkdir -p cache
echo "=== Fetching HIGHER/WETH (last 30 days) ==="
npx tsx fetch-events.ts \
--pool 0xCC28456d4Ff980CeE3457Ca809a257E52Cd9CDb0 \
--days 30 \
--output cache/higher-weth-30d.jsonl
echo "=== Fetching DEGEN/WETH (last 30 days) ==="
npx tsx fetch-events.ts \
--pool 0x0cA6485b7e9cF814A3Fd09d81672B07323535b64 \
--days 30 \
--output cache/degen-weth-30d.jsonl
echo "=== Fetching TOSHI/WETH (last 30 days) ==="
npx tsx fetch-events.ts \
--pool 0x4b0Aaf3EBb163dd45F663b38b6d93f6093EBC2d3 \
--days 30 \
--output cache/toshi-weth-30d.jsonl
echo ""
echo "=== Done. Event counts: ==="
for f in cache/higher-weth-30d.jsonl cache/degen-weth-30d.jsonl cache/toshi-weth-30d.jsonl; do
if [ -f "$f" ]; then
count=$(wc -l < "$f")
echo " $f: $count events"
else
echo " $f: MISSING"
fi
done