# mTOFT's fees cannot be paid on native wrapping

mTOFT.wrap double-counts the mint fee on native wrapping, sending full _amount to the vault after already registering the fee, so native wraps revert.

- Payout: Contest reward
- Severity: medium
- Program: Tapioca
- Credited: John_Femi
- Disclosed: 2024-02-14
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-02-tapioca-judging/issues/146
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-02-tapioca%3AM-34
- Tags: domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:business-logic vuln:fee-bypass

**Target:** mTOFT / TOFTVault native wrapping (Solidity)
**Root cause:** _checkAndExtractFees registers feeAmount with the vault (msg.value=feeAmount), then _wrapNative deposits the full _amount again, requiring _amount+feeAmount balance.
**Steps:**
1. Set mintFee > 0 and call wrap() on a non-host chain with erc20==address(0) and msg.value=_amount.
2. wrap() calls _checkAndExtractFees(_amount) which computes feeAmount=(_amount*mintFee)/1e5 and calls vault.registerFees{value: feeAmount}(feeAmount).
3. wrap() then calls _wrapNative(_toAddress,_amount,feeAmount) which calls vault.depositNative{value:_amount}().
4. Contract balance only holds _amount, so the second transfer of _amount reverts unless extra funds were donated.
**How found:** Code reading of wrap()/_checkAndExtractFees()/_wrapNative() flow, noticing the fee is transferred to the vault twice for native tokens.
**Insight:** When a fee is extracted via an external payable call, check whether the subsequent deposit/mint path re-sends the gross amount instead of the net, causing a balance shortfall and revert.
