Skip to content

Commit 6ca9b04

Browse files
committed
feat: add task to initialize Uniswap mock router for testing swaps
1 parent 4688ad4 commit 6ca9b04

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// DRAFT: This script is a draft and may require further implementation or review before production use.
2+
3+
import { task } from "hardhat/config";
4+
import { ethers } from "hardhat";
5+
6+
// Usage: npx hardhat init-uniswap-mock-router --network <network> --router <router-address>
7+
8+
task("init-uniswap-mock-router", "Initialize the Uniswap mock router for testing swaps")
9+
.addParam("router", "The address of the Uniswap mock router contract")
10+
.setAction(async ({ router }, hre) => {
11+
if (!ethers.utils.isAddress(router)) {
12+
throw new Error("Invalid router address provided.");
13+
}
14+
const [signer] = await hre.ethers.getSigners();
15+
const mockRouter = await ethers.getContractAt("UniswapV2Router02Mock", router, signer);
16+
// Example: set up initial liquidity or configuration if needed
17+
// await mockRouter.addLiquidity(...)
18+
console.log(`Uniswap mock router at ${router} is ready for use.`);
19+
});

0 commit comments

Comments
 (0)