feat: improve gas estimation with refactored parameters and better error handling #534
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves gas estimation across Ethereum and Solana chains with refactored configuration parameters, per-network caching, and enhanced error handling.
Key Changes
1. Gas Configuration Refactoring
EIP-1559 Networks (Ethereum Mainnet, Polygon, Arbitrum, Optimism, Base):
maxFeePerGasandmaxPriorityFeePerGaswithbaseFeeandpriorityFeebaseFeeMultiplierparameter (default: 1.2 for 20% buffer)maxFeePerGas = baseFee * baseFeeMultiplier + priorityFeepriorityFeefrom 0.01 to 0.001 GWEILegacy Networks (Avalanche, BSC, Celo, Sepolia):
minGasPricetogasPrice2. Per-Network Gas Caching
Bug Fix: Fixed cross-network cache contamination where Base network was returning Mainnet gas prices
ethereum.ts) and Solana (solana-priority-fees.ts)3. Enhanced Error Handling
Better HTTP status codes and error messages for gas estimation failures:
Error messages now include network context and specific failure reasons.
4. Schema and Configuration Updates
ethereum-network-schema.jsonwith new gas parameterssolana-network-schema.jsonfor consistency["number", "null"]for optional numeric fieldsFiles Changed
Core Implementation (5 files):
src/chains/ethereum/ethereum.config.ts- Update interface with new gas parameterssrc/chains/ethereum/ethereum.ts- Refactor gas estimation logic, per-network cachesrc/chains/ethereum/routes/estimate-gas.ts- Enhanced error handlingsrc/chains/solana/solana-priority-fees.ts- Per-network cache for Solanasrc/chains/solana/solana.ts- Pass network parameter to priority fee estimationTemplates (13 files):
Tests (2 files):
test/chains/ethereum/routes/estimate-gas.test.ts- Updated for new params and error handlingtest/chains/ethereum/infura-service.test.ts- Removed deprecatedminGasPriceTest Plan
Test Coverage
Migration Notes
Breaking Changes: Gas parameter names have changed in network configuration files. Users will need to update their
conf/chains/ethereum/*.ymlandconf/chains/solana/*.ymlfiles.Before (EIP-1559):
After (EIP-1559):
Before (Legacy):
After (Legacy):
gasPrice:Leave values empty to fetch from network. The
baseFeeMultiplierdefaults to 1.2 if not specified.🤖 Generated with Claude Code