From d4975078d7dcaeaad45e9d80091cdfe281124f5b Mon Sep 17 00:00:00 2001 From: rolaman Date: Mon, 7 Oct 2024 14:09:02 +0300 Subject: [PATCH] demo-router: contract + task --- README.md | 3 +-- contracts/UniswapV2Router01.sol | 10 ---------- ignition/modules/Router.ts | 7 +------ tasks/core/demo-router-sync.ts | 4 +--- tasks/core/demo-router.ts | 4 +--- 5 files changed, 4 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index e6bb625..014d8a3 100644 --- a/README.md +++ b/README.md @@ -43,9 +43,8 @@ as well as performing operations like minting, swapping, and burning [View the demo task](https://github.com/NilFoundation/uniswap-v2-nil/blob/main/tasks/core/demo.ts) **Important:** - - The `UniswapV2Pair` is deployed on the same shard as the `UniswapV2Factory`. - Calculations are processed on the user's side. - - Both the currency address and its ID are stored. + - Both the currency address and its ID are stored in the pair contract. 2. **Using Factory, Pair, and Router Contracts** diff --git a/contracts/UniswapV2Router01.sol b/contracts/UniswapV2Router01.sol index e7d3083..8a08823 100644 --- a/contracts/UniswapV2Router01.sol +++ b/contracts/UniswapV2Router01.sol @@ -9,16 +9,6 @@ import "@nilfoundation/smart-contracts/contracts/Nil.sol"; import "./interfaces/IUniswapV2Pair.sol"; contract UniswapV2Router01 is IUniswapV2Router01, NilCurrencyBase { - // not used now - address public immutable factory; - - - constructor(address _factory) public { - // Revert if the factory address is the zero address or an empty string - require(_factory != address(0), "Factory address cannot be the zero address"); - - factory = _factory; - } modifier sameShard(address _addr) { require(Nil.getShardId(_addr) == Nil.getShardId(address(this)), "Sync calls require same shard for all contracts"); diff --git a/ignition/modules/Router.ts b/ignition/modules/Router.ts index b744b66..413f071 100644 --- a/ignition/modules/Router.ts +++ b/ignition/modules/Router.ts @@ -1,12 +1,7 @@ import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; module.exports = buildModule("DeployUniswapV2Router01", (m) => { - const factory = m.getParameter( - "factory", - "0x0000000000000000000000000000000000000000", - ); - - const router = m.contract("UniswapV2Router01", [factory]); + const router = m.contract("UniswapV2Router01"); return { router }; }); diff --git a/tasks/core/demo-router-sync.ts b/tasks/core/demo-router-sync.ts index be37bc8..dffed45 100644 --- a/tasks/core/demo-router-sync.ts +++ b/tasks/core/demo-router-sync.ts @@ -57,9 +57,7 @@ task( console.log("Currency1 deployed " + currency1Address); const { deployedContract: RouterContract, contractAddress: routerAddress } = - await deployNilContract(hre, "UniswapV2Router01", [ - factoryAddress.toLowerCase(), - ]); + await deployNilContract(hre, "UniswapV2Router01"); console.log("Router deployed " + routerAddress); diff --git a/tasks/core/demo-router.ts b/tasks/core/demo-router.ts index c607a8a..148d08a 100644 --- a/tasks/core/demo-router.ts +++ b/tasks/core/demo-router.ts @@ -57,9 +57,7 @@ task("demo-router", "Run demo with Uniswap Router").setAction( console.log("Currency1 deployed " + currency1Address); const { deployedContract: RouterContract, contractAddress: routerAddress } = - await deployNilContract(hre, "UniswapV2Router01", [ - factoryAddress.toLowerCase(), - ]); + await deployNilContract(hre, "UniswapV2Router01"); console.log("Router deployed " + routerAddress);