diff --git a/tests/unitary/pool/stateful/stateful_base.py b/tests/unitary/pool/stateful/stateful_base.py index 3c4665f7..c0347a69 100644 --- a/tests/unitary/pool/stateful/stateful_base.py +++ b/tests/unitary/pool/stateful/stateful_base.py @@ -78,7 +78,14 @@ def initialize_pool(self, pool, amount, user): # --------------- utility methods --------------- + def is_ramping(self) -> bool: + """Check if the pool is currently ramping.""" + + return self.pool.future_A_gamma_time() > boa.env.evm.patch.timestamp + def correct_decimals(self, amount: int, coin_idx: int) -> int: + """Takes an amount that uses 18 decimals and reduces its precision""" + corrected_amount = int( amount // (10 ** (18 - self.decimals[coin_idx])) ) @@ -87,6 +94,9 @@ def correct_decimals(self, amount: int, coin_idx: int) -> int: return corrected_amount def correct_all_decimals(self, amounts: List[int]) -> Tuple[int, int]: + """Takes a list of amounts that use 18 decimals and reduces their + precision to the number of decimals of the respective coins.""" + return [self.correct_decimals(a, i) for i, a in enumerate(amounts)] def get_balanced_deposit_amounts(self, amount: int): @@ -351,10 +361,6 @@ def remove_liquidity_one_coin( # store the balance of the user before the removal user_balances_pre = self.coins[coin_idx].balanceOf(user) - pool_is_ramping = ( - self.pool.future_A_gamma_time() > boa.env.evm.patch.timestamp - ) - # lp tokens before the removal lp_tokens_balance_pre = self.pool.balanceOf(user) @@ -446,7 +452,7 @@ def remove_liquidity_one_coin( # decimals: with such a low precision admin fees might be 0 or self.decimals[i] <= 4 ), f"the admin fees collected should be positive for coin {i}" - assert not pool_is_ramping, "claim admin fees while ramping" + assert not self.is_ramping(), "claim admin fees while ramping" # deduce the claimed amount from the pool balances self.balances[i] -= claimed_amount diff --git a/tests/unitary/pool/stateful/test_stateful.py b/tests/unitary/pool/stateful/test_stateful.py index 1675d6e8..723d8c6d 100644 --- a/tests/unitary/pool/stateful/test_stateful.py +++ b/tests/unitary/pool/stateful/test_stateful.py @@ -4,14 +4,7 @@ from hypothesis.strategies import data, floats, integers, sampled_from from stateful_base import StatefulBase -from tests.utils.constants import ( - MAX_A, - MAX_GAMMA, - MIN_A, - MIN_GAMMA, - MIN_RAMP_TIME, - UNIX_DAY, -) +from tests.utils.constants import MAX_A, MAX_GAMMA, MIN_A, MIN_GAMMA, UNIX_DAY from tests.utils.strategies import address @@ -279,16 +272,7 @@ class RampingStateful(ImbalancedLiquidityStateful): # we fuzz the ramp duration up to a year days = integers(min_value=1, max_value=365) - def can_ramp_again(self): - """ - Checks if the pool is not already ramping. - """ - return ( - boa.env.evm.patch.timestamp - > self.pool.initial_A_gamma_time() + (MIN_RAMP_TIME - 1) - ) - - @precondition(can_ramp_again) + @precondition(lambda self: not self.is_ramping()) @rule( A_change=change_step_strategy, gamma_change=change_step_strategy, diff --git a/tests/utils/constants.py b/tests/utils/constants.py index 588056bb..250299fd 100644 --- a/tests/utils/constants.py +++ b/tests/utils/constants.py @@ -17,7 +17,6 @@ MIN_A = N_COINS**N_COINS * A_MULTIPLIER / 10 MAX_A = N_COINS**N_COINS * A_MULTIPLIER * 1000 -MIN_RAMP_TIME = 86400 UNIX_DAY = 86400 MIN_FEE = 5 * 10**5