mantlenetworkio / mantle

Mantle | Mass adoption of decentralized & token-governed technologies. With Mantle Network, Mantle Treasury, and token holder-governed products initiatives.

Home Page:https://www.mantle.xyz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bridge][contracts]: Possible rounding issues.

Ethanncnm opened this issue · comments

commented

Describe the bug
The _initiateERC20Deposit function does not account of tokens that charge fees on transfer.

There is an expectation that the _amount of tokens deposited to the project contract when calling depositERC20To or depositERC20 will be equal to the amount of tokens deposited and hence the mapping deposits is updated by adding the same _amount. However, there are ERC20s that do, or may in the future, charge fees on transfer that will violate this expectation and affect the contract’s accounting in the deposits mapping.

Below is the function _initiateERC20Deposit from the L1StandardBridge contract (Some part of the function is replaced by /) [removed code] to only show the relevant code)
image

Expected behavior
Consider implementing a require check that compares the contract’s balance before and after a token transfer to ensure that the expected amount of tokens are transferred.