Skip to content

Commit

Permalink
fix: add ma_exp_time setup and changing methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bout3fiddy committed Sep 18, 2023
1 parent 34535cf commit d4012ab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
10 changes: 10 additions & 0 deletions contracts/implementations/plain-2/Plain2Balances.vy
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ def initialize(
self.name = name
self.symbol = concat(_symbol, "-f")

self.ma_exp_time = 865 # set it to default = 10 mins

self.DOMAIN_SEPARATOR = keccak256(
_abi_encode(EIP712_TYPEHASH, keccak256(name), keccak256(VERSION), chain.id, self)
)
Expand Down Expand Up @@ -1118,6 +1120,14 @@ def withdraw_admin_fees():
self.admin_balances[i] = 0


@external
def set_ma_exp_time(_ma_exp_time: uint256):
assert msg.sender == Factory(self.factory).admin() # dev: only owner
assert _ma_exp_time != 0

self.ma_exp_time = _ma_exp_time


@pure
@external
def version() -> String[8]:
Expand Down
23 changes: 16 additions & 7 deletions contracts/implementations/plain-2/Plain2Price.vy
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# @version 0.3.9
"""
@title StableSwap
@title CurveStableSwap2Prices
@author Curve.Fi
@license Copyright (c) Curve.Fi, 2020-2021 - all rights reserved
@notice 2 coin pool implementation with no lending
@license Copyright (c) Curve.Fi, 2023 - all rights reserved
@notice 2 coin pool implementation for tokens with rate oracles.
@dev ERC20 support for return True/revert, return True/False, return None
"""

Expand Down Expand Up @@ -171,6 +171,8 @@ def initialize(
self.name = name
self.symbol = concat(_symbol, "-f")

self.ma_exp_time = 865 # set it to default = 10 mins

self.DOMAIN_SEPARATOR = keccak256(
_abi_encode(EIP712_TYPEHASH, keccak256(name), keccak256(VERSION), chain.id, self)
)
Expand Down Expand Up @@ -1128,7 +1130,7 @@ def withdraw_admin_fees():


@external
def set_oracles(_method_ids: uint256[N_COINS], _oracles: address[N_COINS]):
def set_oracles(_method_ids: bytes4[N_COINS], _oracles: address[N_COINS]):
"""
@notice Set the oracles used for calculating rates
@dev if any value is empty, rate will fallback to value provided on initialize, one time use.
Expand All @@ -1139,12 +1141,19 @@ def set_oracles(_method_ids: uint256[N_COINS], _oracles: address[N_COINS]):
assert msg.sender == self.originator

for i in range(N_COINS):
assert (_method_ids[i] << 32) == 0
self.oracles[i] = (_method_ids[i] & convert(_oracles[i], uint256))
self.oracles[i] = convert(_method_ids[i], uint256) * 2**224 | convert(_oracles[i], uint256)

self.originator = empty(address)


@external
def set_ma_exp_time(_ma_exp_time: uint256):
assert msg.sender == Factory(self.factory).admin() # dev: only owner
assert _ma_exp_time != 0

self.ma_exp_time = _ma_exp_time


@pure
@external
def version() -> String[8]:
Expand All @@ -1157,4 +1166,4 @@ def version() -> String[8]:
@view
@external
def oracle(_idx: uint256) -> address:
return convert(self.oracles[_idx] % 2**160, address)
return convert(self.oracles[_idx] % 2**160, address)

0 comments on commit d4012ab

Please sign in to comment.