Tadle

Tadle
DeFiFoundry
27,750 USDC
View results
Submission Details
Severity: low
Invalid

Decimal Precision Difference in `PreMarket::_updateReferralBonus` Leads to Incorrect `remainingPlatformFee`

Summary

A discrepancy in decimal precision among variables used in the PreMarket::_updateReferralBonus function leads to incorrect calculation of the remainingPlatformFee. This can result in inaccurate accounting and potential financial discrepancies within the protocol.

Vulnerability Details

The PreMarket::_updateReferralBonus function utilizes variables with different decimal precisions, specifically platformFee, referrerRate, and authorityRate. The issue arises when calculating the remainingPlatformFee, as seen in the following code:

function _updateReferralBonus(...) internal returns (uint256 remainingPlatformFee) {
if (referralInfo.referrer == address(0x0)) {
remainingPlatformFee = platformFee;
} else {
uint256 referrerReferralBonus = platformFee.mulDiv(
referralInfo.referrerRate,
Constants.REFERRAL_RATE_DECIMAL_SCALER,
Math.Rounding.Floor
);
// Update referrer referral bonus
tokenManager.addTokenBalance(
TokenBalanceType.ReferralBonus,
referralInfo.referrer,
makerInfo.tokenAddress,
referrerReferralBonus
);
uint256 authorityReferralBonus = platformFee.mulDiv(
referralInfo.authorityRate,
Constants.REFERRAL_RATE_DECIMAL_SCALER,
Math.Rounding.Floor
);
// Update authority referral bonus
tokenManager.addTokenBalance(
TokenBalanceType.ReferralBonus,
_msgSender(),
makerInfo.tokenAddress,
authorityReferralBonus
);
remainingPlatformFee = platformFee - referrerReferralBonus - authorityReferralBonus;
}
}

Issue Breakdown:

  • platformFee: The token-based fee, which can have varying decimals depending on the chosen token.

  • referrerRate and authorityRate: These rates are calculated using a fixed decimal scaler, Constants.REFERRAL_RATE_DECIMAL_SCALER.

  • Problem: The difference in decimal precision among these variables leads to an incorrect calculation of the remainingPlatformFee. This discrepancy arises because the platformFee and the referral bonuses (referrerReferralBonus and authorityReferralBonus) are not consistently scaled, causing the remainingPlatformFee to be inaccurately computed.

Impact

The incorrect calculation of remainingPlatformFee due to decimal precision differences can lead to inaccurate financial accounting within the protocol, potentially resulting in overpayment or underpayment of fees, and ultimately, financial loss.

Tools Used

  • Manual analysis

Recommendations

To resolve this issue, the protocol should adjust the scale of all variables to ensure they have consistent decimal precision. This can be done by standardizing the decimal precision across platformFee, referrerReferralBonus, and authorityReferralBonus before performing any calculations.

Updates

Lead Judging Commences

0xnevi Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

[invalid] finding-Admin-Errors-Malicious

The following issues and its duplicates are invalid as admin errors/input validation/malicious intents are1 generally considered invalid based on [codehawks guidelines](https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity#findings-that-may-be-invalid). If they deploy/set inputs of the contracts appropriately, there will be no issue. Additionally admins are trusted as noted in READ.ME they can break certain assumption of the code based on their actions, and

Appeal created

krisrenzo Submitter
12 months ago
0xnevi Lead Judge
12 months ago
0xnevi Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

[invalid] finding-Admin-Errors-Malicious

The following issues and its duplicates are invalid as admin errors/input validation/malicious intents are1 generally considered invalid based on [codehawks guidelines](https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity#findings-that-may-be-invalid). If they deploy/set inputs of the contracts appropriately, there will be no issue. Additionally admins are trusted as noted in READ.ME they can break certain assumption of the code based on their actions, and

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.