trade incentive fix && test
This commit is contained in:
@@ -33,7 +33,7 @@ contract DODOIncentive is InitializableOwnable {
|
||||
// ============ Storage ============
|
||||
address public immutable _DODO_TOKEN_;
|
||||
address public _DODO_PROXY_;
|
||||
uint256 public dodoPerBlock = 10 * 10**18;
|
||||
uint256 public dodoPerBlock;
|
||||
uint256 public defaultRate = 10;
|
||||
mapping(address => uint256) public boosts;
|
||||
|
||||
@@ -44,7 +44,6 @@ contract DODOIncentive is InitializableOwnable {
|
||||
// ============ Events ============
|
||||
|
||||
event SetBoost(address token, uint256 boostRate);
|
||||
event SetSwitch(bool isOpen);
|
||||
event SetNewProxy(address dodoProxy);
|
||||
event SetPerReward(uint256 dodoPerBlock);
|
||||
event SetDefaultRate(uint256 defaultRate);
|
||||
@@ -63,6 +62,7 @@ contract DODOIncentive is InitializableOwnable {
|
||||
emit SetBoost(_token, _boostRate);
|
||||
}
|
||||
|
||||
//switch
|
||||
function changePerReward(uint256 _dodoPerBlock) public onlyOwner {
|
||||
_updateTotalReward();
|
||||
dodoPerBlock = _dodoPerBlock;
|
||||
@@ -110,8 +110,8 @@ contract DODOIncentive is InitializableOwnable {
|
||||
}
|
||||
|
||||
function _updateTotalReward() internal {
|
||||
lastRewardBlock = uint32(block.number);
|
||||
totalReward = uint112(_getTotalReward());
|
||||
lastRewardBlock = uint32(block.number);
|
||||
}
|
||||
|
||||
function _update(uint256 _totalReward, uint256 _totalDistribution) internal {
|
||||
@@ -127,7 +127,7 @@ contract DODOIncentive is InitializableOwnable {
|
||||
}
|
||||
|
||||
function _getTotalReward() internal view returns (uint256) {
|
||||
if (block.number < lastRewardBlock || lastRewardBlock == 0) {
|
||||
if (lastRewardBlock == 0) {
|
||||
return totalReward;
|
||||
} else {
|
||||
return totalReward + (block.number - lastRewardBlock) * dodoPerBlock;
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import {ReentrancyGuard} from "../lib/ReentrancyGuard.sol";
|
||||
import {InitializableOwnable} from "../lib/InitializableOwnable.sol";
|
||||
|
||||
//for test update
|
||||
contract FeeRateModelLogicUpdate is ReentrancyGuard ,InitializableOwnable{
|
||||
//DEFAULT
|
||||
uint256 public _FEE_RATE_;
|
||||
mapping(address => uint256) feeMapping;
|
||||
|
||||
function setSpecificFeeRate(address trader, uint256 feeRate) external onlyOwner {
|
||||
require(trader != address(0), "INVALID ADDRESS!");
|
||||
feeMapping[trader] = 0;
|
||||
}
|
||||
|
||||
function setFeeRate(uint256 newFeeRate) external onlyOwner {
|
||||
_FEE_RATE_ = _FEE_RATE_+ newFeeRate;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user