From a5a71c81ac6fe0ac6741bad14a10f812e4d07ea0 Mon Sep 17 00:00:00 2001 From: Edward Amor Date: Wed, 16 Aug 2023 02:05:35 -0400 Subject: [PATCH] fix: update implementations --- .../implementations/plain-2/Plain2Balances.vy | 43 +++++++++++++++++++ .../implementations/plain-2/Plain2Basic.vy | 43 +++++++++++++++++++ .../implementations/plain-2/Plain2ETH.vy | 43 +++++++++++++++++++ .../plain-2/Plain2Optimized.vy | 43 +++++++++++++++++++ .../implementations/plain-3/Plain3Balances.vy | 43 +++++++++++++++++++ .../implementations/plain-3/Plain3Basic.vy | 43 +++++++++++++++++++ .../implementations/plain-3/Plain3ETH.vy | 43 +++++++++++++++++++ .../plain-3/Plain3Optimized.vy | 43 +++++++++++++++++++ .../implementations/plain-4/Plain4Balances.vy | 43 +++++++++++++++++++ .../implementations/plain-4/Plain4Basic.vy | 43 +++++++++++++++++++ .../implementations/plain-4/Plain4ETH.vy | 43 +++++++++++++++++++ .../plain-4/Plain4Optimized.vy | 43 +++++++++++++++++++ 12 files changed, 516 insertions(+) diff --git a/contracts/implementations/plain-2/Plain2Balances.vy b/contracts/implementations/plain-2/Plain2Balances.vy index fc6c437..0a56b0d 100644 --- a/contracts/implementations/plain-2/Plain2Balances.vy +++ b/contracts/implementations/plain-2/Plain2Balances.vy @@ -994,3 +994,46 @@ def withdraw_admin_fees(): @external def version() -> String[8]: return VERSION + + +event CommitNewFee: + deadline: uint256 + new_fee: uint256 + + +event NewFee: + fee: uint256 + + +MAX_FEE: constant(uint256) = 5 * 10 ** 9 +ADMIN_ACTIONS_DELAY: constant(uint256) = 3 * 86400 + +future_fee: public(uint256) +admin_actions_deadline: public(uint256) + + +@external +def commit_new_fee(new_fee: uint256): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert self.admin_actions_deadline == 0 # dev: active action + assert new_fee != 0 and new_fee <= MAX_FEE # dev: fee exceeds maximum + + _deadline: uint256 = block.timestamp + ADMIN_ACTIONS_DELAY + self.admin_actions_deadline = _deadline + self.future_fee = new_fee + + log CommitNewFee(_deadline, new_fee) + + +@external +def apply_new_fee(): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert block.timestamp >= self.admin_actions_deadline # dev: insufficient time + assert self.admin_actions_deadline != 0 # dev: no active action + + self.admin_actions_deadline = 0 + _fee: uint256 = self.future_fee + self.fee = _fee + + log NewFee(_fee) + diff --git a/contracts/implementations/plain-2/Plain2Basic.vy b/contracts/implementations/plain-2/Plain2Basic.vy index 3ceb9cf..da8c605 100644 --- a/contracts/implementations/plain-2/Plain2Basic.vy +++ b/contracts/implementations/plain-2/Plain2Basic.vy @@ -982,3 +982,46 @@ def version() -> String[8]: @notice Get the version of this token contract """ return VERSION + + +event CommitNewFee: + deadline: uint256 + new_fee: uint256 + + +event NewFee: + fee: uint256 + + +MAX_FEE: constant(uint256) = 5 * 10 ** 9 +ADMIN_ACTIONS_DELAY: constant(uint256) = 3 * 86400 + +future_fee: public(uint256) +admin_actions_deadline: public(uint256) + + +@external +def commit_new_fee(new_fee: uint256): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert self.admin_actions_deadline == 0 # dev: active action + assert new_fee != 0 and new_fee <= MAX_FEE # dev: fee exceeds maximum + + _deadline: uint256 = block.timestamp + ADMIN_ACTIONS_DELAY + self.admin_actions_deadline = _deadline + self.future_fee = new_fee + + log CommitNewFee(_deadline, new_fee) + + +@external +def apply_new_fee(): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert block.timestamp >= self.admin_actions_deadline # dev: insufficient time + assert self.admin_actions_deadline != 0 # dev: no active action + + self.admin_actions_deadline = 0 + _fee: uint256 = self.future_fee + self.fee = _fee + + log NewFee(_fee) + diff --git a/contracts/implementations/plain-2/Plain2ETH.vy b/contracts/implementations/plain-2/Plain2ETH.vy index 9985aa2..c0b8de8 100644 --- a/contracts/implementations/plain-2/Plain2ETH.vy +++ b/contracts/implementations/plain-2/Plain2ETH.vy @@ -1011,3 +1011,46 @@ def version() -> String[8]: @notice Get the version of this token contract """ return VERSION + + +event CommitNewFee: + deadline: uint256 + new_fee: uint256 + + +event NewFee: + fee: uint256 + + +MAX_FEE: constant(uint256) = 5 * 10 ** 9 +ADMIN_ACTIONS_DELAY: constant(uint256) = 3 * 86400 + +future_fee: public(uint256) +admin_actions_deadline: public(uint256) + + +@external +def commit_new_fee(new_fee: uint256): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert self.admin_actions_deadline == 0 # dev: active action + assert new_fee != 0 and new_fee <= MAX_FEE # dev: fee exceeds maximum + + _deadline: uint256 = block.timestamp + ADMIN_ACTIONS_DELAY + self.admin_actions_deadline = _deadline + self.future_fee = new_fee + + log CommitNewFee(_deadline, new_fee) + + +@external +def apply_new_fee(): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert block.timestamp >= self.admin_actions_deadline # dev: insufficient time + assert self.admin_actions_deadline != 0 # dev: no active action + + self.admin_actions_deadline = 0 + _fee: uint256 = self.future_fee + self.fee = _fee + + log NewFee(_fee) + diff --git a/contracts/implementations/plain-2/Plain2Optimized.vy b/contracts/implementations/plain-2/Plain2Optimized.vy index 00db748..7e9656d 100644 --- a/contracts/implementations/plain-2/Plain2Optimized.vy +++ b/contracts/implementations/plain-2/Plain2Optimized.vy @@ -890,3 +890,46 @@ def version() -> String[8]: @notice Get the version of this token contract """ return VERSION + + +event CommitNewFee: + deadline: uint256 + new_fee: uint256 + + +event NewFee: + fee: uint256 + + +MAX_FEE: constant(uint256) = 5 * 10 ** 9 +ADMIN_ACTIONS_DELAY: constant(uint256) = 3 * 86400 + +future_fee: public(uint256) +admin_actions_deadline: public(uint256) + + +@external +def commit_new_fee(new_fee: uint256): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert self.admin_actions_deadline == 0 # dev: active action + assert new_fee != 0 and new_fee <= MAX_FEE # dev: fee exceeds maximum + + _deadline: uint256 = block.timestamp + ADMIN_ACTIONS_DELAY + self.admin_actions_deadline = _deadline + self.future_fee = new_fee + + log CommitNewFee(_deadline, new_fee) + + +@external +def apply_new_fee(): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert block.timestamp >= self.admin_actions_deadline # dev: insufficient time + assert self.admin_actions_deadline != 0 # dev: no active action + + self.admin_actions_deadline = 0 + _fee: uint256 = self.future_fee + self.fee = _fee + + log NewFee(_fee) + diff --git a/contracts/implementations/plain-3/Plain3Balances.vy b/contracts/implementations/plain-3/Plain3Balances.vy index d8bd929..1c1694d 100644 --- a/contracts/implementations/plain-3/Plain3Balances.vy +++ b/contracts/implementations/plain-3/Plain3Balances.vy @@ -1000,3 +1000,46 @@ def version() -> String[8]: @notice Get the version of this token contract """ return VERSION + + +event CommitNewFee: + deadline: uint256 + new_fee: uint256 + + +event NewFee: + fee: uint256 + + +MAX_FEE: constant(uint256) = 5 * 10 ** 9 +ADMIN_ACTIONS_DELAY: constant(uint256) = 3 * 86400 + +future_fee: public(uint256) +admin_actions_deadline: public(uint256) + + +@external +def commit_new_fee(new_fee: uint256): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert self.admin_actions_deadline == 0 # dev: active action + assert new_fee != 0 and new_fee <= MAX_FEE # dev: fee exceeds maximum + + _deadline: uint256 = block.timestamp + ADMIN_ACTIONS_DELAY + self.admin_actions_deadline = _deadline + self.future_fee = new_fee + + log CommitNewFee(_deadline, new_fee) + + +@external +def apply_new_fee(): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert block.timestamp >= self.admin_actions_deadline # dev: insufficient time + assert self.admin_actions_deadline != 0 # dev: no active action + + self.admin_actions_deadline = 0 + _fee: uint256 = self.future_fee + self.fee = _fee + + log NewFee(_fee) + diff --git a/contracts/implementations/plain-3/Plain3Basic.vy b/contracts/implementations/plain-3/Plain3Basic.vy index 517af7a..fbbb9d3 100644 --- a/contracts/implementations/plain-3/Plain3Basic.vy +++ b/contracts/implementations/plain-3/Plain3Basic.vy @@ -985,3 +985,46 @@ def version() -> String[8]: @notice Get the version of this token contract """ return VERSION + + +event CommitNewFee: + deadline: uint256 + new_fee: uint256 + + +event NewFee: + fee: uint256 + + +MAX_FEE: constant(uint256) = 5 * 10 ** 9 +ADMIN_ACTIONS_DELAY: constant(uint256) = 3 * 86400 + +future_fee: public(uint256) +admin_actions_deadline: public(uint256) + + +@external +def commit_new_fee(new_fee: uint256): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert self.admin_actions_deadline == 0 # dev: active action + assert new_fee != 0 and new_fee <= MAX_FEE # dev: fee exceeds maximum + + _deadline: uint256 = block.timestamp + ADMIN_ACTIONS_DELAY + self.admin_actions_deadline = _deadline + self.future_fee = new_fee + + log CommitNewFee(_deadline, new_fee) + + +@external +def apply_new_fee(): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert block.timestamp >= self.admin_actions_deadline # dev: insufficient time + assert self.admin_actions_deadline != 0 # dev: no active action + + self.admin_actions_deadline = 0 + _fee: uint256 = self.future_fee + self.fee = _fee + + log NewFee(_fee) + diff --git a/contracts/implementations/plain-3/Plain3ETH.vy b/contracts/implementations/plain-3/Plain3ETH.vy index 71c5959..333521a 100644 --- a/contracts/implementations/plain-3/Plain3ETH.vy +++ b/contracts/implementations/plain-3/Plain3ETH.vy @@ -1020,3 +1020,46 @@ def version() -> String[8]: @notice Get the version of this token contract """ return VERSION + + +event CommitNewFee: + deadline: uint256 + new_fee: uint256 + + +event NewFee: + fee: uint256 + + +MAX_FEE: constant(uint256) = 5 * 10 ** 9 +ADMIN_ACTIONS_DELAY: constant(uint256) = 3 * 86400 + +future_fee: public(uint256) +admin_actions_deadline: public(uint256) + + +@external +def commit_new_fee(new_fee: uint256): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert self.admin_actions_deadline == 0 # dev: active action + assert new_fee != 0 and new_fee <= MAX_FEE # dev: fee exceeds maximum + + _deadline: uint256 = block.timestamp + ADMIN_ACTIONS_DELAY + self.admin_actions_deadline = _deadline + self.future_fee = new_fee + + log CommitNewFee(_deadline, new_fee) + + +@external +def apply_new_fee(): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert block.timestamp >= self.admin_actions_deadline # dev: insufficient time + assert self.admin_actions_deadline != 0 # dev: no active action + + self.admin_actions_deadline = 0 + _fee: uint256 = self.future_fee + self.fee = _fee + + log NewFee(_fee) + diff --git a/contracts/implementations/plain-3/Plain3Optimized.vy b/contracts/implementations/plain-3/Plain3Optimized.vy index 0c31fe4..3776628 100644 --- a/contracts/implementations/plain-3/Plain3Optimized.vy +++ b/contracts/implementations/plain-3/Plain3Optimized.vy @@ -893,3 +893,46 @@ def version() -> String[8]: @notice Get the version of this token contract """ return VERSION + + +event CommitNewFee: + deadline: uint256 + new_fee: uint256 + + +event NewFee: + fee: uint256 + + +MAX_FEE: constant(uint256) = 5 * 10 ** 9 +ADMIN_ACTIONS_DELAY: constant(uint256) = 3 * 86400 + +future_fee: public(uint256) +admin_actions_deadline: public(uint256) + + +@external +def commit_new_fee(new_fee: uint256): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert self.admin_actions_deadline == 0 # dev: active action + assert new_fee != 0 and new_fee <= MAX_FEE # dev: fee exceeds maximum + + _deadline: uint256 = block.timestamp + ADMIN_ACTIONS_DELAY + self.admin_actions_deadline = _deadline + self.future_fee = new_fee + + log CommitNewFee(_deadline, new_fee) + + +@external +def apply_new_fee(): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert block.timestamp >= self.admin_actions_deadline # dev: insufficient time + assert self.admin_actions_deadline != 0 # dev: no active action + + self.admin_actions_deadline = 0 + _fee: uint256 = self.future_fee + self.fee = _fee + + log NewFee(_fee) + diff --git a/contracts/implementations/plain-4/Plain4Balances.vy b/contracts/implementations/plain-4/Plain4Balances.vy index 4c0579e..48f321e 100644 --- a/contracts/implementations/plain-4/Plain4Balances.vy +++ b/contracts/implementations/plain-4/Plain4Balances.vy @@ -1000,3 +1000,46 @@ def version() -> String[8]: @notice Get the version of this token contract """ return VERSION + + +event CommitNewFee: + deadline: uint256 + new_fee: uint256 + + +event NewFee: + fee: uint256 + + +MAX_FEE: constant(uint256) = 5 * 10 ** 9 +ADMIN_ACTIONS_DELAY: constant(uint256) = 3 * 86400 + +future_fee: public(uint256) +admin_actions_deadline: public(uint256) + + +@external +def commit_new_fee(new_fee: uint256): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert self.admin_actions_deadline == 0 # dev: active action + assert new_fee != 0 and new_fee <= MAX_FEE # dev: fee exceeds maximum + + _deadline: uint256 = block.timestamp + ADMIN_ACTIONS_DELAY + self.admin_actions_deadline = _deadline + self.future_fee = new_fee + + log CommitNewFee(_deadline, new_fee) + + +@external +def apply_new_fee(): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert block.timestamp >= self.admin_actions_deadline # dev: insufficient time + assert self.admin_actions_deadline != 0 # dev: no active action + + self.admin_actions_deadline = 0 + _fee: uint256 = self.future_fee + self.fee = _fee + + log NewFee(_fee) + diff --git a/contracts/implementations/plain-4/Plain4Basic.vy b/contracts/implementations/plain-4/Plain4Basic.vy index e79a379..e139b8c 100644 --- a/contracts/implementations/plain-4/Plain4Basic.vy +++ b/contracts/implementations/plain-4/Plain4Basic.vy @@ -985,3 +985,46 @@ def version() -> String[8]: @notice Get the version of this token contract """ return VERSION + + +event CommitNewFee: + deadline: uint256 + new_fee: uint256 + + +event NewFee: + fee: uint256 + + +MAX_FEE: constant(uint256) = 5 * 10 ** 9 +ADMIN_ACTIONS_DELAY: constant(uint256) = 3 * 86400 + +future_fee: public(uint256) +admin_actions_deadline: public(uint256) + + +@external +def commit_new_fee(new_fee: uint256): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert self.admin_actions_deadline == 0 # dev: active action + assert new_fee != 0 and new_fee <= MAX_FEE # dev: fee exceeds maximum + + _deadline: uint256 = block.timestamp + ADMIN_ACTIONS_DELAY + self.admin_actions_deadline = _deadline + self.future_fee = new_fee + + log CommitNewFee(_deadline, new_fee) + + +@external +def apply_new_fee(): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert block.timestamp >= self.admin_actions_deadline # dev: insufficient time + assert self.admin_actions_deadline != 0 # dev: no active action + + self.admin_actions_deadline = 0 + _fee: uint256 = self.future_fee + self.fee = _fee + + log NewFee(_fee) + diff --git a/contracts/implementations/plain-4/Plain4ETH.vy b/contracts/implementations/plain-4/Plain4ETH.vy index 1a7b64a..a2546be 100644 --- a/contracts/implementations/plain-4/Plain4ETH.vy +++ b/contracts/implementations/plain-4/Plain4ETH.vy @@ -1020,3 +1020,46 @@ def version() -> String[8]: @notice Get the version of this token contract """ return VERSION + + +event CommitNewFee: + deadline: uint256 + new_fee: uint256 + + +event NewFee: + fee: uint256 + + +MAX_FEE: constant(uint256) = 5 * 10 ** 9 +ADMIN_ACTIONS_DELAY: constant(uint256) = 3 * 86400 + +future_fee: public(uint256) +admin_actions_deadline: public(uint256) + + +@external +def commit_new_fee(new_fee: uint256): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert self.admin_actions_deadline == 0 # dev: active action + assert new_fee != 0 and new_fee <= MAX_FEE # dev: fee exceeds maximum + + _deadline: uint256 = block.timestamp + ADMIN_ACTIONS_DELAY + self.admin_actions_deadline = _deadline + self.future_fee = new_fee + + log CommitNewFee(_deadline, new_fee) + + +@external +def apply_new_fee(): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert block.timestamp >= self.admin_actions_deadline # dev: insufficient time + assert self.admin_actions_deadline != 0 # dev: no active action + + self.admin_actions_deadline = 0 + _fee: uint256 = self.future_fee + self.fee = _fee + + log NewFee(_fee) + diff --git a/contracts/implementations/plain-4/Plain4Optimized.vy b/contracts/implementations/plain-4/Plain4Optimized.vy index e66f5bf..18369e5 100644 --- a/contracts/implementations/plain-4/Plain4Optimized.vy +++ b/contracts/implementations/plain-4/Plain4Optimized.vy @@ -892,3 +892,46 @@ def version() -> String[8]: @notice Get the version of this token contract """ return VERSION + + +event CommitNewFee: + deadline: uint256 + new_fee: uint256 + + +event NewFee: + fee: uint256 + + +MAX_FEE: constant(uint256) = 5 * 10 ** 9 +ADMIN_ACTIONS_DELAY: constant(uint256) = 3 * 86400 + +future_fee: public(uint256) +admin_actions_deadline: public(uint256) + + +@external +def commit_new_fee(new_fee: uint256): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert self.admin_actions_deadline == 0 # dev: active action + assert new_fee != 0 and new_fee <= MAX_FEE # dev: fee exceeds maximum + + _deadline: uint256 = block.timestamp + ADMIN_ACTIONS_DELAY + self.admin_actions_deadline = _deadline + self.future_fee = new_fee + + log CommitNewFee(_deadline, new_fee) + + +@external +def apply_new_fee(): + assert msg.sender == Factory(self.factory).admin() # dev: only owner + assert block.timestamp >= self.admin_actions_deadline # dev: insufficient time + assert self.admin_actions_deadline != 0 # dev: no active action + + self.admin_actions_deadline = 0 + _fee: uint256 = self.future_fee + self.fee = _fee + + log NewFee(_fee) +