Open code423n4 opened 2 years ago
Ruhum
Structs should always be packed to save gas
https://github.com/code-423n4/2021-12-yetifinance/blob/main/packages/contracts/contracts/PriceFeed.sol#L56
https://github.com/code-423n4/2021-12-yetifinance/blob/main/packages/contracts/contracts/PriceFeed.sol#L64
https://github.com/code-423n4/2021-12-yetifinance/blob/main/packages/contracts/contracts/Dependencies/Whitelist.sol#L28
none
Pack structs, e.g.:
// unpacked, higher gas (6 storage slots): struct CollateralParams { uint256 ratio; address oracle; uint256 decimals; bool active; address priceCurve; uint256 index; bool isWrapped; } // packed (needs 5 storage slots) struct CollateralParams { uint256 ratio; uint256 decimals; uint256 index; address oracle; bool active; address priceCurve; bool isWrapped; }
@LilYeti : Duplicate with #4 #5 and #6
Taking as main
Handle
Ruhum
Vulnerability details
Impact
Structs should always be packed to save gas
Proof of Concept
https://github.com/code-423n4/2021-12-yetifinance/blob/main/packages/contracts/contracts/PriceFeed.sol#L56
https://github.com/code-423n4/2021-12-yetifinance/blob/main/packages/contracts/contracts/PriceFeed.sol#L64
https://github.com/code-423n4/2021-12-yetifinance/blob/main/packages/contracts/contracts/Dependencies/Whitelist.sol#L28
Tools Used
none
Recommended Mitigation Steps
Pack structs, e.g.: