From 939d8028b2983889d989a2a2274701a5d008f674 Mon Sep 17 00:00:00 2001 From: John Bergschneider Date: Thu, 14 Oct 2021 02:45:35 -0400 Subject: [PATCH] Updated setRewards to only allow goverence and updated tests Revert "Updated setRewards to only allow goverence and updated tests" This reverts commit 6220becf2a3c60a5cabaf729a1c924a0963c9946. Revert "Revert "Updated setRewards to only allow goverence and updated tests"" This reverts commit 7ec43fdd1ac0a93135a9d8c438fbcc8927970ee7. fix: updated setRewards fix: updated setRewards Fix: Update setRewards Remove DS fix: updated setRewards Only gov or strat can setRewards --- contracts/BaseStrategy.sol | 6 +++++- tests/functional/strategy/test_config.py | 8 +++++++- tests/functional/vault/test_config.py | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/contracts/BaseStrategy.sol b/contracts/BaseStrategy.sol index 317d5ea4d..6a3244684 100644 --- a/contracts/BaseStrategy.sol +++ b/contracts/BaseStrategy.sol @@ -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 || @@ -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; diff --git a/tests/functional/strategy/test_config.py b/tests/functional/strategy/test_config.py index 5042d87cb..73a7d7c4d 100644 --- a/tests/functional/strategy/test_config.py +++ b/tests/functional/strategy/test_config.py @@ -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), @@ -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}) diff --git a/tests/functional/vault/test_config.py b/tests/functional/vault/test_config.py index f20e52d50..c6c45307e 100644 --- a/tests/functional/vault/test_config.py +++ b/tests/functional/vault/test_config.py @@ -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})