@@ -167,22 +167,38 @@ def fetch_gas_price(oracle_url: str) -> Wei | None:
167167 response = requests .get (oracle_url )
168168 response .raise_for_status ()
169169 data : dict = response .json ()
170+
171+ print (f"🔍 Gas price oracle response: { data } " )
170172
171173 if "result" in data :
172174 gas_price = int (data ["result" ], 16 )
173175 elif "fast" in data :
174176 gas_price = self .w3 .to_wei (data ["fast" ], "gwei" )
177+ elif "result" in data and "SafeGasPrice" in data ["result" ]:
178+ # Handle Basescan format
179+ gas_price = self .w3 .to_wei (data ["result" ]["SafeGasPrice" ], "gwei" )
180+ elif "result" in data and "FastGasPrice" in data ["result" ]:
181+ # Handle Basescan format with FastGasPrice
182+ gas_price = self .w3 .to_wei (data ["result" ]["FastGasPrice" ], "gwei" )
175183 else :
184+ print (f"⚠️ Unknown gas price oracle format: { data } " )
176185 return None
177186
178- # Ensure minimum gas price (1 gwei = 1,000,000,000 wei)
179- min_gas_price = self .w3 .to_wei (1 , "gwei" ) # 1 gwei minimum
187+ print (f"💰 Parsed gas price: { gas_price } wei" )
188+
189+ # Ensure minimum gas price (2 gwei = 2,000,000,000 wei)
190+ min_gas_price = self .w3 .to_wei (2 , "gwei" ) # 2 gwei minimum
180191 if gas_price < min_gas_price :
181192 print (f"⚠️ Gas price from oracle too low ({ gas_price } wei), using minimum ({ min_gas_price } wei)" )
182- return min_gas_price
193+ gas_price = min_gas_price
194+
195+ # Apply multiplier to ensure transaction goes through (1.5x)
196+ gas_price = int (gas_price * 1.5 )
197+ print (f"🚀 Final gas price with multiplier: { gas_price } wei" )
183198
184199 return gas_price
185- except Exception :
200+ except Exception as e :
201+ print (f"❌ Error fetching gas price from { oracle_url } : { e } " )
186202 return None
187203
188204 oracles = self .gas_price_oracle
@@ -198,14 +214,14 @@ def fetch_gas_price(oracle_url: str) -> Wei | None:
198214 # Fallback: use network gas price with minimum
199215 try :
200216 network_gas_price = self .w3 .eth .gas_price
201- min_gas_price = self .w3 .to_wei (1 , "gwei" ) # 1 gwei minimum
217+ min_gas_price = self .w3 .to_wei (2 , "gwei" ) # 2 gwei minimum
202218 if network_gas_price < min_gas_price :
203219 print (f"⚠️ Network gas price too low ({ network_gas_price } wei), using minimum ({ min_gas_price } wei)" )
204220 return min_gas_price
205221 return network_gas_price
206222 except Exception :
207223 # Final fallback: return minimum gas price
208- return self .w3 .to_wei (1 , "gwei" )
224+ return self .w3 .to_wei (2 , "gwei" )
209225
210226 def _init_contracts (self ):
211227 for contract in self .abi .keys ():
0 commit comments