Skip to content

Commit 3f3acb8

Browse files
chore: bump testing contracts to vyper 0.4.3
1 parent 4f1c0c0 commit 3f3acb8

16 files changed

+132
-117
lines changed

contracts/testing/BlockCounter.vy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# @version 0.3.10
1+
# version 0.4.3
22

33
block_counter: public(uint256)
44
time_counter: public(uint256)
55
last_time: public(uint256)
66

7-
@external
7+
@deploy
88
def __init__():
99
self.block_counter = 1
1010
self.time_counter = 0

contracts/testing/ChainlinkAggregatorMock.vy

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @version ^0.3.9
1+
# pragma version 0.4.3
22
"""
33
@notice Chainlink Aggregator Mock for testing
44
"""
@@ -8,8 +8,7 @@ ADMIN: immutable(address)
88
price: int256
99

1010

11-
@payable
12-
@external
11+
@deploy
1312
def __init__(decimals: uint8, admin: address, price: int256):
1413
self.decimals = decimals
1514

contracts/testing/ConstantMonetaryPolicy.vy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @version 0.3.10
1+
# @version 0.4.3
22
"""
33
Although this monetary policy works, it's only intended to be used in tests
44
"""
@@ -7,7 +7,7 @@ admin: public(address)
77
rate: public(uint256)
88

99

10-
@external
10+
@deploy
1111
def __init__(admin: address):
1212
self.admin = admin
1313

