1
- # @ version 0.3.10
1
+ # pragma version 0.4.3
2
2
"""
3
3
@title CryptoWithStablePriceWsteth
4
4
@notice Price oracle for tricrypto+wsteth for crvUSD. Not limiting the price with chainlink - relying on tricrypto-ng
@@ -60,7 +60,7 @@ WSTETH: public(immutable(wstETH))
60
60
use_chainlink: public (bool )
61
61
62
62
63
- @external
63
+ @deploy
64
64
def __init__ (
65
65
tricrypto: Tricrypto,
66
66
ix: uint256 ,
@@ -80,10 +80,10 @@ def __init__(
80
80
STAKEDSWAP = staked_swap
81
81
FACTORY = factory
82
82
WSTETH = wsteth
83
- _stablecoin: address = stable_aggregator.stablecoin ()
83
+ _stablecoin: address = staticcall stable_aggregator.stablecoin ()
84
84
_redeemable: address = empty (address )
85
85
STABLECOIN = _stablecoin
86
- coins: address [2 ] = [stableswap.coins (0 ), stableswap.coins (1 )]
86
+ coins: address [2 ] = [staticcall stableswap.coins (0 ), staticcall stableswap.coins (1 )]
87
87
is_inverse: bool = False
88
88
if coins[0 ] == _stablecoin:
89
89
_redeemable = coins[1 ]
@@ -93,13 +93,13 @@ def __init__(
93
93
assert coins[1 ] == _stablecoin
94
94
IS_INVERSE = is_inverse
95
95
REDEEMABLE = _redeemable
96
- assert tricrypto.coins (0 ) == _redeemable
96
+ assert staticcall tricrypto.coins (0 ) == _redeemable
97
97
98
98
self .use_chainlink = True
99
99
CHAINLINK_AGGREGATOR_ETH = chainlink_aggregator_eth
100
- CHAINLINK_PRICE_PRECISION_ETH = 10 ** convert (chainlink_aggregator_eth.decimals (), uint256 )
100
+ CHAINLINK_PRICE_PRECISION_ETH = 10 ** convert (staticcall chainlink_aggregator_eth.decimals (), uint256 )
101
101
CHAINLINK_AGGREGATOR_STETH = chainlink_aggregator_steth
102
- CHAINLINK_PRICE_PRECISION_STETH = 10 ** convert (chainlink_aggregator_steth.decimals (), uint256 )
102
+ CHAINLINK_PRICE_PRECISION_STETH = 10 ** convert (staticcall chainlink_aggregator_steth.decimals (), uint256 )
103
103
BOUND_SIZE = bound_size
104
104
105
105
@@ -142,38 +142,38 @@ def redeemable() -> address:
142
142
@internal
143
143
@view
144
144
def _raw_price () -> uint256 :
145
- p_crypto_r: uint256 = TRICRYPTO.price_oracle (TRICRYPTO_IX) # d_usdt/d_eth
146
- p_stable_r: uint256 = STABLESWAP.price_oracle () # d_usdt/d_st
147
- p_stable_agg: uint256 = STABLESWAP_AGGREGATOR.price () # d_usd/d_st
145
+ p_crypto_r: uint256 = staticcall TRICRYPTO.price_oracle (TRICRYPTO_IX) # d_usdt/d_eth
146
+ p_stable_r: uint256 = staticcall STABLESWAP.price_oracle () # d_usdt/d_st
147
+ p_stable_agg: uint256 = staticcall STABLESWAP_AGGREGATOR.price () # d_usd/d_st
148
148
if IS_INVERSE:
149
- p_stable_r = 10 ** 36 / p_stable_r
150
- crv_p: uint256 = p_crypto_r * p_stable_agg / p_stable_r # d_usd/d_eth
149
+ p_stable_r = 10 ** 36 // p_stable_r
150
+ crv_p: uint256 = p_crypto_r * p_stable_agg // p_stable_r # d_usd/d_eth
151
151
152
152
use_chainlink: bool = self .use_chainlink
153
153
154
154
# Limit ETH price
155
155
if use_chainlink:
156
- chainlink_lrd: ChainlinkAnswer = CHAINLINK_AGGREGATOR_ETH.latestRoundData ()
156
+ chainlink_lrd: ChainlinkAnswer = staticcall CHAINLINK_AGGREGATOR_ETH.latestRoundData ()
157
157
if block .timestamp - min (chainlink_lrd.updated_at, block .timestamp ) <= CHAINLINK_STALE_THRESHOLD:
158
- chainlink_p: uint256 = convert (chainlink_lrd.answer, uint256 ) * 10 ** 18 / CHAINLINK_PRICE_PRECISION_ETH
159
- lower: uint256 = chainlink_p * (10 ** 18 - BOUND_SIZE) / 10 ** 18
160
- upper: uint256 = chainlink_p * (10 ** 18 + BOUND_SIZE) / 10 ** 18
158
+ chainlink_p: uint256 = convert (chainlink_lrd.answer, uint256 ) * 10 ** 18 // CHAINLINK_PRICE_PRECISION_ETH
159
+ lower: uint256 = chainlink_p * (10 ** 18 - BOUND_SIZE) // 10 ** 18
160
+ upper: uint256 = chainlink_p * (10 ** 18 + BOUND_SIZE) // 10 ** 18
161
161
crv_p = min (max (crv_p, lower), upper)
162
162
163
- p_staked: uint256 = STAKEDSWAP.price_oracle () # d_eth / d_steth
163
+ p_staked: uint256 = staticcall STAKEDSWAP.price_oracle () # d_eth / d_steth
164
164
165
165
# Limit STETH price
166
166
if use_chainlink:
167
- chainlink_lrd: ChainlinkAnswer = CHAINLINK_AGGREGATOR_STETH.latestRoundData ()
167
+ chainlink_lrd: ChainlinkAnswer = staticcall CHAINLINK_AGGREGATOR_STETH.latestRoundData ()
168
168
if block .timestamp - min (chainlink_lrd.updated_at, block .timestamp ) <= CHAINLINK_STALE_THRESHOLD:
169
- chainlink_p: uint256 = convert (chainlink_lrd.answer, uint256 ) * 10 ** 18 / CHAINLINK_PRICE_PRECISION_STETH
170
- lower: uint256 = chainlink_p * (10 ** 18 - BOUND_SIZE) / 10 ** 18
171
- upper: uint256 = chainlink_p * (10 ** 18 + BOUND_SIZE) / 10 ** 18
169
+ chainlink_p: uint256 = convert (chainlink_lrd.answer, uint256 ) * 10 ** 18 // CHAINLINK_PRICE_PRECISION_STETH
170
+ lower: uint256 = chainlink_p * (10 ** 18 - BOUND_SIZE) // 10 ** 18
171
+ upper: uint256 = chainlink_p * (10 ** 18 + BOUND_SIZE) // 10 ** 18
172
172
p_staked = min (max (p_staked, lower), upper)
173
173
174
- p_staked = min (p_staked, 10 ** 18 ) * WSTETH.stEthPerToken () / 10 ** 18 # d_eth / d_wsteth
174
+ p_staked = min (p_staked, 10 ** 18 ) * staticcall WSTETH.stEthPerToken () / / 10 ** 18 # d_eth / d_wsteth
175
175
176
- return p_staked * crv_p / 10 ** 18
176
+ return p_staked * crv_p // 10 ** 18
177
177
178
178
179
179
@external
@@ -195,5 +195,5 @@ def price_w() -> uint256:
195
195
196
196
@external
197
197
def set_use_chainlink (do_it: bool ):
198
- assert msg .sender == FACTORY.admin ()
198
+ assert msg .sender == staticcall FACTORY.admin ()
199
199
self .use_chainlink = do_it
0 commit comments