Reserve contest - arialblack14's results

A permissionless platform to launch and govern asset-backed stable currencies.

General Information

Platform: Code4rena

Start Date: 06/01/2023

Pot Size: $210,500 USDC

Total HM: 27

Participants: 73

Period: 14 days

Judge: 0xean

Total Solo HM: 18

Id: 203

League: ETH

Reserve

Findings Distribution

Researcher Performance

Rank: 73/73

Findings: 1

Award: $72.44

Gas:
grade-b

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Awards

72.4433 USDC - $72.44

Labels

bug
G (Gas Optimization)
grade-b
G-34

External Links

GAS OPTIMIZATION REPORT β›½

[G-1] Use calldata instead of memory.

Description

Use calldata instead of memory for function parameters saves gas if the function argument is only read.

βœ… Recommendation

Use calldata instead of memory.

πŸ” Findings:

protocol/contracts/libraries/String.sol#L11function toLower(string memory str) internal pure returns (string memory) {
protocol/contracts/libraries/test/StringCallerMock.sol#L9function toLower(string memory str) external pure returns (string memory){

[G-2] ++i/i++ should be unchecked{++i}/unchecked{i++} when it is not possible for them to overflow, for example when used in for and while loops

Description

In Solidity 0.8+, there’s a default overflow check on unsigned integers. It’s possible to uncheck this in for-loops and save some gas at each iteration, but at the cost of some code readability, as this uncheck cannot be made inline. Example for loop:

for (uint i = 0; i < length; i++) {
// do something that doesn't change the value of i
}

In this example, the for loop post condition, i.e., i++ involves checked arithmetic, which is not required. This is because the value of i is always strictly less than length <= 2**256 - 1. Therefore, the theoretical maximum value of i to enter the for-loop body is 2**256 - 2. This means that the i++ in the for loop can never overflow. Regardless, the overflow checks are performed by the compiler.

Unfortunately, the Solidity optimizer is not smart enough to detect this and remove the checks. You should manually do this by:

for (uint i = 0; i < length; i = unchecked_inc(i)) {
	// do something that doesn't change the value of i
}

function unchecked_inc(uint i) returns (uint) {
	unchecked {
		return i + 1;
	}
}

Or just:

for (uint i = 0; i < length;) {
	// do something that doesn't change the value of i
	unchecked { i++; 	}
}

Note that it’s important that the call to unchecked_inc is inlined. This is only possible for solidity versions starting from 0.8.2.

Gas savings: roughly speaking this can save 30-40 gas per loop iteration. For lengthy loops, this can be significant! (This is only relevant if you are using the default solidity checked arithmetic.)

βœ… Recommendation

Use the unchecked keyword

πŸ” Findings:

protocol/contracts/libraries/String.sol#L14for (uint256 i = 0; i < bStr.length; i++) {
protocol/contracts/p1/BasketHandler.sol#L653for (uint256 i = 0; i < erc20s.length; i++) {
protocol/contracts/p1/Distributor.sol#L133for (uint256 i = 0; i < numTransfers; i++) {
protocol/contracts/plugins/mocks/EasyAuction.sol#L277for (uint256 i = 0; i < _minBuyAmounts.length; i++) {
protocol/contracts/plugins/mocks/EasyAuction.sol#L288for (uint256 i = 0; i < _minBuyAmounts.length; i++) {
protocol/contracts/plugins/mocks/EasyAuction.sol#L316for (uint256 i = 0; i < _sellOrders.length; i++) {
protocol/contracts/plugins/mocks/EasyAuction.sol#L344for (uint256 i = 0; i < iterationSteps; i++) {
protocol/contracts/plugins/mocks/EasyAuction.sol#L513for (uint256 i = 0; i < orders.length; i++) {
protocol/contracts/plugins/mocks/EasyAuction.sol#L524for (uint256 i = 0; i < orders.length; i++) {

[G-3] Use assembly to check for address(0)

Description

You can save about 6 gas per instance if using assembly to check for address(0)

πŸ” Findings:

