-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_airdrop.py
42 lines (36 loc) · 1.2 KB
/
test_airdrop.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
from utils import actions, checks, utils
import pytest
def test_airdrop(
chain,
accounts,
token,
vault,
strategy,
user,
strategist,
amount,
RELATIVE_APPROX,
token_whale,
):
# Deposit to the vault
actions.user_deposit(user, vault, token, amount)
# Harvest 1: Send funds through the strategy
chain.sleep(1)
strategy.harvest({"from": strategist})
total_assets = strategy.estimatedTotalAssets()
assert pytest.approx(total_assets, rel=RELATIVE_APPROX) == amount
# we airdrop tokens to strategy
airdrop_amount = amount * 0.1 # 10% of current assets
token.transfer(strategy, airdrop_amount, {"from": token_whale})
# check that estimatedTotalAssets estimates correctly
assert total_assets + airdrop_amount == strategy.estimatedTotalAssets()
before_pps = vault.pricePerShare()
# Harvest 2: Realize profit
chain.sleep(1)
strategy.harvest()
chain.sleep(3600 * 6) # 6 hrs needed for profits to unlock
chain.mine(1)
profit = token.balanceOf(vault.address) # Profits go to vault
# TODO: Uncomment the lines below
assert token.balanceOf(strategy) + profit > amount
assert vault.pricePerShare() > before_pps