Skip to content

Commit

Permalink
add asset types; fix: _stored_rates in plain pools not reading extern…
Browse files Browse the repository at this point in the history
…al rates
  • Loading branch information
bout3fiddy committed Oct 12, 2023
1 parent 237828d commit 63b46dc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
20 changes: 20 additions & 0 deletions contracts/main/CurveStableSwapFactoryNG.vy
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ FEE_DENOMINATOR: constant(uint256) = 10 ** 10
admin: public(address)
future_admin: public(address)

asset_types: public(HashMap[uint8, String[20]])

pool_list: public(address[4294967296]) # master list of pools
pool_count: public(uint256) # actual length of pool_list
pool_data: HashMap[address, PoolArray]
Expand Down Expand Up @@ -107,6 +109,12 @@ def __init__(_fee_receiver: address, _owner: address):
self.fee_receiver = _fee_receiver
self.admin = _owner

self.asset_types[0] = "Standard"
self.asset_types[1] = "Oracle"
self.asset_types[2] = "Rebasing"
self.asset_types[3] = "ERC4626"


# <--- Factory Getters --->


Expand Down Expand Up @@ -438,6 +446,7 @@ def get_pool_asset_types(_pool: address) -> DynArray[uint8, MAX_COINS]:
0. Standard ERC20 token with no additional features
1. Oracle - token with rate oracle (e.g. wrapped staked ETH)
2. Rebasing - token with rebase (e.g. staked ETH)
3. ERC4626 - e.g. sDAI
"""
return self.pool_data[_pool].asset_types

Expand Down Expand Up @@ -840,3 +849,14 @@ def set_fee_receiver(_pool: address, _fee_receiver: address):
"""
assert msg.sender == self.admin # dev: admin only
self.fee_receiver = _fee_receiver


@external
def add_asset_type(_id: uint8, _name: String[10]):
"""
@notice Admin only method that adds a new asset type.
@param _id asset type id.
@param _name Name of the asset type.
"""
assert msg.sender == self.admin # dev: admin only
self.asset_types[_id] = _name
2 changes: 1 addition & 1 deletion contracts/main/CurveStableSwapMetaNG.vy
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def _stored_rates() -> DynArray[uint256, MAX_COINS]:
]
oracles: DynArray[uint256, MAX_COINS] = self.oracles

if not self.oracles[0] == 0 and asset_types[0] == 1:
if asset_types[0] == 1 and not self.oracles[0] == 0:

# NOTE: fetched_rate is assumed to be 10**18 precision
fetched_rate: uint256 = convert(
Expand Down
5 changes: 1 addition & 4 deletions contracts/main/CurveStableSwapNG.vy
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,7 @@ def _stored_rates() -> DynArray[uint256, MAX_COINS]:
if i == N_COINS_128:
break

if oracles[i] == 0:
continue

if asset_types[i] == 1:
if asset_types[i] == 1 and not oracles[i] == 0:

# NOTE: fetched_rate is assumed to be 10**18 precision
fetched_rate: uint256 = convert(
Expand Down

0 comments on commit 63b46dc

Please sign in to comment.