-
Notifications
You must be signed in to change notification settings - Fork 3
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 #86 from stakedotlink/feature/update-event-logic
feat: Deployment scripts and contract changes
- Loading branch information
Showing
8 changed files
with
226 additions
and
13 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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"CommunityVCS": "0xAc12290b097f6893322F5430627e472131fBC1B5", | ||
"MerkleDistributor": "0xe7Dd77d408920c000C40C35c4c111318Ba8B4767" | ||
"MerkleDistributor": "0xe7Dd77d408920c000C40C35c4c111318Ba8B4767", | ||
"PriorityPool": "0xDdC796a66E8b83d0BcCD97dF33A6CcFBA8fd60eA", | ||
"StakingPool": "0xb8b295df2cd735b15BE5Eb419517Aa626fc43cD5", | ||
"Multisig": "0xB351EC0FEaF4B99FdFD36b484d9EC90D0422493D" | ||
} |
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,63 @@ | ||
import { ethers, upgrades, run } from 'hardhat' | ||
import { getContract } from '../utils/deployment' | ||
import { StakingPool, PriorityPool, CommunityVCS } from '../../typechain-types' | ||
|
||
async function main() { | ||
const stakingPool = (await getContract('LINK_StakingPool')) as StakingPool | ||
const priorityPool = (await getContract('LINK_PriorityPool')) as PriorityPool | ||
const communityVCS = (await getContract('LINK_CommunityVCS')) as CommunityVCS | ||
|
||
const stakingPoolImp = (await upgrades.prepareUpgrade( | ||
stakingPool.address, | ||
await ethers.getContractFactory('StakingPool'), | ||
{ | ||
kind: 'uups', | ||
unsafeAllowRenames: false, | ||
} | ||
)) as string | ||
console.log('StakingPool implementation deployed at: ', stakingPoolImp) | ||
|
||
await verifyContract(stakingPoolImp, []) | ||
|
||
const priorityPoolImp = (await upgrades.prepareUpgrade( | ||
priorityPool.address, | ||
await ethers.getContractFactory('PriorityPool'), | ||
{ | ||
kind: 'uups', | ||
unsafeAllowRenames: false, | ||
} | ||
)) as string | ||
console.log('PriorityPool implementation deployed at: ', priorityPoolImp) | ||
|
||
await verifyContract(priorityPoolImp, []) | ||
|
||
const communityVCSImp = (await upgrades.prepareUpgrade( | ||
communityVCS.address, | ||
await ethers.getContractFactory('CommunityVCS'), | ||
{ | ||
kind: 'uups', | ||
unsafeAllowRenames: false, | ||
} | ||
)) as string | ||
console.log('CommunityVCS implementation deployed at: ', communityVCSImp) | ||
await verifyContract(communityVCSImp, []) | ||
} | ||
|
||
async function verifyContract(contractAddress: string, constructorArguments: any[]) { | ||
try { | ||
await run('verify:verify', { | ||
address: contractAddress, | ||
constructorArguments: constructorArguments, | ||
}) | ||
console.log(`Contract verified: ${contractAddress}`) | ||
} catch (error: any) { | ||
console.error(`Verification failed for ${contractAddress}: ${error.message}`) | ||
} | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error) | ||
process.exit(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,73 @@ | ||
import { ethers } from 'hardhat' | ||
import Safe, { EthersAdapter } from '@safe-global/protocol-kit' | ||
import SafeApiKit from '@safe-global/api-kit' | ||
import { MetaTransactionData } from '@safe-global/safe-core-sdk-types' | ||
import { PriorityPool, StakingPool, CommunityVCS } from '../../typechain-types' | ||
import { getContract } from '../utils/deployment' | ||
import { getAccounts } from '../utils/helpers' | ||
|
||
const multisigAddress = '0xB351EC0FEaF4B99FdFD36b484d9EC90D0422493D' | ||
|
||
// New implementation addresses for the contracts | ||
const priorityPoolNewImplementation = '0xYourNewPriorityPoolAddress' | ||
const stakingPoolNewImplementation = '0xYourNewStakingPoolAddress' | ||
const communityVCSNewImplementation = '0xYourNewCommunityVCSAddress' | ||
|
||
async function main() { | ||
const { signers } = await getAccounts() | ||
const ethAdapter = new EthersAdapter({ | ||
ethers, | ||
signerOrProvider: signers[0], | ||
}) | ||
const safeSdk = await Safe.create({ ethAdapter, safeAddress: multisigAddress }) | ||
const safeService = new SafeApiKit({ | ||
txServiceUrl: 'https://safe-transaction-mainnet.safe.global', | ||
ethAdapter, | ||
}) | ||
|
||
const priorityPool = (await getContract('PriorityPool')) as PriorityPool | ||
const stakingPool = (await getContract('StakingPool')) as StakingPool | ||
const communityVCS = (await getContract('CommunityVCS')) as CommunityVCS | ||
|
||
const safeTransactionData: MetaTransactionData[] = [ | ||
{ | ||
to: priorityPool.address, | ||
data: | ||
(await priorityPool.populateTransaction.upgradeTo(priorityPoolNewImplementation)).data || | ||
'', | ||
value: '0', | ||
}, | ||
{ | ||
to: stakingPool.address, | ||
data: | ||
(await stakingPool.populateTransaction.upgradeTo(stakingPoolNewImplementation)).data || '', | ||
value: '0', | ||
}, | ||
{ | ||
to: communityVCS.address, | ||
data: | ||
(await communityVCS.populateTransaction.upgradeTo(communityVCSNewImplementation)).data || | ||
'', | ||
value: '0', | ||
}, | ||
] | ||
|
||
const safeTransaction = await safeSdk.createTransaction({ safeTransactionData }) | ||
const safeTxHash = await safeSdk.getTransactionHash(safeTransaction) | ||
const senderSignature = await safeSdk.signTransactionHash(safeTxHash) | ||
|
||
await safeService.proposeTransaction({ | ||
safeAddress: multisigAddress, | ||
safeTransactionData: safeTransaction.data, | ||
safeTxHash, | ||
senderAddress: signers[0].address, | ||
senderSignature: senderSignature.data, | ||
}) | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error) | ||
process.exit(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,60 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.15; | ||
import {StakingPool} from "../../../../contracts/core/StakingPool.sol"; | ||
import {PriorityPool} from "../../../../contracts/core/priorityPool/PriorityPool.sol"; | ||
import {CommunityVCS} from "../../../../contracts/linkStaking/CommunityVCS.sol"; | ||
import {CommunityVaultAutomation} from "../../../../contracts/linkStaking/CommunityVaultAutomation.sol"; | ||
import {BaseTest} from "../../Base.t.sol"; | ||
|
||
contract Deployment is BaseTest { | ||
bool internal _fork = true; | ||
StakingPool internal stakingPool; | ||
PriorityPool internal priorityPool; | ||
CommunityVCS internal communityVCS; | ||
CommunityVaultAutomation internal communityVaultAutomation; | ||
uint256 internal minRewardsTotal = 650 ether; | ||
uint256 internal minRewardsPerVault = 65 ether; | ||
address internal multisig; | ||
|
||
function setUp() public { | ||
BaseTest.init(_fork); | ||
communityVCS = CommunityVCS(getValue("CommunityVCS")); | ||
stakingPool = StakingPool(getValue("StakingPool")); | ||
priorityPool = PriorityPool(getValue("PriorityPool")); | ||
multisig = getValue("Multisig"); | ||
vm.startPrank(multisig); | ||
communityVaultAutomation = new CommunityVaultAutomation(address(communityVCS), minRewardsTotal, minRewardsPerVault); | ||
|
||
// upgrade CommunityVCS | ||
CommunityVCS impl = new CommunityVCS(); | ||
communityVCS.upgradeTo(address(impl)); | ||
|
||
// upgrade StakingPool | ||
StakingPool stakingPoolImpl = new StakingPool(); | ||
stakingPool.upgradeTo(address(stakingPoolImpl)); | ||
|
||
// upgrade PriorityPool | ||
PriorityPool priorityPoolImpl = new PriorityPool(); | ||
priorityPool.upgradeTo(address(priorityPoolImpl)); | ||
vm.stopPrank(); | ||
} | ||
|
||
function testFork_upgrade_successful() public { | ||
assertEq(address(communityVCS), address(getValue("CommunityVCS"))); | ||
assertEq(address(stakingPool), getValue("StakingPool")); | ||
assertEq(address(priorityPool), getValue("PriorityPool")); | ||
} | ||
|
||
function testFork_CommunityVaultAutomation_success() public { | ||
assertEq(communityVaultAutomation.minRewardsTotal(), minRewardsTotal); | ||
assertEq(communityVaultAutomation.minRewardsPerVault(), minRewardsPerVault); | ||
} | ||
|
||
function testFork_StakingPool_owner() public { | ||
assertEq(stakingPool.priorityPool(), address(priorityPool)); | ||
} | ||
|
||
function testFork_PriorityPool_owner() public { | ||
assertEq(address(priorityPool.stakingPool()), address(stakingPool)); | ||
} | ||
} |
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,8 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.15; | ||
|
||
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
|
||
contract UUPSProxy is ERC1967Proxy { | ||
constructor(address _implementation, bytes memory _data) ERC1967Proxy(_implementation, _data) {} | ||
} |