diff --git a/router/.gitignore b/router/.gitignore index c46197e..a2d7205 100644 --- a/router/.gitignore +++ b/router/.gitignore @@ -7,3 +7,4 @@ coverage.json cache artifacts +typechain-types \ No newline at end of file diff --git a/router/scripts/deploy-gamma-ratios-calculator.ts b/router/scripts/deploy-gamma-ratios-calculator.ts new file mode 100644 index 0000000..1f96fb5 --- /dev/null +++ b/router/scripts/deploy-gamma-ratios-calculator.ts @@ -0,0 +1,18 @@ +import { ethers } from "hardhat"; + +async function main() { + const gammaRatiosCalculator = await ethers.deployContract( + "GammaRatiosCalculator", + [] + ); + + await gammaRatiosCalculator.waitForDeployment(); + console.log( + `GammaRatiosCalculator deployed to ${gammaRatiosCalculator.target}` + ); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/router/scripts/deploy-router-simulator.ts b/router/scripts/deploy-router-simulator.ts deleted file mode 100644 index 4069719..0000000 --- a/router/scripts/deploy-router-simulator.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { ethers } from "hardhat"; - -async function main() { - const routerSimulator = await ethers.deployContract("RouterSimulator", []); - await routerSimulator.waitForDeployment(); - console.log(`RouterSimulator deployed to ${routerSimulator.target}`); -} - -main().catch((error) => { - console.error(error); - process.exitCode = 1; -}); diff --git a/router/scripts/deploy-router.ts b/router/scripts/deploy-router.ts deleted file mode 100644 index 7262286..0000000 --- a/router/scripts/deploy-router.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { ethers } from "hardhat"; - -async function main() { - const router = await ethers.deployContract("Router", []); - - await router.waitForDeployment(); - - console.log(`Router deployed to ${router.target}`); -} - -main().catch((error) => { - console.error(error); - process.exitCode = 1; -}); diff --git a/router/scripts/deploy.ts b/router/scripts/deploy.ts new file mode 100644 index 0000000..f49d644 --- /dev/null +++ b/router/scripts/deploy.ts @@ -0,0 +1,67 @@ +import { ethers, run } from "hardhat"; + +async function main() { + // Fetch current gas price from the network using JSON-RPC + const currentGasPriceHex = await ethers.provider.send("eth_gasPrice", []); + // Convert the hexadecimal string to a BigInt + const currentGasPrice = BigInt(currentGasPriceHex); + // Add 1 Gwei (which is 1e9 Wei) to the current gas price + const adjustedGasPrice = currentGasPrice + BigInt(1e9); + + const router = await ethers.deployContract("Router", [], { + gasPrice: adjustedGasPrice.toString(), + }); + await router.waitForDeployment(); + console.log(`Router deployed to ${router.target}`); + + const routerSimulator = await ethers.deployContract("RouterSimulator", [], { + gasPrice: adjustedGasPrice.toString(), + }); + await routerSimulator.waitForDeployment(); + console.log(`RouterSimulator deployed to ${routerSimulator.target}`); + + console.log(`Waiting to verify...`); + await setTimeout(() => {}, 15000); + + const verifyContract = async ({ + address, + constructorArguments, + }: { + address: any; + constructorArguments: any; + }) => { + let verificationSuccess = false; + while (!verificationSuccess) { + try { + await run("verify:verify", { + address, + constructorArguments, + }); + verificationSuccess = true; // Breaks the loop if verification succeeds + console.log(`Successfully verified contract at ${address}`); + } catch (e) { + console.error( + `Verification failed for ${address}. Retrying in 5 seconds.` + ); + await new Promise((resolve) => setTimeout(resolve, 5000)); // Waits for 5 seconds before retrying + } + } + }; + + await verifyContract({ + address: router.target, + constructorArguments: [], + }); + + await verifyContract({ + address: routerSimulator.target, + constructorArguments: [], + }); + + console.log(`Successfully verified contracts`); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/tsconfig.json b/tsconfig.json index b79a175..13ef90a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,9 @@ { "$schema": "https://json.schemastore.org/tsconfig", + "ts-node": { + "esm": true, + "experimentalSpecifierResolution": "node" + }, "compilerOptions": { "target": "ESNext", "moduleResolution": "NodeNext",