protocol/contracts/mixins/Auth.sol#L94require(account != address(0), "cannot grant role to address 0");
protocol/contracts/mixins/ComponentRegistry.sol#L37require(address(val) != address(0), "invalid RToken address");
protocol/contracts/mixins/ComponentRegistry.sol#L45require(address(val) != address(0), "invalid StRSR address");
protocol/contracts/mixins/ComponentRegistry.sol#L53require(address(val) != address(0), "invalid AssetRegistry address");
protocol/contracts/mixins/ComponentRegistry.sol#L61require(address(val) != address(0), "invalid BasketHandler address");
protocol/contracts/mixins/ComponentRegistry.sol#L69require(address(val) != address(0), "invalid BackingManager address");
protocol/contracts/mixins/ComponentRegistry.sol#L77require(address(val) != address(0), "invalid Distributor address");
protocol/contracts/mixins/ComponentRegistry.sol#L85require(address(val) != address(0), "invalid RSRTrader address");
protocol/contracts/mixins/ComponentRegistry.sol#L93require(address(val) != address(0), "invalid RTokenTrader address");
protocol/contracts/mixins/ComponentRegistry.sol#L101require(address(val) != address(0), "invalid Furnace address");
protocol/contracts/mixins/ComponentRegistry.sol#L109require(address(val) != address(0), "invalid Broker address");
protocol/contracts/p1/Broker.sol#L57require(address(gnosis_) != address(0), "invalid Gnosis address");
protocol/contracts/p1/Broker.sol#L59address(tradeImplementation_) != address(0),
protocol/contracts/p1/Deployer.sol#L49address(rsr_) != address(0) &&
protocol/contracts/p1/Deployer.sol#L50address(gnosis_) != address(0) &&
protocol/contracts/p1/Deployer.sol#L51address(rsrAsset_) != address(0) &&
protocol/contracts/p1/Deployer.sol#L52address(implementations_.main) != address(0) &&
protocol/contracts/p1/Deployer.sol#L53address(implementations_.trade) != address(0) &&
protocol/contracts/p1/Deployer.sol#L54address(implementations_.components.assetRegistry) != address(0) &&
protocol/contracts/p1/Deployer.sol#L55address(implementations_.components.backingManager) != address(0) &&
protocol/contracts/p1/Deployer.sol#L56address(implementations_.components.basketHandler) != address(0) &&
protocol/contracts/p1/Deployer.sol#L57address(implementations_.components.broker) != address(0) &&
protocol/contracts/p1/Deployer.sol#L58address(implementations_.components.distributor) != address(0) &&
protocol/contracts/p1/Deployer.sol#L59address(implementations_.components.furnace) != address(0) &&
protocol/contracts/p1/Deployer.sol#L60address(implementations_.components.rsrTrader) != address(0) &&
protocol/contracts/p1/Deployer.sol#L61address(implementations_.components.rTokenTrader) != address(0) &&
protocol/contracts/p1/Deployer.sol#L62address(implementations_.components.rToken) != address(0) &&
protocol/contracts/p1/Deployer.sol#L63address(implementations_.components.stRSR) != address(0),
protocol/contracts/p1/Deployer.sol#L109require(owner != address(0) && owner != address(this), "invalid owner");
protocol/contracts/p1/Distributor.sol#L162require(dest != address(0), "dest cannot be zero");
protocol/contracts/p1/Main.sol#L32require(address(rsr_) != address(0), "invalid RSR address");
protocol/contracts/p1/RevenueTrader.sol#L29require(address(tokenToBuy_) != address(0), "invalid token address");
protocol/contracts/p1/RevenueTrader.sol#L54if (address(trades[erc20]) != address(0)) return;
protocol/contracts/p1/StRSR.sol#L675require(from != address(0), "ERC20: transfer from the zero address");
protocol/contracts/p1/StRSR.sol#L676require(to != address(0), "ERC20: transfer to the zero address");
protocol/contracts/p1/StRSR.sol#L695require(account != address(0), "ERC20: mint to the zero address");
protocol/contracts/p1/StRSR.sol#L711require(account != address(0), "ERC20: burn from the zero address");
protocol/contracts/p1/StRSR.sol#L732require(owner != address(0), "ERC20: approve from the zero address");
protocol/contracts/p1/StRSR.sol#L733require(spender != address(0), "ERC20: approve to the zero address");
protocol/contracts/p1/StRSRVotes.sol#L172if (src != address(0)) {
protocol/contracts/p1/StRSRVotes.sol#L181if (dst != address(0)) {
protocol/contracts/p1/mixins/Component.sol#L34require(address(main_) != address(0), "main is zero address");
protocol/contracts/p1/mixins/RecollateralizationLib.sol#L401if (address(trade.sell) == address(0) && address(trade.buy) != address(0)) {
protocol/contracts/plugins/aave/ERC20.sol#L242require(sender != address(0), "ERC20: transfer from the zero address");
protocol/contracts/plugins/aave/ERC20.sol#L243require(recipient != address(0), "ERC20: transfer to the zero address");
protocol/contracts/plugins/aave/ERC20.sol#L262require(account != address(0), "ERC20: mint to the zero address");
protocol/contracts/plugins/aave/ERC20.sol#L283require(account != address(0), "ERC20: burn from the zero address");
protocol/contracts/plugins/aave/ERC20.sol#L310require(owner != address(0), "ERC20: approve from the zero address");
protocol/contracts/plugins/aave/ERC20.sol#L311require(spender != address(0), "ERC20: approve to the zero address");
protocol/contracts/plugins/aave/StaticATokenLM.sol#L94if (address(incentivesController) != address(0)) {
protocol/contracts/plugins/aave/StaticATokenLM.sol#L142require(owner != address(0), StaticATokenErrors.INVALID_OWNER);
protocol/contracts/plugins/aave/StaticATokenLM.sol#L170require(depositor != address(0), StaticATokenErrors.INVALID_DEPOSITOR);
protocol/contracts/plugins/aave/StaticATokenLM.sol#L210require(owner != address(0), StaticATokenErrors.INVALID_OWNER);
protocol/contracts/plugins/aave/StaticATokenLM.sol#L294require(recipient != address(0), StaticATokenErrors.INVALID_RECIPIENT);
protocol/contracts/plugins/aave/StaticATokenLM.sol#L317require(recipient != address(0), StaticATokenErrors.INVALID_RECIPIENT);
protocol/contracts/plugins/aave/StaticATokenLM.sol#L366if (from != address(0)) {
protocol/contracts/plugins/aave/StaticATokenLM.sol#L369if (to != address(0)) {
protocol/contracts/plugins/assets/Asset.sol#L49require(address(chainlinkFeed_) != address(0), "missing chainlink feed");
protocol/contracts/plugins/assets/Asset.sol#L51require(address(erc20_) != address(0), "missing erc20");
protocol/contracts/plugins/assets/CTokenFiatCollateral.sol#L26require(address(comptroller_) != address(0), "comptroller missing");
protocol/contracts/plugins/assets/CTokenNonFiatCollateral.sol#L29address(targetUnitChainlinkFeed_) != address(0),
protocol/contracts/plugins/assets/CTokenSelfReferentialCollateral.sol#L30require(address(comptroller_) != address(0), "comptroller missing");
protocol/contracts/plugins/assets/EURFiatCollateral.sol#L24require(address(uoaPerTargetFeed_) != address(0), "missing uoaPerTarget feed");
protocol/contracts/plugins/assets/NonFiatCollateral.sol#L24require(address(uoaPerTargetFeed_) != address(0), "missing uoaPerTarget feed");
protocol/contracts/plugins/assets/RTokenAsset.sol#L28require(address(erc20_) != address(0), "missing erc20");
protocol/contracts/plugins/mocks/ATokenMock.sol#L81if (address(aaveToken) != address(0) && aaveBalances[msg.sender] > 0) {
protocol/contracts/plugins/mocks/ComptrollerMock.sol#L24if (address(compToken) != address(0)) {
protocol/contracts/plugins/mocks/EasyAuction.sol#L260if (allowListManger != address(0)) {
protocol/contracts/plugins/mocks/vendor/EasyAuction.sol#L615return self.idToAddress[id + 1] != address(0);
protocol/contracts/plugins/mocks/vendor/EasyAuction.sol#L637require(addr != address(0), "Cannot insert zero address");
protocol/contracts/plugins/mocks/vendor/EasyAuction.sol#L640[if (self.addressToId[addr] != 0
protocol/contracts/plugins/mocks/vendor/EasyAuction.sol#L936require(newOwner != address(0), "Ownable: new owner is the zero address");
protocol/contracts/plugins/trading/GnosisTrade.sol#L98assert(origin_ != address(0));

