mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-02-03 08:42:50 +00:00
da758aceaa
* Initial setup with hardhat. * Deploy Factory contract. * Deploy tokens and create pool using factory contract. * Deploy contract to private network. * Implement separate scripts for deploying Factory, Token and Pool. Co-authored-by: nikugogoi <95nikass@gmail.com>
28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
import { task, types } from "hardhat/config";
|
|
import {
|
|
abi as FACTORY_ABI,
|
|
} from '@uniswap/v3-core/artifacts/contracts/UniswapV3Factory.sol/UniswapV3Factory.json'
|
|
import { ContractTransaction } from "ethers";
|
|
|
|
task("create-pool", "Creates pool using Factory contract")
|
|
.addParam('factory', 'Address of factory contract', undefined, types.string)
|
|
.addParam('token0', 'Address of first token contract', undefined, types.string)
|
|
.addParam('token1', 'Address of second token contract', undefined, types.string)
|
|
.addParam('fee', "The pool's fee", undefined, types.int)
|
|
.setAction(async (args, hre) => {
|
|
const { factory: factoryAddress, token0, token1, fee } = args
|
|
const [signer] = await hre.ethers.getSigners();
|
|
const factory = new hre.ethers.Contract(factoryAddress, FACTORY_ABI, signer);
|
|
const transaction: ContractTransaction = await factory.createPool(token0, token1, fee)
|
|
const receipt = await transaction.wait();
|
|
|
|
if (receipt.events) {
|
|
const poolCreatedEvent = receipt.events.find(el => el.event === 'PoolCreated');
|
|
|
|
if (poolCreatedEvent && poolCreatedEvent.args) {
|
|
const { pool } = poolCreatedEvent.args;
|
|
console.log('Pool deployed to:', pool);
|
|
}
|
|
}
|
|
});
|