# Conservative Gas Price Methodology

## Overview

All deployment cost estimates use a **conservative approach** that ensures sufficient funds are available even during gas price fluctuations.

## Method: 2.5x Highest Price

The system:
1. Fetches gas prices from **MetaMask** (via ETHEREUM_MAINNET_RPC)
2. Fetches gas prices from **Etherscan** (via ETHERSCAN_API_KEY)
3. Compares both and selects the **highest**
4. Applies a **2.5x multiplier** for safety margin

## Formula

```
Conservative Gas Price = MAX(MetaMask Gas, Etherscan Gas) × 2.5
```

## Example

If:
- MetaMask reports: 0.10 gwei
- Etherscan reports: 0.097 gwei
- Highest: 0.10 gwei
- Conservative: 0.10 × 2.5 = **0.25 gwei**

## Fallback

If no gas prices can be retrieved from either source, the system uses **2.5 gwei** as a fallback.

## Benefits

1. **Safety Margin**: 2.5x multiplier accounts for gas price spikes
2. **Multiple Sources**: Uses both MetaMask and Etherscan for accuracy
3. **Dynamic Cap**: Adapts to current market conditions
4. **Realistic Estimates**: Uses actual market prices as baseline

## Usage

```bash
# Get conservative gas price (2.5x highest)
./scripts/deployment/get-conservative-gas-price.sh

# Calculate costs with conservative estimates
./scripts/deployment/calculate-conservative-costs.sh

# Update all documentation
./scripts/deployment/update-all-cost-estimates.sh
```

## API Keys Required

- `ETHERSCAN_API_KEY` - For Etherscan Gas API v2
- `ETHEREUM_MAINNET_RPC` - For MetaMask gas price (Infura endpoint)

## Notes

- Conservative estimates may be higher than actual costs
- This ensures sufficient funds are always available
- Actual deployment costs may be 20-40% lower than conservative estimates
- The 2.5x multiplier provides a safety buffer for unexpected gas spikes
- System adapts to current market conditions (not a fixed cap)
