L-1: Some tokens will not be compatible
Summary:
Some tokens will not be compatible:
- Some tokens (e.g. UNI, COMP) revert if the value passed to approve or transfer is larger than uint96.
Description:
File: src/L1YearnEscrow.sol
100 | originTokenAddress().forceApprove(_vaultAddress, 2 ** 256 - 1);
247 | originToken.forceApprove(_vaultAddress, 2 ** 256 - 1);
- Some tokens have a fee on transfer which will result in more tokens bridged to L2 than received by the L1 escrow.
function bridgeToken(address destinationAddress, uint256 amount, bool forceUpdateGlobalExitRoot) external {
require(destinationAddress != address(0), "TokenWrapped::PolygonBridgeERC20Base: Zero Address");
_receiveTokens(amount);
// Encode message data
bytes memory messageData = abi.encode(destinationAddress, amount);
// Send message data through the bridge
_bridgeMessage(messageData, forceUpdateGlobalExitRoot);
emit BridgeTokens(destinationAddress, amount);
}
Impact:
Low. Only a small number of tokens are affected.
Recommendation:
- You could add an optional parameter to the
initializeandupdateVaultto pass a max approval value. - Since the
bridgeToken()function can't be overridden, you could check the balance actually received by the L1 escrow in_receiveTokens()and revert if it differs from theamount.
Developer Response:
Acknowledged.
As discussed in Discord as long as the approval to UNI/COMP is max uint256 the approvals work.
Weird tokens like fee on transfer tokens would not work with the vaults as well so should not be used at all with this setup.