{"id":19079233,"url":"https://github.com/weavevm/univ2-fork","last_synced_at":"2025-10-27T06:19:24.347Z","repository":{"id":243593611,"uuid":"812080184","full_name":"weaveVM/univ2-fork","owner":"weaveVM","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-26T13:39:07.000Z","size":17512,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-30T05:41:37.688Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://univ2-fork.vercel.app","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weaveVM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-07T23:14:27.000Z","updated_at":"2025-03-26T13:39:14.000Z","dependencies_parsed_at":"2024-06-27T19:18:53.809Z","dependency_job_id":"c8f3ae8b-2f2c-4781-bc94-17c8f2568586","html_url":"https://github.com/weaveVM/univ2-fork","commit_stats":null,"previous_names":["leeftk/uni-interface"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaveVM%2Funiv2-fork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaveVM%2Funiv2-fork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaveVM%2Funiv2-fork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaveVM%2Funiv2-fork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weaveVM","download_url":"https://codeload.github.com/weaveVM/univ2-fork/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251651221,"owners_count":21621702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T02:13:54.849Z","updated_at":"2025-10-27T06:19:14.994Z","avatar_url":"https://github.com/weaveVM.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monorepo Setup Instructions\n\n## Prerequisites\n\n- Node.js (via NVM) with Node 14\n- Yarn\n- Foundry (for smart contracts)\n\n## Setup\n\n### Interface\n\n1. Install Node 14 using NVM:\n```bash\n   nvm install 14\n   nvm use 14\n```\n2. Navigate to v2-sdk folder and build:\n\n```\ncd packages/interface/v2-sdk\nyarn install\nyarn build\n```\n\n4. Navigate to interface folder and start the project:\n\n```\ncd ../interface\nyarn install\nyarn start\n```\n\n## Smart Contract\n1. Navigate to Smart Contracts\n\n```\ncd packages/contracts\nforge install\nforge test\n\n```\n\n```\nmy-monorepo/\n├── package.json\n├── tsconfig.json\n└── packages/\n    ├── interface/\n    │   ├── v2-sdk/\n    │   └── src/\n    └── contracts/\n        └── src/\n```\n\n# Steps to Compile and Deploy the Smart Contracts\n\n1. Once you clone the repo, run the commands `foundryup` and `forge install` to install all the dependencies.\n\n2. You will find the `v2-core` and `v2-periphery` folders under the `lib` folder. If you make any changes in the code, you can use the file at `contracts/script/Imports.s.sol` to build each of these.\n\n3. Calculate the `INIT_CODE_HASH` by navigating to `contracts/out/UniswapV2Pair.sol/UniswapV2Pair.json` and copying the key-value pair of the bytecode key. Paste it into the site [Keccak-256 Online Tool](https://emn178.github.io/online-tools/keccak_256.html) to calculate the hash. Copy the hash and update it in the file at `contracts/lib/v2-periphery/contracts/libraries/UniswapV2Library.sol` in the `pairFor()` function. Then, build the contracts once again.\n\n4. Now that this is done, it's time to deploy the contracts.\n\n5. First, navigate to the working directory - `univ2-fork/packages/contracts`. It's time to deploy `UniswapV2Factory`:\n\n    ```sh\n    forge create --rpc-url \u003crpc_url\u003e --constructor-args \u003caddress_fee_setter\u003e --private-key \u003cprivate_key\u003e lib/v2-core/contracts/UniswapV2Factory.sol:UniswapV2Factory\n    ```\n\n6. Now, let's deploy the WETH clone, i.e., `WWVM`:\n\n    ```sh\n    forge create --rpc-url \u003crpc_url\u003e --private-key \u003cprivate_key\u003e contracts/test/mocks/WWVM.sol:WWVM\n    ```\n\n7. Now that we are aware of both the factory and WETH addresses, it's time to deploy the `UniswapV2Router`:\n\n    ```sh\n    forge create --rpc-url \u003crpc_url\u003e --constructor-args \u003cfactory_address\u003e \u003cweth_address\u003e --private-key \u003cprivate_key\u003e lib/v2-periphery/contracts/UniswapV2Router02.sol:UniswapV2Router02\n    ```\n\n8. If you want to test the router with a couple of tokens, you can deploy the mock ERC20 contracts as well:\n\n    ```sh\n    forge create --rpc-url \u003crpc_url\u003e --constructor-args \"Token A\" \"TKNA\" --private-key \u003cprivate_key\u003e test/mocks/ERC20Mintable.sol:ERC20Mintable\n    ```\n\n9. Voila! That's the end of the contract deployments.\n\n---\n\n# Steps to Set Up the Frontend Code\n\nThis tutorial will be divided into two sections:\n\n## 1. Setting Up the UniswapV2 SDK\n\n1.1 Navigate to the `interface/v2-sdk` folder and run `yarn` to install dependencies.\n\n1.2 Go to `src/constants.ts` and in the `ChainId` enum, add the chain ID of the chain where your contracts were deployed. We will be adding the Weave testnet chain ID, which is 9496. Next, change the value of `FACTORY_ADDRESS` to the address of your own V2 factory contract you deployed. Finally, change the `INIT_CODE_HASH` to the one in your `UniswapV2Library`'s `pairFor()` function.\n\n1.3 Go to `src/entities/token.ts`. Locate the `WETH` constant and add your own `ChainId` and the address of the WETH smart contract you deployed earlier.\n\n1.4 Go to `src/entities/currency.ts`. In the `public readonly ETHER`, change the symbol (`ETH`) and name (`Ether`) to that of your preferred chain. In our case, it has been changed to `tWVM`.\n\n1.5 Run `yarn build`. Your v2-sdk is ready.\n\n## 2. Setting Up the UniswapV2 Interface\n\n2.1 Go to the `package.json` file. Under the `devDependencies` key, locate `@uniswap/sdk`. Change the value to `“file:../v2-sdk”`. Run `yarn`.\n\n2.2 Go to `src/constants/index.ts`. Change the constant `ROUTER_ADDRESS` to the address of the Router contract we deployed. Now, add the `ChainId` of the new chain where our smart contracts were deployed, in our case Weave.\n\n2.3 Go to `src/connectors/index.ts`. Locate the `supportedChainIds` array and add the chain ID of our own chain. It’s Weave, and the chain ID is 9496.\n\n2.4 Check point 5 from [this guide](https://goldrush.dev/docs/unified-api/guides/how-to-clone-uniswapv2-frontend) to ensure completion.\n\n2.5 Go to `src/components/Header/index.ts`. In the `NETWORK_LABELS` constant, add Weave to the list of values in the object.\n\n2.6 Go to `src/constants/v1/index.ts`. In the `V1_FACTORY_ADDRESSES`, add `ChainID.WEAVE` to the list and set the value to the address of the UniswapV2 Factory contract we had deployed earlier.\n\n2.7 Go to `/src/state/lists/hooks.ts`. In the `EMPTY_LIST` constant, add `ChainId.WEAVE` to the list of values.\n\n2.8 Go to `/src/utils/index.ts`. In the `ETHERSCAN_PREFIXES` constant, add `9496: ‘weave’` to the list of key-value pairs.\n\n2.9 Run `yarn start` for your frontend to compile and open in a browser.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweavevm%2Funiv2-fork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweavevm%2Funiv2-fork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweavevm%2Funiv2-fork/lists"}