code-423n4 / 2022-04-backd-findings

6 stars 4 forks source link

QA Report #81

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Some tokens require the approval to be zero before calling approve with a non-zero value

Summary: some ERC20 tokens require approving to 0 first

Details: Some tokens (such as USDT) do not work when changing the allowance from an existing non-zero allowance value.

Mitigation: In L50 of TopUpAction.sol change the code to

IERC20(token).safeApprove(stakerVaultAddress, 0);
IERC20(token).safeApprove(stakerVaultAddress, depositAmount);

The same pattern should be applied to the following lines mutatis mutandis:

Impact: Low, depending which tokens will be integrated in backd

Misleading Error message

Summary: misleading error message could potentially confuse developers when debugging code

Details:

On L86 of Preparable.sol, if deadlines[key] is zero then the return message will be Error.DEADLINE_NOT_ZERO, which is the opposite condition of the error (cf. L28 of Preparable.sol for the same error but with the correct context).

The same can be said of L98 of Preparable.sol.

Impact: Code QA

Typos

TODOs left in the code