contracts/testing/CryptoWithStablePriceWsteth.vy

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @version 0.3.10
1+
# pragma version 0.4.3
22
"""
33
@title CryptoWithStablePriceWsteth
44
@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))
6060
use_chainlink: public(bool)
6161

6262

63-
@external
63+
@deploy
6464
def __init__(
6565
tricrypto: Tricrypto,
6666
ix: uint256,
@@ -80,10 +80,10 @@ def __init__(
8080
STAKEDSWAP = staked_swap
8181
FACTORY = factory
8282
WSTETH = wsteth
83-
_stablecoin: address = stable_aggregator.stablecoin()
83+
_stablecoin: address = staticcall stable_aggregator.stablecoin()
8484
_redeemable: address = empty(address)
8585
STABLECOIN = _stablecoin
86-
coins: address[2] = [stableswap.coins(0), stableswap.coins(1)]
86+
coins: address[2] = [staticcall stableswap.coins(0), staticcall stableswap.coins(1)]
8787
is_inverse: bool = False
8888
if coins[0] == _stablecoin:
8989
_redeemable = coins[1]
@@ -93,13 +93,13 @@ def __init__(
9393
assert coins[1] == _stablecoin
9494
IS_INVERSE = is_inverse
9595
REDEEMABLE = _redeemable
96-
assert tricrypto.coins(0) == _redeemable
96+
assert staticcall tricrypto.coins(0) == _redeemable
9797

9898
self.use_chainlink = True
9999
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)
101101
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)
103103
BOUND_SIZE = bound_size
104104

105105

@@ -142,38 +142,38 @@ def redeemable() -> address:
142142
@internal
143143
@view
144144
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
148148
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
151151

152152
use_chainlink: bool = self.use_chainlink
153153

154154
# Limit ETH price
155155
if use_chainlink:
156-
chainlink_lrd: ChainlinkAnswer = CHAINLINK_AGGREGATOR_ETH.latestRoundData()
156+
chainlink_lrd: ChainlinkAnswer = staticcall CHAINLINK_AGGREGATOR_ETH.latestRoundData()
157157
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
161161
crv_p = min(max(crv_p, lower), upper)
162162

163-
p_staked: uint256 = STAKEDSWAP.price_oracle() # d_eth / d_steth
163+
p_staked: uint256 = staticcall STAKEDSWAP.price_oracle() # d_eth / d_steth
164164

165165
# Limit STETH price
166166
if use_chainlink:
167-
chainlink_lrd: ChainlinkAnswer = CHAINLINK_AGGREGATOR_STETH.latestRoundData()
167+
chainlink_lrd: ChainlinkAnswer = staticcall CHAINLINK_AGGREGATOR_STETH.latestRoundData()
168168
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
172172
p_staked = min(max(p_staked, lower), upper)
173173

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
175175

176-
return p_staked * crv_p / 10**18
176+
return p_staked * crv_p // 10**18
177177

178178

179179
@external
@@ -195,5 +195,5 @@ def price_w() -> uint256:
195195

196196
@external
197197
def set_use_chainlink(do_it: bool):
198-
assert msg.sender == FACTORY.admin()
198+
assert msg.sender == staticcall FACTORY.admin()
199199
self.use_chainlink = do_it

contracts/testing/DummyFlashBorrower.vy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# @version 0.3.10
1+
# pragma version 0.4.3
22

3-
from vyper.interfaces import ERC20
3+
from ethereum.ercs import IERC20
44

55
interface ERC3156FlashLender:
66
def flashFee(token: address, amount: uint256) -> uint256: view
@@ -15,7 +15,7 @@ success: bool
1515
send_back: bool
1616

1717

18-
@external
18+
@deploy
1919
def __init__(_lender: address):
2020
"""
2121
@notice FlashBorrower constructor. Gets FlashLender address.
@@ -37,14 +37,14 @@ def onFlashLoan(
3737
assert msg.sender == LENDER, "FlashBorrower: Untrusted lender"
3838
assert initiator == self, "FlashBorrower: Untrusted loan initiator"
3939
assert data == b"", "Non-empty data"
40-
assert ERC20(token).balanceOf(self) == amount
40+
assert staticcall IERC20(token).balanceOf(self) == amount
4141
assert fee == 0
4242

4343
self.count += 1
4444
self.total_amount += amount
4545

4646
if self.send_back:
47-
ERC20(token).transfer(LENDER, amount + fee)
47+
extcall IERC20(token).transfer(LENDER, amount + fee)
4848

4949
return keccak256("ERC3156FlashBorrower.onFlashLoan")
5050

@@ -54,4 +54,4 @@ def flashBorrow(token: address, amount: uint256, send_back: bool = True):
5454
@notice Initiate a flash loan.
5555
"""
5656
self.send_back = send_back
57-
ERC3156FlashLender(LENDER).flashLoan(self, token, amount, b"")
57+
extcall ERC3156FlashLender(LENDER).flashLoan(self, token, amount, b"")

contracts/testing/DummyLMCallback.vy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @version 0.3.10
1+
# pragma version 0.4.3
22

33
MAX_TICKS_UINT: constant(uint256) = 50
44

@@ -8,7 +8,7 @@ _debug_user_shares: public(HashMap[address, HashMap[int256, uint256]])
88
AMM: immutable(address)
99

1010

11-
@external
11+
@deploy
1212
def __init__(amm: address):
1313
AMM = amm
1414

@@ -17,7 +17,7 @@ def __init__(amm: address):
1717
def callback_collateral_shares(n: int256, collateral_per_share: DynArray[uint256, MAX_TICKS_UINT]):
1818
assert msg.sender == AMM
1919
i: int256 = n
20-
for s in collateral_per_share:
20+
for s: uint256 in collateral_per_share:
2121
self._debug_collateral_per_share[i] = s
2222
i += 1
2323

@@ -26,6 +26,6 @@ def callback_collateral_shares(n: int256, collateral_per_share: DynArray[uint256
2626
def callback_user_shares(user: address, n: int256, user_shares: DynArray[uint256, MAX_TICKS_UINT]):
2727
assert msg.sender == AMM
2828
i: int256 = n
29-
for s in user_shares:
29+
for s: uint256 in user_shares:
3030
self._debug_user_shares[user][i] = s
3131
i += 1

contracts/testing/DummyPriceOracle.vy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @version 0.3.10
1+
# pragma version 0.4.3
22

33
"""
44
This contract is for testing only.
@@ -9,7 +9,7 @@ price: public(uint256)
99
ADMIN: immutable(address)
1010

1111

12-
@external
12+
@deploy
1313
def __init__(admin: address, price: uint256):
1414
self.price = price
1515
ADMIN = admin

0 commit comments

Comments
 (0)