> For the complete documentation index, see [llms.txt](https://reports.immunefi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://reports.immunefi.com/yeet/41873-sc-insight-protocol-fee-loss-due-to-incorrect-fee-calculation-in-moneybrinter.sol.md).

# #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**](https://immunefi.com/audit-competition/audit-comp-yeet)

* **Report ID:** #41873
* **Report Type:** Smart Contract
* **Report severity:** Insight
* **Target:** <https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/contracts/MoneyBrinter.sol>
* **Impacts:**
  * Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield

## 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%`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://reports.immunefi.com/yeet/41873-sc-insight-protocol-fee-loss-due-to-incorrect-fee-calculation-in-moneybrinter.sol.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
