Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: sepolia and op sepolia #17

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
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
14 changes: 8 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ ENCRYPTED_PRIVATE_KEY=
# HTTPs providers
MAINNET_HTTPS_URL=
OPTIMISM_HTTPS_URL=
GOERLI_HTTPS_URL=
OP_GOERLI_HTTPS_URL=
POLYGON_HTTPS_URL=
SEPOLIA_HTTPS_URL=
OP_SEPOLIA_HTTPS_URL=

# Account's private keys
MAINNET_PRIVATE_KEY=
OPTIMISM_PRIVATE_KEY=
GOERLI_PRIVATE_KEY=
OP_GOERLI_PRIVATE_KEY=
POLYGON_PRIVATE_KEY=
SEPOLIA_PRIVATE_KEY=
OP_SEPOLIA_PRIVATE_KEY=

# Etherscan (optional, only for verifying smart contracts)
ETHERSCAN_API_KEY=
ETHEREUM_ETHERSCAN_API_KEY=
OPTIMISTIC_ETHERSCAN_API_KEY=
GOERLI_ETHERSCAN_API_KEY=
OP_GOERLI_ETHERSCAN_API_KEY=
POLYGON_ETHERSCAN_API_KEY=
OP_SEPOLIA_ETHERSCAN_API_KEY=

HARDHAT_DEPLOY_LOG=TRUE
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cache
artifacts
deployments/hardhat
deployments/localhost
deployments/**/solcInputs

# Config files
.env
Expand Down
4 changes: 2 additions & 2 deletions deploy/0-mainnet/001_keep3r_v1.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import IERC20 from '../../artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.json';
import ERC20ForTest from '../../artifacts/solidity/for-test/ERC20ForTest.sol/ERC20ForTest.json';

const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { kp3rV1 } = await hre.getNamedAccounts();

await hre.deployments.save('KP3Rv1', {
address: kp3rV1,
abi: IERC20.abi,
abi: ERC20ForTest.abi,
});
};

Expand Down
3 changes: 1 addition & 2 deletions deploy/1-mainnet-test/101_uni_v3_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import IUniswapV3Factory from '../../artifacts/@uniswap/v3-core/contracts/interf
import IUniswapV3Pool from '../../artifacts/@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol/IUniswapV3Pool.json';

const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer, weth } = await hre.getNamedAccounts();
const { deployer, weth, uniV3Factory } = await hre.getNamedAccounts();

const kp3RForTest = await hre.deployments.get('KP3Rv1');
const uniV3Factory = '0x1f98431c8ad98523631ae4a59f267346ea31f984';

