Platform: Code4rena
Start Date: 27/01/2022
Pot Size: $75,000 USDT
Total HM: 6
Participants: 29
Period: 7 days
Judge: leastwood
Total Solo HM: 6
Id: 72
League: ETH
Rank: 13/29
Findings: 2
Award: $996.99
🌟 Selected for report: 9
🚀 Solo Findings: 0
rfa
expensive gas
https://github.com/code-423n4/2022-01-openleverage/blob/main/openleverage-contracts/contracts/dex/bsc/BscDexAggregatorV1.sol#L44 all the parameter pointer (memory) can replaced by calldata
#0 - ColaM12
2022-01-28T09:50:06Z
Duplicate to #29
🌟 Selected for report: rfa
104.6634 USDT - $104.66
rfa
expensive gas
https://github.com/code-423n4/2022-01-openleverage/blob/main/openleverage-contracts/contracts/farming/FarmingPools.sol#L53
1 second difference can be ignored to validate distributions[stakeToken].starttime
. using > operator can save gas
manual review
require(block.timestamp > distributions[stakeToken].starttime, "not start");
🌟 Selected for report: rfa
104.6634 USDT - $104.66
rfa
expensive gas
https://github.com/code-423n4/2022-01-openleverage/blob/main/openleverage-contracts/contracts/XOLE.sol#L93
instead of using toShare
to store oleToken.balanceOf(address(this)).sub(claimable).sub(totalLocked).sub(devFund);
. Just use newReward
directly to save more gas.
uint newReward; if (fromToken == address(oleToken)) { uint claimable = totalRewarded.sub(withdrewReward); newReward= oleToken.balanceOf(address(this)).sub(claimable).sub(totalLocked).sub(devFund); require(newReward >= amount, 'Exceed OLE balance');
🌟 Selected for report: rfa
104.6634 USDT - $104.66
rfa
expensive gas
https://github.com/code-423n4/2022-01-openleverage/blob/main/openleverage-contracts/contracts/dex/eth/EthDexAggregatorV1.sol#L151-L158
better use require()
here
function calSellAmount(address buyToken, address sellToken, uint24 buyTax, uint24 sellTax, uint buyAmount, bytes memory data) external view override returns (uint sellAmount){ require(data.isUniV2Class(), 'Unsupported dex'); sellAmount = uniV2CalSellAmount(dexInfo[data.toDex()], buyToken, sellToken, buyAmount, buyTax, sellTax); }
🌟 Selected for report: rfa
104.6634 USDT - $104.66
rfa
expensive gas
remove _unsedFactory;
#0 - ColaM12
2022-01-28T09:46:14Z
_unusedFactory is used to satisfied the DexAggregatorInterface which inherit by EthDexAggregator as well.
🌟 Selected for report: rfa
104.6634 USDT - $104.66
rfa
expensive gas
https://github.com/code-423n4/2022-01-openleverage/blob/main/openleverage-contracts/contracts/dex/bsc/BscDexAggregatorV1.sol#L22
we can set the pancakeFacory
address directly at line 22. then use constant.
(the address has already exist at: https://github.com/code-423n4/2022-01-openleverage/blob/main/openleverage-contracts/contracts/dex/bsc/BscDexAggregatorV1.sol#L28 )
#0 - ColaM12
2022-01-28T09:28:30Z
Currently designed to be compatible with multiple environments which may have different addresses.
🌟 Selected for report: rfa
104.6634 USDT - $104.66
rfa
expensive gas
replace the 2 lines of code by just 1 line:
dexInfo[dexName[i]] = DexInfo(factoryAddr[i], fees[i]);
🌟 Selected for report: rfa
104.6634 USDT - $104.66
rfa
expensive gas usage
https://github.com/code-423n4/2022-01-openleverage/blob/main/openleverage- contracts/contracts/dex/bsc/UniV2ClassDex.sol#L15
The implementation of Utils
library on BscDexAggregatorV1.sol
contract is more gas efficient(remove line 15 on UniV2ClassDex.sol
)
#0 - ColaM12
2022-01-28T11:42:39Z
Not improving gas efficiency.
🌟 Selected for report: rfa
104.6634 USDT - $104.66
rfa
expensive gas
https://github.com/code-423n4/2022-01-openleverage/blob/main/openleverage-contracts/contracts/dex/bsc/BscDexAggregatorV1.sol#L183
instead of caching V2PriceOracle
. just readit directly to the storage. (use storage as pointer instead of memory)
V2PriceOracle storage priceOracle = uniV2PriceOracle[IUniswapV2Pair(pair)];
🌟 Selected for report: rfa
104.6634 USDT - $104.66
rfa
expensive gas
https://github.com/code-423n4/2022-01-openleverage/blob/main/openleverage-contracts/contracts/dex/eth/EthDexAggregatorV1.sol#L71-L76
its unnecessary to store msg.sender
in the payer
. Just pass msg.sender
as an argument on buyAmount
remove line 71
47.0985 USDT - $47.10
rfa
expensive gas
https://github.com/code-423n4/2022-01-openleverage/blob/main/openleverage-contracts/contracts/dex/bsc/BscDexAggregatorV1.sol#L45 && operatoris using more gas than just using multiple require()
require(dexName.length == factoryAddr.length, 'EOR'); require(dexName.length == fees.length, 'EOR');
#0 - ColaM12
2022-01-28T09:51:23Z
Duplicate to #63