Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions examples/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def main() -> None:
block = w3.eth.block_number

# Simulation is only supported on mainnet
if network == "mainnet":
if network == Network.MAINNET:
# Simulate bundle on current block.
# If your RPC provider is not fast enough, you may get "block extrapolation negative"
# error message triggered by "extrapolate_timestamp" function in "flashbots.py".
Expand Down Expand Up @@ -207,8 +207,16 @@ def main() -> None:
break
except TransactionNotFound:
logger.info(f"Bundle not found in block {block + 1}")
cancel_res = w3.flashbots.cancel_bundles(replacement_uuid)
logger.info(f"Canceled {cancel_res}")
try:
cancel_res = w3.flashbots.cancel_bundles(replacement_uuid)
logger.info(f"Canceled {cancel_res}")
except Exception as e:
if "400" in str(e):
logger.warning(
f"Bundle cancellation returned 400 error (bundle may not exist), ignoring: {e}"
)
else:
raise

log_account_balances(w3, sender.address, receiver)

Expand Down