-
Notifications
You must be signed in to change notification settings - Fork 7
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 #46 from darcys22/testnet-superuser
setup contracts for testnet deployment includeing superuser functions
- Loading branch information
Showing
3 changed files
with
115 additions
and
0 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
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); | ||
} | ||
|
||
} |
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,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); | ||
} | ||
} |
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,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; | ||
}); |