function _approveTokenIfNeeded(address token, address spender) private {
if (IERC20(token).allowance(address(this), spender) == 0) {
IERC20(token).safeApprove(spender, uint256(~0));
}
}
I found this function in a popular DeFi protocol.
uint256(~0)
looks new to me.
Is this a different way of getting the largest available uint256 value? Like type(uint256).max
?
The compiler version is v0.7.0+commit.9e61f92b.