Open code423n4 opened 2 years ago
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/CitadelMinter.sol#L152
Recommended Mitigation Steps: change to prefix increment and unchecked
========================================================================
+=
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/CitadelMinter.sol#L279 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/KnightingRound.sol#L196-L199
Recommended Mitigation Steps: Change to:
_newTotalWeight += _weight;
!=
>
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/CitadelMinter.sol#L343 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/Funding.sol#L170 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/Funding.sol#L452
require(length != 0, "CitadelMinter: no funding pools");
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/CitadelMinter.sol#L152 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/CitadelMinter.sol#L180-L182 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/SupplySchedule.sol#L192
Recommended Mitigation Steps: remove 0
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/CitadelMinter.sol#L366 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/StakedCitadel.sol#L416
delete fundingPoolWeights[_pool];
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/Funding.sol#L236 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/KnightingRound.sol#L250
Recommended Mitigation Steps:
Unchecked{ limitLeft_ = assetCap - assetCumulativeFunded; }
>=
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/Funding.sol#L270-L271 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/Funding.sol#L361
Recommended Mitigation Steps: 1 second difference can be ignored to validate Change from: >= or <= to: > or <
<=
<
calldata
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/Funding.sol#L244
Recommended Mitigation Steps: Change memory to calldata
memory
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/StakedCitadel.sol#L859
Recommended Mitigation Steps: declare governancePerformanceFee, strategistPerformanceFee in function returns and delete #L874 can save gas
returns
function _calculatePerformanceFee(uint256 _amount) internal view returns (uint256 governancePerformanceFee, uint256 strategistPerformanceFee) //@audit-info return here { uint256 governancePerformanceFee = _calculateFee( _amount, performanceFeeGovernance ); uint256 strategistPerformanceFee = _calculateFee( _amount, performanceFeeStrategist ); }
citadelAmountWithoutDiscount
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/Funding.sol#L207
Recommended Mitigation Steps: citadelAmountWithoutDiscount only called once. just calculated directly to citadelAmount_ #L211
citadelAmount_
if (funding.discount > 0) { citadelAmount_ = ((_assetAmountIn * citadelPriceInAsset)* MAX_BPS) / (MAX_BPS - funding.discount); }
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/CitadelMinter.sol#L152
Recommended Mitigation Steps: change to prefix increment and unchecked
========================================================================
+=
to increase value on varProof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/CitadelMinter.sol#L279 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/KnightingRound.sol#L196-L199
Recommended Mitigation Steps: Change to:
========================================================================
!=
instead of>
is more gas efficientProof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/CitadelMinter.sol#L343 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/Funding.sol#L170 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/Funding.sol#L452
Recommended Mitigation Steps: Change to:
========================================================================
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/CitadelMinter.sol#L152 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/CitadelMinter.sol#L180-L182 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/SupplySchedule.sol#L192
Recommended Mitigation Steps: remove 0
========================================================================
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/CitadelMinter.sol#L366 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/StakedCitadel.sol#L416
Recommended Mitigation Steps: Change to:
========================================================================
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/Funding.sol#L236 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/KnightingRound.sol#L250
Recommended Mitigation Steps:
========================================================================
>
is cheaper than>=
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/Funding.sol#L270-L271 https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/Funding.sol#L361
Recommended Mitigation Steps: 1 second difference can be ignored to validate Change from:
>=
or<=
to:>
or<
========================================================================
calldata
to store struct data type can save gasProof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/Funding.sol#L244
Recommended Mitigation Steps: Change
memory
tocalldata
========================================================================
Proof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/StakedCitadel.sol#L859
Recommended Mitigation Steps: declare governancePerformanceFee, strategistPerformanceFee in function
returns
and delete #L874 can save gas========================================================================
citadelAmountWithoutDiscount
MSTOREProof of Concept: https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/Funding.sol#L207
Recommended Mitigation Steps:
citadelAmountWithoutDiscount
only called once. just calculated directly tocitadelAmount_
#L211========================================================================