Skip to content

Commit

Permalink
test: increasing test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertoCentonze committed Apr 22, 2024
1 parent 827e446 commit a69abb6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
8 changes: 4 additions & 4 deletions contracts/main/CurveTwocryptoOptimized.vy
Original file line number Diff line number Diff line change
Expand Up @@ -1897,12 +1897,12 @@ def ramp_A_gamma(
assert future_gamma < MAX_GAMMA + 1

ratio: uint256 = 10**18 * future_A / A_gamma[0]
assert ratio < 10**18 * MAX_A_CHANGE + 1
assert ratio > 10**18 / MAX_A_CHANGE - 1
assert ratio < 10**18 * MAX_A_CHANGE + 1 # dev: A change too high
assert ratio > 10**18 / MAX_A_CHANGE - 1 # dev: A change too low

ratio = 10**18 * future_gamma / A_gamma[1]
assert ratio < 10**18 * MAX_A_CHANGE + 1
assert ratio > 10**18 / MAX_A_CHANGE - 1
assert ratio < 10**18 * MAX_A_CHANGE + 1 # dev: gamma change too high
assert ratio > 10**18 / MAX_A_CHANGE - 1 # dev: gamma change too low

self.initial_A_gamma = initial_A_gamma
self.initial_A_gamma_time = block.timestamp
Expand Down
26 changes: 26 additions & 0 deletions tests/unitary/pool/admin/test_revert_ramp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def test_revert_unauthorised_ramp(swap, user):

def test_revert_ramp_while_ramping(swap, factory_admin):

# sanity check: ramping is not active
assert swap.initial_A_gamma_time() == 0

A_gamma = [swap.A(), swap.gamma()]
Expand All @@ -30,6 +31,7 @@ def test_revert_fast_ramps(swap, factory_admin):

def test_revert_unauthorised_stop_ramp(swap, factory_admin, user):

# sanity check: ramping is not active
assert swap.initial_A_gamma_time() == 0

A_gamma = [swap.A(), swap.gamma()]
Expand All @@ -39,3 +41,27 @@ def test_revert_unauthorised_stop_ramp(swap, factory_admin, user):

with boa.env.prank(user), boa.reverts(dev="only owner"):
swap.stop_ramp_A_gamma()


def test_revert_ramp_too_far(swap, factory_admin):

# sanity check: ramping is not active
assert swap.initial_A_gamma_time() == 0

A = swap.A()
gamma = swap.gamma()
future_time = boa.env.vm.state.timestamp + 86400 + 1

with boa.env.prank(factory_admin), boa.reverts("A change too high"):
future_A = A * 11 # can at most increase by 10x
swap.ramp_A_gamma(future_A, gamma, future_time)
with boa.env.prank(factory_admin), boa.reverts("A change too low"):
future_A = A // 11 # can at most decrease by 10x
swap.ramp_A_gamma(future_A, gamma, future_time)

with boa.env.prank(factory_admin), boa.reverts("gamma change too high"):
future_gamma = gamma * 10 # can at most increase by 10x
swap.ramp_A_gamma(A, future_gamma, future_time)
with boa.env.prank(factory_admin), boa.reverts("gamma change too low"):
future_gamma = gamma // 11 # can at most decrease by 10x
swap.ramp_A_gamma(A, future_gamma, future_time)

0 comments on commit a69abb6

Please sign in to comment.