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

feat: update name and symbol #206

Merged
merged 2 commits into from
Sep 11, 2024
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: 2 additions & 0 deletions TECH_SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ When deploying a new vault, it requires the following parameters:
- role_manager: account that can assign and revoke Roles
- profit_max_unlock_time: max amount of time profit will be locked before being distributed

All deployment variables besides the `asset` can be updated post deployment.

## Normal Operation

### Deposits / Mints
Expand Down
21 changes: 21 additions & 0 deletions contracts/VaultV3.vy
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,27 @@ def _process_report(strategy: address) -> (uint256, uint256):
return (gain, loss)

# SETTERS #

@external
def setName(name: String[64]):
"""
@notice Change the vault name.
@dev Can only be called by the Role Manager.
fp-crypto marked this conversation as resolved.
Show resolved Hide resolved
@param name The new name for the vault.
"""
assert msg.sender == self.role_manager, "not allowed"
self.name = name

@external
def setSymbol(symbol: String[32]):
"""
@notice Change the vault name.
@dev Can only be called by the Role Manager.
@param symbol The new name for the vault.
"""
assert msg.sender == self.role_manager, "not allowed"
self.symbol = symbol

@external
def set_accountant(new_accountant: address):
"""
Expand Down
40 changes: 40 additions & 0 deletions tests/unit/vault/test_role_base_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,3 +684,43 @@ def test__remove_role__wont_add(gov, vault, bunny, strategy):

with ape.reverts("not allowed"):
vault.add_strategy(strategy, sender=bunny)


def test__set_name(gov, vault, bunny):
name = vault.name()
new_name = "New Vault Name"

with ape.reverts("not allowed"):
vault.setName(new_name, sender=bunny)

vault.set_role(bunny, ROLES.ALL, sender=gov)

with ape.reverts("not allowed"):
vault.setName(new_name, sender=bunny)

assert vault.name() != new_name

vault.setName(new_name, sender=gov)

assert vault.name() == new_name
assert vault.name() != name


def test__set_symbol(gov, vault, bunny):
symbol = vault.name()
new_symbol = "New Vault symbol"

with ape.reverts("not allowed"):
vault.setSymbol(new_symbol, sender=bunny)

vault.set_role(bunny, ROLES.ALL, sender=gov)

with ape.reverts("not allowed"):
vault.setSymbol(new_symbol, sender=bunny)

assert vault.symbol() != new_symbol

vault.setSymbol(new_symbol, sender=gov)

assert vault.symbol() == new_symbol
assert vault.symbol() != symbol
Loading