|
1 | 1 | import boa
|
2 | 2 | import pytest
|
3 |
| -from tests.utils.deployers import FAKE_LEVERAGE_DEPLOYER, ERC20_MOCK_DEPLOYER |
4 |
| - |
5 |
| -@pytest.fixture(scope="module", params=[True, False]) |
6 |
| -def tokens_for_vault(admin, stablecoin, decimals, request): |
7 |
| - stablecoin_is_borrowed = request.param |
8 |
| - with boa.env.prank(admin): |
9 |
| - token = ERC20_MOCK_DEPLOYER.deploy(decimals) |
10 |
| - if stablecoin_is_borrowed: |
11 |
| - borrowed_token = stablecoin |
12 |
| - collateral_token = token |
13 |
| - else: |
14 |
| - borrowed_token = token |
15 |
| - collateral_token = stablecoin |
16 |
| - return borrowed_token, collateral_token |
| 3 | +from tests.utils.deployers import FAKE_LEVERAGE_DEPLOYER |
| 4 | +from tests.utils.deployers import SEMILOG_MONETARY_POLICY_DEPLOYER |
17 | 5 |
|
18 | 6 |
|
19 | 7 | @pytest.fixture(scope="module")
|
20 |
| -def collateral_token(tokens_for_vault): |
21 |
| - return tokens_for_vault[1] |
| 8 | +def market_type(): |
| 9 | + """Force lending-only markets for tests in this folder.""" |
| 10 | + return "lending" |
22 | 11 |
|
23 | 12 |
|
24 | 13 | @pytest.fixture(scope="module")
|
25 |
| -def borrowed_token(tokens_for_vault): |
26 |
| - return tokens_for_vault[0] |
| 14 | +def lending_monetary_policy(): |
| 15 | + """Override lending policy to Semilog for all tests in this folder.""" |
| 16 | + return SEMILOG_MONETARY_POLICY_DEPLOYER |
27 | 17 |
|
28 | 18 |
|
29 | 19 | @pytest.fixture(scope="module")
|
30 |
| -def lending_market(proto, borrowed_token, collateral_token, price_oracle, admin): |
| 20 | +def fake_leverage(collateral_token, borrowed_token, controller, admin): |
31 | 21 | with boa.env.prank(admin):
|
32 |
| - result = proto.create_lending_market( |
33 |
| - borrowed_token=borrowed_token, |
34 |
| - collateral_token=collateral_token, |
35 |
| - A=100, |
36 |
| - fee=int(0.006 * 1e18), |
37 |
| - loan_discount=int(0.09 * 1e18), |
38 |
| - liquidation_discount=int(0.06 * 1e18), |
39 |
| - price_oracle=price_oracle, |
40 |
| - name="Test vault", |
41 |
| - min_borrow_rate=int(0.005 * 1e18) // (365 * 86400), # 0.5% APR |
42 |
| - max_borrow_rate=int(0.5 * 1e18) // (365 * 86400) # 50% APR |
43 |
| - ) |
44 |
| - return result |
45 |
| - |
46 |
| - |
47 |
| -@pytest.fixture(scope="module") |
48 |
| -def vault(lending_market): |
49 |
| - return lending_market['vault'] |
50 |
| - |
51 |
| - |
52 |
| -@pytest.fixture(scope="module") |
53 |
| -def market_controller(lending_market, admin): |
54 |
| - controller = lending_market['controller'] |
55 |
| - with boa.env.prank(admin): |
56 |
| - controller.set_borrow_cap(2**256 - 1) |
57 |
| - return controller |
58 |
| - |
59 |
| - |
60 |
| -@pytest.fixture(scope="module") |
61 |
| -def market_amm(lending_market): |
62 |
| - return lending_market['amm'] |
63 |
| - |
64 |
| - |
65 |
| -@pytest.fixture(scope="module") |
66 |
| -def monetary_policy(market_controller, borrowed_token, admin): |
67 |
| - from tests.utils.deployers import SEMILOG_MONETARY_POLICY_DEPLOYER |
68 |
| - # Override default policy with Semilog for lending test suite |
69 |
| - min_borrow_rate = int(0.005 * 1e18) // (365 * 86400) # 0.5% APR |
70 |
| - max_borrow_rate = int(0.5 * 1e18) // (365 * 86400) # 50% APR |
71 |
| - with boa.env.prank(admin): |
72 |
| - mp = SEMILOG_MONETARY_POLICY_DEPLOYER.deploy( |
| 22 | + leverage = FAKE_LEVERAGE_DEPLOYER.deploy( |
73 | 23 | borrowed_token.address,
|
74 |
| - min_borrow_rate, |
75 |
| - max_borrow_rate, |
| 24 | + collateral_token.address, |
| 25 | + controller.address, |
| 26 | + 3000 * 10**18, |
76 | 27 | )
|
77 |
| - market_controller.set_monetary_policy(mp) |
78 |
| - return mp |
79 |
| - |
80 |
| - |
81 |
| -@pytest.fixture(scope="module") |
82 |
| -def filled_controller(vault, borrowed_token, market_controller, admin): |
83 |
| - with boa.env.prank(admin): |
84 |
| - amount = 100 * 10**6 * 10**(borrowed_token.decimals()) |
85 |
| - boa.deal(borrowed_token, admin, amount) |
86 |
| - borrowed_token.approve(vault.address, 2**256 - 1) |
87 |
| - vault.deposit(amount) |
88 |
| - return market_controller |
89 |
| - |
90 |
| - |
91 |
| -@pytest.fixture(scope="module") |
92 |
| -def fake_leverage(collateral_token, borrowed_token, market_controller, admin): |
93 |
| - with boa.env.prank(admin): |
94 |
| - leverage = FAKE_LEVERAGE_DEPLOYER.deploy(borrowed_token.address, collateral_token.address, |
95 |
| - market_controller.address, 3000 * 10**18) |
96 | 28 | boa.deal(collateral_token, leverage.address, 1000 * 10**collateral_token.decimals())
|
97 | 29 | return leverage
|
0 commit comments