# The recipient receives free collateral token if an ERC20 token that deducts a fee on transfer used as baseToken

Collateral.deposit credits the pre-fee _amount instead of the actual received balance, so fee-on-transfer baseTokens mint excess collateral and corrupt deposit accounting.

- Payout: Contest reward
- Severity: medium
- Program: prePO
- Credited: Koolex
- Disclosed: 2023-01-27
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2022-12-prepo-findings/issues/52
- Library page: https://bugbountylibrary.com/r/c4%3A2022-12-prepo%3AM-02
- Tags: domain:web3 impact:funds-loss impact:integrity kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error

**Target:** Collateral.sol deposit/withdraw and DepositHook/WithdrawHook accounting
**Root cause:** Collateral.deposit uses the caller-supplied _amount for minting and hook accounting rather than the actual balance delta received after transferFrom, so fee-on-transfer tokens cause over-crediting.
**Steps:**
1. Use a baseToken that deducts 1% on transfer.
2. Call `deposit(100e18)`; `baseToken.transferFrom` delivers only 99e18 to the contract.
3. Collateral passes `_amount=100e18` to DepositHook and computes collateralMintAmount from 100e18 minus treasury fee.
4. Recipient receives collateral tokens for 100e18 despite only 99e18 deposited; DepositRecord globalNetDepositAmount inflated.
5. On withdraw, user receives less baseToken than owed; treasury fee under-collected.
**How found:** Reviewer noticed transferFrom return/balance not reconciled with _amount and traced _amount into DepositHook and mint calculation, recognizing fee-on-transfer discrepancy.
**Exploitation:** Attacker deposits a fee-on-transfer baseToken; contract mints collateral based on nominal amount, yielding more collateral/PPO than the value actually transferred in, and skews global deposit accounting.
**Insight:** Any protocol accepting arbitrary ERC20 baseTokens must measure balance delta around transferFrom rather than trusting the requested amount; check every downstream use of _amount including hooks and share minting.
