Skip to content
Business logic Audit finding Intermediate

Protocol fee loss due to incorrect fee calculation in MoneyBrinter.sol

The contract's fee calculation for withdrawals and redemptions undercharges the exit fee because it adds the fee to the asset amount before converting to shares, resulting in an effective fee lower than intended. An attacker could repeatedly withdraw to pay less fee than expected, causing a loss of protocol fee revenue.

OxSimao Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#41873 [SC-Insight] Protocol fee loss due to incorrect fee calculation in MoneyBrinter.sol

Submitted on Mar 19th 2025 at 03:16:10 UTC by @OxSimao for Audit Comp | Yeet

Description

Brief/Intro

MoneyBrinter.sol incorrectly undercharges borrowing fee due to a math error.

Vulnerability Details

MoneyBrinter.sol implements previewWithdraw() and previewRedeem() and calculates the result including the exit fee, exitFeeBasisPoints. However, this calculation is incorrect.

Suppose there are 1000 assets and shares, user wants to withdraw 100 assets and calls withdraw(), internally calling previewWithdraw() to calculate the fee. feeBasisPoints is 1000 (10%) and _BASIS_POINT_SCALE is 1e4.

Solidity
uint256 fee = assets * feeBasisPoints / _BASIS_POINT_SCALE = 100 * 1000 / 10000 = 10;
return super.previewWithdraw(assets + fee) = super.previewWithdraw(100 + 10) = 110 * totalSupply / totalAssets = 110 * 1000 / 1000 = 110;

So, calling previewWithdraw() with 100 assets returns 110 shares. However, this fee is smaller than feeBasisPoints = 10%, as 110 shares should give 110 * 0.9 = 99 shares, which is 99 assets also given same total supply and total assets. The actual fee applied is:

  1. 110 shares are worth 110 assets;
  2. out of 110 assets, 100 assets are withdrawn
  3. 1 - 100/110 = 0.091, so the fee is actually 9.1%. This represents a 0.9% fee loss.

Issue is similar for previewRedeem().

Solidity
function previewWithdraw(uint256 assets) public view override returns (uint256) {
    uint256 fee = _feeOnRaw(assets, exitFeeBasisPoints);
    return super.previewWithdraw(assets + fee);
}

function previewRedeem(uint256 shares) public view override returns (uint256) {
    uint256 assets = super.previewRedeem(shares);
    return assets - _feeOnTotal(assets, exitFeeBasisPoints);
}

Impact Details

Significant fee loss, if fee is 10%, actual fee is 9.1%, showing a 0.9% fee loss.

References

https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/contracts/MoneyBrinter.sol?utm\\_source=immunefi#L142-L150

Proof of Concept

Proof of Concept

Described in the report above but it boils down to:

  1. User calls MoneyBrinter::withdraw(), but instead of paying an exit fee of 10%, pays 9.1%.

The original report as published on Immunefi, by OxSimao. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the fee is added to the asset amount before converting to shares, but the fee should be calculated on the total shares needed to cover both the withdrawal and the fee.

Impact

The protocol loses a portion of its exit fee revenue, with the example showing a 0.9% loss when the intended fee is 10%.

What the attacker needed

None

How it was found

  1. User calls MoneyBrinter::withdraw() with 100 assets.
  2. The contract calculates a fee of 10 assets (10% of 100).
  3. It then calls super.previewWithdraw(110) which returns 110 shares.
  4. The user effectively pays only 9.1% fee instead of 10%.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

This is a smart contract bug where the fee charged when you take money out is calculated incorrectly. Instead of charging the full 10% fee, the code effectively charges only about 9.1%, so the protocol loses money each time someone withdraws.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More from Yeet

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.