Why two Uni V3 pools have different bytecodes?

Viewed 57

I am trying to assess if two smart contracts (address_1 and address_2) are both Uni V3 pools using web3.

My idea was to request each contract's runtime bytecode as follows:

sc_i_bytecode = w3.eth.getCode(w3.toChecksumAddress(address_i))

And then compare them with the bytecode of another smart contract that I know represents a Uni V3 pool. I do know that both contacts at address_1 and address_2 are Uni V3 pools, but when I get their bytecodes as above they do not match (i.e. sc_1_bytecode != sc_2_bytecode, although both of them were implemented by the same Uni V3 factory?). They do not seem to match the bytecode of my Uni V3 reference bytecode either. I am just wondering if I am missing something and those can have indeed different bytecodes?

Thanks

1 Answers

You could call the factory() method on the smart contract

https://etherscan.io/address/0xcbcdf9626bc03e24f779434178a73a0b4bad62ed#readContract

and verify that it matches the address of the v3 factory contract: https://etherscan.io/address/0x1f98431c8ad98523631ae4a59f267346ea31f984

In your two example pools the factory() method returns the same v3 factory contract address: 0x6c6Bc977E13Df9b0de53b251522280BB72383700 0xcbcdf9626bc03e24f779434178a73a0b4bad62ed

Method from the contract code on etherscan:

interface IUniswapV3PoolImmutables {
    /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
    /// @return The contract address
    function factory() external view returns (address);


As to your question of why they have different bytecodes - I'm not 100% sure. Potentially could be related to the settings? (pulled from etherscan as well)

{
  "optimizer": {
    "enabled": true,
    "runs": 800
  },
  "metadata": {
    "bytecodeHash": "none"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  },
  "libraries": {}
}
Related