Skip to content

Commit

Permalink
fix tax device gauge rewards bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ququzone committed Aug 20, 2024
1 parent cef7167 commit af922af
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions contracts/AdhocVoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ contract AdhocVoter is IAdhocVoter, Initializable {
mapping(address => uint256) public weights;
uint256 public totalWeight;

function initialize(
) public initializer {
function initialize() public initializer {
governor = msg.sender;
weekly = 100_000 * 1e18;
activePeriod = ((block.timestamp) / WEEK) * WEEK;
Expand Down Expand Up @@ -60,7 +59,7 @@ contract AdhocVoter is IAdhocVoter, Initializable {
uint256 _balanceOf = address(this).balance;
require(_balanceOf >= _emission, "InsufficientFund");

uint256 perWeightReward = _balanceOf / totalWeight;
uint256 perWeightReward = _emission / totalWeight;
address[] memory _gauges = gauges.values();
for (uint256 i = 0; i < _gauges.length; i++) {
address _gauge = _gauges[i];
Expand All @@ -85,6 +84,7 @@ contract AdhocVoter is IAdhocVoter, Initializable {

weights[_gauge] = _weight;
totalWeight += _weight;
gauges.add(_gauge);
IIncentive(_incentive).setGauge(_gauge);
emit WeightChanged(_gauge, _weight);
}
Expand Down
1 change: 0 additions & 1 deletion contracts/gauges/RewardGauge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ abstract contract RewardGauge is IRewardGauge, ERC2771Context, ReentrancyGuard {
/// @inheritdoc IRewardGauge
address public voter;

uint256 internal constant DURATION = 7 days; // rewards are released over 7 days
uint256 internal constant PRECISION = 10 ** 18;
uint256 public constant TOKENLESS_PRODUCTION = 40;
uint256 public constant BASE = 100;
Expand Down
7 changes: 6 additions & 1 deletion contracts/gauges/TaxDeviceGauge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import "../interfaces/ITaxGauge.sol";
contract TaxDeviceGauge is RewardGauge, ERC721Holder, ITaxGauge {
event DepositDevice(address indexed from, address indexed to, uint256 amount, uint256 tokenId);
event WithdrawDevice(address indexed from, uint256 amount, uint256 tokenId);
event SetTaxer(address indexed taxer);
event SetTaxRatio(address indexed taxer, uint256 ratio);

mapping(uint256 => address) public tokenStaker;

Expand All @@ -34,7 +36,7 @@ contract TaxDeviceGauge is RewardGauge, ERC721Holder, ITaxGauge {
_updateRewards(_recipient);

IERC721(stakingToken).safeTransferFrom(sender, address(this), _tokenId);
uint256 _amount = 1;
uint256 _amount = 100;
totalSupply += _amount;
balanceOf[_recipient] += _amount;
tokenStaker[_tokenId] = _recipient;
Expand Down Expand Up @@ -90,13 +92,16 @@ contract TaxDeviceGauge is RewardGauge, ERC721Holder, ITaxGauge {
if (msg.sender != voter) revert NotVoter();

taxer = _taxer;
emit SetTaxer(_taxer);
}

function changeTaxRatio(uint256 _ratio) external {
require(_ratio != taxRatio, "same taxRatio for taxer");
require(_ratio <= 50, "two large tax ratio");
if (msg.sender != voter) revert NotVoter();

taxRatio = _ratio;
emit SetTaxRatio(taxer, _ratio);
}

function changeVoter(address _voter) external {
Expand Down

0 comments on commit af922af

Please sign in to comment.