Submitted by cmichel
The ERC4626.deposit/mint functions do not work well with fee-on-transfer tokens as the amount variable is the pre-fee amount, including the fee, whereas the totalAssets do not include the fee anymore.
This can be abused to mint more shares than desired.
A deposit(1000) should result in the same shares as two deposits of deposit(500) but it does not because amount is the pre-fee amount.
Assume a fee-on-transfer of 20%. Assume current totalAmount = 1000, totalShares = 1000 for simplicity.
In total, the two deposits lead to 35 more shares than a single deposit of the sum of the deposits.
amount should be the amount excluding the fee, i.e., the amount the contract actually received.
This can be done by subtracting the pre-contract balance from the post-contract balance.
However, this would create another issue with ERC777 tokens.
Maybe previewDeposit should be overwritten by vaults supporting fee-on-transfer tokens to predict the post-fee amount. And do the shares computation on that, but then the afterDeposit is still called with the original amount and implementers need to be aware of this.
Joeysantoro (Tribe Turbo) disputed and commented:
Alex the Entreprenerd (judge) commented:
