Skip to content

Commit

Permalink
fix: enums
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Oct 23, 2023
1 parent 31782ba commit f80664a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
20 changes: 10 additions & 10 deletions contracts/accountants/GenericAccountant.vy
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def addVault(vault: address):
vault or strategy. Each fee will be set separately.
@param vault The address of a vault to allow to use this accountant.
"""
assert msg.sender == self.feeManager, "not fee manager"
assert msg.sender == self.feeManager, "!fee manager"
assert not self.vaults[vault], "already added"

self.vaults[vault] = True
Expand All @@ -266,7 +266,7 @@ def removeVault(vault: address):
@notice Removes a vault for this accountant to charge fee for.
@param vault The address of a vault to allow to use this accountant.
"""
assert msg.sender == self.feeManager, "not fee manager"
assert msg.sender == self.feeManager, "!fee manager"
assert self.vaults[vault], "not added"

self.vaults[vault] = False
Expand All @@ -288,7 +288,7 @@ def updateDefaultConfig(
@param default_refund Default refund ratio to give back on losses.
@param default_maxFee Default max fee to allow as a percent of gain.
"""
assert msg.sender == self.feeManager, "not fee manager"
assert msg.sender == self.feeManager, "!fee manager"
assert default_management <= MANAGEMENT_FEE_THRESHOLD, "exceeds management fee threshold"
assert default_performance <= PERFORMANCE_FEE_THRESHOLD, "exceeds performance fee threshold"

Expand Down Expand Up @@ -322,7 +322,7 @@ def setCustomConfig(
@param custom_refund Custom refund ratio to give back on losses.
@param custom_maxFee Custom max fee to allow as a percent of gain.
"""
assert msg.sender == self.feeManager, "not fee manager"
assert msg.sender == self.feeManager, "!fee manager"
assert self.vaults[vault], "vault not added"
assert custom_management <= MANAGEMENT_FEE_THRESHOLD, "exceeds management fee threshold"
assert custom_performance <= PERFORMANCE_FEE_THRESHOLD, "exceeds performance fee threshold"
Expand All @@ -347,7 +347,7 @@ def removeCustomConfig(vault: address, strategy: address):
@notice Removes a previously set custom config for a strategy.
@param strategy The strategy to remove custom setting for.
"""
assert msg.sender == self.feeManager, "not fee manager"
assert msg.sender == self.feeManager, "!fee manager"
assert self.custom[vault][strategy], "No custom fees set"

# Set all the strategies custom fees to 0.
Expand All @@ -364,7 +364,7 @@ def setMaxLoss(maxLoss: uint256):
@notice Set the max loss parameter to be used on withdraws.
@param maxLoss Amount in basis points.
"""
assert msg.sender == self.feeManager, "not fee manager"
assert msg.sender == self.feeManager, "!fee manager"
assert maxLoss <= MAX_BPS, "higher than 100%"

self.maxLoss = maxLoss
Expand All @@ -382,7 +382,7 @@ def withdrawUnderlying(vault: address, amount: uint256):
@param vault The vault to redeem from.
@param amount The amount in the underlying to withdraw.
"""
assert msg.sender == self.feeManager, "not fee manager"
assert msg.sender == self.feeManager, "!fee manager"
IVault(vault).withdraw(amount, self, self, self.maxLoss)


Expand All @@ -395,7 +395,7 @@ def distribute(token: address) -> uint256:
@param token The token to distribute.
@return The amount of token distributed.
"""
assert msg.sender == self.feeManager, "not fee manager"
assert msg.sender == self.feeManager, "!fee manager"

rewards: uint256 = ERC20(token).balanceOf(self)
self._erc20_safe_transfer(token, self.feeRecipient, rewards)
Expand All @@ -412,7 +412,7 @@ def setFutureFeeManager(futureFeeManager: address):
call accept_feeManager in order to update the actual feeManager.
@param futureFeeManager Address to set to futureFeeManager.
"""
assert msg.sender == self.feeManager, "not fee manager"
assert msg.sender == self.feeManager, "!fee manager"
assert futureFeeManager != empty(address), "ZERO ADDRESS"
self.futureFeeManager = futureFeeManager

Expand All @@ -437,7 +437,7 @@ def setFeeRecipient(newFeeRecipient: address):
@notice Set a new address to receive distributed rewards.
@param newFeeRecipient Address to receive distributed fees.
"""
assert msg.sender == self.feeManager, "not fee manager"
assert msg.sender == self.feeManager, "!fee manager"
assert newFeeRecipient != empty(address), "ZERO ADDRESS"
oldFeeRecipient: address = self.feeRecipient
self.feeRecipient = newFeeRecipient
Expand Down
1 change: 1 addition & 0 deletions contracts/accountants/HelathCheckAccountant.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ contract HealthCheckAccountant {

/// @notice Enum defining change types (added or removed).
enum ChangeType {
NULL,
ADDED,
REMOVED
}
Expand Down
10 changes: 5 additions & 5 deletions tests/test_generic_accountant.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def test_set_fee_manager(generic_accountant, daddy, user):
assert accountant.feeManager() == daddy
assert accountant.futureFeeManager() == ZERO_ADDRESS

with ape.reverts("not fee manager"):
with ape.reverts("!fee manager"):
accountant.setFutureFeeManager(user, sender=user)

with ape.reverts("not future fee manager"):
Expand Down Expand Up @@ -242,10 +242,10 @@ def test_set_fee_recipient(generic_accountant, daddy, user, fee_recipient):
assert accountant.feeManager() == daddy
assert accountant.feeRecipient() == fee_recipient

with ape.reverts("not fee manager"):
with ape.reverts("!fee manager"):
accountant.setFeeRecipient(user, sender=user)

with ape.reverts("not fee manager"):
with ape.reverts("!fee manager"):
accountant.setFeeRecipient(user, sender=fee_recipient)

with ape.reverts("ZERO ADDRESS"):
Expand Down Expand Up @@ -280,7 +280,7 @@ def test_distribute(
assert vault.balanceOf(daddy.address) == 0
assert vault.balanceOf(fee_recipient.address) == 0

with ape.reverts("not fee manager"):
with ape.reverts("!fee manager"):
accountant.distribute(vault.address, sender=user)

tx = accountant.distribute(vault.address, sender=daddy)
Expand Down Expand Up @@ -313,7 +313,7 @@ def test_withdraw_underlying(
assert vault.balanceOf(accountant.address) == amount
assert asset.balanceOf(accountant.address) == 0

with ape.reverts("not fee manager"):
with ape.reverts("!fee manager"):
accountant.withdrawUnderlying(vault.address, amount, sender=user)

tx = accountant.withdrawUnderlying(vault.address, amount, sender=daddy)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_healthcheck_accountant.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def test_set_fee_manager(healthcheck_accountant, daddy, user):
assert accountant.feeManager() == daddy
assert accountant.futureFeeManager() == ZERO_ADDRESS

with ape.reverts("not fee manager"):
with ape.reverts("!fee manager"):
accountant.setFutureFeeManager(user, sender=user)

with ape.reverts("not future fee manager"):
Expand Down Expand Up @@ -341,10 +341,10 @@ def test_set_fee_recipient(healthcheck_accountant, daddy, user, fee_recipient):
assert accountant.feeManager() == daddy
assert accountant.feeRecipient() == fee_recipient

with ape.reverts("not fee manager"):
with ape.reverts("!fee manager"):
accountant.setFeeRecipient(user, sender=user)

with ape.reverts("not fee manager"):
with ape.reverts("!fee manager"):
accountant.setFeeRecipient(user, sender=fee_recipient)

with ape.reverts("ZERO ADDRESS"):
Expand Down Expand Up @@ -385,7 +385,7 @@ def test_distribute(
assert vault.balanceOf(daddy.address) == 0
assert vault.balanceOf(fee_recipient.address) == 0

with ape.reverts("not fee manager"):
with ape.reverts("!fee manager"):
accountant.distribute(vault.address, sender=user)

tx = accountant.distribute(vault.address, sender=daddy)
Expand Down Expand Up @@ -418,7 +418,7 @@ def test_withdraw_underlying(
assert vault.balanceOf(accountant.address) == amount
assert asset.balanceOf(accountant.address) == 0

with ape.reverts("not fee manager"):
with ape.reverts("!fee manager"):
accountant.withdrawUnderlying(vault.address, amount, sender=user)

tx = accountant.withdrawUnderlying(vault.address, amount, sender=daddy)
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
DAY = 86400
WEEK = 7 * DAY
YEAR = 31_556_952 # same value used in vault
MAX_INT = 2 ** 256 - 1
MAX_INT = 2**256 - 1
ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"
MAX_BPS = 10_000

Expand Down

0 comments on commit f80664a

Please sign in to comment.