Skip to content

Commit

Permalink
rewrote test env setup scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
BkChoy committed Oct 23, 2024
1 parent b72805a commit e05e531
Show file tree
Hide file tree
Showing 14 changed files with 580 additions and 441 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"deploy": "ts-node --files scripts/test/deploy/deploy.ts",
"geth-dev-fund": "ts-node --files scripts/test/geth-dev-fund.ts",
"start-test-env": "node scripts/test/start-test-envs.js",
"setup-test-env": "ts-node --files scripts/test/setup-test-env.ts",
"setup-test-env": "ts-node --files scripts/test/setup/setup-test-env.ts",
"compile": "npx hardhat compile",
"tsc": "tsc",
"prettier": "prettier --check \"contracts/**/*.sol*\" \"test/**/*.ts*\" \"scripts/**/*.ts*\"",
Expand All @@ -36,6 +36,7 @@
"@types/fs-extra": "^11.0.4",
"@types/mocha": ">=9.1.0",
"@types/node": ">=18.0.0",
"bs58": "^6.0.0",
"chai": "^4.2.0",
"ethers": "^6.4.0",
"fs-extra": "^11.2.0",
Expand Down
6 changes: 4 additions & 2 deletions scripts/test/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import fs from 'fs'
import { deployCore } from './modules/deploy-core'
import { deployLINKStaking } from './modules/deploy-link-staking'
import { deployMETISStaking } from './modules/deploy-metis-staking'
import { deployTestContracts } from './modules/deploy-test-contracts'
import { deployDeprecated } from './modules/deploy-deprecated'
import { deployOther } from './modules/deploy-other'

const path = './deployments/localhost.json'

Expand All @@ -11,10 +12,11 @@ async function main() {
fs.unlinkSync(path)
}

await deployTestContracts()
await deployDeprecated()
await deployCore()
await deployLINKStaking()
await deployMETISStaking()
await deployOther()
}

main()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { updateDeployments, deploy } from '../../../utils/deployment'