[G-4] Multiple address mappings can be combined into a single mapping of an address to a struct, where appropriate.

Description

Saves a storage slot for the mapping. Depending on the circumstances and sizes of types, can avoid a Gsset (20000 gas) per mapping combined. Reads and subsequent writes can also be cheaper when a function requires both values and they both fit in the same storage slot. Finally, if both fields are accessed in the same function, can save ~42 gas per access due to not having to recalculate the key's keccak256 hash (Gkeccak256 - 30 gas) and that calculation's associated stack operations.

βœ… Recommendation

Where appropriate, you can combine multiple address mappings into a single mapping of an address to a struct.

πŸ” Findings:


[G-5] Using storage instead of memory for structs/arrays saves gas.

Description

When fetching data from a storage location, assigning the data to a memory variable causes all fields of the struct/array to be read from storage, which incurs a Gcoldsload (2100 gas) for each field of the struct/array. If the fields are read from the new memory variable, they incur an additional MLOAD rather than a cheap stack read. Instead of declaring the variable with the memory keyword, declaring the variable with the storage keyword and caching any fields that need to be re-read in stack variables, will be much cheaper, only incuring the Gcoldsload for the fields actually read. The only time it makes sense to read the whole struct/array into a memory variable, is if the full struct/array is being returned by the function, is being passed to a function that requires memory, or if the array/struct is being read from another memory array/struct(src)

