Skip to content

Commit

Permalink
Updated setRewards to only allow goverence and updated tests
Browse files Browse the repository at this point in the history
Revert "Updated setRewards to only allow goverence and updated tests"

This reverts commit 6220bec.

Revert "Revert "Updated setRewards to only allow goverence and updated tests""

This reverts commit 7ec43fd.

fix: updated setRewards

fix: updated setRewards

Fix: Update setRewards

Remove DS

fix: updated setRewards

Only gov or strat can setRewards
  • Loading branch information
jhb10c committed Oct 14, 2021
1 parent 912e04d commit 939d802
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion contracts/BaseStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ abstract contract BaseStrategy {
require(msg.sender == governance());
}

function _onlyRewarder() internal {
require(msg.sender == governance() || msg.sender == strategist);
}

function _onlyKeepers() internal {
require(
msg.sender == keeper ||
Expand Down Expand Up @@ -377,7 +381,7 @@ abstract contract BaseStrategy {
* @param _rewards The address to use for pulling rewards.
*/
function setRewards(address _rewards) external {
_onlyStrategist();
_onlyRewarder();
require(_rewards != address(0));
vault.approve(rewards, 0);
rewards = _rewards;
Expand Down
8 changes: 7 additions & 1 deletion tests/functional/strategy/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_strategy_harvest_permission(
@pytest.mark.parametrize(
"getter,setter,val,gov_allowed,strategist_allowed",
[
("rewards", "setRewards", None, False, True),
("rewards", "setRewards", None, True, True),
("keeper", "setKeeper", None, True, True),
("minReportDelay", "setMinReportDelay", 1000, True, True),
("maxReportDelay", "setMaxReportDelay", 2000, True, True),
Expand Down Expand Up @@ -135,6 +135,12 @@ def test_set_strategist_authority(strategy, strategist, rando):
strategy.setStrategist(rando, {"from": strategist})


def test_set_rewards(strategy, rando):
# Only gov or strategist can setRewards
with brownie.reverts():
strategy.setRewards(rando, {"from": rando})


def test_strategy_setParams_bad_vals(gov, strategist, strategy):
with brownie.reverts():
strategy.setKeeper(ZERO_ADDRESS, {"from": gov})
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/vault/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,6 @@ def test_vault_setLockedProfitDegradation_range(gov, vault):
def test_vault_setParams_bad_vals(gov, vault):
with brownie.reverts():
vault.setRewards(ZERO_ADDRESS, {"from": gov})

# No one can set rewards but governance
with brownie.reverts():
vault.setRewards(vault, {"from": gov})

0 comments on commit 939d802

Please sign in to comment.