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

fix: updated setRewards #474

Merged
merged 1 commit into from
Oct 20, 2021
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
2 changes: 1 addition & 1 deletion SPECIFICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

### Definitions

- Management: Trusted with privledged access for limited operations (ensuring performance of Vaults)
- Management: Trusted with privileged access for limited operations (ensuring performance of Vaults)
- Guardian: Trusted with privileged access for limited operations (ensuring safety of Vaults)

### Normal Operation
Expand Down
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
1 change: 0 additions & 1 deletion tests/functional/vault/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,5 @@ def test_vault_setLockedProfitDegradation_range(gov, vault):
def test_vault_setParams_bad_vals(gov, vault):
with brownie.reverts():
vault.setRewards(ZERO_ADDRESS, {"from": gov})

with brownie.reverts():
vault.setRewards(vault, {"from": gov})