Incorrect referral fee handling in `_handleTransfers` function
Medium
Finding Description and Impact
Root Cause
The referralFeeCost
is computed in the _handleTransfers
function but is not deducted from buyerFeeTotal
or transferred to the referrer. This creates the following issues:
- Unrealized Payment to Referrer: The calculated
referralFeeCost
is not distributed, leading to the referrer being denied the reward they are entitled to. - Incorrect Accounting: The
buyerFeeTotal
incorrectly reflects the entire fee without subtracting the portion allocated to the referrer.
Impact
- Reputation Damage: The marketplace may face backlash for failing to reward referrers as expected.
- Loss of Referral Incentives: Users might be dissuaded from referring new participants, hampering ecosystem growth.
- Financial Discrepancies: Incorrect fee distribution can lead to disputes or potential loss of funds during settlements.
Recommended Mitigation Steps
- Deduct Referral Fee from
buyerFeeTotal
: - Transfer Referral Fee to Referrer:
referralFeeCost = 0; if (_referral != address(0) && listing.whitelist == address(0)) { referralFeeCost = (baseAmount * bfee * IMarketplaceSetting(marketplaceSetting).referralFee()) / (BASE * BASE); IERC20(listing.currency).safeTransfer(_referral, referralFeeCost); buyerFeeTotal = buyerFeeTotal - referralFeeCost ; }