Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas Optimizations #52

Open
code423n4 opened this issue Apr 18, 2022 · 0 comments
Open

Gas Optimizations #52

code423n4 opened this issue Apr 18, 2022 · 0 comments
Labels
bug Something isn't working G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

Issues found

Don't Initialize Variables with Default Value

Impact

Issue Information: G001 - variables with default value

Findings:

CitadelMinter.sol::152 => for (uint256 i = 0; i < numPools; i++) {
CitadelMinter.sol::180 => uint256 lockingAmount = 0;
CitadelMinter.sol::181 => uint256 stakingAmount = 0;
CitadelMinter.sol::182 => uint256 fundingAmount = 0;
SupplySchedule.sol::103 => uint256 mintable = 0;
SupplySchedule.sol::192 => uint256 mintable = 0;
lib/GlobalAccessControlManaged.sol::47 => bool validRoleFound = false;
lib/GlobalAccessControlManaged.sol::48 => for (uint256 i = 0; i < roles.length; i++) {
test/BaseFixture.sol::293 => for (uint256 i = 0; i < numAddressesToTrack; i++) {

Cache Array Length Outside of Loop

Impact

Issue Information: G002 - array length outside loop

Findings:

CitadelMinter.sol::344 => for (uint256 i; i < length; ++i) {
lib/GlobalAccessControlManaged.sol::48 => for (uint256 i = 0; i < roles.length; i++) {
lib/SafeERC20.sol::96 => if (returndata.length > 0) {
test/utils/SnapshotUtils.sol::16 => for (uint256 i; i < length; ++i) {
test/utils/SnapshotUtils.sol::41 => if (address(MULTICALL).code.length == 0) {
test/utils/SnapshotUtils.sol::66 => for (uint256 i; i < length; ++i) {

Long Revert Strings

Impact

Issue Information: G007 - long (revert) strings

Findings:

CitadelMinter.sol::301 => "CitadelMinter: Sum of propvalues must be 10000 bps"
CitadelMinter.sol::321 => "CitadelMinter: last mint timestamp already initialized"
CitadelMinter.sol::328 => "CitadelMinter: supply schedule start not initialized"
CitadelMinter.sol::370 => "CitadelMinter: funding pool does not exist for removal"
CitadelMinter.sol::377 => "CitadelMinter: funding pool already exists"
Funding.sol::148 => "Funding: citadel price from oracle flagged and pending review"
Funding.sol::298 => "cannot decrease cap below global sum of assets in"
Funding.sol::325 => "cannot sweep funding asset, use claimAssetToTreasury()"
Funding.sol::390 => "Funding: sale recipient should not be zero"
GlobalAccessControl.sol::118 => "Role string and role do not match"
KnightingRound.sol::122 => "KnightingRound: start date may not be in the past"
KnightingRound.sol::126 => "KnightingRound: the sale duration must not be zero"
KnightingRound.sol::130 => "KnightingRound: the price must not be zero"
KnightingRound.sol::134 => "KnightingRound: sale recipient should not be zero"
KnightingRound.sol::273 => require(!finalized, "KnightingRound: already finalized");
KnightingRound.sol::277 => "KnightingRound: not enough balance"
KnightingRound.sol::295 => "KnightingRound: start date may not be in the past"
KnightingRound.sol::297 => require(!finalized, "KnightingRound: already finalized");
KnightingRound.sol::314 => "KnightingRound: the sale duration must not be zero"
KnightingRound.sol::316 => require(!finalized, "KnightingRound: already finalized");
KnightingRound.sol::333 => "KnightingRound: the price must not be zero"
KnightingRound.sol::351 => "KnightingRound: sale recipient should not be zero"
KnightingRound.sol::384 => require(!finalized, "KnightingRound: already finalized");
StakedCitadel.sol::192 => "performanceFeeGovernance too high"
StakedCitadel.sol::196 => "performanceFeeStrategist too high"
StakedCitadel.sol::508 => "Please withdrawToVault before changing strat"
StakedCitadel.sol::537 => "performanceFeeStrategist too high"
StakedCitadel.sol::632 => "Excessive strategist performance fee"
StakedCitadel.sol::652 => "Excessive governance performance fee"
StakedCitadelVester.sol::137 => require(msg.sender == vault, "StakedCitadelVester: only xCTDL vault");
StakedCitadelVester.sol::138 => require(_amount > 0, "StakedCitadelVester: cannot vest 0");
SupplySchedule.sol::62 => "SupplySchedule: minting not started"
SupplySchedule.sol::92 => "SupplySchedule: minting not started"
SupplySchedule.sol::96 => "SupplySchedule: already minted up to current block"
SupplySchedule.sol::139 => "SupplySchedule: minting already started"
SupplySchedule.sol::143 => "SupplySchedule: minting must start at or after current time"
SupplySchedule.sol::157 => "SupplySchedule: rate already set for given epoch"
SupplySchedule.sol::181 => "SupplySchedule: minting not started"
SupplySchedule.sol::185 => "SupplySchedule: attempting to mint before start block"
SupplySchedule.sol::189 => "SupplySchedule: already minted up to current block"
SupplySchedule.sol::227 => "total mintable after this iteration",

Prefix increments are cheaper than postfix increments

Impact

Issue Information: G009 - Prefix increments are cheaper than postfix increments

Findings:

CitadelMinter.sol::152 => for (uint256 i = 0; i < numPools; i++) {
SupplySchedule.sol::208 => for (uint256 i = startingEpoch; i <= endingEpoch; i++) {
lib/GlobalAccessControlManaged.sol::48 => for (uint256 i = 0; i < roles.length; i++) {
test/BaseFixture.sol::293 => for (uint256 i = 0; i < numAddressesToTrack; i++) {
test/utils/Utils.sol::21 => digits++;
@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Apr 18, 2022
code423n4 added a commit that referenced this issue Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

1 participant