Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions deploy/deploy.js → deploy/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = async ({ ethers, getNamedAccounts, deployments, getChainId }) => {
import { DeployFunction } from "hardhat-deploy/types";
import { VoteEscrow } from "../typechain/VoteEscrow";

const func: DeployFunction = async ({ run, ethers, getNamedAccounts, deployments, getChainId }): Promise<void> => {
console.log("RPC URL: ", ethers.provider.connection.url);
const chainId = parseInt(await getChainId());
console.log("chainId: ", chainId);
Expand All @@ -15,8 +18,6 @@ module.exports = async ({ ethers, getNamedAccounts, deployments, getChainId }) =
if (chainId === HARDHAT_ID || chainId === CHAPEL_ID || chainId === MUMBAI_ID) {
// lock ION for testing
lockedTokenAddress = ionicTokenAddress;


} else {
// lockedTokenAddress = BAL8020;
}
Expand Down Expand Up @@ -73,8 +74,8 @@ module.exports = async ({ ethers, getNamedAccounts, deployments, getChainId }) =
}
});

//const ve = await deployments.getArtifact("VoteEscrow");
// console.log(JSON.stringify(ve));
const ve = (await ethers.getContract("VoteEscrow", deployer)) as VoteEscrow;
console.log(JSON.stringify(ve));

const timer = await deployments.deploy("EpochsTimer", {
contract: "EpochsTimer",
Expand Down Expand Up @@ -120,6 +121,8 @@ module.exports = async ({ ethers, getNamedAccounts, deployments, getChainId }) =
console.log(`set the voter in the escrow with tx ${tx.hash}`);

// TODO configure a bridge
}
};

func.tags = ["prod"];

module.exports.tags = ["prod"];
export default func;
41 changes: 16 additions & 25 deletions hardhat.config.js → hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
const { configDotenv } = require("dotenv");
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-waffle";
import "@typechain/hardhat";
import { config as dotEnvConfig } from "dotenv";
import "hardhat-abi-exporter";
import "hardhat-deploy";
import { HardhatUserConfig } from "hardhat/types/config";

require("@nomiclabs/hardhat-etherscan");
require("@nomiclabs/hardhat-waffle");
require('@nomiclabs/hardhat-truffle5');
require('@nomiclabs/hardhat-web3');
require("hardhat-gas-reporter");
require('hardhat-contract-sizer');
require("solidity-coverage");
require('hardhat-spdx-license-identifier');
require('hardhat-abi-exporter');
require('hardhat-storage-layout');
require('@openzeppelin/hardhat-upgrades');
const fs = require("fs");
require('hardhat-deploy');
var HardhatUserConfig = require("hardhat/types/config").HardhatUserConfig;
import "./tasks";

console.info('loading the .env config...');
configDotenv();
dotEnvConfig();

const OVERRIDE_RPC_URL = process.env.OVERRIDE_RPC_URL || process.env.ETH_PROVIDER_URL; // Deprecated: ETH_PROVIDER_URL
const mnemonic =
process.env.MNEMONIC ||
"test test test test test test test test test test test junk";
const mnemonic = process.env.MNEMONIC || "test test test test test test test test test test test junk";

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
Expand Down Expand Up @@ -55,7 +44,7 @@ module.exports = {
allowUnlimitedContractSize: true,
chainId: 1337,
gas: 25e6,
gasPrice: 20e10,
gasPrice: 20e10
},
arbitrum: {
url: OVERRIDE_RPC_URL || `https://arb1.arbitrum.io/rpc`,
Expand All @@ -71,6 +60,8 @@ module.exports = {
accounts: { mnemonic },
chainId: 80001,
url: OVERRIDE_RPC_URL || "https://rpc-mumbai.maticvigil.com"
},
}
}
}
};

