In general, declaring dynamic function parameters as calldata instead of memory could save gas since the parameters are not copied into the memory but directly read from the call data.
Consider changing the memory keyword to calldata in the referenced functions. However, two of them require local variables to be rearranged or scoped to avoid "stack too deep" compiler errors. Please refer to this link for the detailed implementation.
Handle
shw
Vulnerability details
Impact
In general, declaring dynamic function parameters as
calldata
instead ofmemory
could save gas since the parameters are not copied into the memory but directly read from the call data.Proof of Concept
Referenced code: Gov.sol#L138 Gov.sol#L165 Manager.sol#L46 Manager.sol#L74-L75 Manager.sol#L95-L97 Manager.sol#L142-L144 Manager.sol#L166 Manager.sol#L168 Manager.sol#L203-L206 Payout.sol#L110-L113 SherX.sol#L193-L194 SherXERC20.sol#L53
Recommended Mitigation Steps
Consider changing the
memory
keyword tocalldata
in the referenced functions. However, two of them require local variables to be rearranged or scoped to avoid "stack too deep" compiler errors. Please refer to this link for the detailed implementation.