Hubble contest - Tomio's results

Multi-collateral/Cross-Margin Perpetual Futures on Avalanche.

General Information

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

Hubble

Findings Distribution

Researcher Performance

Rank: 39/39

Findings: 1

Award: $87.40

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

Awards

87.3994 USDC - $87.40

Labels

bug
duplicate
G (Gas Optimization)

External Links

  1. save traders.length in memory can save gas https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/HubbleViewer.sol#L58 // gas cost 24003

Change to:

uint len = traders.length; notionalPositions = new uint256[](len); margins = new int256[](len); for (uint i = 0; i < len; i++) {

// gas cost 23992

========================================================================

  1. considered using unchecked can save gas https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/HubbleViewer.sol#L306 // gas cost 23796

Change to:

if (totalDTokenSupply > 0) { unchecked{ vUSD = vUSDBalance * dToken / totalDTokenSupply; vAsset = vAssetBalance * dToken / totalDTokenSupply; } }

// gas cost 23080

========================================================================

  1. using multipe require can save gas instead of && https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/MarginAccount.sol#L461 // gas cost 26717

Change to:

require(idx > VUSD_IDX); require(idx < supportedCollateral, "collateral not seizable");

// gas cost 26709

========================================================================

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