Files
smom-dbis-138/docs/guides/GAS_FEE_CALCULATIONS.md
defiQUG 1fb7266469 Add Oracle Aggregator and CCIP Integration
- Introduced Aggregator.sol for Chainlink-compatible oracle functionality, including round-based updates and access control.
- Added OracleWithCCIP.sol to extend Aggregator with CCIP cross-chain messaging capabilities.
- Created .gitmodules to include OpenZeppelin contracts as a submodule.
- Developed a comprehensive deployment guide in NEXT_STEPS_COMPLETE_GUIDE.md for Phase 2 and smart contract deployment.
- Implemented Vite configuration for the orchestration portal, supporting both Vue and React frameworks.
- Added server-side logic for the Multi-Cloud Orchestration Portal, including API endpoints for environment management and monitoring.
- Created scripts for resource import and usage validation across non-US regions.
- Added tests for CCIP error handling and integration to ensure robust functionality.
- Included various new files and directories for the orchestration portal and deployment scripts.
2025-12-12 14:57:48 -08:00

153 lines
5.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Gas Fee Calculations for Mainnet Deployments
## Overview
This document calculates the gas fees required to deploy CCIP WETH bridge contracts on Ethereum Mainnet using **conservative estimates** based on MetaMask and Etherscan gas prices.
**Important**: These gas fees are **ONLY for the bridge contracts**, not the WETH contracts:
- **WETH9 and WETH10 on Mainnet**: Already exist (deployed years ago) - **NO deployment needed**
- **WETH9 and WETH10 on ChainID 138**: Predeployed in genesis.json - **NO deployment needed**
- **Bridge contracts**: NEW contracts that need deployment on BOTH chains
## Conservative Gas Price Calculation
**Method**: 2.5x the highest gas price between MetaMask and Etherscan estimates
**Formula**: `Conservative Gas Price = MAX(MetaMask Gas, Etherscan Gas) × 2.5`
**Current Analysis**:
- Highest (MetaMask/Etherscan): .155444001 gwei (from Etherscan)
- **Conservative (2.5x)**: .388610002 gwei
- **Last Updated**: 2025-11-13 05:49:03 UTC
> **Note**: Run `./scripts/deployment/get-conservative-gas-price.sh` to get the latest conservative estimate.
## Contracts to Deploy
1. **CCIPWETH9Bridge** - Bridge for WETH9 cross-chain transfers
2. **CCIPWETH10Bridge** - Bridge for WETH10 cross-chain transfers
## Gas Calculation Formula
```
Total Gas = Base Transaction Gas + Constructor Gas + (Contract Size × Gas per Byte)
```
Where:
- **Base Transaction Gas**: 21,000 gas
- **Constructor Gas**: ~50,000 gas (approximate, depends on constructor logic)
- **Contract Size**: Size of deployed bytecode in bytes
- **Gas per Byte**: 16 gas per byte of contract code
## Contract Sizes
Based on compiled contracts:
| Contract | Size (bytes) | Code Gas | Constructor Gas | Base Gas | Total Gas |
|----------|--------------|----------|-----------------|----------|-----------|
| CCIPWETH9Bridge | ~12,000 | 192,000 | 50,000 | 21,000 | ~263,000 |
| CCIPWETH10Bridge | ~12,000 | 192,000 | 50,000 | 21,000 | ~263,000 |
| **Total** | **24,000** | **384,000** | **100,000** | **42,000** | **~526,000** |
## Conservative Cost Estimates
### Current Conservative Gas Price: .388610002 gwei (2.5x highest)
**Calculation**: MAX(MetaMask Gas, Etherscan Gas) × 2.5
| Contract | Gas | Cost (ETH) | Cost (USD @ $2,500/ETH) |
|----------|-----|------------|-------------------------|
| CCIPWETH9Bridge | ~263,000 | ~0.0001022 ETH | ~$.2555110000 |
| CCIPWETH10Bridge | ~263,000 | ~0.0001022 ETH | ~$.2555110000 |
| Configuration (4 calls) | ~200,000 | ~0.00007772 ETH | ~$.1943050000 |
| **Total** | **~726,000** | **~0.00028213 ETH** | **~$.7053270000** |
> **Conservative Estimate**: At .388610002 gwei (2.5x of .155444001 gwei), total deployment cost is approximately **0.00028213 ETH ($.7053270000)**.
## Cost Estimates at Different Gas Prices
### At 30 gwei (Low Activity)
| Contract | Gas | Cost (ETH) | Cost (USD @ $2,500/ETH) |
|----------|-----|------------|-------------------------|
| CCIPWETH9Bridge | ~263,000 | ~0.00789 ETH | ~$19.73 |
| CCIPWETH10Bridge | ~263,000 | ~0.00789 ETH | ~$19.73 |
| Configuration | ~200,000 | ~0.006 ETH | ~$15.00 |
| **Total** | **~726,000** | **~0.02178 ETH** | **~$54.46** |
### At 50 gwei (Moderate Network Activity)
| Contract | Gas | Cost (ETH) | Cost (USD @ $2,500/ETH) |
|----------|-----|------------|-------------------------|
| CCIPWETH9Bridge | ~263,000 | ~0.01315 ETH | ~$32.88 |
| CCIPWETH10Bridge | ~263,000 | ~0.01315 ETH | ~$32.88 |
| Configuration | ~200,000 | ~0.01 ETH | ~$25.00 |
| **Total** | **~726,000** | **~0.0363 ETH** | **~$90.75** |
### At 100 gwei (High Network Activity)
| Contract | Gas | Cost (ETH) | Cost (USD @ $2,500/ETH) |
|----------|-----|------------|-------------------------|
| CCIPWETH9Bridge | ~263,000 | ~0.0263 ETH | ~$65.75 |
| CCIPWETH10Bridge | ~263,000 | ~0.0263 ETH | ~$65.75 |
| Configuration | ~200,000 | ~0.02 ETH | ~$50.00 |
| **Total** | **~726,000** | **~0.0726 ETH** | **~$181.50** |
## Total Deployment Cost Summary
### Conservative Estimate (Current: .388610002 gwei)
- Deployment: ~0.00028213 ETH (~$.7053270000)
- Configuration: ~0.00007772 ETH (~$.1943050000)
- **Total**: ~.0003598528 ETH (~$.8996320000)
**Recommended Budget**: .0003385569 ETH (~$.8463922500)
### Minimum (30 gwei, low activity)
- Deployment: ~0.01578 ETH (~$39.46)
- Configuration: ~0.006 ETH (~$15.00)
- **Total**: ~0.02178 ETH (~$54.46)
### Moderate (50 gwei)
- Deployment: ~0.0263 ETH (~$65.75)
- Configuration: ~0.01 ETH (~$25.00)
- **Total**: ~0.0363 ETH (~$90.75)
### High Activity (100 gwei)
- Deployment: ~0.0526 ETH (~$131.50)
- Configuration: ~0.02 ETH (~$50.00)
- **Total**: ~0.0726 ETH (~$181.50)
## Recommendations
1. **Use Conservative Estimates**: Always use 2.5x the highest gas price for safety margin
2. **Monitor Gas Prices**: Run `./scripts/deployment/get-conservative-gas-price.sh` before deployment
3. **Deploy during low network activity** (typically weekends or off-peak hours)
4. **Have buffer ETH** - Keep recommended budget amount for deployments and configuration
## Real-Time Gas Price Check
You can check current conservative gas prices using:
```bash
# Get conservative gas price (2.5x highest)
./scripts/deployment/get-conservative-gas-price.sh
# Calculate conservative costs
./scripts/deployment/calculate-conservative-costs.sh
# Update all documentation
./scripts/deployment/update-all-cost-estimates.sh
```
## Notes
- Gas prices fluctuate based on network activity
- Conservative estimates use 2.5x the highest gas price between MetaMask and Etherscan
- Actual costs may be lower than conservative estimates
- Consider using Layer 2 solutions for lower costs (if applicable)
- Bridge configuration can be done in separate transactions to spread costs