Approved tokens after a failed DEX swap: allowance status
Can a DEX use approved tokens after a swap fails? Usually yes: a separate ERC-20 approval remains available to its spender until used, changed, or revoked.
Crypto Blog Newsroom4 min read
Usually, yes: if you approved an ERC-20 token in a separate transaction, a failed DEX swap does not cancel the remaining allowance.
- A separate approval transaction can remain in effect after a swap fails.
- A reverted swap rolls back its own changes, including any token transfer it attempted.
- The allowance applies to a named spender address and an amount.
Say you approve 100 tokens for a DEX, then submit a swap that reverts. The failed swap does not transfer those tokens, but the earlier approval can still let the approved spender use some or all of the remaining allowance later. The amount available depends on the token’s current allowance.
A separate approval can survive a reverted swap
An ERC-20 approval and a swap are separate on-chain state changes when they are sent as separate transactions. The approval sets an allowance in the token contract for a specified spender address. The swap then tries to execute using its own transaction.
If that swap reverts, the EVM rolls back the changes made inside the swap transaction. It does not undo the earlier approval transaction. So the swap may fail without moving tokens, while the allowance remains available to the approved spender.
Matcha swap is an aggregator that finds trade routes across liquidity sources, which makes approval status a useful part of diagnosing a failed trade. Its approval prompt is a concrete case of an approval-confirmed swap prompt: the prompt and the swap can involve separate transactions, so the approval may remain even if the trade fails.
An allowance is permission for a spender address to call transferFrom for up to the approved amount. It is not a token transfer. The tokens stay in your wallet unless a transaction causes the spender contract to call transferFrom and the token contract accepts that call.
That distinction matters after a failure. A reverted swap transaction does not complete its token transfer, but an earlier allowance can still be used in a later eligible transaction. Whether that can happen depends on the token contract, the spender address, its code, and the remaining allowance.
The spender and remaining allowance determine what stays usable
The approved spender address determines which address received permission, and the allowance determines the maximum amount it can draw with transferFrom. An approval does not authorize every DEX or every contract to use your tokens.
To assess the risk after a failed swap, identify the token contract and spender address in the approval transaction, then inspect the current allowance for that pair. The swap transaction hash can show that the trade reverted; the approval transaction is separate evidence of the permission you granted.
In the example, if the 100-token approval remains untouched, the spender may still have permission for up to 100 tokens. If some allowance was used in another transaction, the remaining amount may be lower. If you replaced the allowance or revoked it in a later transaction, the current amount may also differ from the original approval.
Matcha swap can route through different liquidity sources, but routing does not change which spender address the token approval names. Confirm that address before deciding whether to keep the allowance. Revoke it if you no longer want that spender to have the permission; revocation changes the allowance through another on-chain transaction.
An approval and a swap can also be bundled into one atomic transaction. If that single transaction reverts, the approval made inside it is rolled back along with the swap. In that case, the failed transaction does not leave behind its attempted approval.
Related
Does a failed swap use up an ERC-20 approval?
A failed swap does not automatically use up a separate ERC-20 approval. The current allowance changes only if a transaction successfully changes it, such as a later token transfer through transferFrom, a replacement approval, or a revocation.
How can I revoke a token approval after a failed swap?
Revoke the allowance for the token and spender address you approved, using a wallet or approval tool that submits the change on-chain. Confirm the token, spender, and current allowance before signing. After the revocation transaction succeeds, the spender no longer has that allowance to use.