This is a short post detailing two bug fixes for the Uniswap V3 bot.
I will release periodic posts like this as I identify and fix bugs. Thank you for reporting issues!
Flashbots Middleware Fix
This is a frustrating one but is important to share. The bot uses the web3-flashbots middleware to perform simulation and send bundles to the relay.
The newest version (v1.1.0) has a bug that throws an exception when the send_bundle
method is called with the optional opts
argument omitted. It’s optional so the middleware is expected to perform correctly, but it does not.
I’ve isolated the cause of the error and posted an issue on their github which you can follow if interested.
Workaround
Until they fix this issue, the workaround is to adjust all calls to send_bundle
to include a dictionary. This dictionary can have values if you are using these optional arguments, or empty if you are not.
For example, change this:
w3.flashbots.send_bundle(
bundle,
target_block_number=target_block + i,
)
to this:
w3.flashbots.send_bundle(
bundle,
target_block_number=target_block + i,
opts={},
)
Version Note
This regression was introduced in the new release (v1.1.0). You do not need to apply this workaround if you are using the older version.
I will post an update when the fix is implemented in the official version.
Tick Bitmap Fixes
I’ve isolated two bugs in the V3 helper that were affecting tick bitmaps.
Tick Range Gap
This bug would generate exceptions about lower_word
being unreferenced. This occurred because I made a bad assumption in my pre-calculation checks that a requested tick word would never be generated within the existing range of known words. It turns out that the behavior of the external_update
method was affecting this assumption. If external_update
attempts to update the liquidity at an unknown tick, it will fetch that single tick before proceeding. This can leave a “gap” in the known tick range, which invalidated my assumption. The helper now behaves correctly.
Out-of-Order Check
I defined the known tick word range with two variables (min_word
and max_word
). Unfortunately I did this after using it in a pre-calculation check, which threw exceptions about an unreferenced variable.
The fix was simple: flip the position of those two code blocks. You can see that commit HERE.
Fixes
Pull the latest version of degenbot from github to apply these fixes.