generated from yearn/brownie-strategy-mix
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtest_joint_migration2.py
51 lines (40 loc) · 1.61 KB
/
test_joint_migration2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import brownie
import pytest
from brownie import Contract, Wei
def test_join_migration2(chain, accounts, Joint):
providerB = Contract("0xF878E59600124ca46a30193A3F76EDAc99591698")
old_joint = Contract(providerB.joint())
providerA = Contract(old_joint.providerA())
gov = accounts.at(old_joint.governance(), force=True)
old_joint.setRatio(1, {"from": gov, "gas_price": "1 gwei"})
old_joint.harvest({"from": gov})
old_joint.liquidatePosition({"from": gov})
old_joint.setReinvest(False, {"from": gov})
old_joint.harvest({"from": gov})
assert providerA.balanceOfWant() > 0
assert providerB.balanceOfWant() > 0
assert old_joint.balanceOfB() + old_joint.balanceOfA() == 0
assert old_joint.balanceOfStake() == 0
new_joint = Joint.deploy(
old_joint.governance(),
old_joint.strategist(),
old_joint.keeper(),
old_joint.tokenA(),
old_joint.tokenB(),
old_joint.router(),
{"from": gov},
)
providerA.setJoint(new_joint, {"from": gov})
providerB.setJoint(new_joint, {"from": gov})
new_joint.setProviderA(providerA, {"from": gov})
new_joint.setProviderB(providerB, {"from": gov})
assert providerA.takeProfit() == False
assert providerB.takeProfit() == False
vaultA = Contract(providerA.vault())
vaultA.updateStrategyMaxDebtPerHarvest(providerA, 0, {"from": gov})
vaultB = Contract(providerB.vault())
vaultB.updateStrategyMaxDebtPerHarvest(providerB, 0, {"from": gov})
providerA.harvest({"from": gov})
providerB.harvest({"from": gov})
# Invest capital
new_joint.harvest({"from": gov})