Skip to content

Commit

Permalink
Merge branch 'feat/tests' of https://github.com/curvefi/twocrypto-ng
Browse files Browse the repository at this point in the history
…into feat/tests
  • Loading branch information
bout3fiddy committed Nov 6, 2023
2 parents 3be3a0f + f901e54 commit 244144f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions contracts/experimental/n=2.vy
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def _newton_y(ANN: uint256, gamma: uint256, x: uint256[N_COINS], D: uint256, i:
ANN = A * N**N
"""
# Safety checks
# assert ANN > MIN_A - 1 and ANN < MAX_A + 1 # dev: unsafe values A
# assert gamma > MIN_GAMMA - 1 and gamma < MAX_GAMMA + 1 # dev: unsafe values gamma
# assert D > 10**17 - 1 and D < 10**15 * 10**18 + 1 # dev: unsafe values D
assert ANN > MIN_A - 1 and ANN < MAX_A + 1 # dev: unsafe values A
assert gamma > MIN_GAMMA - 1 and gamma < MAX_GAMMA + 1 # dev: unsafe values gamma
assert D > 10**17 - 1 and D < 10**15 * 10**18 + 1 # dev: unsafe values D

x_j: uint256 = x[1 - i]
y: uint256 = D**2 / (x_j * N_COINS**2)
Expand Down Expand Up @@ -84,7 +84,7 @@ def _newton_y(ANN: uint256, gamma: uint256, x: uint256[N_COINS], D: uint256, i:
diff = y_prev - y
if diff < max(convergence_limit, y / 10**14):
frac: uint256 = y * 10**18 / D
# assert (frac > 10**16 - 1) and (frac < 10**20 + 1) # dev: unsafe value for y
assert (frac > 10**16 - 1) and (frac < 10**20 + 1) # dev: unsafe value for y
return y

raise "Did not converge"
Expand Down
9 changes: 4 additions & 5 deletions tests/unitary/math/test_get_y.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@

A_MUL = 10000
MIN_A = int(N_COINS**N_COINS * A_MUL / 10)
MAX_A = int(N_COINS**N_COINS * A_MUL * 100000)
MAX_A = int(N_COINS**N_COINS * A_MUL * 1000)

# gamma from 1e-8 up to 0.05
MIN_GAMMA = 10**10
MAX_GAMMA = 5 * 10**16
MAX_GAMMA = 2 * 10**15

pytest.current_case_id = 0
pytest.negative_sqrt_arg = 0
Expand Down Expand Up @@ -53,10 +52,10 @@ def inv_target_decimal_n2(A, gamma, x, D):
min_value=10**18, max_value=10**14 * 10**18
), # 1 USD to 100T USD
xD=st.integers(
min_value=int(1.001e16), max_value=int(0.999e20)
min_value=5 * 10**16, max_value=10**19
), # <- ratio 1e18 * x/D, typically 1e18 * 1
yD=st.integers(
min_value=int(1.001e16), max_value=int(0.999e20)
min_value=5 * 10**16, max_value=10**19
), # <- ratio 1e18 * y/D, typically 1e18 * 1
gamma=st.integers(min_value=MIN_GAMMA, max_value=MAX_GAMMA),
j=st.integers(min_value=0, max_value=1),
Expand Down

0 comments on commit 244144f

Please sign in to comment.