export async function deployTestContracts() {
export async function deployDeprecated() {
const lplToken = await deploy('contracts/core/tokens/base/ERC677.sol:ERC677', [
'LinkPool',
'LPL',
Expand All @@ -15,9 +15,6 @@ export async function deployTestContracts() {
])
console.log('LINKToken deployed: ', linkToken.target)

const multicall = await deploy('Multicall3', [])
console.log('Multicall3 deployed: ', multicall.target)

const poolOwners = await deploy('PoolOwnersV1', [lplToken.target])
console.log('PoolOwners (v1) deployed: ', poolOwners.target)

Expand All @@ -34,7 +31,7 @@ export async function deployTestContracts() {
'linkLPLA',
poolOwners.target,
])
console.log('PoolAllowance (v1) deployed: ', multicall.target)
console.log('PoolAllowance (v1) deployed: ', poolAllowance.target)

let tx = await poolOwners.addRewardToken(
linkToken.target,
Expand All @@ -50,7 +47,6 @@ export async function deployTestContracts() {
PoolOwnersV1: poolOwners.target,
LINK_OwnersRewardsPoolV1: ownersRewardsPoolV1.target,
PoolAllowanceV1: poolAllowance.target,
Multicall3: multicall.target,
},
{
LPLToken: 'contracts/core/tokens/base/ERC677.sol:ERC677',
Expand Down
24 changes: 15 additions & 9 deletions scripts/test/deploy/modules/deploy-link-staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function deployOperatorVCS(vaultDepositController: string) {
stakingRewardsMock.target,
toEther(1000),
toEther(75000),
toEther(10000000),
toEther(1000000),
28 * 86400,
7 * 86400,
])
Expand Down Expand Up @@ -64,7 +64,7 @@ async function deployOperatorVCS(vaultDepositController: string) {
await (await linkToken.transfer(pfAlertsControllerMock.target, toEther(10000))).wait()
await (await stakingPool.addStrategy(operatorVCS.target)).wait()

for (let i = 0; i < 3; i++) {
for (let i = 0; i < 5; i++) {
await (
await operatorVCS.addVault(ethers.ZeroAddress, accounts[0], pfAlertsControllerMock.target)
).wait()
Expand All @@ -80,9 +80,9 @@ async function deployOperatorVCS(vaultDepositController: string) {

// Community Vault Controller Strategy
const CommunityVCSArgs = {
maxDepositSizeBP: 9000, //basis point amount of the remaing deposit room in the Chainlink staking contract that can be deposited at once
maxDepositSizeBP: 10000, //basis point amount of the remaing deposit room in the Chainlink staking contract that can be deposited at once
vaultDeploymentThreshold: 10, // the min number of non-full vaults before a new batch is deployed
vaultDeploymentAmount: 10, // amount of vaults to deploy when threshold is met
vaultDeploymentAmount: 5, // amount of vaults to deploy when threshold is met
fees: [], // fee receivers & percentage amounts in basis points
vaultMaxDeposits: toEther(15000), // max number of tokens that a vault can hold
}
Expand All @@ -97,7 +97,7 @@ async function deployCommunityVCS(vaultDepositController: string) {
stakingRewardsMock.target,
toEther(1000),
toEther(15000),
toEther(10000000),
toEther(1000000),
28 * 86400,
7 * 86400,
])
Expand Down Expand Up @@ -223,6 +223,7 @@ export async function deployLINKStaking() {

await (await sdlPoolPrimary.addToken(stakingPool.target, stLinkSDLRewardsPool.target)).wait()
await (await stakingPool.setPriorityPool(priorityPool.target)).wait()
await (await stakingPool.setRebaseController(accounts[0])).wait()
await (await priorityPool.setDistributionOracle(accounts[0])).wait()
await (await priorityPool.setWithdrawalPool(withdrawalPool.target)).wait()

Expand All @@ -238,9 +239,14 @@ export async function deployLINKStaking() {
7 * 86400,
5,
])
console.log('FundFlowController deployed at', fundFlowController.target)
console.log('LINK_FundFlowController deployed at', fundFlowController.target)

updateDeployments({
FundFlowController: fundFlowController.target,
})
updateDeployments(
{
LINK_FundFlowController: fundFlowController.target,
},
{
LINK_FundFlowController: 'FundFlowController',
}
)
}
21 changes: 9 additions & 12 deletions scripts/test/deploy/modules/deploy-metis-staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,21 @@ import {
} from '../../../utils/deployment'
import { getAccounts, toEther } from '../../../utils/helpers'

async function deploySequencerVCS() {
async function deployL2Strategy() {
const metisToken = (await getContract('METISToken')) as ERC20
const stakingPool = (await getContract('METIS_StakingPool')) as StakingPool

const sequencerVCS = await deployUpgradeable('StrategyMock', [
const l2Strategy = await deployUpgradeable('StrategyMock', [
metisToken.target,
stakingPool.target,
toEther(1000),
toEther(10),
toEther(100000),
toEther(20000),
])
console.log('SequencerVCS deployed: ', sequencerVCS.target)
console.log('METIS_L2Strategy deployed: ', l2Strategy.target)

await (await stakingPool.addStrategy(sequencerVCS.target)).wait()
await (await stakingPool.addStrategy(l2Strategy.target)).wait()

updateDeployments(
{ METIS_SequencerVCS: sequencerVCS.target },
{ METIS_SequencerVCS: 'SequencerVCS' }
)
updateDeployments({ METIS_L2Strategy: l2Strategy.target }, { METIS_L2Strategy: 'StrategyMock' })
}

// Wrapped stMETIS
Expand Down Expand Up @@ -109,9 +106,9 @@ export async function deployMETISStaking() {
])
console.log('stMetis_SDLRewardsPool deployed: ', stMetisSDLRewardsPool.target)

await (await stakingPool.addFee(stMetisSDLRewardsPool.target, 1000)).wait()
await (await sdlPoolPrimary.addToken(stakingPool.target, stMetisSDLRewardsPool.target)).wait()
await (await stakingPool.setPriorityPool(priorityPool.target)).wait()
await (await stakingPool.setRebaseController(accounts[0])).wait()
await (await priorityPool.setDistributionOracle(accounts[0])).wait()
await (await priorityPool.setWithdrawalPool(withdrawalPool.target)).wait()

Expand All @@ -134,5 +131,5 @@ export async function deployMETISStaking() {
}
)

await deploySequencerVCS()
await deployL2Strategy()
}
44 changes: 44 additions & 0 deletions scripts/test/deploy/modules/deploy-other.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { ERC677 } from '../../../../typechain-types'
import { updateDeployments, deploy, getContract } from '../../../utils/deployment'
import { getAccounts } from '../../../utils/helpers'

const vestingStart = 1695312000 // Sep 21 2023 12pm EDT
const vestingDuration = 4 * 365 * 86400 // 4 years

export async function deployOther() {
const { accounts } = await getAccounts()
const linkToken = (await getContract('LINKToken')) as ERC677
const stakingPool = await getContract('LINK_StakingPool')

// Multicall

const multicall = await deploy('Multicall3', [])
console.log('Multicall3 deployed: ', multicall.target)

// stLINK/LINK Curve Mock

const curveMock = await deploy('CurveMock', [stakingPool.target, linkToken.target])
console.log('LINK_CurvePool deployed: ', curveMock.target)

// Node Operator SDL Vesting

let vesting0 = await deploy('Vesting', [accounts[0], accounts[12], vestingStart, vestingDuration])
console.log('SDL_Vesting_NOP_0 deployed: ', vesting0.target)

let vesting1 = await deploy('Vesting', [accounts[0], accounts[13], vestingStart, vestingDuration])
console.log('SDL_Vesting_NOP_1 deployed: ', vesting1.target)

updateDeployments(
{
SDL_Vesting_NOP_0: vesting0.target,
SDL_Vesting_NOP_1: vesting1.target,
LINK_CurvePool: curveMock.target,
Multicall3: multicall.target,
},
{
SDL_Vesting_NOP_0: 'Vesting',
SDL_Vesting_NOP_1: 'Vesting',
LINK_CurvePool: 'CurveMock',
}
)
}
Loading

0 comments on commit e05e531

Please sign in to comment.