Skip to content

Commit

Permalink
Deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Shchepetov committed Aug 6, 2024
1 parent f038cf3 commit 54f9bc1
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 9 deletions.
6 changes: 5 additions & 1 deletion .env.mock
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ AZUR=0x765...456
UNSTAKEPERIOD=2592000
REWARD_POOL_ADDRESS=

NAME="Staked $AZUR"
SYMBOL="stAZUR"
REWARD_POOL_V2_ADDRESS=0xa..d3

POLYGONSCAN_API_KEY=1N..XX
ETHERSCAN_API_KEY=1N..XX
MUMBAI_PRIVATE_KEY=db0e..82c2
POLYGON_PRIVATE_KEY=db0e..82c2
MAINNET_PRIVATE_KEY=db0e..82c2
INFURA_API_KEY=
INFURA_API_KEY=
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"compile": "npx hardhat compile",
"test": "npx hardhat test",
"prettier-sol": "npx prettier --write \"contracts/**/*.sol\"",
"prettier-js": "npx prettier --write {scripts,test,utils}/*.js --print-width 120 --tab-width 2",
"prettier-js": "npx prettier --write {scripts/*,test,utils}/*.js --print-width 120 --tab-width 2",
"coverage": "npx hardhat coverage"
}
}
2 changes: 1 addition & 1 deletion scripts/deploy.js → scripts/RewardPool/deploy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { ethers } = require("hardhat");
const hre = require("hardhat");
const { getTimeout, deployRewardPool } = require("../utils/utils");
const { getTimeout, deployRewardPool } = require("../../utils/utils");

async function main() {
const [deployer] = await ethers.getSigners();
Expand Down
4 changes: 2 additions & 2 deletions scripts/upgrade.js → scripts/RewardPool/upgrade.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { ethers } = require("hardhat");
const hre = require("hardhat");
const { getTimeout, deployRewardPool } = require("../utils/utils");
const { getTimeout } = require("../../utils/utils");

async function main() {
const [deployer] = await ethers.getSigners();
Expand All @@ -19,7 +19,7 @@ async function main() {

const REWARDPOOL = await ethers.getContractFactory("RewardPool");

const rewardPool = await upgrades.upgradeProxy(REWARD_POOL_ADDRESS, REWARDPOOL);
await upgrades.upgradeProxy(REWARD_POOL_ADDRESS, REWARDPOOL);
await timeout();
let rewardPoolImplAddress = await upgrades.erc1967.getImplementationAddress(REWARD_POOL_ADDRESS);

Expand Down
31 changes: 31 additions & 0 deletions scripts/RewardPoolV2/deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { ethers } = require("hardhat");
const hre = require("hardhat");
const { getTimeout, deployRewardPoolV2 } = require("../../utils/utils");

async function main() {
const [deployer] = await ethers.getSigners();

// ........................ ENV ENV ENV ................
const AZUR = process.env.AZUR;
const NAME = process.env.NAME;
const SYMBOL = process.env.SYMBOL;
const UNSTAKEPERIOD = process.env.UNSTAKEPERIOD;
// ........................ ENV ENV ENV ................

console.log("Deployer wallet:", deployer.address);

const chainId = await hre.network.provider.send("eth_chainId");
const timeout = getTimeout(chainId);

const rewardPoolV2 = await deployRewardPoolV2(AZUR, deployer, NAME, SYMBOL, UNSTAKEPERIOD);

await timeout();
console.log("RewardPoolV2:", await rewardPoolV2.getAddress());
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
31 changes: 31 additions & 0 deletions scripts/RewardPoolV2/upgrade.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { ethers } = require("hardhat");
const hre = require("hardhat");
const { getTimeout } = require("../../utils/utils");

async function main() {
const [deployer] = await ethers.getSigners();

// ........................ ENV ENV ENV ................
const REWARD_POOL_V2_ADDRESS = process.env.REWARD_POOL_V2_ADDRESS;
// ........................ ENV ENV ENV ................

console.log("Deployer wallet:", deployer.address);
console.log("Upgrading RewardPoolV2:", REWARD_POOL_V2_ADDRESS);

const chainId = await hre.network.provider.send("eth_chainId");
const timeout = getTimeout(chainId);

const RewardPoolV2 = await ethers.getContractFactory("RewardPoolV2");
await upgrades.upgradeProxy(REWARD_POOL_V2_ADDRESS, RewardPoolV2);
await timeout();

const rewardPoolV2ImplAddress = await upgrades.erc1967.getImplementationAddress(REWARD_POOL_V2_ADDRESS);
console.log("RewardPoolV2 new implementation address:", rewardPoolV2ImplAddress);
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
2 changes: 1 addition & 1 deletion test/RewardPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("RewardPool", function () {
const rewardPool = await deployRewardPool(azur.address, owner, UNSTAKEPERIOD);
rewardPool.address = await rewardPool.getAddress();

const stAzur = await deployRewardPoolV2(azur.address, owner, UNSTAKEPERIOD);
const stAzur = await deployRewardPoolV2(azur.address, owner, "Staked $AZUR", "stAZUR", UNSTAKEPERIOD);
stAzur.address = await stAzur.getAddress();

await azur.connect(owner).approve(rewardPool.address, INIT_MINT);
Expand Down
2 changes: 1 addition & 1 deletion test/RewardPoolV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("RewardPool", function () {
await azur.waitForDeployment();
azur.address = await azur.getAddress();

const stAzur = await deployRewardPoolV2(azur.address, owner, WITHDRAWAL_DELAY);
const stAzur = await deployRewardPoolV2(azur.address, owner, "Staked $AZUR", "stAZUR", WITHDRAWAL_DELAY);
stAzur.address = await stAzur.getAddress();

await azur.connect(owner).transfer(user.address, INIT_BALANCE);
Expand Down
4 changes: 2 additions & 2 deletions utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ const deployRewardPool = async (azurAddress, owner, unstakedPeriod) => {
return rewardPool;
};

const deployRewardPoolV2 = async (azurAddress, owner, unstakePeriod) => {
const deployRewardPoolV2 = async (azurAddress, owner, name, symbol, unstakePeriod) => {
const RewardPoolV2 = await ethers.getContractFactory("RewardPoolV2", { signer: owner });
const rewardPoolV2 = await upgrades.deployProxy(RewardPoolV2, [azurAddress, "Staked AZUR", "stAZUR", unstakePeriod]);
const rewardPoolV2 = await upgrades.deployProxy(RewardPoolV2, [azurAddress, name, symbol, unstakePeriod]);
await rewardPoolV2.waitForDeployment();
return rewardPoolV2;
};
Expand Down

0 comments on commit 54f9bc1

Please sign in to comment.