Some standard ERC20 tokens have approval race protections. Specifically, tokens like USDT and KNC do not allow approving an amount ( M > 0 ) when an existing amount ( N > 0 ) is already approved. In the current implementation, the approve function is called within the _transfer function, which is triggered for every tillIn() and withdraw() function call. The approve function does not reset the approval to zero before setting it to the desired value. Due to this, transactions involving these tokens can revert.
The issue is present in the approve function of the CapitalPool.sol :
Additionally, this function is called by the _transfer function in TokenManager.sol:
Note: submitting this issue `Med` because this code is used in critical funcitons and called frequently
The approve function directly sets the allowance to the maximum value without first resetting it to zero. This can cause transactions to revert for tokens that have built-in protections against changing the allowance from a non-zero value to another non-zero value.
Manual Review
Modify the approve function in CapitalPool.sol to first set the allowance to zero before setting it to the desired value. This ensures compatibility with tokens that have approval race protections.
I believe this is invalid, - For weird ERC20s with front-running approval protection such as UDST (only known instance so far), max approval is likely only required to be invoked once, considering the supply cap of such tokens. (USDT supply is at 53.8 billion (53.8e9 * 1e9, so this is 100% sufficient) - If approvals are insufficient, a new proxy for tadle market can always be deployed via the TadleFactory contract and migrated
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.