Skip to content

Commit

Permalink
apply fee instantaneously
Browse files Browse the repository at this point in the history
  • Loading branch information
bout3fiddy committed Jun 28, 2023
1 parent e8fd754 commit 9f97a83
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 62 deletions.
38 changes: 7 additions & 31 deletions contracts/main/CurveStableSwap2NG.vy
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ event StopRampA:
A: uint256
t: uint256

event CommitNewFee:
new_fee: uint256

event ApplyNewFee:
fee: uint256

Expand All @@ -127,6 +124,8 @@ IS_REBASING: public(immutable(bool))
factory: public(address)
coins: public(address[N_COINS])
stored_balances: uint256[N_COINS]
fee: public(uint256) # fee * 1e10
FEE_DENOMINATOR: constant(uint256) = 10 ** 10

# ---------------------- Pool Amplification Parameters -----------------------

Expand All @@ -139,21 +138,11 @@ future_A: public(uint256)
initial_A_time: public(uint256)
future_A_time: public(uint256)

# ---------------------------- Fee Variables ---------------------------------
# ---------------------------- Admin Variables -------------------------------

ADMIN_FEE: constant(uint256) = 5000000000

FEE_DENOMINATOR: constant(uint256) = 10 ** 10
MAX_FEE: constant(uint256) = 5 * 10 ** 9
fee: public(uint256) # fee * 1e10
future_fee: public(uint256)

# ---------------------------- Admin Variables -------------------------------

MIN_RAMP_TIME: constant(uint256) = 86400
ADMIN_ACTIONS_DEADLINE_DT: constant(uint256) = 86400 * 3
admin_action_deadline: public(uint256)

admin_balances: public(uint256[N_COINS])

# ----------------------- Oracle Specific vars -------------------------------
Expand Down Expand Up @@ -1793,26 +1782,13 @@ def stop_ramp_A():


@external
def commit_new_fee(_new_fee: uint256):
assert msg.sender == Factory(self.factory).admin()
assert _new_fee <= MAX_FEE
assert self.admin_action_deadline == 0
def apply_new_fee(_new_fee: uint256):

self.future_fee = _new_fee
self.admin_action_deadline = block.timestamp + ADMIN_ACTIONS_DEADLINE_DT
log CommitNewFee(_new_fee)


@external
def apply_new_fee():
assert msg.sender == Factory(self.factory).admin()
deadline: uint256 = self.admin_action_deadline
assert deadline != 0 and block.timestamp >= deadline
assert _new_fee <= MAX_FEE
self.fee = _new_fee

fee: uint256 = self.future_fee
self.fee = fee
self.admin_action_deadline = 0
log ApplyNewFee(fee)
log ApplyNewFee(_new_fee)


@external
Expand Down
38 changes: 7 additions & 31 deletions contracts/main/CurveStableSwapMetaNG.vy
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ event StopRampA:
A: uint256
t: uint256

event CommitNewFee:
new_fee: uint256

event ApplyNewFee:
fee: uint256

Expand All @@ -145,6 +142,8 @@ BASE_COINS: immutable(address[MAX_POOL_COINS])
factory: public(address)
coins: public(address[N_COINS])
stored_balances: uint256[N_COINS]
fee: public(uint256) # fee * 1e10
FEE_DENOMINATOR: constant(uint256) = 10 ** 10

# ---------------------- Pool Amplification Parameters -----------------------

Expand All @@ -157,21 +156,11 @@ future_A: public(uint256)
initial_A_time: public(uint256)
future_A_time: public(uint256)

# ---------------------------- Fee Variables ---------------------------------
# ---------------------------- Admin Variables -------------------------------

ADMIN_FEE: constant(uint256) = 5000000000

FEE_DENOMINATOR: constant(uint256) = 10 ** 10
MAX_FEE: constant(uint256) = 5 * 10 ** 9
fee: public(uint256) # fee * 1e10
future_fee: public(uint256)

# ---------------------------- Admin Variables -------------------------------

MIN_RAMP_TIME: constant(uint256) = 86400
ADMIN_ACTIONS_DEADLINE_DT: constant(uint256) = 86400 * 3
admin_action_deadline: public(uint256)

admin_balances: public(uint256[N_COINS])

# ----------------------- Oracle Specific vars -------------------------------
Expand Down Expand Up @@ -2020,26 +2009,13 @@ def stop_ramp_A():


@external
def commit_new_fee(_new_fee: uint256):
assert msg.sender == Factory(self.factory).admin()
assert _new_fee <= MAX_FEE
assert self.admin_action_deadline == 0
def apply_new_fee(_new_fee: uint256):

self.future_fee = _new_fee
self.admin_action_deadline = block.timestamp + ADMIN_ACTIONS_DEADLINE_DT
log CommitNewFee(_new_fee)


@external
def apply_new_fee():
assert msg.sender == Factory(self.factory).admin()
deadline: uint256 = self.admin_action_deadline
assert deadline != 0 and block.timestamp >= deadline
assert _new_fee <= MAX_FEE
self.fee = _new_fee

fee: uint256 = self.future_fee
self.fee = fee
self.admin_action_deadline = 0
log ApplyNewFee(fee)
log ApplyNewFee(_new_fee)


@external
Expand Down

0 comments on commit 9f97a83

Please sign in to comment.