Platform: Code4rena
Start Date: 03/05/2022
Pot Size: $75,000 USDC
Total HM: 6
Participants: 55
Period: 7 days
Judge: Albert Chon
Total Solo HM: 2
Id: 116
League: COSMOS
Rank: 19/55
Findings: 2
Award: $651.51
🌟 Selected for report: 0
🚀 Solo Findings: 0
Contract Gravity.sol
does not properly handle ERC20 tokens that charge fee on their transfers. Implementation of such a tokens does not transfer exact amount provided to transfer()
but part of it is charged as a fee, burned or used in some other way. This leads to incorrect accounting and effectively to loss of funds.
Manual Review / VSCode
It is recommended to add support for ERC20 tokens with built-in fees. Example of the implementation:
uint256 ourStartingBalance = IERC20(_tokenContract).balanceOf(address(this)); IERC20(_tokenContract).safeTransferFrom(msg.sender, address(this), _amount); uint256 ourEndingBalance = IERC20(_tokenContract).balanceOf(address(this)); require(ourEndingBalance > ourStartingBalance, "ERC20 reduced balance"); state_lastEventNonce = state_lastEventNonce + 1; emit SendToCosmosEvent( _tokenContract, msg.sender, _destination, _amount, ourEndingBalance - ourStartingBalance, state_lastEventNonce );
#0 - mlukanova
2022-05-10T14:48:35Z
Duplicate of #3