You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using i++ instead ++i for all the loops, the variable i is incremented using i++. It is known that implementation by using ++i costs less gas per iteration than i++.
Tools Used
Manual Review
Occurances
main/src/CitadelMinter.sol#L152
Reorder Struct can saving gas
Since address was 20 bytes and uint256 was 32 bytes on struct, this implementation below can be used for gas opt
struct FundingParams {
address discountManager;
uint256 discount;
uint256 minDiscount;
uint256 maxDiscount;
uint256 assetCumulativeFunded; /// persistent sum of asset amount in over lifetime of contract.
uint256 assetCap; /// Max asset token that can be taken in by the contract (defines the cap for citadel sold)
}
Using short reason string can be used for saving more gas
Every reason string takes at least 32 bytes. Use short reason strings that fits in 32 bytes or it will become more expensive.
= 0
If a variable was not set/initialized, it is assumed to have default value to 0
this implementation was used for saving more gas by removing
= 0
##POC
https://blog.polymath.network/solidity-tips-and-tricks-to-save-gas-and-reduce-bytecode-size-c44580b218e6
##TOOLS USED
Visual Studio Code, Manual Review
##Mitigation Step
Remove
= 0
##Occurances
https://github.com/code-423n4/2022-04-badger-citadel/blob/18f8c392b6fc303fe95602eba6303725023e53da/src/CitadelMinter.sol#L180-L182
Another Occurance
uint256 i = 0
intouint i
for saving more gasthis implementation can saving more gas for each loops.
##Tool Used
Manual Review
##Recommended Mitigation
Change it
Occurances
Using i++ instead ++i for all the loops, the variable i is incremented using i++. It is known that implementation by using ++i costs less gas per iteration than i++.
Tools Used
Manual Review
Occurances
Since
address
was 20 bytes anduint256
was 32 bytes on struct, this implementation below can be used for gas opt##Tool Used
Manual Review
##Recommended Mitigation
https://github.com/code-423n4/2022-04-badger-citadel/blob/18f8c392b6fc303fe95602eba6303725023e53da/src/Funding.sol#L46-L53
Every reason string takes at least 32 bytes. Use short reason strings that fits in 32 bytes or it will become more expensive.
##Tool Used
Manual Review
##Occurance :
This implementation below can be saving more gas
##Tool Used
Manual Review
##Recommended Mitigation
changed to
This implementation can be used for saving more gas, instead cache vesting[msg.sender].claimedAmounts it can be changed by using
+=
instead.##POC
https://www.tutorialspoint.com/solidity/solidity_operators.htm
##Tool Used
Manual Review
##Recommended Mitigation
The text was updated successfully, but these errors were encountered: