Platform: Code4rena
Start Date: 17/02/2022
Pot Size: $75,000 USDC
Total HM: 20
Participants: 39
Period: 7 days
Judges: moose-code, JasoonS
Total Solo HM: 13
Id: 89
League: ETH
Rank: 39/39
Findings: 1
Award: $87.40
🌟 Selected for report: 0
🚀 Solo Findings: 0
87.3994 USDC - $87.40
traders.length
in memory can save gas
https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/HubbleViewer.sol#L58
// gas cost 24003Change to:
uint len = traders.length; notionalPositions = new uint256[](len); margins = new int256[](len); for (uint i = 0; i < len; i++) {
// gas cost 23992
========================================================================
unchecked
can save gas
https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/HubbleViewer.sol#L306
// gas cost 23796Change to:
if (totalDTokenSupply > 0) { unchecked{ vUSD = vUSDBalance * dToken / totalDTokenSupply; vAsset = vAssetBalance * dToken / totalDTokenSupply; } }
// gas cost 23080
========================================================================
require
can save gas instead of &&
https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/MarginAccount.sol#L461
// gas cost 26717Change to:
require(idx > VUSD_IDX); require(idx < supportedCollateral, "collateral not seizable");
// gas cost 26709
========================================================================