Asymmetry contest - smaul's results

A protocol to help diversify and decentralize liquid staking derivatives.

General Information

Platform: Code4rena

Start Date: 24/03/2023

Pot Size: $49,200 USDC

Total HM: 20

Participants: 246

Period: 6 days

Judge: Picodes

Total Solo HM: 1

Id: 226

League: ETH

Asymmetry Finance

Findings Distribution

Researcher Performance

Rank: 139/246

Findings: 2

Award: $23.92

QA:
grade-b
Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Optimize the pausing into an single operation.

SafEth.sol#L64 , SafEth.sol#L109

Change pausestaking & pauseunstaking in a single variable, and use it to pause both staking & unstaking.

Once something bad happens to the protocol you should pause all operation in a single function call. Delete pausestaking & pauseunstaking and use pause and change pausestaking & pauseunstaking to pause all over the code base.

#0 - c4-sponsor

2023-04-10T21:08:31Z

toshiSat marked the issue as sponsor disputed

#1 - c4-judge

2023-04-24T18:41:35Z

Picodes marked the issue as grade-b

Instead reading storage variable every time store it in memory variable

SafEth.sol#L73 , SafEth.sol#L74 , SafEth.sol#L115 , SafEth.sol#L118

At Line 73 & 74 derivatives[i] value is fetched from storage and used directly in the for loop for 3 times that's mean 3 SLOAD call which is expensive as SLOAD cost minimum 100 Gas, instead we can store derivatives[i] value in a memory variable and use this value which will be MLOAD call and it's only cost 3 Gas.

To save Gas implement the code like below:

       for (uint i = 0; i < derivativeCount; i++)
            IDerivative derivativeValue = derivatives[i];
            underlyingValue +=
                (derivativeValue.ethPerDerivative(derivativeValue.balance()) *
                    derivativeValue.balance()) /
                10 ** 18;

This same optimization can be applied similarly into Line 115 & 118.

Calling balance() function two times which can be expensive

SafEth.sol#L73 , SafEth.sol#L74

At line 73 & 74 balance() function is called two times which will be costing more Gas as their is many internal & external function calls and that can be optimized by storing balance() function value in a memory variable and use it when it's required.

To save Gas implement the code like below:

        for (uint i = 0; i < derivativeCount; i++)
            uint256 derivativeBalance = derivatives[i].balance();
            underlyingValue +=
                (derivatives[i].ethPerDerivative(derivativeBalance) *
                    derivativeBalance) /
                10 ** 18;

#0 - c4-sponsor

2023-04-10T20:45:29Z

elmutt marked the issue as sponsor confirmed

#1 - c4-judge

2023-04-23T19:12:17Z

Picodes 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