Skip to content

Commit

Permalink
Merge pull request #46 from darcys22/testnet-superuser
Browse files Browse the repository at this point in the history
setup contracts for testnet deployment includeing superuser functions
  • Loading branch information
Doy-lee authored Jul 4, 2024
2 parents 5c0dc5f + c33422a commit 6b7c18a
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
21 changes: 21 additions & 0 deletions contracts/test/TestnetRewardRatePool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;

import "../RewardRatePool.sol";

contract TestnetRewardRatePool is RewardRatePool {
using SafeERC20 for IERC20;
// Function to set the lastPaidOutTime (onlyOwner)
function setLastPaidOutTime(uint256 _lastPaidOutTime) external onlyOwner {
lastPaidOutTime = _lastPaidOutTime;
}

event SENTWithdrawn(uint256 amount);

// Function to withdraw SENT tokens back to the owner
function withdrawSENT(uint256 amount) external onlyOwner {
SENT.safeTransfer(owner(), amount);
emit SENTWithdrawn(amount);
}

}
12 changes: 12 additions & 0 deletions contracts/test/TestnetServiceNodeRewards.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;

import "../ServiceNodeRewards.sol";

contract TestnetServiceNodeRewards is ServiceNodeRewards {
// New function for owner to remove nodes without BLS signature validation
function removeNodeByOwner(uint64 serviceNodeID) external onlyOwner {
IServiceNodeRewards.ServiceNode memory node = this.serviceNodes(serviceNodeID);
_removeBLSPublicKey(serviceNodeID, node.deposit);
}
}
82 changes: 82 additions & 0 deletions scripts/deploy-testnet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// We require the Hardhat Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through `node <script>`.
//
// You can also run a script with `npx hardhat run <script>`. If you do that, Hardhat
// will compile your contracts, add the Hardhat Runtime Environment's members to the
// global scope, and execute the script.
const hre = require("hardhat");
const chalk = require('chalk')

let principal = 250000;
let bigAtomicPrincipal = ethers.parseUnits(principal.toString(), 9);

async function main() {
// Deploy a mock ERC20 token
try {
// Deploy a mock ERC20 token
MockERC20 = await ethers.getContractFactory("MockERC20");
mockERC20 = await MockERC20.deploy("SENT Token", "SENT", 9);
} catch (error) {
console.error("Error deploying MockERC20:", error);
}

// Get signers
[owner] = await ethers.getSigners();

RewardRatePool = await ethers.getContractFactory("TestnetRewardRatePool");
rewardRatePool = await upgrades.deployProxy(RewardRatePool, [await owner.getAddress(), await mockERC20.getAddress()]);

await mockERC20.transfer(rewardRatePool, bigAtomicPrincipal);

// Deploy the ServiceNodeRewards contract
ServiceNodeRewardsMaster = await ethers.getContractFactory("TestnetServiceNodeRewards");
serviceNodeRewards = await upgrades.deployProxy(ServiceNodeRewardsMaster,[
await mockERC20.getAddress(), // token address
await rewardRatePool.getAddress(), // foundation pool address
120_000_000_000, // staking requirement
10, // max contributors
0, // liquidator reward ratio
0, // pool share of liquidation ratio
1 // recipient ratio
]);
await serviceNodeRewards.waitForDeployment();

snContributionContractFactory = await ethers.getContractFactory("ServiceNodeContributionFactory");
snContributionFactory = await snContributionContractFactory.deploy(serviceNodeRewards);

await snContributionFactory.waitForDeployment();

rewardRatePool.setBeneficiary(serviceNodeRewards);

console.log(
' ',
chalk.cyan(`SENT Contract Address`),
'deployed to:',
chalk.greenBright(await mockERC20.getAddress()),
)
console.log(
' ',
chalk.cyan(`Service Node Rewards Contract`),
'deployed to:',
chalk.greenBright(await serviceNodeRewards.getAddress()),
)
console.log(
' ',
chalk.cyan(`Reward Rate Pool Contract`),
'deployed to:',
chalk.greenBright(await rewardRatePool.getAddress()),
)
console.log(
' ',
chalk.cyan(`Service Node Contribution Factory Contract`),
'deployed to:',
chalk.greenBright(await snContributionFactory.getAddress()),
)
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});

0 comments on commit 6b7c18a

Please sign in to comment.