In Uniswap V3, we make heavy use of a FullMath#mulDiv
, which allows you to multiply two numbers x
and y
then divide by a third number d
, when x * y > type(uint256).max
but x * y / d <= type(uint256).max
This function is extremely useful to smart contract developers working with fixed point math. Hari (@_hrkrshnn) suggested that we write an EIP to add a muldiv opcode.
Is there any reason this shouldn’t be built into the EVM? Should it be a precompile since the result can overflow?