Fix USDT approval in cleanupErc20sViaCall using safeApproveWithRetry#58
Open
clemsos wants to merge 2 commits into
Open
Fix USDT approval in cleanupErc20sViaCall using safeApproveWithRetry#58clemsos wants to merge 2 commits into
clemsos wants to merge 2 commits into
Conversation
cleanupErc20sViaCall approved the call target with a typed IERC20(token).approve(to, amount). Mainnet USDT does not return a bool from approve(), so Solidity reverts when decoding the empty returndata, surfacing as EXECUTION_REVERTED and blocking gasless aUSDT -> mUSD conversions. Replace the typed approve with solady's safeApproveWithRetry, which tolerates tokens that do not return a bool on approve and resets the allowance to zero before re-approving a non-zero value (the second USDT quirk). All affected routers already declare 'using SafeTransferLib for address', so no new imports are required. Applies to the active v3 routers only; the deprecated v2.1 routers are left untouched. Refs: DEC-1106
Add mainnet-fork regression tests for the safeApproveWithRetry fix in cleanupErc20sViaCall, exercising both real USDT quirks against the live token and covering both changed v3 routers (tstore + non-tstore): - approve no longer reverts on USDT's missing bool return (the original EXECUTION_REVERTED that blocked gasless aUSDT -> mUSD) - the residual non-zero allowance path: when a target consumes less than the approved amount, the next cleanup re-approves over the residual without reverting (USDT's non-zero-over-non-zero approve guard) Also documents the root cause: a typed approve against real USDT reverts while decoding a bool from empty returndata. Refs: DEC-1106
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Replace the typed
IERC20.approve()call incleanupErc20sViaCallwith solady'ssafeApproveWithRetryto support non-standard ERC20 tokens like USDT.Key Changes
RelayRouterV3.solandRelayRouterV3_NonTstore.solto usetoken.safeApproveWithRetry(to, amount)instead ofIERC20(token).approve(to, amount)in thecleanupErc20sViaCallfunctionRelayRouterV3UsdtCleanupTest.sol) covering two USDT quirks:approvereturns no bool, causing typed calls to revert when decoding empty returndataImplementation Details
The fix addresses real-world compatibility issues with mainnet USDT (TetherToken):
safeApproveWithRetryhandles tokens that don't return a bool fromapproveThis resolves the EXECUTION_REVERTED error that previously blocked gasless aUSDT → mUSD transactions.
https://claude.ai/code/session_01Rh3tu7gX2ztgQMvSRbG5pX