# Which side of a swap the fee is taken on, and whether it gets taken twice

Mentorship Series #13 · 17 December 2025 · [@0xfirefist](https://x.com/0xFireFist) · Mento V3 · Cantina

Mentorship Series · [The Contest Academy](https://0xsimao.com/the-contest-academy) · written by 0xSimao

---

We continued the Mento V3 [contest](https://cantina.xyz/competitions/fe8e03b1-f8db-4698-8a21-44b3a862e434) on Cantina.

**Lesson Summary:**

- expectedAmountIn comes from amountOut. If the fee is 1% and I want to get 100, I should get 99. But here I think I should just return 101(fee included);
- protocol fee is also applied to amountIn, so it looks good for now;
- newReserveValue already removed protocol fee (_swapCheck), because the protocol fee was transferred out and the reserves were updated before checking the swap;
- In the check, why are both fees taken when the protocol fee was already taken and the reserves reset?
- Should the fees be taken on the amount in, or on the amount out?
- Make sure totalFeeInToken1 is correct.

https://youtu.be/OEvVRqYISbU

Session video: https://youtu.be/OEvVRqYISbU

Written by 0xSimao (https://0xsimao.com/) · Sherlock's 2025 Watson of the Year · 21 first places in 57 audit contests.

---

Newer: [Rounding always favours the protocol, and what mint does against a one-wei reserve](https://0xsimao.com/the-contest-academy/mento-rounding-one-wei-reserve) · Older: [Division by a variable, oracle-priced pools, and trading limits split into small swaps](https://0xsimao.com/the-contest-academy/mento-oracle-pools-trading-limits)
