-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from oxoxDev/upgrade-pool-voter
feat: add script to upgrade Pool Voter
- Loading branch information
Showing
5 changed files
with
121 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {ethers, upgrades} from "hardhat"; | ||
|
||
const ZERO_TOKEN_ADDRESS = "0x78354f8DcCB269a615A7e0a24f9B0718FDC3C7A7"; | ||
const OMNICHAIN_STAKING_ADDRESS = "0xf374229a18ff691406f99CCBD93e8a3f16B68888"; | ||
|
||
async function main() { | ||
|
||
const poolVoterProxy = "0x5346e9ab27D7874Db95993667D1Cb8338913f0aF" | ||
const poolVoter = await ethers.getContractFactory("PoolVoter"); | ||
|
||
console.log("Upgradig to new PoolVoter implementation"); | ||
|
||
if (ZERO_TOKEN_ADDRESS.length && OMNICHAIN_STAKING_ADDRESS.length) { | ||
|
||
const upgradedPoolVoter = await upgrades.upgradeProxy(poolVoterProxy, poolVoter); | ||
const tx = await upgradedPoolVoter.init(OMNICHAIN_STAKING_ADDRESS, ZERO_TOKEN_ADDRESS); | ||
await tx.wait(); | ||
|
||
console.log("PoolVoter upgraded to", upgradedPoolVoter.address); | ||
} else { | ||
throw new Error("Invalid init arguments"); | ||
} | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { expect, should } from "chai"; | ||
import { e18, initMainnetUser } from "../../fixtures/utils"; | ||
import { VestedZeroNFT, VotingPowerCombined } from "../../../typechain-types"; | ||
import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers"; | ||
import { time } from "@nomicfoundation/hardhat-network-helpers"; | ||
import { setForkBlock } from "../utils"; | ||
import { getNetworkDetails } from "../constants"; | ||
import { | ||
Contract, | ||
ContractTransactionResponse, | ||
parseEther, | ||
parseUnits, | ||
} from "ethers"; | ||
import { ethers } from "hardhat"; | ||
import { getGovernanceContracts } from "../helper"; | ||
|
||
const FORK = process.env.FORK === "true"; | ||
const FORKED_NETWORK = process.env.FORKED_NETWORK ?? ""; | ||
const BLOCK_NUMBER = 5969983; | ||
|
||
const STAKING_ADDRESS = "0xf374229a18ff691406f99CCBD93e8a3f16B68888"; | ||
const REWARD_ADDRESS = "0x78354f8DcCB269a615A7e0a24f9B0718FDC3C7A7"; | ||
const OWNER = "0x0F6e98A756A40dD050dC78959f45559F98d3289d"; | ||
|
||
if (FORK) { | ||
let votingPowerCombined: VotingPowerCombined; | ||
let deployerForked: SignerWithAddress; | ||
describe.only("VotingPowerCombined ForkTests", async () => { | ||
beforeEach(async () => { | ||
votingPowerCombined = await ethers.getContractAt( | ||
"VotingPowerCombined", | ||
"0x2666951A62d82860E8e1385581E2FB7669097647" | ||
); | ||
[deployerForked] = await ethers.getSigners(); | ||
await setForkBlock(BLOCK_NUMBER); | ||
|
||
// | ||
|
||
const poolVoterFactory = await ethers.getContractFactory("PoolVoter"); | ||
const poolVoter = await poolVoterFactory.deploy(); | ||
await poolVoter.init(STAKING_ADDRESS, REWARD_ADDRESS, votingPowerCombined.target); | ||
|
||
const owner = await initMainnetUser(OWNER); | ||
await votingPowerCombined.connect(owner).setAddresses(STAKING_ADDRESS, REWARD_ADDRESS, poolVoter.target); | ||
}); | ||
|
||
it("Should reset voting power", async () => { | ||
const resetterWallet = await initMainnetUser("0x7Ff4e6A2b7B43cEAB1fC07B0CBa00f834846ADEd", parseEther('100')); | ||
|
||
const resetTransaction = votingPowerCombined.connect(resetterWallet).reset(resetterWallet.address); | ||
await expect(resetTransaction).to.not.be.revertedWith('Invalid reset performed'); | ||
}); | ||
}); | ||
} |