Inefficient Payment Structure in _splitProtocolFee Function
Low/Info issue submitted by Bigsam
Summary
The _splitProtocolFee function in the contract currently transfers funds to the referrer individually for mintReferrerShare and collectionReferrerShare. However, since both shares ultimately belong to the same referrer, it is more efficient to pay the full referrer share at once instead of making separate payments.
Vulnerability Detail
In the _splitProtocolFee function, the mintReferrerShare and collectionReferrerShare are calculated individually, and funds are transferred to the referrer for each share. This approach results in unnecessary gas costs and transaction complexity. Instead, the full referrer share can be calculated once and paid to the referrer in a single transaction.
Impact
The current payment structure in the _splitProtocolFee function may lead to increased gas costs and inefficiencies in contract execution. While the impact may be marginal, optimizing the payment structure can improve transaction throughput and reduce overall transaction costs.
To optimize gas usage and simplify transaction handling, it is recommended to pay the full referrer share at once instead of individually paying the mintReferrerShare and collectionReferrerShare. This approach reduces transaction complexity and ensures more efficient use of gas.
Inefficient Payment Structure in _splitProtocolFee Function
Low/Info issue submitted by Bigsam
Summary
The
_splitProtocolFee
function in the contract currently transfers funds to the referrer individually formintReferrerShare
andcollectionReferrerShare
. However, since both shares ultimately belong to the same referrer, it is more efficient to pay the full referrer share at once instead of making separate payments.Vulnerability Detail
In the
_splitProtocolFee
function, themintReferrerShare
andcollectionReferrerShare
are calculated individually, and funds are transferred to the referrer for each share. This approach results in unnecessary gas costs and transaction complexity. Instead, the full referrer share can be calculated once and paid to the referrer in a single transaction.Impact
The current payment structure in the
_splitProtocolFee
function may lead to increased gas costs and inefficiencies in contract execution. While the impact may be marginal, optimizing the payment structure can improve transaction throughput and reduce overall transaction costs.Code Snippet
https://github.com/sherlock-audit/2024-04-titles/blob/main/wallflower-contract-v2/src/fees/FeeManager.sol#L412-L441
https://github.com/sherlock-audit/2024-04-titles/blob/main/wallflower-contract-v2/src/fees/FeeManager.sol#L422
https://github.com/sherlock-audit/2024-04-titles/blob/main/wallflower-contract-v2/src/fees/FeeManager.sol#L430-L434
https://github.com/sherlock-audit/2024-04-titles/blob/main/wallflower-contract-v2/src/fees/FeeManager.sol#L436-L440
Tool used
Manual Review
Recommendation
To optimize gas usage and simplify transaction handling, it is recommended to pay the full referrer share at once instead of individually paying the
mintReferrerShare
andcollectionReferrerShare
. This approach reduces transaction complexity and ensures more efficient use of gas.