Skip to content

Commit

Permalink
Small clean-ups
Browse files Browse the repository at this point in the history
  • Loading branch information
pgbrandao committed Nov 25, 2023
1 parent 71409d3 commit 313f107
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 26 deletions.
1 change: 1 addition & 0 deletions router/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ coverage.json
cache
artifacts

typechain-types
18 changes: 18 additions & 0 deletions router/scripts/deploy-gamma-ratios-calculator.ts
Original file line number Diff line number Diff line change
@@ -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;
});
12 changes: 0 additions & 12 deletions router/scripts/deploy-router-simulator.ts

This file was deleted.

14 changes: 0 additions & 14 deletions router/scripts/deploy-router.ts

This file was deleted.

67 changes: 67 additions & 0 deletions router/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -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;
});
4 changes: 4 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"ts-node": {
"esm": true,
"experimentalSpecifierResolution": "node"
},
"compilerOptions": {
"target": "ESNext",
"moduleResolution": "NodeNext",
Expand Down

0 comments on commit 313f107

Please sign in to comment.