Skip to content

Commit

Permalink
demo-router: contract + task
Browse files Browse the repository at this point in the history
  • Loading branch information
Rolaman committed Oct 7, 2024
1 parent aaaef18 commit d497507
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 24 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
10 changes: 0 additions & 10 deletions contracts/UniswapV2Router01.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
7 changes: 1 addition & 6 deletions ignition/modules/Router.ts
Original file line number Diff line number Diff line change
@@ -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 };
});
4 changes: 1 addition & 3 deletions tasks/core/demo-router-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 1 addition & 3 deletions tasks/core/demo-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit d497507

Please sign in to comment.