forked from curvefi/curve-contract
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_compounded.py
21 lines (19 loc) · 986 Bytes
/
test_compounded.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from .conftest import use_lending
def test_cerc20(w3, coins, cerc20s):
from_creator = {'from': w3.eth.accounts[0]}
bob = w3.eth.accounts[1]
from_bob = {'from': bob}
for t, c, l in zip(coins, cerc20s, use_lending):
if l:
amount = 10 ** 5 * 10 ** t.caller.decimals()
t.functions.transfer(bob, amount).transact(from_creator)
t.functions.approve(c.address, amount).transact(from_bob)
c.functions.mint(amount).transact(from_bob)
# Check according to definition
assert c.caller.balanceOf(bob) * c.caller.exchangeRateStored() // 10 ** 18 == amount
# Tweak exchange rate
c.functions.set_exchange_rate(c.caller.exchangeRateStored() * 6 // 5).transact(from_creator)
# Get back
c.functions.redeem(c.caller.balanceOf(bob)).transact(from_bob)
assert t.caller.balanceOf(bob) == amount * 6 // 5
assert c.caller.balanceOf(bob) == 0