Fix slashMiner in DioneStaking
This commit is contained in:
parent
4b3aa6df57
commit
0114f53f6d
@ -59,11 +59,11 @@ contract DioneStaking is Ownable, ReentrancyGuard {
|
|||||||
minimumStake = _minimumStake;
|
minimumStake = _minimumStake;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mine new dione oracle task, only can be executed by aggregator contract
|
// Mine new dione oracle task, only can be executed by oracle contract
|
||||||
function mine(address _minerAddr) public nonReentrant {
|
function mine(address _minerAddr) public nonReentrant {
|
||||||
require(msg.sender == dioneOracleAddress, "not oracle contract");
|
require(msg.sender == dioneOracleAddress, "not oracle contract");
|
||||||
MinerInfo storage miner = minerInfo[_minerAddr];
|
MinerInfo storage miner = minerInfo[_minerAddr];
|
||||||
require(miner.amount >= minimumStake);
|
require(miner.amount >= minimumStake, "not enough stake");
|
||||||
dione.mint(_minerAddr, minerReward);
|
dione.mint(_minerAddr, minerReward);
|
||||||
miner.lastRewardBlock = block.number;
|
miner.lastRewardBlock = block.number;
|
||||||
emit Mine(_minerAddr, block.number);
|
emit Mine(_minerAddr, block.number);
|
||||||
@ -141,11 +141,12 @@ contract DioneStaking is Ownable, ReentrancyGuard {
|
|||||||
|
|
||||||
function slashMiner(address miner, address[] memory receipentMiners) public {
|
function slashMiner(address miner, address[] memory receipentMiners) public {
|
||||||
require(msg.sender == disputeContractAddr, "Exception: caller is not the dispute contract");
|
require(msg.sender == disputeContractAddr, "Exception: caller is not the dispute contract");
|
||||||
|
|
||||||
uint256 share = minerInfo[miner].amount.div(receipentMiners.length);
|
uint256 share = minerInfo[miner].amount.div(receipentMiners.length);
|
||||||
|
|
||||||
for (uint8 i = 0; i < receipentMiners.length; i++) {
|
for (uint8 i = 0; i < receipentMiners.length; i++) {
|
||||||
minerInfo[miner].amount.sub(share);
|
minerInfo[miner].amount = minerInfo[miner].amount.sub(share);
|
||||||
minerInfo[receipentMiners[i]].amount += share;
|
minerInfo[receipentMiners[i]].amount = minerInfo[receipentMiners[i]].amount.add(share);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import { task } from "hardhat/config";
|
import { task } from "hardhat/config";
|
||||||
import "@nomiclabs/hardhat-ethers";
|
import "@nomiclabs/hardhat-ethers";
|
||||||
|
import "hardhat-tracer";
|
||||||
|
import "@nomiclabs/hardhat-waffle";
|
||||||
|
import "hardhat-ethernal";
|
||||||
|
|
||||||
task("accounts", "Prints the list of accounts", async (args, hre) => {
|
task("accounts", "Prints the list of accounts", async (args, hre) => {
|
||||||
const accounts = await hre.ethers.getSigners();
|
const accounts = await hre.ethers.getSigners();
|
||||||
@ -13,7 +16,7 @@ export default {
|
|||||||
solidity: "0.8.3",
|
solidity: "0.8.3",
|
||||||
networks: {
|
networks: {
|
||||||
ganache: {
|
ganache: {
|
||||||
url: `http://localhost:7545`,
|
url: `http://localhost:8545`,
|
||||||
accounts: {
|
accounts: {
|
||||||
mnemonic: "test test test test test test test test test test test junk"
|
mnemonic: "test test test test test test test test test test test junk"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user