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
Emitting a storage value for the followings: CitadelMinter.sol#L269, CitadelMinter.sol#L354, Funding.sol#L343, Funding.sol#L434-435, Funding.sol#L461-462, StakedCitadel.sol#L424, StakedCitadelVester.sol#L148,StakedCitadelVester.sol#L150, SupplySchedule.sol#L196-198 The emitted values can all be cached and emitted accordingly to minimize usage of SLOADs
At StakedCitadel.sol#L817 : The substraction can be unchecked since the condition is already met by if statement on StakedCitadel.sol#L816 and the substraction can not overflow.
At Funding.sol#L236 : The substraction can be unchecked since the condition is already met by if statement on Funding.sol#L235 and the substraction can not overflow.
At KnightingRound.sol#L250 : The substraction can be unchecked since the condition is already met by if statement on KnightingRound.sol#L249 and the substraction can not overflow.
At StakedCitadelVester.sol#L112 : The substraction can be unchecked since the condition is already met by if statement on StakedCitadelVester.sol#L111 and the substraction can not overflow.
At CitadelMinter.sol#L199 : The substraction can be unchecked since the condition is already met since lockingAmount is deposited to the vaul on line 195.
At SupplySchedule.sol#L105 : The substraction can be unchecked since the condition is already met on SupplySchedule.sol#L99-100
At StakedCitadelVester.sol#L112 and StakedCitadelVester.sol#L117 : The substraction can be unchecked since the condition is already met in claimableBalance() method's if statement.
At StakedCitadel.sol#L818 , the function is calling withdraw method which again calls _withdraw method in the same contract (not inheriting other contracts' functions). However, for IStrategy(strategy).withdraw(_toWithdraw); statement, the logic can be inlined to prevent repetetive calls inside the same contract.
Use bytes32 instead of string to save gas whenever possible since tring is a dynamic data structure and therefore is more gas consuming then bytes32.
You could use bytes32 instead of string in the following places: StakedCitadel.sol#L85-L86 , inside StakedCitadel.sol initialize() method.
Numerous constant' variables on many locations throughout the contracts can be declared as immutable to save gas.
Choosing either named return or explicit instead of specifying both may reduce gas due to unnecessary bytecode introduced. There is an inconsistent use of implicit named return variables across the entire codebase which makes readability and maintainability hard.
Below methods are only a few examples for this:
At Funding.sol :
function deposit(uint256_assetAmountIn, uint256_minCitadelOut)
external
onlyWhenPriceNotFlagged
gacPausable
nonReentrant
returns (uint256citadelAmount_)
function getAmountOut(uint256_assetAmountIn)
publicviewreturns (uint256citadelAmount_)
function getStakedCitadelAmountOut(uint256_assetAmountIn) publicviewreturns (uint256xCitadelAmount_)
function getRemainingFundable() externalviewreturns (uint256limitLeft_)
function getFundingParams() externalviewreturns (FundingParams memory)
function getDiscount() externalviewreturns (uint256)
Using custom errors instead of returning strings saves gas. But due to the complexity and the unique methods of the project, this may not be the best approach. Then, trying to reduce the error strings less than 32 bytes is also a cheaper gas saving method.
The text was updated successfully, but these errors were encountered:
Gas Optimizations
Emitting a storage value for the followings:
CitadelMinter.sol#L269
,CitadelMinter.sol#L354
,Funding.sol#L343
,Funding.sol#L434-435
,Funding.sol#L461-462
,StakedCitadel.sol#L424
,StakedCitadelVester.sol#L148
,StakedCitadelVester.sol#L150
,SupplySchedule.sol#L196-198
The emitted values can all be cached and emitted accordingly to minimize usage of SLOADsAt
StakedCitadel.sol#L817
: The substraction can be unchecked since the condition is already met byif
statement onStakedCitadel.sol#L816
and the substraction can not overflow.At
Funding.sol#L236
: The substraction can be unchecked since the condition is already met byif
statement onFunding.sol#L235
and the substraction can not overflow.At
KnightingRound.sol#L250
: The substraction can be unchecked since the condition is already met byif
statement onKnightingRound.sol#L249
and the substraction can not overflow.At
StakedCitadelVester.sol#L112
: The substraction can be unchecked since the condition is already met byif
statement onStakedCitadelVester.sol#L111
and the substraction can not overflow.At
CitadelMinter.sol#L199
: The substraction can be unchecked since the condition is already met sincelockingAmount
is deposited to the vaul on line 195.At
SupplySchedule.sol#L105
: The substraction can be unchecked since the condition is already met onSupplySchedule.sol#L99-100
At
StakedCitadelVester.sol#L112
andStakedCitadelVester.sol#L117
: The substraction can be unchecked since the condition is already met inclaimableBalance()
method'sif
statement.At
StakedCitadel.sol#L818
, the function is callingwithdraw
method which again calls_withdraw
method in the same contract (not inheriting other contracts' functions). However, forIStrategy(strategy).withdraw(_toWithdraw);
statement, the logic can be inlined to prevent repetetive calls inside the same contract.Use bytes32 instead of string to save gas whenever possible since tring is a dynamic data structure and therefore is more gas consuming then bytes32.
You could use bytes32 instead of string in the following places:
StakedCitadel.sol#L85-L86
, insideStakedCitadel.sol
initialize()
method.Numerous
constant
' variables on many locations throughout the contracts can be declared asimmutable
to save gas.Choosing either named
return
or explicit instead of specifying both may reduce gas due to unnecessary bytecode introduced. There is an inconsistent use of implicit named return variables across the entire codebase which makes readability and maintainability hard.Below methods are only a few examples for this:
At
Funding.sol
:The text was updated successfully, but these errors were encountered: