Uniswap / v3-periphery

🦄 🦄 🦄 Peripheral smart contracts for interacting with Uniswap v3
https://uniswap.org
GNU General Public License v2.0
1.16k stars 1.08k forks source link

TypeError: Explicit type conversion not allowed from "uint256" to "address". #324

Open yilmazbingo opened 1 year ago

yilmazbingo commented 1 year ago

I got an issue compiling my contract in hardhat. I copied the code to Remix and got the same error. This part of the code has an issue:

function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {
        require(key.token0 < key.token1);
        // errror message points this line
        pool = address(
            uint256(
                keccak256(
                    abi.encodePacked(
                        hex'ff',
                        factory,
                        keccak256(abi.encode(key.token0, key.token1, key.fee)),
                        POOL_INIT_CODE_HASH
                    )
                )
            )
        );

for pool=adress I get this error: "TypeError: Explicit type conversion not allowed from "uint256" to "address".".

keccak256 returns bytes32, it is wrapped by uint256 and that is wrapped by address. everything seems fine. I do not know what is causing issue

sambacha commented 1 year ago

Your using a compiler version after 0.7.6, 0.8.0 introduces this change, you can either fix it or upgrade to 0.7.6