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 all 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
5 changes: 2 additions & 3 deletions contracts/FeePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,8 @@ 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 optionalProxy {
require(messageSender == address(rewardsDistribution()), "RewardsDistribution only");
// 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
20 changes: 20 additions & 0 deletions test/contracts/FeePool.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ contract('FeePool', async accounts => {
systemSettings,
exchangeRates,
feePoolState,
rewardsDistribution,
delegateApprovals,
sUSDContract,
addressResolver,
Expand All @@ -82,6 +83,7 @@ contract('FeePool', async accounts => {
FeePoolState: feePoolState,
DebtCache: debtCache,
ProxyFeePool: feePoolProxy,
RewardsDistribution: rewardsDistribution,
Synthetix: synthetix,
SystemSettings: systemSettings,
SynthsUSD: sUSDContract,
Expand All @@ -103,6 +105,7 @@ contract('FeePool', async accounts => {
'SystemSettings',
'SystemStatus',
'RewardEscrowV2',
'RewardsDistribution',
'DelegateApprovals',
'CollateralManager',
'WrapperFactory',
Expand Down Expand Up @@ -193,6 +196,23 @@ contract('FeePool', async accounts => {
});

describe('restricted methods', () => {
before(async () => {
await proxyThruTo({
proxy: feePoolProxy,
target: feePool,
fncName: 'setMessageSender',
from: account1,
args: [rewardsDistribution.address],
});
});
it('setRewardsToDistribute() cannot be called by an unauthorized account', async () => {
await onlyGivenAddressCanInvoke({
fnc: feePool.setRewardsToDistribute,
accounts,
args: ['0'],
reason: 'RewardsDistribution only',
});
});
it('appendAccountIssuanceRecord() cannot be invoked directly by any account', async () => {
await onlyGivenAddressCanInvoke({
fnc: feePool.appendAccountIssuanceRecord,
Expand Down