export default config;
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"@chainlink/contracts": "^0.4.1",
"@nomiclabs/hardhat-ethers": "^2.0.5",
"@nomiclabs/hardhat-etherscan": "^3.1.7",
"@nomiclabs/hardhat-truffle5": "^2.0.5",
"@nomiclabs/hardhat-waffle": "^2.0.3",
Expand All @@ -15,9 +13,6 @@
"@openzeppelin/contracts-upgradeable": "^4.7.0",
"@openzeppelin/hardhat-upgrades": "^1.17.0",
"@openzeppelin/test-helpers": "^0.5.15",
"@pythnetwork/pyth-sdk-solidity": "^2.2.0",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"dotenv": "^16.0.0",
"ethereum-waffle": "^3.4.4",
"ethers": "^5.6.1",
Expand All @@ -27,15 +22,14 @@
"hardhat-gas-reporter": "^1.0.8",
"hardhat-spdx-license-identifier": "^2.0.3",
"hardhat-storage-layout": "^0.1.6",
"mocha": "^9.2.2",
"solidity-coverage": "^0.7.20",
"ts-node": "^10.9.1"
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.13"
},
"scripts": {
"forge": "forge",
"prettier": "prettier --write --plugin=prettier-plugin-solidity 'contracts/**/*.sol' --config .prettierrc",
"lint": "prettier --list-different 'contracts/**/*.sol'",
"deploy": "hardhat deploy --tags prod --no-compile",
"typechain": "echo '> Creating typechain types...'; [ ! -d ./typechain ] && typechain --target ethers-v5 --out-dir './typechain' './out/**/*.json' --show-stack-traces",
"deploy:localhost": "hardhat --network localhost deploy --tags prod --no-compile",
"deploy:chapel": "hardhat --network chapel deploy --tags prod --no-compile",
"deploy:mumbai": "hardhat --network mumbai deploy --tags prod --no-compile"
Expand All @@ -44,8 +38,13 @@
"contracts"
],
"devDependencies": {
"@typechain/hardhat": "^9.0.0",
"hardhat-deploy": "^0.11.34",
"prettier": "^2.6.2",
"prettier-plugin-solidity": "^1.0.0-beta.19"
"prettier-plugin-solidity": "^1.0.0-beta.19",
"typechain": "^8.3.1",
"@typechain/ethers-v5": "^11.1.0",
"typescript": "^5.1.6",
"ts-node": "^10.9.1"
}
}
2 changes: 2 additions & 0 deletions tasks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import "./utils";
import "./voter";
46 changes: 46 additions & 0 deletions tasks/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { task, types } from "hardhat/config";

export default task("boost:tx", "increase the max gas fees to speed up a tx")
.addParam("txHash", "tx hash", undefined, types.string)
.addParam("nonce", "nonce", undefined, types.int)
.setAction(async ({ txHash, nonce }, { ethers }) => {
const tr = await ethers.provider.getTransaction(txHash);

console.log(`tx response ${JSON.stringify(tr)}`);

const signer = await ethers.getSigner(tr.from);
const tx = await signer.sendTransaction({
from: tr.from,
to: tr.to,
value: tr.value,
nonce: nonce,
data: tr.data,
gasLimit: tr.gasLimit,
maxFeePerGas: tr.maxFeePerGas?.mul(120).div(100),
maxPriorityFeePerGas: tr.maxPriorityFeePerGas?.mul(120).div(100)
});
console.log(`new tx hash ${tx.hash}`);
await tx.wait();
console.log(`tx mined ${tx.hash}`);
});

task("cancel:tx", "cancel a tx with the same nonce")
.addParam("nonce", "nonce", undefined, types.int)
.addParam("sender", "sender address", "deployer", types.string)
.setAction(async ({ nonce, sender }, { ethers, getChainId }) => {
const chainid = parseInt(await getChainId());
if (chainid != 137) throw new Error(`configure the max gas fees for the chain`);

const signer = await ethers.getNamedSigner(sender);
const tx = await signer.sendTransaction({
from: signer.address,
to: signer.address,
value: 0,
nonce,
maxFeePerGas: ethers.utils.parseUnits("300", "gwei"),
maxPriorityFeePerGas: ethers.utils.parseUnits("120", "gwei")
});
console.log(`cancelling tx hash ${tx.hash}`);
await tx.wait();
console.log(`tx mined ${tx.hash}`);
});
41 changes: 41 additions & 0 deletions tasks/voter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { task, types } from "hardhat/config";
import { Voter } from "../typechain/Voter";

enum VoterFactoryAction {
ADD,
REMOVE,
REPLACE
}

// npx hardhat voter:factory --action 0 --gauge 0x000 --network chapel
export default task("voter:factory", "increase the max gas fees to speed up a tx")
.addParam("action", "which action to take", 1, types.int)
.addOptionalParam("gauge", "gauge address", undefined, types.string)
.addOptionalParam("pos", "position value", undefined, types.int)
.setAction(async ({ gauge, action, pos }, { ethers }) => {
const deployer = await ethers.getNamedSigner("deployer");

const voter = (await ethers.getContract("Voter", deployer)) as Voter;

let tx;

switch (action) {
case VoterFactoryAction.ADD:
console.log(`adding ${gauge} for voter ${voter.address}`);
tx = await voter.addFactory(gauge);
await tx.wait();
break;
case VoterFactoryAction.REMOVE:
console.log(`removing ${gauge} at ${pos}`);
tx = await voter.removeFactory(pos);
await tx.wait();
break;
case VoterFactoryAction.REPLACE:
console.log(`replacing ${gauge} for voter ${voter.address} at ${pos}`);
tx = await voter.replaceFactory(gauge, pos);
await tx.wait();
break;
default:
throw new Error(`invalid action ${action}`);
}
});
11 changes: 11 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"resolveJsonModule": true
}
}
Loading