From 70937ecc6c51e837b7a39f79070721ef40679a5b Mon Sep 17 00:00:00 2001 From: ququzone Date: Tue, 22 Oct 2024 10:07:09 +0800 Subject: [PATCH] add deplot reward pool script --- script/12_deploy_fixed_reward_pool.ts | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 script/12_deploy_fixed_reward_pool.ts diff --git a/script/12_deploy_fixed_reward_pool.ts b/script/12_deploy_fixed_reward_pool.ts new file mode 100644 index 0000000..69dcccd --- /dev/null +++ b/script/12_deploy_fixed_reward_pool.ts @@ -0,0 +1,41 @@ +import { ethers, upgrades } from 'hardhat'; +require('dotenv').config(); + +async function main() { + if (!process.env.DEVICE_NFT) { + console.log(`Please provide DEVICE_NFT address`); + return; + } + if (!process.env.START_BLOCK) { + console.log(`Please provide START_BLOCK`); + return; + } + if (!process.env.REWARD_PER_BLOCK) { + console.log(`Please provide REWARD_PER_BLOCK (unit: IOTX)`); + return; + } + + let owner = (await ethers.getSigners())[0].address; + if (process.env.OWNER) { + owner = process.env.OWNER; + } + + const ownedWeightedNFT = await ethers.deployContract('OwnedWeightedNFT', [process.env.DEVICE_NFT, owner]); + await ownedWeightedNFT.waitForDeployment(); + + const pool = await upgrades.deployProxy( + await ethers.getContractFactory('FixedRewardPool'), + [ownedWeightedNFT.target, process.env.START_BLOCK, ethers.parseEther(process.env.REWARD_PER_BLOCK)], + { + initializer: 'initialize', + }, + ); + await pool.waitForDeployment(); + + console.log(`FixedRewardPool for ${process.env.DEVICE_NFT} deployed to ${pool.target}`); +} + +main().catch(err => { + console.error(err); + process.exitCode = 1; +});