Tadle

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

Incorrect Platform Fee Calculation Leading to Excessive Charges

Incorrect Platform Fee Calculation Leading to Excessive Charges

Summary

An error in the platform fee calculation causes users to deposit double the intended amount as collateral, leading to potential loss of funds or denial of service (DoS).

Vulnerability Details

When users call PreMarkets::createOffer to create stock, they are charged a platformFee using the platformFeeRate.

Key Code Sections:

  1. The platform fee rate is set in SystemConfig::updateUserPlatformFeeRate:

function updateUserPlatformFeeRate(
address _accountAddress,
uint256 _platformFeeRate
) external onlyOwner {
require(
_platformFeeRate <= Constants.PLATFORM_FEE_DECIMAL_SCALER,
"Invalid platform fee rate"
);
userPlatformFeeRate[_accountAddress] = _platformFeeRate;
emit UpdateUserPlatformFeeRate(_accountAddress, _platformFeeRate);
}
  1. The platformFeeRate is constrained to be <= Constants.PLATFORM_FEE_DECIMAL_SCALER, which has a value of 1_000_000.

  2. The problematic formula for calculating the platform fee:

uint256 platformFee = depositAmount.mulDiv(
platformFeeRate,
Constants.PLATFORM_FEE_DECIMAL_SCALER
);

The Issue:

The formula used to calculate the platform fee is incorrect, causing users to deposit an amount equal to the entire deposit as a fee. This error arises because the platformFeeRate can be equal to PLATFORM_FEE_DECIMAL_SCALER, resulting in the platformFee equaling the depositAmount.

Proof of Concept

Consider the following scenario:

  • Deposit Amount: 100,000,000 USDC

  • Platform Fee Rate: 1,000,000

Using the current formula:

platformFee = (100,000,000 * 1,000,000) / 1,000,000
platformFee = 100,000,000 USDC

This results in the platform fee being equal to the entire deposit amount, doubling the intended collateral.

Impact

This bug leads to a significant loss of funds for users and could potentially result in a denial of service (DoS) as users may be unable to proceed with their transactions due to excessive fees.

Tools Used

Manual code review.

Recommendations

According to Tadle's documentation, the platform fee should be 0.5% for all transactions. The developers need to reconsider the value range for platformFeeRate to ensure it reflects the intended fee percentage. Additionally, the formula for calculating the platform fee should be corrected to accurately calculate the desired fee.

Updates

Lead Judging Commences

0xnevi Lead Judge about 1 year 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.