βœ… Recommendation

Use storage for struct/array

πŸ” Findings:

protocol/contracts/p1/BackingManager.sol#L219[uint256[] memory toRSR = new uint256;](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/BackingManager.sol#L219 )
protocol/contracts/p1/BackingManager.sol#L220[uint256[] memory toRToken = new uint256;](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/BackingManager.sol#L220 )
protocol/contracts/p1/BasketHandler.sol#L169[uint192[] memory refAmts = new uint192;](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/BasketHandler.sol#L169 )
protocol/contracts/p1/BasketHandler.sol#L225[bytes32[] memory names = new bytes32;](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/BasketHandler.sol#L225 )
protocol/contracts/p1/BasketHandler.sol#L541[uint192[] memory goodWeights = new uint192;](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/BasketHandler.sol#L541 )
protocol/contracts/p1/BasketHandler.sol#L545[uint192[] memory totalWeights = new uint192;](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/BasketHandler.sol#L545 )
protocol/contracts/p1/BasketHandler.sol#L642[uint192[] memory refAmts = new uint192;](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/BasketHandler.sol#L642 )
protocol/contracts/p1/Deployer.sol#L230[IAsset[] memory assets = new IAsset;](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/Deployer.sol#L230 )
protocol/contracts/p1/Distributor.sol#L105[Transfer[] memory transfers = new Transfer;](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/Distributor.sol#L105 )
protocol/contracts/p1/RToken.sol#L666[uint256[] memory amt = new uint256;](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/RToken.sol#L666 )
protocol/contracts/p1/RToken.sol#L750[uint256[] memory amtDeposits = new uint256;](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/RToken.sol#L750 )
protocol/contracts/p1/mixins/RewardableLib.sol#L64[uint256[] memory deltas = new uint256; // {qTok}](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/mixins/RewardableLib.sol#L64 )
protocol/contracts/plugins/aave/StaticATokenLM.sol#L389[address[] memory assets = new address;](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/plugins/aave/StaticATokenLM.sol#L389 )
protocol/contracts/plugins/aave/StaticATokenLM.sol#L411[address[] memory assets = new address;](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/plugins/aave/StaticATokenLM.sol#L411 )
protocol/contracts/plugins/aave/StaticATokenLM.sol#L545[address[] memory assets = new address;](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/plugins/aave/StaticATokenLM.sol#L545 )
protocol/contracts/plugins/aave/StaticATokenLM.sol#L582[address[] memory assets = new address;](https://github.com/reserve-protocol/protocol/tree/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/plugins/aave/StaticATokenLM.sol#L582 )

[G-6] Empty blocks should be removed or emit something.

Description

