Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with INIT_CODE_PAIR_HASH #1

Open
johnwhitton opened this issue Nov 30, 2021 · 1 comment
Open

Problem with INIT_CODE_PAIR_HASH #1

johnwhitton opened this issue Nov 30, 2021 · 1 comment

Comments

@johnwhitton
Copy link
Contributor

johnwhitton commented Nov 30, 2021

Describe the bug
When generating and retrieving pairs using the UniswapV2Factory the INIT_CODE_PAIR_HASH appears to be different when deploying vs testing locally.

Believe the problem is similar to Uniswap/v2-core#102

I found the cause of the problem.Because I did not use pre-compiled smart contracts.Instead I used truffle to compile smart contracts.When I compiled the CalHash contract with yarn compile,

To Reproduce
For deployment we use the hash generated by the following

const MANUAL_INIT_CODE_HASH = keccak256(['bytes'],[bytecode]);

which is 0x2b3916d184be5391113dc61053ef6e55b1214905619aa198de8ef903f9acffd2

And we have added this value to the UniswapV2Library.sol minus the 0x prefix.
You can see the value returned on Kovan using the UniswapV2Factory in explorer

However when running 00_InitHash.test.ts we get the value 0xb96a05d90581cfac1f99c92b02f2e69fbca4e5c26498be0dc204d91318c9f56b

and when trying to addLiquidity
await addLiquidityKLP(this, "kangaEth", this.kanga, this.weth, "6000000000000000000", "6000000000000000000", "60000000000000000000", "6000000000000000000", this.alice.address)

we get the following error

 2) KangaMaker
       checkInitHash
         check ability to add liquidity:
     Error: Transaction reverted: function call to a non-contract account
      at UniswapV2Router02.getReserves (contracts/uniswapv2/libraries/UniswapV2Library.sol:33)
      at UniswapV2Router02._addLiquidity (contracts/uniswapv2/UniswapV2Router02.sol:46)
      at UniswapV2Router02.addLiquidity (contracts/uniswapv2/UniswapV2Router02.sol:72)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
      at EthModule._estimateGasAction (node_modules/hardhat/src/internal/hardhat-network/provider/modules/eth.ts:402:9)
      at HardhatNetworkProvider.request (node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:102:18)
      at EthersProviderWrapper.send (node_modules/hardhat-deploy-ethers/src/ethers-provider-wrapper.ts:13:20)

This can be resolved by updating And we have added this value to the UniswapV2Library.sol to b96a05d90581cfac1f99c92b02f2e69fbca4e5c26498be0dc204d91318c9f56b but then deployments are broken

Expected behavior

  1. The same init_hash can be used for testing and deployment
  2. Adding liquidity works for testing and deployments.

Actual behavior

  1. init_hash is different for testing and deployments
  2. Adding liquidity fails when using the wrong init_hash

Additional context
Reference tickets

@ckukner
Copy link

ckukner commented Jan 26, 2022

maybe it wasn't very clear but which one allowed you to migrate
0x2b3916d184be5391113dc61053ef6e55b1214905619aa198de8ef903f9acffd2
or
0xb96a05d90581cfac1f99c92b02f2e69fbca4e5c26498be0dc204d91318c9f56b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants