Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIP-200: Fix FeePool Rewards Distribution #1650

Merged
merged 8 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions contracts/FeePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,7 @@ contract FeePool is Owned, Proxyable, LimitedSetup, MixinSystemSettings, IFeePoo
/**
* @notice The RewardsDistribution contract informs us how many SNX rewards are sent to RewardEscrow to be claimed.
*/
function setRewardsToDistribute(uint amount) external {
address rewardsAuthority = address(rewardsDistribution());
require(messageSender == rewardsAuthority || msg.sender == rewardsAuthority, "Caller is not rewardsAuthority");
function setRewardsToDistribute(uint amount) external onlyRewardsDistribution {
// Add the amount of SNX rewards to distribute on top of any rolling unclaimed amount
_recentFeePeriodsStorage(0).rewardsToDistribute = _recentFeePeriodsStorage(0).rewardsToDistribute.add(amount);
}
Expand Down Expand Up @@ -746,6 +744,12 @@ contract FeePool is Owned, Proxyable, LimitedSetup, MixinSystemSettings, IFeePoo
_;
}

modifier onlyRewardsDistribution {
bool isRewardsDistribution = msg.sender == address(rewardsDistribution());
require(isRewardsDistribution, "RewardsDistribution only");
_;
}

modifier notFeeAddress(address account) {
require(account != FEE_ADDRESS, "Fee address not allowed");
_;
Expand Down
9 changes: 9 additions & 0 deletions test/contracts/FeePool.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ contract('FeePool', async accounts => {
reason: 'Issuer and SynthetixState only',
});
});

it('setRewardsToDistribute() cannot be invoked directly by any account', async () => {
await onlyGivenAddressCanInvoke({
fnc: feePool.setRewardsToDistribute,
accounts,
args: ['0'],
reason: 'RewardsDistribution only',
});
});
});

describe('when the issuanceRatio is 0.2', () => {
Expand Down