PegExchanger.sol#takeFrom, PegExchanger.sol#giveTo and TRIBERagequit.sol#takeFrom are implemented in a similar manner. After transferFrom call, the return value is cached to a parameter called check, after that it is controlled whether check is true. But the used transferFrom functions never return false. They simply revert if there is a problem with the transaction. Therefore, it is possible to implement those functions more gas efficient.
Therefore following implementation:
function takeFrom(address target, uint256 amount) internal {
bool check = token0.transferFrom(target, address(this), amount);
require(check, "erc20 transfer failed");
}
Handle
0x0x0x
Vulnerability details
Concept
PegExchanger.sol#takeFrom
,PegExchanger.sol#giveTo
andTRIBERagequit.sol#takeFrom
are implemented in a similar manner. AftertransferFrom
call, the return value is cached to a parameter calledcheck
, after that it is controlled whethercheck
istrue
. But the usedtransferFrom
functions never returnfalse
. They simply revert if there is a problem with the transaction. Therefore, it is possible to implement those functions more gas efficient.Therefore following implementation:
Can be replaced with: