20,000 USDC
View results
Submission Details
Severity: gas

## [G-27] Use hardcode address instead address(this)

Summary

[G-27] Use hardcode address instead address(this)

Instead of using address(this), it is more gas-efficient to pre-calculate and use the hardcoded address. Foundry’s script.sol and solmate’s LibRlp.sol contracts can help achieve this.
References: https://book.getfoundry.sh/reference/forge-std/compute-create-address

file: /src/Fees.sol
28 uint256 amount = IERC20(_profits).balanceOf(address(this));

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Fees.sol#L28

file: /src/Fees.sol
43 IERC20(WETH).transfer(staking, IERC20(WETH).balanceOf(address(this)));

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Fees.sol#L43

file: /src/Staking.sol
57 balance = WETH.balanceOf(address(this));

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Staking.sol#L57

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.