yearn/Yearn-ERC4626-Router

Uniswap's Multicall library incorrectly parses revert reason length and does not bubble up custom errors

Opened this issue · 0 comments

Uniswap's Multicall library only bubbles up revert reason when the length of the byte array is 68 >= (4 for error selector + 32 for string length + at least 32 for string content)

This leads to empty reverts even if the underlying contract implements custom errors.

(bool success, bytes memory result) = address(this).delegatecall(data[i]);
if (!success) {
// Next 5 lines from https://ethereum.stackexchange.com/a/83577
if (result.length < 68) revert();
assembly {
result := add(result, 0x04)
}
revert(abi.decode(result, (string)));
}

Furthermore it seems like it incorrectly attempts to splice revertData, rather than splicing the 4 bytes selector, it shifts the pointer to the length of the bytes by 4 and leads to high length bytes. Ends up relying on abi.decode's behavior to deal with incorrect string length

Discussion from the Uniswap repo here: Uniswap/v3-periphery#254

Would be nice to replace this with a better (and correct) way to pass the revert data like from OZ

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/17a8955cd8ed2c9a269421a11c2e2774b796e305/contracts/utils/Address.sol#L143-L158