Skip to content

Commit

Permalink
Merge branch 'leon/prepare-epoch2-deployment' into 'develop'
Browse files Browse the repository at this point in the history
OCT-837: Prepare epoch 2 contracts deployment

See merge request wildland/governance/octant!691
  • Loading branch information
leoni-q committed Sep 5, 2023
2 parents 03834e2 + d15c8c3 commit f2a91f5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
9 changes: 5 additions & 4 deletions contracts-v1/deploy/0020_deploy_epochs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ethers } from 'hardhat';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';

import { DECISION_WINDOW, EPOCH_DURATION, EPOCHS_START } from '../env';
import { AUTH_ADDRESS, DECISION_WINDOW, EPOCH_DURATION, EPOCHS_START } from '../env';
import { AUTH, EPOCHS } from '../helpers/constants';
import { getLatestBlockTimestamp } from '../helpers/misc-utils';

Expand All @@ -12,19 +12,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments;
const { deployer } = await hre.getNamedAccounts();

const authAddress = AUTH_ADDRESS || (await ethers.getContract(AUTH)).address;

const now = await getLatestBlockTimestamp();
let decisionWindow = DECISION_WINDOW;
let epochDuration = EPOCH_DURATION;

if (['hardhat', 'localhost'].includes(hre.network.name)) {
decisionWindow = 120;
epochDuration = 300;
}
const start = EPOCHS_START || now - epochDuration;

const auth = await ethers.getContract(AUTH);

await deploy(EPOCHS, {
args: [start, epochDuration, decisionWindow, auth.address],
args: [start, epochDuration, decisionWindow, authAddress],
autoMine: true,
from: deployer,
log: true,
Expand Down
9 changes: 5 additions & 4 deletions contracts-v1/deploy/0030_deploy_deposits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@ import { ethers } from 'hardhat';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';

import { GLM_ADDRESS } from '../env';
import { AUTH_ADDRESS, GLM_ADDRESS } from '../env';
import { AUTH, DEPOSITS, TOKEN } from '../helpers/constants';

// This function needs to be declared this way, otherwise it's not understood by test runner.
// eslint-disable-next-line func-names
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments;
const { deployer } = await hre.getNamedAccounts();

const authAddress = AUTH_ADDRESS || (await ethers.getContract(AUTH)).address;

let glmAddress = GLM_ADDRESS;
if (['hardhat', 'localhost'].includes(hre.network.name)) {
const token = await ethers.getContract(TOKEN);
glmAddress = token.address;
}

const auth = await ethers.getContract(AUTH);

await deploy(DEPOSITS, {
args: [glmAddress, auth.address],
args: [glmAddress, authAddress],
autoMine: true,
from: deployer,
log: true,
Expand Down
9 changes: 5 additions & 4 deletions contracts-v1/deploy/0070_deploy_proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import { ethers } from 'hardhat';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';

import { PROPOSALS_ADDRESSES, PROPOSALS_CID } from '../env';
import { AUTH_ADDRESS, PROPOSALS_ADDRESSES, PROPOSALS_CID } from '../env';
import { AUTH, PROPOSALS } from '../helpers/constants';

// This function needs to be declared this way, otherwise it's not understood by test runner.
// eslint-disable-next-line func-names
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments;
const { deployer } = await hre.getNamedAccounts();

const authAddress = AUTH_ADDRESS || (await ethers.getContract(AUTH)).address;

let proposalAddresses = PROPOSALS_ADDRESSES.split(',');

/// for localhost and testnet same set of proposals is used
Expand All @@ -19,10 +22,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
proposalAddresses = unnamedAddresses.slice(0, 10);
}

const auth = await ethers.getContract(AUTH);

await deploy(PROPOSALS, {
args: [PROPOSALS_CID, proposalAddresses, auth.address],
args: [PROPOSALS_CID, proposalAddresses, authAddress],
autoMine: true,
from: deployer,
log: true,
Expand Down
5 changes: 3 additions & 2 deletions contracts-v1/deploy/0080_deploy_vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ethers } from 'hardhat';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';

import { AUTH_ADDRESS } from '../env';
import { AUTH, VAULT } from '../helpers/constants';

// This function needs to be declared this way, otherwise it's not understood by test runner.
Expand All @@ -10,10 +11,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deploy } = hre.deployments;
const { deployer } = await hre.getNamedAccounts();

const auth = await ethers.getContract(AUTH);
const authAddress = AUTH_ADDRESS || (await ethers.getContract(AUTH)).address;

await deploy(VAULT, {
args: [auth.address],
args: [authAddress],
autoMine: true,
from: deployer,
log: true,
Expand Down
2 changes: 2 additions & 0 deletions contracts-v1/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const IS_GAS_REPORTING_ENABLED = Boolean(process.env.IS_GAS_REPORTING_ENABLED) |
// ----------------
// CONTRACTS ADDRESSES
// ----------------
const AUTH_ADDRESS = process.env.AUTH_ADDRESS || '';
const GNT_ADDRESS = process.env.GNT_ADDRESS || '0xE6de13D64F6036E4E3f5fC84B5EB620C5C7c1050';
const GLM_ADDRESS = process.env.GLM_ADDRESS || '0x7DD9c5Cba05E151C895FDe1CF355C9A1D5DA6429';
const GLM_FAUCET_ADDRESS =
Expand All @@ -46,6 +47,7 @@ const EPOCH_DURATION = Number(process.env.EPOCH_DURATION) || 600;
const DECISION_WINDOW = Number(process.env.DECISION_WINDOW) || 600;

export {
AUTH_ADDRESS,
PROPOSALS_CID,
PROPOSALS_ADDRESSES,
MULTISIG_ADDRESS,
Expand Down

0 comments on commit f2a91f5

Please sign in to comment.