Skip to content

Commit

Permalink
chore: remane flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlagonia committed Oct 6, 2023
1 parent 20a137f commit 1332f5d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 38 deletions.
24 changes: 13 additions & 11 deletions contracts/VaultV3.vy
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ event UpdateAccountant:
event UpdateDefaultQueue:
new_default_queue: DynArray[address, MAX_QUEUE]

event UpdateOverrideQueue:
override_queue: bool
event UpdateUseDefaultQueue:
use_default_queue: bool

event UpdatedMaxDebtForStrategy:
sender: indexed(address)
Expand Down Expand Up @@ -209,8 +209,8 @@ FACTORY: public(immutable(address))
strategies: public(HashMap[address, StrategyParams])
# The current default withdrawal queue.
default_queue: public(DynArray[address, MAX_QUEUE])
# Should custom withdraw queues be overriden
override_queue: public(bool)
# Should the vault use the default_queue regardless whats passed in.
use_default_queue: public(bool)

# ERC20 - amount of shares per account
balance_of: HashMap[address, uint256]
Expand Down Expand Up @@ -709,8 +709,8 @@ def _redeem(
# Cache the default queue.
_strategies: DynArray[address, MAX_QUEUE] = self.default_queue

# If a custom queue was passed, and we dont override it.
if len(strategies) != 0 and not self.override_queue:
# If a custom queue was passed, and we dont force the default queue.
if len(strategies) != 0 and not self.use_default_queue:
# Use the custom queue.
_strategies = strategies

Expand Down Expand Up @@ -1239,15 +1239,17 @@ def set_default_queue(new_default_queue: DynArray[address, MAX_QUEUE]):
log UpdateDefaultQueue(new_default_queue)

@external
def set_override_queue(override_queue: bool):
def set_use_default_queue(use_default_queue: bool):
"""
@notice Set a new value for `override_queue`.
@param override_queue New value.
@notice Set a new value for `use_default_queue`.
@dev If set `True` the default queue will always be
used no matter whats passed in.
@param use_default_queue new value.
"""
self._enforce_role(msg.sender, Roles.QUEUE_MANAGER)
self.override_queue = override_queue
self.use_default_queue = use_default_queue

log UpdateOverrideQueue(override_queue)
log UpdateUseDefaultQueue(use_default_queue)

@external
def set_deposit_limit(deposit_limit: uint256):
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/vault/test_role_base_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ def test_set_default_queue__no_queue_manager__reverts(bunny, vault):
vault.set_default_queue([], sender=bunny)


def test_override_queue__no_queue_manager__reverts(bunny, vault):
def test_use_default_queue__no_queue_manager__reverts(bunny, vault):
with ape.reverts("not allowed"):
vault.set_override_queue(True, sender=bunny)
vault.set_use_default_queue(True, sender=bunny)


def test_set_default_queue__queue_manager(gov, vault, strategy, bunny):
Expand All @@ -344,7 +344,7 @@ def test_set_default_queue__queue_manager(gov, vault, strategy, bunny):
assert vault.get_default_queue() == []


def test_set_override_queue__queue_manager(gov, vault, strategy, bunny):
def test_set_use_default_queue__queue_manager(gov, vault, strategy, bunny):
# We temporarily give bunny the role of DEBT_MANAGER
tx = vault.set_role(bunny.address, ROLES.QUEUE_MANAGER, sender=gov)

Expand All @@ -353,13 +353,13 @@ def test_set_override_queue__queue_manager(gov, vault, strategy, bunny):
assert event[0].account == bunny.address
assert event[0].role == ROLES.QUEUE_MANAGER

assert vault.override_queue() == False
tx = vault.set_override_queue(True, sender=bunny)
assert vault.use_default_queue() == False
tx = vault.set_use_default_queue(True, sender=bunny)

event = list(tx.decode_logs(vault.UpdateOverrideQueue))
event = list(tx.decode_logs(vault.UpdateUseDefaultQueue))
assert len(event) == 1
assert event[0].override_queue == True
assert vault.override_queue() == True
assert event[0].use_default_queue == True
assert vault.use_default_queue() == True


# PROFIT UNLOCK MANAGER
Expand Down
30 changes: 15 additions & 15 deletions tests/unit/vault/test_role_permissioned_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,9 +714,9 @@ def test_set_default_queue__queue_manager_closed__reverts(bunny, vault):
vault.set_default_queue([], sender=bunny)


def test_set_override_queue__queue_manager_closed__reverts(bunny, vault):
def test_set_use_default_queue__queue_manager_closed__reverts(bunny, vault):
with ape.reverts("not allowed"):
vault.set_override_queue(True, sender=bunny)
vault.set_use_default_queue(True, sender=bunny)


def test_set_default_queue__queue_manager_open(gov, vault, strategy, bunny):
Expand All @@ -733,7 +733,7 @@ def test_set_default_queue__queue_manager_open(gov, vault, strategy, bunny):
assert vault.get_default_queue() == []


def test_set_override_queue__queue_manager_open(gov, vault, strategy, bunny):
def test_set_use_default_queue__queue_manager_open(gov, vault, strategy, bunny):
# We temporarily give bunny the role of DEBT_MANAGER
tx = vault.set_open_role(ROLES.QUEUE_MANAGER, sender=gov)

Expand All @@ -742,13 +742,13 @@ def test_set_override_queue__queue_manager_open(gov, vault, strategy, bunny):
assert event[0].role == ROLES.QUEUE_MANAGER
assert event[0].status == RoleStatusChange.OPENED

assert vault.override_queue() == False
tx = vault.set_override_queue(True, sender=bunny)
assert vault.use_default_queue() == False
tx = vault.set_use_default_queue(True, sender=bunny)

event = list(tx.decode_logs(vault.UpdateOverrideQueue))
event = list(tx.decode_logs(vault.UpdateUseDefaultQueue))
assert len(event) == 1
assert event[0].override_queue == True
assert vault.override_queue() == True
assert event[0].use_default_queue == True
assert vault.use_default_queue() == True


def test_set_default_queue__queue_manager_open_then_close__reverts(
Expand Down Expand Up @@ -777,7 +777,7 @@ def test_set_default_queue__queue_manager_open_then_close__reverts(
vault.set_default_queue([], sender=fish)


def test_set_override_queue__queue_manager_open_then_close__reverts(
def test_set_use_default_queue__queue_manager_open_then_close__reverts(
gov, vault, strategy, bunny, fish
):
# We temporarily give bunny the role of DEBT_MANAGER
Expand All @@ -788,13 +788,13 @@ def test_set_override_queue__queue_manager_open_then_close__reverts(
assert event[0].role == ROLES.QUEUE_MANAGER
assert event[0].status == RoleStatusChange.OPENED

assert vault.override_queue() == False
tx = vault.set_override_queue(True, sender=bunny)
assert vault.use_default_queue() == False
tx = vault.set_use_default_queue(True, sender=bunny)

event = list(tx.decode_logs(vault.UpdateOverrideQueue))
event = list(tx.decode_logs(vault.UpdateUseDefaultQueue))
assert len(event) == 1
assert event[0].override_queue == True
assert vault.override_queue() == True
assert event[0].use_default_queue == True
assert vault.use_default_queue() == True

tx = vault.close_open_role(ROLES.QUEUE_MANAGER, sender=gov)

Expand All @@ -804,4 +804,4 @@ def test_set_override_queue__queue_manager_open_then_close__reverts(
assert event[0].status == RoleStatusChange.CLOSED

with ape.reverts("not allowed"):
vault.set_override_queue(False, sender=fish)
vault.set_use_default_queue(False, sender=fish)
8 changes: 4 additions & 4 deletions tests/unit/vault/test_strategy_withdraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -2012,7 +2012,7 @@ def test_withdraw__with_multiple_liquid_strategies_more_assets_than_debt__withdr
assert asset.balanceOf(fish) == amount


def test_withdraw__with_custom_queue_and_override_queue__overrides(
def test_withdraw__with_custom_queue_and_use_default_queue__overrides(
gov,
fish,
fish_amount,
Expand Down Expand Up @@ -2049,7 +2049,7 @@ def test_withdraw__with_custom_queue_and_override_queue__overrides(
add_debt_to_strategy(gov, strategy, vault, amount_per_strategy)

# Set override to true
vault.set_override_queue(True, sender=gov)
vault.set_use_default_queue(True, sender=gov)

# Set queue to opposite of the custom one
vault.set_default_queue([second_strategy, first_strategy], sender=gov)
Expand Down Expand Up @@ -2089,7 +2089,7 @@ def test_withdraw__with_custom_queue_and_override_queue__overrides(
assert vault.balanceOf(fish) > 0


def test_redeem__with_custom_queue_and_override_queue__overrides(
def test_redeem__with_custom_queue_and_use_default_queue__overrides(
gov,
fish,
fish_amount,
Expand Down Expand Up @@ -2126,7 +2126,7 @@ def test_redeem__with_custom_queue_and_override_queue__overrides(
add_debt_to_strategy(gov, strategy, vault, amount_per_strategy)

# Set override to true
vault.set_override_queue(True, sender=gov)
vault.set_use_default_queue(True, sender=gov)

# Set queue to opposite of the custom one
vault.set_default_queue([second_strategy, first_strategy], sender=gov)
Expand Down

0 comments on commit 1332f5d

Please sign in to comment.