Merge pull request 'fix: chore: fetch and cache Uniswap V3 replay datasets for evolution backtesting (#883)' (#884) from fix/issue-883 into master
This commit is contained in:
commit
367dae31b8
2 changed files with 54 additions and 1 deletions
2
onchain/script/backtesting/.gitignore
vendored
2
onchain/script/backtesting/.gitignore
vendored
|
|
@ -1,2 +1,2 @@
|
|||
# Cache files generated by fetch-events.ts at runtime — do not commit
|
||||
cache/
|
||||
cache/*.jsonl
|
||||
|
|
|
|||
53
onchain/script/backtesting/fetch-datasets.sh
Executable file
53
onchain/script/backtesting/fetch-datasets.sh
Executable 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue