for (uint256 i; i < length; ++i) {
if (!is1155) {
require(seizeAmounts[i] == 1, "CNFT: Amounts must be all 1s for non-ERC1155s.");
}
totalAmount += seizeAmounts[i];
}
proposed change:
for (uint256 i; i < length) {
if (!is1155) {
require(seizeAmounts[i] == 1, "CNFT: Amounts must be all 1s for non-ERC1155s.");
}
totalAmount += seizeAmounts[i];
unchecked{ ++i; }
}
for (uint256 i; i < length; ++i) {
if (!is1155) {
require(amounts[i] == 1, "CNFT: Amounts must be all 1s for non-ERC1155s.");
}
totalAmount += amounts[i];
}
proposed change:
for (uint256 i; i < length;) {
if (!is1155) {
require(amounts[i] == 1, "CNFT: Amounts must be all 1s for non-ERC1155s.");
}
totalAmount += amounts[i];
unchecked {++i;}
}
Gas Optimizations
Unnecessarily initialized Variable
proposed change:
https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/CNft.sol#L175
proposed change:
https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/CNft.sol#L97
proposed change:
https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/CNft.sol#L49
Set Unchanging variables to immutable
proposed change:
https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/PriceOracleImplementation.sol#L11
Use Unchecked Arithmetic
proposed change:
https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/CNft.sol#L151-L153
proposed change:
https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/CNft.sol#L145-L149
proposed change:
https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/CNft.sol#L98-L103
proposed change:
https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/CNft.sol#L72-L73
proposed change:
https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/CNft.sol#L62-L70
proposed change:
https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/CNft.sol#L50-L55