Description:Description\
The Router, GnosisRouter, MainnetRouter, and MarketFactory contracts use memory for function arguments where calldata could be utilized instead. Using calldata allows the data to remain in the original transaction data without copying it into memory, resulting in a significant gas optimization for functions that do not mutate the passed arguments. The issue occurs when arguments passed to functions are marked as memory, even though they are not modified or passed to other functions that expect memory.
Example Locations:
redeemToBase in GnosisRouter
redeemToDai in MainnetRouter
_redeemPositions in Router
createCategoricalMarket in MarketFactory
createMultiScalarMarket in MarketFactory
encodeRealityQuestionWithOutcomes in MarketFactory
The function createNewMarketParams in MarketFactory
Impact\
While this is classified as a low risk, addressing it can result in gas savings by reducing unnecessary memory allocation. Optimizing these areas can be especially beneficial when large arrays or strings are involved.
Recommendation\
Use calldata instead of memory if the data passed into the function does not need to be changed.
Github username: -- Twitter username: -- Submission hash (on-chain): 0x054e4a4fc6326471ce25af2986acf2e88d9227aa96b9dd3f2f59e84287ac0510 Severity: low
Description: Description\ The
Router
,GnosisRouter
,MainnetRouter
, andMarketFactory
contracts use memory for function arguments where calldata could be utilized instead. Using calldata allows the data to remain in the original transaction data without copying it into memory, resulting in a significant gas optimization for functions that do not mutate the passed arguments. The issue occurs when arguments passed to functions are marked as memory, even though they are not modified or passed to other functions that expect memory.Example Locations:
Impact\ While this is classified as a low risk, addressing it can result in gas savings by reducing unnecessary memory allocation. Optimizing these areas can be especially beneficial when large arrays or strings are involved.
Recommendation\ Use
calldata
instead ofmemory
if the data passed into the function does not need to be changed.