await hre.deployments.save('WETH', {
address: weth,
Expand Down
44 changes: 30 additions & 14 deletions deploy/1-mainnet-test/110_job_for_test.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,54 @@
import { WETH_ADDRESS } from '@e2e/common';
import { toUnit } from '@utils/bn';
import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer, kp3rV1 } = await hre.getNamedAccounts();
const { deployer } = await hre.getNamedAccounts();
const kp3RForTest = await hre.deployments.get('KP3Rv1');
const keep3rV2 = await hre.deployments.get('Keep3rForTestnet');
const pairManager = await hre.deployments.get('UniV3PairManager');

const jobForTest = await hre.deployments.deploy('BasicJob', {
const jobForTest = await hre.deployments.deploy('JobForTest', {
from: deployer,
contract: 'solidity/for-test/JobForTest.sol:JobForTest',
args: [keep3rV2.address],
log: true,
});

// register job
if (jobForTest.newlyDeployed) {
const jobs = await hre.deployments.read('Keep3rForTestnet', 'jobs');

if (!jobs.includes(jobForTest.address)) {
await hre.deployments.execute('Keep3rForTestnet', { from: deployer, log: true }, 'addJob', jobForTest.address);
}

const LIQUIDITY = await hre.deployments.read('Keep3rForTestnet', 'liquidityAmount', jobForTest.address, pairManager.address);
if (LIQUIDITY == 0) {
const liquidity = await hre.deployments.read('Keep3rForTestnet', 'liquidityAmount', jobForTest.address, pairManager.address);

if (liquidity == 0) {
// deployer needs to have KP3R and WETH balance
let klpBalance = await hre.deployments.read('UniV3PairManager', 'balanceOf', deployer);
if (klpBalance == 0) {
const wethBalance = await hre.deployments.read('WETH', 'balanceOf', deployer);
if (wethBalance < toUnit(1)) {
if (wethBalance < toUnit(0.1)) {
await hre.deployments.execute('WETH', { from: deployer, log: true, value: toUnit(0.1) }, 'deposit');
}
const kp3rBalance = await hre.deployments.read('KP3Rv1', 'balanceOf', deployer);
if (kp3rBalance < toUnit(100)) {
await hre.deployments.execute('KP3Rv1', { from: deployer, log: true }, 'mint(uint256)', toUnit(1));
if (kp3rBalance < toUnit(10)) {
await hre.deployments.execute('KP3Rv1', { from: deployer, log: true }, 'mint(uint256)', toUnit(100_000));
}

await hre.deployments.execute('KP3Rv1', { from: deployer, log: true }, 'approve', pairManager.address, toUnit(100));
await hre.deployments.execute('WETH', { from: deployer, log: true }, 'approve', pairManager.address, toUnit(100));
await hre.deployments.execute('WETH', { from: deployer, log: true }, 'approve', pairManager.address, toUnit(100_000));

let mintArguments: any[];

// Check if WETH is the first token in the pair
if (WETH_ADDRESS > kp3RForTest.address) {
mintArguments = [toUnit(0.1), toUnit(100_000), 0, 0, deployer];
} else {
mintArguments = [toUnit(100_000), toUnit(0.1), 0, 0, deployer];
}

const mintArguments: any[] = [toUnit(1), toUnit(0.1), 0, 0, deployer];
await hre.deployments.execute('UniV3PairManager', { from: deployer, log: true }, 'mint', ...mintArguments);

klpBalance = await hre.deployments.read('UniV3PairManager', 'balanceOf', deployer);
Expand All @@ -55,14 +66,19 @@ const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnviro
);
}

const IS_KEEPER = await hre.deployments.read('Keep3rForTestnet', 'isKeeper', deployer);
if (!IS_KEEPER) {
const isKeeper = await hre.deployments.read('Keep3rForTestnet', 'isKeeper', deployer);
if (!isKeeper) {
// register deployer as keeper
await hre.deployments.execute('Keep3rForTestnet', { from: deployer, log: true }, 'bond', kp3RForTest.address, 0);

// wait for bond to be processed
console.log('waiting for bond to be processed');
await new Promise((resolve) => setTimeout(resolve, 10_000));

await hre.deployments.execute('Keep3rForTestnet', { from: deployer, log: true }, 'activate', kp3RForTest.address);
}

await hre.deployments.execute('BasicJob', { from: deployer, log: true, gasLimit: 1e6 }, 'work');
await hre.deployments.execute('JobForTest', { from: deployer, log: true, gasLimit: 1e6 }, 'work');
};

deployFunction.dependencies = ['testnet-keep3r'];
Expand Down
6 changes: 3 additions & 3 deletions deploy/2-sidechain/203_keep3r_helper_and_sidechain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer, governor, kp3rV1, weth, kp3rWethOracle, wethUsdOracle } = await hre.getNamedAccounts();
const { deployer, governor, kp3rV1, weth, kp3rWethOracle, wethUsdOracle, usdDecimals } = await hre.getNamedAccounts();
const { kp3rV1: mainnetKp3rV1 } = await hre.companionNetworks['mainnet'].getNamedAccounts();

const keep3rEscrow = await hre.deployments.get('Keep3rEscrow');
Expand All @@ -11,7 +11,7 @@ const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnviro
const currentNonce: number = await hre.ethers.provider.getTransactionCount(deployer);
const keeperV2Address: string = hre.ethers.utils.getContractAddress({ from: deployer, nonce: currentNonce + 1 });

const keep3rHelperArgs = [keeperV2Address, governor, mainnetKp3rV1, weth, kp3rWethOracle, wethUsdOracle];
const keep3rHelperArgs = [keeperV2Address, governor, mainnetKp3rV1, weth, kp3rWethOracle, wethUsdOracle, usdDecimals];

const keep3rHelper = await hre.deployments.deploy('Keep3rHelperSidechain', {
from: deployer,
Expand All @@ -22,7 +22,7 @@ const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnviro

const keep3rV2Args = [governor, keep3rHelper.address, kp3rV1, keep3rEscrow.address];

const keep3r = await hre.deployments.deploy('Keep3rSidechain', {
await hre.deployments.deploy('Keep3rSidechain', {
contract: 'solidity/contracts/sidechain/Keep3rSidechain.sol:Keep3rSidechain',
from: deployer,
args: keep3rV2Args,
Expand Down
8 changes: 3 additions & 5 deletions deploy/3-sidechain-test/301_keep3r_helper_and_sidechain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer, governor, kp3rV1, kp3rWethOracle, wethUsdOracle } = await hre.getNamedAccounts();
const { kp3rV1: mainnetKp3rV1, weth: mainnetWeth } = await hre.companionNetworks['mainnet'].getNamedAccounts();

const { deployer, governor, kp3rV1, weth, kp3rWethOracle, wethUsdOracle, usdDecimals } = await hre.getNamedAccounts();
const keep3rEscrow = await hre.deployments.get('Keep3rEscrow');

// precalculate the address of Keep3rV2 contract
const currentNonce: number = await hre.ethers.provider.getTransactionCount(deployer);
const keeperV2Address: string = hre.ethers.utils.getContractAddress({ from: deployer, nonce: currentNonce + 1 });

const keep3rHelperArgs = [keeperV2Address, governor, mainnetKp3rV1, mainnetWeth, kp3rWethOracle, wethUsdOracle];
const keep3rHelperArgs = [keeperV2Address, governor, kp3rV1, weth, kp3rWethOracle, wethUsdOracle, usdDecimals];

const keep3rHelper = await hre.deployments.deploy('Keep3rHelperSidechain', {
from: deployer,
Expand All @@ -22,7 +20,7 @@ const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnviro

const keep3rV2Args = [governor, keep3rHelper.address, kp3rV1, keep3rEscrow.address];

const keep3r = await hre.deployments.deploy('Keep3rSidechainForTestnet', {
await hre.deployments.deploy('Keep3rSidechainForTestnet', {
contract: 'solidity/for-test/testnet/Keep3rSidechainForTestnet.sol:Keep3rSidechainForTestnet',
from: deployer,
args: keep3rV2Args,
Expand Down
25 changes: 16 additions & 9 deletions deploy/3-sidechain-test/311_job_rated_for_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,48 @@ const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnviro
abi: IERC20.abi,
});

const jobForTest = await hre.deployments.deploy('BasicJob', {
const jobForTest = await hre.deployments.deploy('JobRatedForTest', {
from: deployer,
contract: 'solidity/for-test/JobRatedForTest.sol:JobRatedForTest',
args: [keep3rV2.address],
log: true,
});

// register job
if (jobForTest.newlyDeployed) {
const jobs = await hre.deployments.read('Keep3rSidechainForTestnet', 'jobs');

if (!jobs.includes(jobForTest.address)) {
await hre.deployments.execute('Keep3rSidechainForTestnet', { from: deployer, log: true }, 'addJob', jobForTest.address);
}

const LIQUIDITY = await hre.deployments.read('Keep3rSidechainForTestnet', 'liquidityAmount', jobForTest.address, wkLP);
if (LIQUIDITY == 0) {
const liquidity = await hre.deployments.read('Keep3rSidechainForTestnet', 'liquidityAmount', jobForTest.address, wkLP);
if (liquidity == 0) {
// deployer needs to have kLP balance
const keep3rSidechain = await hre.deployments.get('Keep3rSidechainForTestnet');

await hre.deployments.execute('wkLP', { from: deployer, log: true }, 'approve', keep3rSidechain.address, toUnit(10));
await hre.deployments.execute(
'Keep3rSidechainForTestnet',
{ from: deployer, log: true },
'addLiquidityToJob',
jobForTest.address,
wkLP,
toUnit(1)
toUnit(10)
);
}

const IS_KEEPER = await hre.deployments.read('Keep3rSidechainForTestnet', 'isKeeper', deployer);
if (!IS_KEEPER) {
const isKeeper = await hre.deployments.read('Keep3rSidechainForTestnet', 'isKeeper', deployer);
if (!isKeeper) {
// register deployer as keeper
await hre.deployments.execute('Keep3rSidechainForTestnet', { from: deployer, log: true }, 'bond', kp3rV1, 0);

// wait for bond to be processed
console.log('waiting for bond to be processed');
await new Promise((resolve) => setTimeout(resolve, 10_000));

await hre.deployments.execute('Keep3rSidechainForTestnet', { from: deployer, log: true, gasLimit: 1e6 }, 'activate', kp3rV1);
}

await hre.deployments.execute('BasicJob', { from: deployer, log: true, gasLimit: 1e6 }, 'work');
await hre.deployments.execute('JobRatedForTest', { from: deployer, log: true, gasLimit: 1e6 }, 'work');
};

deployFunction.dependencies = ['approve-testnet-liquidity'];
Expand Down
2 changes: 1 addition & 1 deletion deploy/4-verify/421_verify_testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnviro
const keep3rV2 = await hre.deployments.get('Keep3rForTestnet');
await verifyContract(hre, keep3rV2);

const jobForTest = await hre.deployments.getOrNull('BasicJob');
const jobForTest = await hre.deployments.getOrNull('JobForTest');
if (jobForTest) {
await verifyContract(hre, jobForTest);
}
Expand Down
2 changes: 1 addition & 1 deletion deploy/4-verify/422_verify_testnet_sidechain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnviro
const keep3rV2 = await hre.deployments.get('Keep3rSidechainForTestnet');
await verifyContract(hre, keep3rV2);

const jobForTest = await hre.deployments.getOrNull('BasicJob');
const jobForTest = await hre.deployments.getOrNull('JobRatedForTest');
if (jobForTest) {
await verifyContract(hre, jobForTest);
}
Expand Down
1 change: 0 additions & 1 deletion deployments/goerli/.chainId

This file was deleted.

133 changes: 0 additions & 133 deletions deployments/goerli/BasicJob.json

This file was deleted.

Loading
Loading