Impact: High, because the transaction might be left hanging in the mempool and be executed way later than the user wanted at a possibly worse price
Likelihood: Medium, because there is a great chance that the user won't adjust the gas price to be lucrative for the validators to include its transaction fast
The deadline parameter in swapExactTokensForTokensSupportingFeeOnTransferTokens, swapExactETHForTokensSupportingFeeOnTransferTokens, and swapExactTokensForETHSupportingFeeOnTransferTokens() which are called in the convert methods inside ExchangeAgent.sol is hardcoded to block.timestamp.
Now when the deadline is hardcoded as block.timestamp, the transaction will not revert because the require statement will always be fulfilled by block.timestamp == block.timestamp.
If a user chooses a transaction fee that is too low for miners to be interested in including the transaction in a block, the transaction stays pending in the mempool for extended periods, which could be hours, days, weeks, or even longer.
This could lead to users getting a worse price because a validator can just hold onto the transaction.
Recommendations
Protocols should let users who interact with AMMs set expiration deadlines. Without this, there's a risk of a serious loss of funds for anyone starting a swap.
Use a user-supplied deadline instead of block.timestamp.
Impact: High, because the transaction might be left hanging in the mempool and be executed way later than the user wanted at a possibly worse price
Likelihood: Medium, because there is a great chance that the user won't adjust the gas price to be lucrative for the validators to include its transaction fast
The deadline parameter in
swapExactTokensForTokensSupportingFeeOnTransferTokens
,swapExactETHForTokensSupportingFeeOnTransferTokens
, andswapExactTokensForETHSupportingFeeOnTransferTokens()
which are called in the convert methods insideExchangeAgent.sol
is hardcoded toblock.timestamp
.Example in
_convertTokenForETH
:The
swapExactTokensForETHSupportingFeeOnTransferTokens
inUniswapV2Router02
contract:The
deadline
parameter enforces a time limit by which the transaction must be executed otherwise it will revert.Let's take a look at the
ensure
modifier that is present in the functions you are calling inUniswapV2Router02
contract:Now when the
deadline
is hardcoded asblock.timestamp
, the transaction will not revert because the require statement will always be fulfilled by block.timestamp == block.timestamp.If a user chooses a transaction fee that is too low for miners to be interested in including the transaction in a block, the transaction stays pending in the mempool for extended periods, which could be hours, days, weeks, or even longer.
This could lead to users getting a worse price because a validator can just hold onto the transaction.
Recommendations
Protocols should let users who interact with AMMs set expiration deadlines. Without this, there's a risk of a serious loss of funds for anyone starting a swap.
Use a user-supplied deadline instead of
block.timestamp
.