code-423n4 / 2022-04-dualityfocus-findings

1 stars 0 forks source link

Gas Optimizations #9

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

https://github.com/code-423n4/2022-04-dualityfocus/blob/main/contracts/compound_rari_fork/ComptrollerStorage.sol#L74 Consider changing the accountAssets mapping to, mapping(address => mapping(tokenSymbol => CToken)).

With above change, adding or deleting tokens from account's list will be easy and a lot of loop processin can be avoided. E.g. https://github.com/code-423n4/2022-04-dualityfocus/blob/main/contracts/compound_rari_fork/Comptroller.sol#L203, the entire for loop can be eliminated. This can be replicated in many places, saving a lot of as fee and reduce contract size.

JeeberC4 commented 2 years ago

Adding to warden's other Gas Optimization #1