code-423n4 / 2021-10-defiprotocol-findings

0 stars 0 forks source link

Cache factory.ownerSplit() #89

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

pauliax

Vulnerability details

Impact

function handleFees calls factory.ownerSplit() twice. To save some gas and reduce the number of external calls, you should save the value after the first call and re-use it later.

Recommended Mitigation Steps

Cache factory.ownerSplit() in a local variable and re-use it.

GalloDaSballo commented 2 years ago

Agree with the warden, specifically you would want to cache this in memory, doing a STATICCALL (view method) is 40 gas plus the cost for reading storage (2100 after first time iirc)

Would cost just 3 gas to store and 3 gas for each subsequent memory read