Uniswap / v3-periphery

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

PoolAddress library is giving an error in Solidity 0.8+ #209

Closed deAngelisAlex closed 2 years ago

deAngelisAlex commented 2 years ago

Dear Uniswap team,

I've been using the PoolAddress library in smart contracts, to get the address of a pool with the tokens and fee, and it seems like a recent update in solidity (0.8) has broken the way that the address is computed.

TypeError: Explicit type conversion not allowed from "uint256" to "address". --> @uniswap/v3-periphery/contracts/libraries/PoolAddress.sol:35:16: | 35 | pool = address( | ^ (Relevant source part starts here and spans across multiple lines).

As you can see, a uint256 cannot be casted to address directly. As a workaround I have casted the uint256 to uint160 first, which works. Obviously, modifying the underlying source code in node_modules is not a practical solution. Should I do a PR with the right fixes on the file?

Kind regards, deAngelisAlex

Myprst commented 2 years ago

I got the same problem: Solidity v0.8.0 Breaking Changes==>New Restrictions address(uint) and uint(address): converting both type-category and width. Replace this by address(uint160(uint)) and uint(uint160(address)) respectively.

jaybanez commented 2 years ago

Hi, I am facing the same issue. Any news about this? I modified PoolAddress.sol as deAngelisAlex, but it is not a long-term solution. Regards, Jaybanez

hensha256 commented 2 years ago

Duplicate of #177