Backd contest - Tadashi's results

Maximize the power of your assets and start earning yield

General Information

Platform: Code4rena

Start Date: 21/04/2022

Pot Size: $100,000 USDC

Total HM: 18

Participants: 60

Period: 7 days

Judge: gzeon

Total Solo HM: 10

Id: 112

League: ETH

Backd

Findings Distribution

Researcher Performance

Rank: 37/60

Findings: 2

Award: $244.27

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Awards

159.3125 USDC - $159.31

Labels

bug
QA (Quality Assurance)
resolved
reviewed

External Links

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

Awards

84.957 USDC - $84.96

Labels

bug
G (Gas Optimization)
resolved
reviewed

External Links

Immutable variable can be constant

Summary: Immutable variable can be changed to constant to reduce deployment cost

Details: Immutable variables are evaluated once at construction time and their value is copied to all the places in the code where they are accessed. For these values, 32 bytes are reserved, even if they would fit in fewer bytes. In particular address variables has only 20 bytes and the immutable variable of L27 of ChainlinkUSDWrapper.sol can be changed to a constant variable, i.e.:

IChainlinkOracle private constant _ethOracle =
        IChainlinkOracle(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419);

Remove branch not being executed

Summary: some branches are not executed and can be eliminated from the code

Details:

Split require to avoid using && opcode

Details: Change L676 of TopUpAction.sol to

require(vars.success, Error.TOP_UP_FAILED);
require(abi.decode(vars.topupResult, (bool)), Error.TOP_UP_FAILED);

in order to avoid using &&.

Note: I only recommend this optimization if backd gives a proper documentation for the error Error.TOP_UP_FAILED. Otherwise, developers may miss one of the conditions when debugging a reverted transaction.

Pre-incrementing a variable is cheaper than post-incrementing it.

Details: i++ can be replaced by ++i in the following loops:

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax Β© 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter