Files
proxmox/scripts/calculate-chain138-gas-price.sh
defiQUG fbda1b4beb
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
docs: Ledger Live integration, contract deploy learnings, NEXT_STEPS updates
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands
- CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround
- CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check
- NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere
- MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates
- LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 15:46:57 -08:00

69 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Load IP configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
# Calculate optimal gas price for ChainID 138 deployments
# Uses RPC gas price API and respects minimum gas price from config
#
# Usage:
# GAS_PRICE=$(bash scripts/calculate-chain138-gas-price.sh)
# echo "Gas price: $GAS_PRICE wei"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
# Load environment (suppress errors)
set +e
if [ -f "$PROJECT_ROOT/.env" ]; then
source "$PROJECT_ROOT/.env" 2>/dev/null || true
fi
if [ -f "$PROJECT_ROOT/smom-dbis-138/.env" ]; then
source "$PROJECT_ROOT/smom-dbis-138/.env" 2>/dev/null || true
fi
set -e
# RPC URL for ChainID 138
RPC_URL="${RPC_URL_138:-http://${RPC_CORE_1}:8545}"
# Minimum gas price from config (1 gwei = 1,000,000,000 wei)
MIN_GAS_PRICE_WEI="${MIN_GAS_PRICE_WEI:-1000000000}"
# Safety multiplier (10% buffer)
SAFETY_MULTIPLIER="${SAFETY_MULTIPLIER:-1.1}"
# Get current gas price from RPC
get_rpc_gas_price() {
local rpc_url=$1
cast gas-price --rpc-url "$rpc_url" 2>/dev/null || echo ""
}
# Calculate optimal gas price
calculate_optimal_gas_price() {
# Try to get current gas price from RPC
local current_gas_price=$(get_rpc_gas_price "$RPC_URL")
# Use minimum if RPC call failed or returned 0
if [ -z "$current_gas_price" ] || [ "$current_gas_price" = "0" ]; then
current_gas_price="$MIN_GAS_PRICE_WEI"
fi
# Use the higher of current or minimum
local base_gas_price=$current_gas_price
if [ "$current_gas_price" -lt "$MIN_GAS_PRICE_WEI" ]; then
base_gas_price="$MIN_GAS_PRICE_WEI"
fi
# Apply safety multiplier (using integer math: * 11 / 10 = 1.1)
local optimal_gas_price=$((base_gas_price * 11 / 10))
echo "$optimal_gas_price"
}
# Output gas price
calculate_optimal_gas_price