Skip to content

Commit

Permalink
add cap to spot prices going into oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
bout3fiddy committed Nov 14, 2023
1 parent 304d17b commit e681684
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion contracts/main/CurveStableSwapMetaNG.vy
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ def upkeep_oracles(xp: DynArray[uint256, MAX_COINS], amp: uint256, D: uint256):

# Upate packed prices -----------------
last_prices_packed_new[0] = self.pack_2(
spot_price[0],
min(spot_price[0], 2 * 10**18), # <----- Cap spot value by 2.
self._calc_moving_average(
last_prices_packed_current[0],
self.ma_exp_time,
Expand Down
6 changes: 3 additions & 3 deletions contracts/main/CurveStableSwapNG.vy
Original file line number Diff line number Diff line change
Expand Up @@ -1341,11 +1341,11 @@ def upkeep_oracles(xp: DynArray[uint256, MAX_COINS], amp: uint256, D: uint256):

# Upate packed prices -----------------
last_prices_packed_new[i] = self.pack_2(
spot_price[i],
min(spot_price[i], 2 * 10**18), # <----- Cap spot value by 2.
self._calc_moving_average(
last_prices_packed_current[i],
self.ma_exp_time,
ma_last_time_unpacked[0], # index 0 is ma_exp_time for prices
ma_last_time_unpacked[0], # index 0 is ma_last_time for prices
)
)

Expand All @@ -1359,7 +1359,7 @@ def upkeep_oracles(xp: DynArray[uint256, MAX_COINS], amp: uint256, D: uint256):
self._calc_moving_average(
last_D_packed_current,
self.D_ma_time,
ma_last_time_unpacked[1], # index 1 is ma_exp_time for D
ma_last_time_unpacked[1], # index 1 is ma_last_time for D
)
)

Expand Down
3 changes: 2 additions & 1 deletion contracts/main/CurveStableSwapNGAOracle.vy
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ admin_balances: public(DynArray[uint256, MAX_COINS])
rate_multipliers: immutable(DynArray[uint256, MAX_COINS])
# [bytes4 method_id][bytes8 <empty>][bytes20 oracle]
oracles: DynArray[uint256, MAX_COINS]
A_oracle: public(uint256)

# For ERC4626 tokens, we need:
call_amount: immutable(DynArray[uint256, MAX_COINS])
Expand Down Expand Up @@ -1331,7 +1332,7 @@ def upkeep_oracles(xp: DynArray[uint256, MAX_COINS], amp: uint256, D: uint256):

# Upate packed prices -----------------
last_prices_packed_new[i] = self.pack_2(
spot_price[i],
min(spot_price[i], 2 * 10**18), # <----- Cap spot value by 2.
self._calc_moving_average(
last_prices_packed_current[i],
self.ma_exp_time,
Expand Down
20 changes: 18 additions & 2 deletions scripts/deploy_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ class PoolSettings:
b"", # method_ids
ZERO_ADDRESS, # oracles
],
"plain": [
"FRAXsDAI", # name
"FRAXSDAI", # symbol
[
"0x853d955aCEf822Db058eb8505911ED77F175b99e", # frax
"0x83F20F44975D03b1b09e64809B757c47f942BEeA", # sdai
],
1500, # A
1000000, # fee
10000000000, # offpeg_fee_multiplier
865, # ma_exp_time
0, # implementation index
[0, 3], # asset_types
[b"", b""], # method_ids
[ZERO_ADDRESS, ZERO_ADDRESS], # oracles
],
}
}

Expand Down Expand Up @@ -196,8 +212,8 @@ def deploy_pool_and_gauge(network, url, account, pool_type, fork):

def main():

fork = False
deploy_pool_and_gauge("ethereum:mainnet", os.environ["RPC_ETHEREUM"], "FIDDYDEPLOYER", "meta", fork)
fork = True
deploy_pool_and_gauge("ethereum:mainnet", os.environ["RPC_ETHEREUM"], "FIDDYDEPLOYER", "plain", fork)


if __name__ == "__main__":
Expand Down

0 comments on commit e681684

Please sign in to comment.