From d14646b48ca708762797e67b880100d4162e659a Mon Sep 17 00:00:00 2001 From: Aodhgan Gleeson <--global> Date: Sun, 3 Jul 2022 18:39:22 -0700 Subject: [PATCH 1/4] add script --- scripts/deploy/deploy-all-no-etherscan.ts | 2 ++ scripts/deploy/deploy-all.ts | 2 ++ .../staking-pool-deploy-no-etherscan.ts | 15 +++++++++++ scripts/deploy/staking-pool-deploy.ts | 26 +++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 scripts/deploy/staking-pool-deploy-no-etherscan.ts create mode 100644 scripts/deploy/staking-pool-deploy.ts diff --git a/scripts/deploy/deploy-all-no-etherscan.ts b/scripts/deploy/deploy-all-no-etherscan.ts index efc0cbba..fb84bb36 100644 --- a/scripts/deploy/deploy-all-no-etherscan.ts +++ b/scripts/deploy/deploy-all-no-etherscan.ts @@ -3,6 +3,7 @@ import {log} from '../../config/logging' import {deployBitDao} from './bitdao-deploy-no-etherscan' import {deployPerformanceBonds} from './bond-deploy-no-etherscan' import {addressEnvironmentVariable} from '../utils/environment-variable' +import {deployStakingPool} from './staking-pool-deploy-no-etherscan' async function main() { const tokenSweepBeneficiary = addressEnvironmentVariable( @@ -11,6 +12,7 @@ async function main() { await run('compile') await deployBitDao() await deployPerformanceBonds(tokenSweepBeneficiary) + await deployStakingPool(tokenSweepBeneficiary) } main() diff --git a/scripts/deploy/deploy-all.ts b/scripts/deploy/deploy-all.ts index f2b23528..44471ae0 100644 --- a/scripts/deploy/deploy-all.ts +++ b/scripts/deploy/deploy-all.ts @@ -2,6 +2,7 @@ import {run} from 'hardhat' import {log} from '../../config/logging' import {deployPerformanceBonds} from './bond-deploy' import {addressEnvironmentVariable} from '../utils/environment-variable' +import {deployStakingPool} from './staking-pool-deploy-no-etherscan' async function main() { const tokenSweepBeneficiary = addressEnvironmentVariable( @@ -11,6 +12,7 @@ async function main() { await run('compile') await deployPerformanceBonds(tokenSweepBeneficiary) + await deployStakingPool(tokenSweepBeneficiary) } main() diff --git a/scripts/deploy/staking-pool-deploy-no-etherscan.ts b/scripts/deploy/staking-pool-deploy-no-etherscan.ts new file mode 100644 index 00000000..c2c562e0 --- /dev/null +++ b/scripts/deploy/staking-pool-deploy-no-etherscan.ts @@ -0,0 +1,15 @@ +import {StakingPoolMediator, StakingPoolFactory} from '../../typechain-types' +import {deployContract, deployContractWithProxy} from '../utils/contract' + +export async function deployStakingPool( + tokenSweepBeneficiary: string +): Promise { + const factory = await deployContract( + 'StakingPoolFactory' + ) + await deployContractWithProxy( + 'StakingPoolMediator', + factory.address, + tokenSweepBeneficiary + ) +} diff --git a/scripts/deploy/staking-pool-deploy.ts b/scripts/deploy/staking-pool-deploy.ts new file mode 100644 index 00000000..ad849083 --- /dev/null +++ b/scripts/deploy/staking-pool-deploy.ts @@ -0,0 +1,26 @@ +import {StakingPoolMediator, StakingPoolFactory} from '../../typechain-types' +import { + awaitContractPropagation, + deployContract, + deployContractWithProxy, + verifyContract +} from '../utils/contract' + +export async function deployStakingPool( + tokenSweepBeneficiary: string +): Promise { + const factory = await deployContract( + 'StakingPoolFactory', + tokenSweepBeneficiary + ) + const mediator = await deployContractWithProxy( + 'StakingPoolMediator', + factory.address, + tokenSweepBeneficiary + ) + + await awaitContractPropagation() + + await verifyContract(factory, tokenSweepBeneficiary) + await verifyContract(mediator, tokenSweepBeneficiary) +} From e6f9043bde9925ae33c118f1c5581a4ca1231682 Mon Sep 17 00:00:00 2001 From: Aodhgan Gleeson <--global> Date: Mon, 4 Jul 2022 18:25:50 -0700 Subject: [PATCH 2/4] create verify scripts --- docs/deploy_remote.md | 62 +++++++++++++++- scripts/verify/create-bond-dao.ts | 17 +++++ scripts/verify/create-dao.ts | 33 ++++----- scripts/verify/create-staking-pool-dao.ts | 17 +++++ scripts/verify/create-staking-pool.ts | 72 +++++++++++++++++++ scripts/verify/whitelist-bond-collateral.ts | 26 +++++++ scripts/verify/whitelist-collateral.ts | 35 +++------ .../whitelist-staking-pool-collateral.ts | 26 +++++++ 8 files changed, 242 insertions(+), 46 deletions(-) create mode 100644 scripts/verify/create-bond-dao.ts create mode 100644 scripts/verify/create-staking-pool-dao.ts create mode 100644 scripts/verify/create-staking-pool.ts create mode 100644 scripts/verify/whitelist-bond-collateral.ts create mode 100644 scripts/verify/whitelist-staking-pool-collateral.ts diff --git a/docs/deploy_remote.md b/docs/deploy_remote.md index e8df846a..6aca4302 100644 --- a/docs/deploy_remote.md +++ b/docs/deploy_remote.md @@ -20,11 +20,21 @@ export DEPLOYER_PRIVATE_KEY=[${EnterYourPrivateKeyHere}] export ETHERSCAN_API_KEY=${EtherYourApiKey} ``` -#### Performance Bonds +#### Performance Bonds and Staking Pool Deployment ```shell npx hardhat run ./scripts/deploy/deploy-all.ts --network remote ``` +#### Performance Bonds Deployment +```shell +npx hardhat run ./scripts/deploy/bond-deploy.ts --network remote +``` + +#### Staking Pool Deployment +```shell +npx hardhat run ./scripts/deploy/staking-pool-deploy.ts --network remote +``` + #### Optional - BitDAO Token _In production (Mainnet) existing ERC20 token contract should be used_ @@ -40,8 +50,10 @@ npx hardhat run ./scripts/deploy/bitdao-deploy-no-etherscan.ts --network remote The terminal running the JSON-RPC node will output the contract addresses, these are needed for later: - `${BondMediator}` : Performance Bond Mediator contract address. - `${BondFactory}` : Performance Bond Factory contract address. +- `${StakingPoolMediator}` : Staking Pool Mediator contract address. +- `${StakingPoolFactory}` : Staking Pool Factory contract address. - `${BitToken}` : Collateral token contract address (BIT). -- `${Treausy}` : Any valid address to use as the treasury. +- `${Treasury}` : Any valid address to use as the treasury. ## Verify contract behaviour Check the contract deployment and operation with the test scripts. @@ -79,7 +91,7 @@ Only whitelisted tokens are accepted as collateral. The script whitelists the value of the environment variable `COLLATERAL_TOKENS_CONTRACT` with the `BOND_MEDIATOR_CONTRACT`. ```shell -npx hardhat run ./scripts/verify/whitelist-collateral.ts --network remote +npx hardhat run ./scripts/verify/whitelist-bond-collateral.ts --network remote ``` #### Create a Performance Bond @@ -89,3 +101,47 @@ The script creates a bond using the environment variables `BOND_MEDIATOR_CONTRAC ```shell npx hardhat run ./scripts/verify/create-managed-bond.ts --network remote ``` + +### Staking Pool +Before any Staking Pools can be created, a number of setup steps are needed. + +##### MacOS +Set the temporary environment variables by substituting the value running the lines in your terminal. +```shell +export STAKING_POOL_MEDIATOR_ADDRESS=${StakingPoolMediator} +export STAKING_POOL_FACTORY_ADDRESS=${StakingPoolFactory} +export COLLATERAL_TOKENS_CONTRACT=${BitToken} // do we need this? +export TREASURY_ADDRESS=${Treasury} +``` + +#### Create a DAO +All Performance Bond operations occur within the scope of a DAO. + +The script creates a new DAO using `STAKING_POOL_MEDIATOR_ADDRESS` and `TREASURY_ADDRESS` +```shell +npx hardhat run ./scripts/verify/create-staking-pool-dao.ts --network remote +``` + +Note the `BigNumber` values from the `CreateDao` event, convert from hex to decimal and that is the DAO id. + +#### MacOS +Set the temporary environment variables by substituting the value running the line in your terminal. +```shell +export DAO_ID=${DAO_ID} +``` + +#### Whitelist the collateral +Only whitelisted tokens are accepted as collateral. + +The script whitelists the value of the environment variable `COLLATERAL_TOKENS_CONTRACT` with the `STAKING_POOL_MEDIATOR_ADDRESS`. +```shell +npx hardhat run ./scripts/verify/whitelist-staking-pool-collateral.ts --network remote +``` + +#### Create a Staking Pool +A Staking Pool managed within the scope of a DAO. + +The script creates a staking pool using the environment variables `STAKING_POOL_MEDIATOR_ADDRESS`, `STAKING_POOL_FACTORY_ADDRESS` and `DAO_ID` +```shell +npx hardhat run ./scripts/verify/create-staking-pool.ts --network remote +``` diff --git a/scripts/verify/create-bond-dao.ts b/scripts/verify/create-bond-dao.ts new file mode 100644 index 00000000..db1c6d87 --- /dev/null +++ b/scripts/verify/create-bond-dao.ts @@ -0,0 +1,17 @@ +import {addressEnvironmentVariable} from '../utils/environment-variable' +import {log} from '../../config/logging' +import {createDao} from './create-dao' + +async function main(): Promise { + const mediator = addressEnvironmentVariable('BOND_MEDIATOR_CONTRACT') + const treasury = addressEnvironmentVariable('TREASURY_ADDRESS') + + return createDao(mediator, treasury, 'PerformanceBondMediator') +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + log.error(error) + process.exit(1) + }) diff --git a/scripts/verify/create-dao.ts b/scripts/verify/create-dao.ts index e787d709..4ddb9cbc 100644 --- a/scripts/verify/create-dao.ts +++ b/scripts/verify/create-dao.ts @@ -1,12 +1,21 @@ import {ethers} from 'hardhat' -import {PerformanceBondMediator} from '../../typechain-types' +import { + PerformanceBondMediator, + StakingPoolMediator +} from '../../typechain-types' import {log} from '../../config/logging' -import {addressEnvironmentVariable} from '../utils/environment-variable' import {logEvents} from '../utils/transaction-event-log' -async function createDao(mediatorAddress: string, treasuryAddress: string) { - const factory = await ethers.getContractFactory('BondMediator') - const contract = factory.attach(mediatorAddress) +export async function createDao( + mediatorAddress: string, + treasuryAddress: string, + mediatorType: string +) { + const factory = await ethers.getContractFactory(mediatorType) + + const contract = ( + factory.attach(mediatorAddress) + ) log.info('Creating a new DAO') @@ -18,17 +27,3 @@ async function createDao(mediatorAddress: string, treasuryAddress: string) { logEvents(receipt) } - -async function main(): Promise { - const mediator = addressEnvironmentVariable('BOND_MEDIATOR_CONTRACT') - const treasury = addressEnvironmentVariable('TREASURY_ADDRESS') - - return createDao(mediator, treasury) -} - -main() - .then(() => process.exit(0)) - .catch((error) => { - log.error(error) - process.exit(1) - }) diff --git a/scripts/verify/create-staking-pool-dao.ts b/scripts/verify/create-staking-pool-dao.ts new file mode 100644 index 00000000..b6e25a7c --- /dev/null +++ b/scripts/verify/create-staking-pool-dao.ts @@ -0,0 +1,17 @@ +import {addressEnvironmentVariable} from '../utils/environment-variable' +import {log} from '../../config/logging' +import {createDao} from './create-dao' + +async function main(): Promise { + const mediator = addressEnvironmentVariable('STAKING_POOL_MEDIATOR_ADDRESS') + const treasury = addressEnvironmentVariable('TREASURY_ADDRESS') + + return createDao(mediator, treasury, 'StakingPoolMediator') +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + log.error(error) + process.exit(1) + }) diff --git a/scripts/verify/create-staking-pool.ts b/scripts/verify/create-staking-pool.ts new file mode 100644 index 00000000..baef3511 --- /dev/null +++ b/scripts/verify/create-staking-pool.ts @@ -0,0 +1,72 @@ +import {ethers} from 'hardhat' +import {StakingPoolMediator} from '../../typechain-types' +import {log} from '../../config/logging' +import { + addressEnvironmentVariable, + bigintEnvironmentVariable +} from '../utils/environment-variable' +import {logCreateBondEvents} from '../utils/transaction-event-log' +import {getTimestampNow} from '../../test/framework/time' +import {RewardType} from '../../test/event/staking/staking-events' + +async function createManagedStakingPool( + mediatorAddress: string, + creatorAddress: string, + daoId: bigint, + collateralTokensAddress: string +): Promise { + const mediatorFactory = await ethers.getContractFactory( + 'StakingPoolMediator' + ) + const mediator = ( + mediatorFactory.attach(mediatorAddress) + ) + + const creatorFactory = await ethers.getContractFactory('StakingPoolFactory') + const creator = creatorFactory.attach(creatorAddress) + + log.info('Creating a new managed staking pool..') + + // how should we populate this with sensible test values? + const stakingPoolInfo = { + daoId, + minTotalPoolStake: 0, + maxTotalPoolStake: 600, + minimumContribution: 5, + epochDuration: 100, + epochStartTimestamp: await getTimestampNow(), + emergencyMode: false, + treasury: creatorAddress, // is this correct? todo + stakeToken: collateralTokensAddress, + rewardType: RewardType.FLOATING, + rewardTokens: [] + } + + const transaction = await mediator.createManagedStakingPool( + stakingPoolInfo, + false, + (await getTimestampNow()) + 86000 + ) + + const receipt = await transaction.wait() + + log.info('Transaction complete with status %s', receipt.status) + + logCreateBondEvents(creator, receipt) +} + +async function main(): Promise { + const creator = addressEnvironmentVariable('STAKING_POOL_FACTORY_ADDRESS') + const mediator = addressEnvironmentVariable('STAKING_POOL_MEDIATOR_ADDRESS') + const collateral = addressEnvironmentVariable('COLLATERAL_TOKENS_CONTRACT') + const daoId = bigintEnvironmentVariable('DAO_ID') + + return createManagedStakingPool(mediator, creator, daoId, collateral) +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + log.error(error) + process.exit(1) + }) diff --git a/scripts/verify/whitelist-bond-collateral.ts b/scripts/verify/whitelist-bond-collateral.ts new file mode 100644 index 00000000..956d6e1e --- /dev/null +++ b/scripts/verify/whitelist-bond-collateral.ts @@ -0,0 +1,26 @@ +import { + addressEnvironmentVariable, + bigintEnvironmentVariable +} from '../utils/environment-variable' +import {log} from '../../config/logging' +import {whitelistCollateral} from './whitelist-collateral' + +async function main(): Promise { + const mediator = addressEnvironmentVariable('BOND_MEDIATOR_CONTRACT') + const collateral = addressEnvironmentVariable('COLLATERAL_TOKENS_CONTRACT') + const daoId = bigintEnvironmentVariable('DAO_ID') + + return whitelistCollateral( + mediator, + daoId, + collateral, + 'StakingPoolMediator' + ) +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + log.error(error) + process.exit(1) + }) diff --git a/scripts/verify/whitelist-collateral.ts b/scripts/verify/whitelist-collateral.ts index 21d3eb28..43bcfb41 100644 --- a/scripts/verify/whitelist-collateral.ts +++ b/scripts/verify/whitelist-collateral.ts @@ -1,19 +1,21 @@ import {ethers} from 'hardhat' -import {PerformanceBondMediator} from '../../typechain-types' -import {log} from '../../config/logging' import { - addressEnvironmentVariable, - bigintEnvironmentVariable -} from '../utils/environment-variable' + PerformanceBondMediator, + StakingPoolMediator +} from '../../typechain-types' +import {log} from '../../config/logging' import {logEvents} from '../utils/transaction-event-log' -async function whitelistCollateral( +export async function whitelistCollateral( mediatorAddress: string, daoId: bigint, - collateralTokens: string + collateralTokens: string, + mediatorType: string ) { - const factory = await ethers.getContractFactory('BondMediator') - const contract = factory.attach(mediatorAddress) + const factory = await ethers.getContractFactory(mediatorType) + const contract = ( + factory.attach(mediatorAddress) + ) log.info('Whitelisting ERC20 token collateral') @@ -28,18 +30,3 @@ async function whitelistCollateral( logEvents(receipt) } - -async function main(): Promise { - const mediator = addressEnvironmentVariable('BOND_MEDIATOR_CONTRACT') - const collateral = addressEnvironmentVariable('COLLATERAL_TOKENS_CONTRACT') - const daoId = bigintEnvironmentVariable('DAO_ID') - - return whitelistCollateral(mediator, daoId, collateral) -} - -main() - .then(() => process.exit(0)) - .catch((error) => { - log.error(error) - process.exit(1) - }) diff --git a/scripts/verify/whitelist-staking-pool-collateral.ts b/scripts/verify/whitelist-staking-pool-collateral.ts new file mode 100644 index 00000000..1b174be3 --- /dev/null +++ b/scripts/verify/whitelist-staking-pool-collateral.ts @@ -0,0 +1,26 @@ +import { + addressEnvironmentVariable, + bigintEnvironmentVariable +} from '../utils/environment-variable' +import {log} from '../../config/logging' +import {whitelistCollateral} from './whitelist-collateral' + +async function main(): Promise { + const mediator = addressEnvironmentVariable('STAKING_POOL_MEDIATOR_ADDRESS') + const collateral = addressEnvironmentVariable('COLLATERAL_TOKENS_CONTRACT') + const daoId = bigintEnvironmentVariable('DAO_ID') + + return whitelistCollateral( + mediator, + daoId, + collateral, + 'StakingPoolMediator' + ) +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + log.error(error) + process.exit(1) + }) From 417014872ec5ef4eacb096836da3ca9ca1df4924 Mon Sep 17 00:00:00 2001 From: Aodhgan Gleeson <--global> Date: Tue, 5 Jul 2022 14:17:45 -0700 Subject: [PATCH 3/4] verify scripts --- docs/deploy_local.md | 52 ++++++++++++++++++++++++-- docs/deploy_remote.md | 2 +- scripts/utils/transaction-event-log.ts | 20 ++++++++-- scripts/verify/create-dao.ts | 1 + scripts/verify/create-managed-bond.ts | 9 ++++- scripts/verify/create-staking-pool.ts | 6 +-- 6 files changed, 78 insertions(+), 12 deletions(-) diff --git a/docs/deploy_local.md b/docs/deploy_local.md index b32879d1..6e285a71 100644 --- a/docs/deploy_local.md +++ b/docs/deploy_local.md @@ -33,6 +33,8 @@ npx hardhat run ./scripts/deploy/deploy-all-no-etherscan.ts --network local The terminal running the JSON-RPC node will output the contract addresses, these are needed for later: - `${BondMediator}` : Performance Bond Mediator contract address. - `${BondFactory}` : Performance Bond Factory contract address. +- `${StakingPoolMediator}` : Staking Pool Mediator contract address. +- `${StakingPoolFactory}` : Staking Pool Factory contract address. - `${BitToken}` : Collateral token contract address (BIT). - `${Treausy}` : Any valid address to use as the treasury. @@ -56,7 +58,7 @@ All Performance Bond operations occur within the scope of a DAO. The script creates a new DAO using `BOND_MEDIATOR_CONTRACT` and `TREASURY_ADDRESS` ```shell -npx hardhat run ./scripts/verify/create-dao.ts --network localhost +npx hardhat run ./scripts/verify/create-bond-dao.ts ``` Note the `BigNumber` values from the `CreateDao` event, convert from hex to decimal and that is the DAO id. @@ -72,7 +74,7 @@ Only whitelisted tokens are accepted as collateral. The script whitelists the value of the environment variable `COLLATERAL_TOKENS_CONTRACT` with the `BOND_MEDIATOR_CONTRACT`. ```shell -npx hardhat run ./scripts/verify/whitelist-collateral.ts --network localhost +npx hardhat run ./scripts/verify/whitelist-bond-collateral.ts ``` #### Create a Performance Bond @@ -80,5 +82,49 @@ A Performance Bond managed within the scope of a DAO. The script creates a bond using the environment variables `BOND_MEDIATOR_CONTRACT`, `BOND_FACTORY_CONTRACT` and `DAO_ID` ```shell -npx hardhat run ./scripts/verify/create-managed-bond.ts --network localhost +npx hardhat run ./scripts/verify/create-managed-bond.ts --network local +``` + +### Staking Pool +Before any Staking Pools can be created, a number of setup steps are needed. + +##### MacOS +Set the temporary environment variables by substituting the value running the lines in your terminal. +```shell +export STAKING_POOL_MEDIATOR_ADDRESS=${StakingPoolMediator} +export STAKING_POOL_FACTORY_ADDRESS=${StakingPoolFactory} +export COLLATERAL_TOKENS_CONTRACT=${BitToken} // do we need this? +export TREASURY_ADDRESS=${Treasury} +``` + +#### Create a DAO +All Performance Bond operations occur within the scope of a DAO. + +The script creates a new DAO using `STAKING_POOL_MEDIATOR_ADDRESS` and `TREASURY_ADDRESS` +```shell +npx hardhat run ./scripts/verify/create-staking-pool-dao.ts --network local +``` + +Note the `BigNumber` values from the `CreateDao` event, convert from hex to decimal and that is the DAO id. + +#### MacOS +Set the temporary environment variables by substituting the value running the line in your terminal. +```shell +export DAO_ID=${DAO_ID} +``` + +#### Whitelist the collateral +Only whitelisted tokens are accepted as collateral. + +The script whitelists the value of the environment variable `COLLATERAL_TOKENS_CONTRACT` with the `STAKING_POOL_MEDIATOR_ADDRESS`. +```shell +npx hardhat run ./scripts/verify/whitelist-staking-pool-collateral.ts --network local +``` + +#### Create a Staking Pool +A Staking Pool managed within the scope of a DAO. + +The script creates a staking pool using the environment variables `STAKING_POOL_MEDIATOR_ADDRESS`, `STAKING_POOL_FACTORY_ADDRESS` and `DAO_ID` +```shell +npx hardhat run ./scripts/verify/create-staking-pool.ts --network local ``` diff --git a/docs/deploy_remote.md b/docs/deploy_remote.md index 6aca4302..d17aba3b 100644 --- a/docs/deploy_remote.md +++ b/docs/deploy_remote.md @@ -75,7 +75,7 @@ All Performance Bond operations occur within the scope of a DAO. The script creates a new DAO using `BOND_MEDIATOR_CONTRACT` and `TREASURY_ADDRESS` ```shell -npx hardhat run ./scripts/verify/create-dao.ts --network remote +npx hardhat run ./scripts/verify/create-bond-dao.ts --network remote ``` Note the `BigNumber` values from the `CreateDao` event, convert from hex to decimal and that is the DAO id. diff --git a/scripts/utils/transaction-event-log.ts b/scripts/utils/transaction-event-log.ts index 8546a6dd..b0332164 100644 --- a/scripts/utils/transaction-event-log.ts +++ b/scripts/utils/transaction-event-log.ts @@ -2,7 +2,8 @@ import {ContractReceipt, Event} from 'ethers' import {createPerformanceBondEventLogs} from '../../test/event/performance-bonds/performance-bond-creator-events' import {eventLog} from '../../test/framework/event-logs' import {log} from '../../config/logging' -import {BondFactory} from '../../typechain-types' +import {PerformanceBondFactory, StakingPoolFactory} from '../../typechain-types' +import {stakingPoolCreatedEventLogs} from '../../test/event/staking/staking-factory-events' function receiptEvents(receipt: ContractReceipt): Event[] { const availableEvents = receipt.events @@ -18,11 +19,24 @@ export function logEvents(receipt: ContractReceipt): void { } export function logCreateBondEvents( - emitter: BondFactory, + emitter: PerformanceBondFactory, receipt: ContractReceipt ): void { const createBondEvents = createPerformanceBondEventLogs( - eventLog('CreateBond', emitter, receipt) + eventLog('CreatePerformanceBond', emitter, receipt) + ) + + for (const event of createBondEvents) { + log.info('CreateBond event: %s', JSON.stringify(event)) + } +} + +export function logCreateStakingPoolEvents( + emitter: StakingPoolFactory, + receipt: ContractReceipt +): void { + const createBondEvents = stakingPoolCreatedEventLogs( + eventLog('CreateStakingPool', emitter, receipt) ) for (const event of createBondEvents) { diff --git a/scripts/verify/create-dao.ts b/scripts/verify/create-dao.ts index 4ddb9cbc..c944349f 100644 --- a/scripts/verify/create-dao.ts +++ b/scripts/verify/create-dao.ts @@ -24,6 +24,7 @@ export async function createDao( const receipt = await transaction.wait() log.info('Transaction complete with status %s', receipt.status) + log.info(receipt) logEvents(receipt) } diff --git a/scripts/verify/create-managed-bond.ts b/scripts/verify/create-managed-bond.ts index 0bf6146d..513e94c6 100644 --- a/scripts/verify/create-managed-bond.ts +++ b/scripts/verify/create-managed-bond.ts @@ -16,12 +16,16 @@ async function createManagedBond( daoId: bigint, collateralTokensAddress: string ): Promise { - const mediatorFactory = await ethers.getContractFactory('BondMediator') + const mediatorFactory = await ethers.getContractFactory( + 'PerformanceBondMediator' + ) const mediator = ( mediatorFactory.attach(mediatorAddress) ) - const creatorFactory = await ethers.getContractFactory('BondFactory') + const creatorFactory = await ethers.getContractFactory( + 'PerformanceBondFactory' + ) const creator = ( creatorFactory.attach(creatorAddress) ) @@ -52,6 +56,7 @@ async function createManagedBond( const receipt = await transaction.wait() + log.info(receipt) log.info('Transaction complete with status %s', receipt.status) logCreateBondEvents(creator, receipt) diff --git a/scripts/verify/create-staking-pool.ts b/scripts/verify/create-staking-pool.ts index baef3511..ea47e2e5 100644 --- a/scripts/verify/create-staking-pool.ts +++ b/scripts/verify/create-staking-pool.ts @@ -5,7 +5,7 @@ import { addressEnvironmentVariable, bigintEnvironmentVariable } from '../utils/environment-variable' -import {logCreateBondEvents} from '../utils/transaction-event-log' +import {logCreateStakingPoolEvents} from '../utils/transaction-event-log' import {getTimestampNow} from '../../test/framework/time' import {RewardType} from '../../test/event/staking/staking-events' @@ -36,7 +36,7 @@ async function createManagedStakingPool( epochDuration: 100, epochStartTimestamp: await getTimestampNow(), emergencyMode: false, - treasury: creatorAddress, // is this correct? todo + treasury: creatorAddress, // todo: is this correct? stakeToken: collateralTokensAddress, rewardType: RewardType.FLOATING, rewardTokens: [] @@ -52,7 +52,7 @@ async function createManagedStakingPool( log.info('Transaction complete with status %s', receipt.status) - logCreateBondEvents(creator, receipt) + logCreateStakingPoolEvents(creator, receipt) } async function main(): Promise { From db6a454982a51bf33ef1708595a70f2cebb26565 Mon Sep 17 00:00:00 2001 From: Aodhgan Gleeson <--global> Date: Tue, 5 Jul 2022 23:28:38 -0700 Subject: [PATCH 4/4] remove comments --- scripts/verify/create-dao.ts | 1 - scripts/verify/create-staking-pool.ts | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/verify/create-dao.ts b/scripts/verify/create-dao.ts index c944349f..4ddb9cbc 100644 --- a/scripts/verify/create-dao.ts +++ b/scripts/verify/create-dao.ts @@ -24,7 +24,6 @@ export async function createDao( const receipt = await transaction.wait() log.info('Transaction complete with status %s', receipt.status) - log.info(receipt) logEvents(receipt) } diff --git a/scripts/verify/create-staking-pool.ts b/scripts/verify/create-staking-pool.ts index ea47e2e5..82733ac8 100644 --- a/scripts/verify/create-staking-pool.ts +++ b/scripts/verify/create-staking-pool.ts @@ -27,7 +27,6 @@ async function createManagedStakingPool( log.info('Creating a new managed staking pool..') - // how should we populate this with sensible test values? const stakingPoolInfo = { daoId, minTotalPoolStake: 0, @@ -36,7 +35,7 @@ async function createManagedStakingPool( epochDuration: 100, epochStartTimestamp: await getTimestampNow(), emergencyMode: false, - treasury: creatorAddress, // todo: is this correct? + treasury: creatorAddress, stakeToken: collateralTokensAddress, rewardType: RewardType.FLOATING, rewardTokens: []