I'm kinda struggling here to find a solution.
I have a code where user can deposit token like USDC, DAI etc...
For example USDC had 6 decimals and DAI has 18 decimals.
How can I have a generic fee calculation in my function so it handle all different case when decimals are differents and also avoid rounding by 0 ?
I have something like this for the calculation :
uint256 feeToCollect = (amount * feeBps * 10**18) / BPS;
uint256 amountWithFee = amount + fee;
IERC20(token).transferFrom(msg.sender, address(this), amountWithFee;
amount = amount that the user deposit
feeBps = 10 so it's 0.1%
BPS = 10000
10**18 is a scale to avoid rounding by 0.
Thank you for your help !
IERC20(token).decimals();