#!/bin/bash
# Complete Reserve System Setup Script
# Sets up price feeds and configures initial reserves

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
cd "$PROJECT_ROOT"
source "$PROJECT_ROOT/scripts/load-env.sh" >/dev/null 2>&1 || true

echo "=== Complete Reserve System Setup ==="
echo ""

# Load environment variables
if [ -f .env ]; then
    source .env
fi

# Step 1: Setup Price Feeds
echo "Step 1: Setting up price feeds..."
forge script script/reserve/SetupPriceFeeds.s.sol:SetupPriceFeeds \
  --rpc-url chain138 \
  --broadcast \
  --verify

echo ""
echo "Step 2: Configuring initial reserves..."
forge script script/reserve/ConfigureInitialReserves.s.sol:ConfigureInitialReserves \
  --rpc-url chain138 \
  --broadcast

echo ""
echo "=== Setup Complete ==="
echo "Reserve System is now ready for operations"