The code should be refactored such that they no longer exist, or the block should do something useful, such as emitting an event or reverting. If the block is an empty if-statement block to avoid doing subsequent checks in the else-if/else conditions, the else-if/else conditions should be nested under the negation of the if-statement, because they involve different classes of checks, which may lead to the introduction of errors when the code is later modified solidity if(x){}else if(y){...}else{...} => if(!x){if(y){...}else{...}}

βœ… Recommendation

Empty blocks should be removed or emit something (The code should be refactored such that they no longer exist, or the block should do something useful, such as emitting an event or reverting.

πŸ” Findings:

protocol/contracts/p1/Main.sol#L23constructor() initializer {}
protocol/contracts/p1/Main.sol#L64function _authorizeUpgrade(address newImplementation) internal override onlyRole(OWNER) {}
protocol/contracts/p1/RToken.sol#L452try main.furnace().melt() {} catch {}
protocol/contracts/p1/RToken.sol#L838function requireNotPausedOrFrozen() private notPausedOrFrozen {}
protocol/contracts/p1/StRSR.sol#L157// draft' = {}, bal' = {}, all totals zero, all rates FIX_ONE.
protocol/contracts/p1/mixins/Component.sol#L25constructor() initializer {}
protocol/contracts/p1/mixins/Component.sol#L57function _authorizeUpgrade(address newImplementation) internal view override governance {}
protocol/contracts/plugins/aave/ERC20.sol#L346) internal virtual {}
protocol/contracts/plugins/aave/StaticATokenLM.sol#L98} catch {}
protocol/contracts/plugins/assets/ATokenFiatCollateral.sol#L40constructor(CollateralConfig memory config) FiatCollateral(config) {}
protocol/contracts/plugins/assets/Asset.sol#L164function claimRewards() external virtual {}
protocol/contracts/plugins/assets/RTokenAsset.sol#L119function claimRewards() external virtual {}
protocol/contracts/plugins/governance/Governance.sol#L44{}
protocol/contracts/plugins/mocks/BadCollateralPlugin.sol#L13constructor(CollateralConfig memory config) ATokenFiatCollateral(config) {}
protocol/contracts/plugins/mocks/BadERC20.sol#L17constructor(string memory name, string memory symbol) ERC20Mock(name, symbol) {}
protocol/contracts/plugins/mocks/ComptrollerMock.sol#L12constructor() {}
protocol/contracts/plugins/mocks/ERC20Mock.sol#L8constructor(string memory name, string memory symbol) ERC20(name, symbol) {}
protocol/contracts/plugins/mocks/EasyAuction.sol#L121constructor() public Ownable() {}
protocol/contracts/plugins/mocks/InvalidATokenFiatCollateralMock.sol#L7constructor(CollateralConfig memory config) ATokenFiatCollateral(config) {}
protocol/contracts/plugins/mocks/InvalidBrokerMock.sol#L48function reportViolation() external {}
protocol/contracts/plugins/mocks/InvalidBrokerMock.sol#L52function setAuctionLength(uint48 newAuctionLength) external governance {}
protocol/contracts/plugins/mocks/InvalidBrokerMock.sol#L56function setDisabled(bool disabled_) external governance {}
protocol/contracts/plugins/mocks/InvalidChainlinkMock.sol#L17{}
protocol/contracts/plugins/mocks/InvalidFiatCollateral.sol#L12constructor(CollateralConfig memory config) FiatCollateral(config) {}
protocol/contracts/plugins/mocks/MockableCollateral.sol#L11constructor(CollateralConfig memory config) ATokenFiatCollateral(config) {}
protocol/contracts/plugins/mocks/NontrivialPegCollateral.sol#L9constructor(CollateralConfig memory config) FiatCollateral(config) {}
protocol/contracts/plugins/mocks/NontrivialPegCollateral.sol#L20constructor(CollateralConfig memory config) FiatCollateral(config) {}
protocol/contracts/plugins/mocks/NontrivialPegCollateral.sol#L31constructor(CollateralConfig memory config) FiatCollateral(config) {}
protocol/contracts/plugins/mocks/NontrivialPegCollateral.sol#L42constructor(CollateralConfig memory config) FiatCollateral(config) {}
protocol/contracts/plugins/mocks/USDCMock.sol#L8constructor(string memory name, string memory symbol) ERC20Mock(name, symbol) {}
protocol/contracts/plugins/mocks/UnpricedAssetPlugin.sol#L27) Asset(priceTimeout_, chainlinkFeed_, oracleError_, erc20_, maxTradeVolume_, oracleTimeout_) {}
protocol/contracts/plugins/mocks/WBTCMock.sol#L8constructor(string memory name, string memory symbol) ERC20Mock(name, symbol) {}
protocol/contracts/plugins/mocks/ZeroDecimalMock.sol#L8constructor(string memory name, string memory symbol) ERC20Mock(name, symbol) {}

[G-7] Use two require statements instead of operator && to save gas.

Description

Usage of double require will save you around 10 gas with the optimizer enabled. See this issue which describes the fact that there is a larger deployment gas cost, but with enough runtime calls, the change ends up being cheaper. Example:

contract Requires {
uint256 public gas;
			
				function check1(uint x) public {
					gas = gasleft();
					require(x == 0 && x < 1 ); // gas cost 22156
					gas -= gasleft();
				}
			
				function check2(uint x) public {
					gas = gasleft();
					require(x == 0); // gas cost 22148
					require(x < 1);
					gas -= gasleft();
	}
}

βœ… Recommendation

Consider changing one require() statement to two require() to save gas

πŸ” Findings:


[G-8] abi.encode() is less efficient than abi.encodePacked()

Description

abi.encode will apply ABI encoding rules. Therefore all elementary types are padded to 32 bytes and dynamic arrays include their length. Therefore it is possible to also decode this data again (with abi.decode) when the type are known.

abi.encodePacked will only use the only use the minimal required memory to encode the data. E.g. an address will only use 20 bytes and for dynamic arrays only the elements will be stored without length. For more info see the Solidity docs for packed mode.

For the input of the keccak method it is important that you can ensure that the resulting bytes of the encoding are unique. So if you always encode the same types and arrays always have the same length then there is no problem. But if you switch the parameters that you encode or encode multiple dynamic arrays you might have conflicts. For example: abi.encodePacked(address(0x0000000000000000000000000000000000000001), uint(0)) encodes to the same as abi.encodePacked(uint(0x0000000000000000000000000000000000000001000000000000000000000000), address(0)) and abi.encodePacked(uint[](1,2), uint[](3)) encodes to the same as abi.encodePacked(uint[](1), uint[](2,3)) Therefore these examples will also generate the same hashes even so they are different inputs. On the other hand you require less memory and therefore in most cases abi.encodePacked uses less gas than abi.encode.

βœ… Recommendation

Use abi.encodePacked() where possible to save gas

πŸ” Findings:

protocol/contracts/p1/StRSR.sol#L778abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)
protocol/contracts/p1/StRSRVotes.sol#L128_hashTypedDataV4(keccak256(abi.encode(_DELEGATE_TYPEHASH, delegatee, nonce, expiry))),
protocol/contracts/plugins/aave/StaticATokenLM.sol#L151abi.encode(PERMIT_TYPEHASH, owner, spender, value, currentValidNonce, deadline)
protocol/contracts/plugins/aave/StaticATokenLM.sol#L179abi.encode(
protocol/contracts/plugins/aave/StaticATokenLM.sol#L219abi.encode(
protocol/contracts/plugins/aave/StaticATokenLM.sol#L269abi.encode(

[G-9] Internal functions only called once can be inlined to save gas.

Description

Not inlining costs 20 to 40 gas because of two extra JUMP instructions and additional stack operations needed for function calls. Check this out: link Note: To sum up, when there is an internal function that is only called once, there is no point for that function to exist.

βœ… Recommendation

TODO - CHECK IF THIS IS REALLY THE CASE!!!!

πŸ” Findings:

protocol/contracts/p1/BasketHandler.sol#L68function empty(Basket storage self) internal {
protocol/contracts/plugins/aave/ERC20.sol#L324function setupDecimals(uint8 decimals) internal {
protocol/contracts/plugins/mocks/vendor/EasyAuction.sol#L243function initializeEmptyList(Data storage self) internal {

#0 - c4-judge

2023-01-24T23:19:48Z

0xean marked the issue as grade-b

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