Skip to content

Commit

Permalink
check A and gamma in implementation constructor and not in factory to…
Browse files Browse the repository at this point in the history
… accommodate for future updates
  • Loading branch information
bout3fiddy committed Nov 22, 2023
1 parent fd2e505 commit d8021ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
13 changes: 0 additions & 13 deletions contracts/main/CurveTwocryptoFactory.vy
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ A_MULTIPLIER: constant(uint256) = 10000
# Limits
MAX_FEE: constant(uint256) = 10 * 10 ** 9

MIN_GAMMA: constant(uint256) = 10 ** 10
MAX_GAMMA: constant(uint256) = 5 * 10**16

MIN_A: constant(uint256) = N_COINS ** N_COINS * A_MULTIPLIER / 100
MAX_A: constant(uint256) = 1000 * A_MULTIPLIER * N_COINS**N_COINS

admin: public(address)
future_admin: public(address)

Expand Down Expand Up @@ -150,13 +144,6 @@ def deploy_pool(
pool_implementation: address = self.pool_implementations[implementation_id]
assert pool_implementation != empty(address), "Pool implementation not set"

# Validate parameters
assert A > MIN_A-1
assert A < MAX_A+1

assert gamma > MIN_GAMMA-1
assert gamma < MAX_GAMMA+1

assert mid_fee < MAX_FEE-1 # mid_fee can be zero
assert out_fee >= mid_fee
assert out_fee < MAX_FEE-1
Expand Down
12 changes: 11 additions & 1 deletion contracts/main/CurveTwocryptoOptimized.vy
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,18 @@ def __init__(

PRECISIONS = precisions # <------------------------ Precisions of coins.

self.initial_A_gamma = packed_A_gamma # <------------------- A and gamma.
# --------------- Validate A and gamma parameters here and not in factory.
A_gamma: uint256[2] = self._unpack_2(packed_A_gamma)

assert A_gamma[0] > MIN_A-1
assert A_gamma[0] < MAX_A+1

assert A_gamma[1] > MIN_GAMMA-1
assert A_gamma[1] < MAX_GAMMA+1

self.initial_A_gamma = packed_A_gamma
self.future_A_gamma = packed_A_gamma
# ------------------------------------------------------------------------

self.packed_rebalancing_params = packed_rebalancing_params # <-- Contains
# rebalancing params: allowed_extra_profit, adjustment_step,
Expand Down

0 comments on commit d8021ec

Please sign in to comment.