You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Handle mainnet USDT allowance reset in Permit2 flows #609
Permit2 flows read the ERC-20 allowance granted to the Permit2 contract. When the allowance is below the required amount, Monarch currently calls approve(Permit2, maxUint256).
Canonical Ethereum mainnet USDT is unusual: it rejects changing an allowance directly from one non-zero value to another. The allowance must first be reset to zero. Its revert has no reason data, so wallets such as Rabby may only show Simulation Failed (#-39000). This is user-state-dependent: users with zero or sufficient/unlimited allowance will not reproduce it.
Required behavior
Special-case canonical mainnet USDT using chain ID + token address, not symbol alone:
allowance >= required: continue without approval
allowance == 0: approve Permit2 for maxUint256, then continue
0 < allowance < required: approve Permit2 for 0, wait for confirmation, approve Permit2 for maxUint256, wait for confirmation, then continue the Permit2 flow
Reflect both approval transactions in transaction tracking and preserve the existing behavior for every other token
Also use >= rather than > when checking whether the current allowance is sufficient, so an exact allowance does not trigger an unnecessary USDT reapproval.
Activity