Submitted by 0x41
The EVM module incorrectly handles fee-on-transfer tokens when converting bank coins back to ERC20s, resulting in unbacked bank coins remaining in circulation. This breaks the intended 1:1 supply tracking invariant between ERC20 tokens and their bank coin representations.
When converting from ERC20 to bank coins via sendToBank, the code correctly accounts for transfer fees by only minting bank coins equal to the amount actually received. However, when converting these bank coins back to ERC20s via convertCoinToEvmBornERC20, the code:
This creates a discrepancy since the original conversion already accounted for fees. The transfer fees are effectively applied twice:
This leaves 4.75 unbacked bank coins in circulation (95 - 90.25), as the code only burns what was actually transferred in the second conversion.
The impact is monetary - it creates unbacked bank coins that can be used in the rest of the system but dont have corresponding ERC20 tokens backing them in the EVM modules account. Over time, this could lead to significant supply inflation of the bank coin representation.
The first conversion correctly handles fees in funtoken.go:
funtoken.go#L162-L170
But when converting back in msg_server.go, it incorrectly applies fees again:
msg_server.go#L597-L613
The code explicitly aims to maintain a supply invariant:
msg_server.go#L603
When converting bank coins back to ERC20s in convertCoinToEvmBornERC20, the code should burn the full input amount of bank coins, not just the amount after fees. This ensures fees are only applied once in the entire conversion cycle.
This maintains the supply invariant since:
The documentation should also be updated to explicitly describe how fee-on-transfer tokens are handled and that fees will apply on both conversions.
k-yang (Nibiru) confirmed and commented:
Nibiru mitigated:
Status: Mitigation confirmed. 
