# uniswap demo
Currently working with the zknode commit 7442b6 (fix state not synced fatal)
In zknode repo run: `make build-docker`
## Repo uniswap-tokenlist:
https://github.com/hermeznetwork/uniswap-tokenlists/blob/main/develop.json
This file adds the tokens A and B to the UI. If the addresses change, you should update it.
`develop` is for local testing.
## Run environment
to run the whole environment, go to the uniswap-demo repo and run: `make start-local`
To stop the environment: `make stop`
### How to deploy uniswap in other network rather than local?
The easiest way to do this task is:
- Modify the config/start.local.json file with the proper content. For example:
```
{
"L2NetworkURL": "https://hermez-mandarin.zkevm-testnet.net:8123",
"L2BridgeAddr": "0x9d98deabc42dd696deb9e40b4f1cab7ddbf55988",
"L2DeployerAddress": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
"L2DeployerPrivateKey": "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
"SleepSeconds": 1
}
```
- Then, run de uniswap-demo with the command `make start-local`. This will start more instance than we need (the one that it is relevant is uniswap-demo in this particular case).
- If the deployment went fine, you will see this log:
```
Deployment succeeded
[[{"message":"Contract UniswapV3Factory deployed","address":"0x05Aa229Aec102f78CE0E852A812a388F076Aa555","hash":"0xc9bc47850b2a183d7cf24647b1c8cdacfab8189352b6c7dbcc771216c8f8db5c"}],[{"message":"UniswapV3Factory added a new fee tier 1 bps with tick spacing 1","hash":"0xcc55fdbfec4188d038de1b0d473658cf0310e40ad465ef5d414531f71a1e4ce6"}],[{"message":"Contract UniswapInterfaceMulticall deployed","address":"0x0f5D1ef48f12b6f691401bfe88c2037c690a6afe","hash":"0x4f403adbccad99bb9627cec9564c39042185f123fd08a01450f92002ea0a40a7"}],[{"message":"Contract ProxyAdmin deployed","address":"0x90118d110B07ABB82Ba8980D1c5cC96EeA810d2C","hash":"0xcb2b20851ad7ed50945d7b03cf07e74ea3168757775f0060ddaad21b9f6d1c65"}],[{"message":"Contract TickLens deployed","address":"0xcA03Dc4665A8C3603cb4Fd5Ce71Af9649dC00d44","hash":"0x7615d6a45444fe72be94cd3f49f1677dfc5f682aa3a70a6d00022606f4832c9e"}],[{"message":"Library NFTDescriptor deployed","address":"0x2dE080e97B0caE9825375D31f5D0eD5751fDf16D","hash":"0x347a53337ad8483021b77df98c79cf4a84d1ebb00d6feb2159594a3b78a20cb5"}],[{"message":"Contract NonfungibleTokenPositionDescriptor deployed","address":"0x73eccD6288e117cAcA738BDAD4FEC51312166C1A","hash":"0x167644740219748a88a48208cad6fd75bdab1156c986aad1dd04f45b92431a78"}],[{"message":"Contract TransparentUpgradeableProxy deployed","address":"0x381445710b5e73d34aF196c53A3D5cDa58EDBf7A","hash":"0x56d0789b64522e2c78eab43c3f14620d1d8b7277e01e0b47e47cdabfb3042b48"}],[{"message":"ProxyAdmin owned by 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 already"}],[{"message":"Contract NonfungiblePositionManager deployed","address":"0xe6b98F104c1BEf218F3893ADab4160Dc73Eb8367","hash":"0x83095ceb4cf5d9eda25f88ca76716adc12df1a488537edd03d35fa913e7bf766"}],[{"message":"Contract V3Migrator deployed","address":"0x5C7c905B505f0Cf40Ab6600d05e677F717916F6B","hash":"0x217c80cb679c53026ea45f5fc7fe1e6f6d543b4a669ca7bc7b2e067168febfda"}],[{"message":"UniswapV3Factory owned by 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 already"}],[{"message":"Contract UniswapV3Staker deployed","address":"0x0D4ff719551E23185Aeb16FFbF2ABEbB90635942","hash":"0x1c44bd491fabcaf6b189993213d475b373c4239f42e06b95c43ab4ae22f65b38"}],[{"message":"Contract Quoter deployed","address":"0x85C5Dd61585773423e378146D4bEC6f8D149E248","hash":"0x6514908aa472b197cd92efdc690026f22e17c6d53b63a893c96b56c9878a5412"}],[{"message":"Contract QuoterV2 deployed","address":"0xfbAb4aa40C202E4e80390171E82379824f7372dd","hash":"0x1040344600b012232e198075ef7fb3a7284cf70bd1dd255e86e7329949a0b9f1"}],[{"message":"Contract SwapRouter02 deployed","address":"0xAfe1b5bdEbD4ae65AF2024738bf0735fbb65d44b","hash":"0x5fc59db0ae5503c38939a0a2f954849b89a413227993f7cafcfa8255cb142546"}]]
Final state
{"v3CoreFactoryAddress":"0x05Aa229Aec102f78CE0E852A812a388F076Aa555","multicall2Address":"0x0f5D1ef48f12b6f691401bfe88c2037c690a6afe","proxyAdminAddress":"0x90118d110B07ABB82Ba8980D1c5cC96EeA810d2C","tickLensAddress":"0xcA03Dc4665A8C3603cb4Fd5Ce71Af9649dC00d44","nftDescriptorLibraryAddressV1_3_0":"0x2dE080e97B0caE9825375D31f5D0eD5751fDf16D","nonfungibleTokenPositionDescriptorAddressV1_3_0":"0x73eccD6288e117cAcA738BDAD4FEC51312166C1A","descriptorProxyAddress":"0x381445710b5e73d34aF196c53A3D5cDa58EDBf7A","nonfungibleTokenPositionManagerAddress":"0xe6b98F104c1BEf218F3893ADab4160Dc73Eb8367","v3MigratorAddress":"0x5C7c905B505f0Cf40Ab6600d05e677F717916F6B","v3StakerAddress":"0x0D4ff719551E23185Aeb16FFbF2ABEbB90635942","quoterAddress":"0x85C5Dd61585773423e378146D4bEC6f8D149E248","quoterV2Address":"0xfbAb4aa40C202E4e80390171E82379824f7372dd","swapRouter02":"0xAfe1b5bdEbD4ae65AF2024738bf0735fbb65d44b"}
```
Now, you should modify the address in the uniswap-ui repo and uniswap-tokenlist repo.
- After this, you need to build and run the uniswap-ui docker to use the addresses and urls (pointing to mandarin for instance).
## uniswap-demo:
To build the docker instance, just run: `make build-docker`
There are a modification in the zknode to allow include only 1 tx per batch due to the bug of the executor.
The modified params are:
```
WaitPeriodSendSequence = "1s"
LastBatchVirtualizationTimeMaxWaitPeriod = "1s"
```
Regarding the prover, there are a config param to increase the log level and see everything that the rom is doing (Use it only if protocol teams requires this information. The generated logs are huge.)
```
"executorROMLineTraces": true,
```
## uniswap-ui:
Url: http://localhost:8043/
Build new image: `docker build -t uniswapui .` or `docker build -t hermeznetwork/uniswap-ui:2.0-itestnet-local .`
Addresses of the Smc are inside .env files. If you are runnin the local environment you should modify .env.development
You don't need to modify the next envVars of the file:
```
REACT_APP_POLYGON_ZKEVM_V2_FACTORY_ADDRESS
REACT_APP_POLYGON_ZKEVM_V2_ROUTER_ADDRESS
REACT_APP_POLYGON_ZKEVM_ENS_REGISTRAR_ADDRESS
REACT_APP_POLYGON_ZKEVM_INIT_CODE_HASH
REACT_APP_LOCALES
REACT_APP_INFURA_KEY
```
The other envVars must be modified with the deployement information provided by uniswap-demo instance if needed.
Take into account that if the addresses for token A and B are different, you should update uniswap-tokenlist repo as well.
The `ARG ENVIRONMENT=development` which allow you to specify one .env or another is defined inside the Dockerfile.
This docker instance should be started automatically from the uniswap-demo repo.
## Repos:
#### Uniswap-UI: (branch zkevm)
`https://github.com/hermeznetwork/uniswap-ui`
#### Uniswap-demo: (branch zkevm)
`https://github.com/0xPolygonHermez/zkevm-uniswap-demo`
#### Uniswap-tokenlist: (branch main)
`https://github.com/hermeznetwork/uniswap-tokenlists`