Open code423n4 opened 2 years ago
https://github.com/code-423n4/2022-03-volt/blob/f1210bf3151095e4d371c9e9d7682d9031860bbd/contracts/peg/NonCustodialPSM.sol#L292
amountFeiToTransfer doesnt need to be checked if was zero
amountFeiToTransfer
Visual Studio Code, Manual Review
Remove it
SafeERC20
https://github.com/code-423n4/2022-03-volt/blob/main/contracts/pcv/PCVDeposit.sol this implementation can be used for another gas opt
Expensive gas
https://docs.openzeppelin.com/contracts/3.x/api/token/erc20#SafeERC20
Manual Review
by do not declaring using SafeERC20 for IERC20; and used safeTransfer and safeTransferFrom.
using SafeERC20 for IERC20;
safeTransfer
safeTransferFrom
if-elseif
https://github.com/code-423n4/2022-03-volt/blob/f1210bf3151095e4d371c9e9d7682d9031860bbd/contracts/peg/NonCustodialPSM.sol#L292-L298 This implementation can be using for saving more gas.
if (amountFeiToTransfer != 0) { IERC20(volt()).safeTransfer(to, amountFeiToTransfer); } if (amountFeiToMint != 0) { rateLimitedMinter.mintVolt(to, amountFeiToMint); }
change to else if to save gas :
else if
if (amountFeiToTransfer != 0) { IERC20(volt()).safeTransfer(to, amountFeiToTransfer); } else if (amountFeiToMint != 0) { rateLimitedMinter.mintVolt(to, amountFeiToMint); }
https://github.com/code-423n4/2022-03-volt/blob/f1210bf3151095e4d371c9e9d7682d9031860bbd/contracts/refs/CoreRef.sol#L27
since this was no-op, removed this can be saving more gas.
Remix
Remove Constructor
This functions could be set external to saving more gas gas
Expensive Gas
https://github.com/code-423n4/2022-03-volt/blob/f1210bf3151095e4d371c9e9d7682d9031860bbd/contracts/core/Permissions.sol#L187 https://github.com/code-423n4/2022-03-volt/blob/f1210bf3151095e4d371c9e9d7682d9031860bbd/contracts/core/Permissions.sol#L202
https://github.com/code-423n4/2022-03-volt/blob/f1210bf3151095e4d371c9e9d7682d9031860bbd/contracts/peg/NonCustodialPSM.sol#L292
amountFeiToTransfer
doesnt need to be checked if was zeroTool Used
Visual Studio Code, Manual Review
Reccomendation Mitigation
Remove it
SafeERC20
function for gas savinghttps://github.com/code-423n4/2022-03-volt/blob/main/contracts/pcv/PCVDeposit.sol this implementation can be used for another gas opt
Impact
Expensive gas
POC
https://docs.openzeppelin.com/contracts/3.x/api/token/erc20#SafeERC20
Tool Used
Manual Review
Reccomendation Mitigation Steps
by do not declaring
using SafeERC20 for IERC20;
and usedsafeTransfer
andsafeTransferFrom
.if-elseif
logic for saving more gashttps://github.com/code-423n4/2022-03-volt/blob/f1210bf3151095e4d371c9e9d7682d9031860bbd/contracts/peg/NonCustodialPSM.sol#L292-L298 This implementation can be using for saving more gas.
Tool used
Visual Studio Code, Manual Review
Recommended Mitigation Step
change to
else if
to save gas :https://github.com/code-423n4/2022-03-volt/blob/f1210bf3151095e4d371c9e9d7682d9031860bbd/contracts/refs/CoreRef.sol#L27
since this was no-op, removed this can be saving more gas.
Impact
Expensive gas
Tool used
Remix
Recommended Mitigation
Remove Constructor
This functions could be set external to saving more gas gas
Impact
Expensive Gas
POC
https://github.com/code-423n4/2022-03-volt/blob/f1210bf3151095e4d371c9e9d7682d9031860bbd/contracts/core/Permissions.sol#L187 https://github.com/code-423n4/2022-03-volt/blob/f1210bf3151095e4d371c9e9d7682d9031860bbd/contracts/core/Permissions.sol#L202