-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapr_base.py
154 lines (135 loc) · 4.18 KB
/
apr_base.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
from gcc_utils import gccPrint
from utils.node import (
w3,
init_chef,
init_chefv2,
)
from utils.prices import (
getDexTokenUSDRatio,
)
from utils.reserves import (
getDataV1Pools,
getDataV2Pools,
)
from utils.constants import (
V1_POOLS,
V2_POOLS,
V2_STABLEPOOL_METADATA,
WETH_ADDRESS,
WNEAR_ADDRESS,
WNEAR_USDC,
WETH_USDC,
TRI_ADDRESS,
WNEAR_TRI,
)
from utils.rewarder_configs import formatRewarderConfigItem, getRewarderConfigs
def apr_base():
gccPrint("Starting APR BASE")
data = []
## chef data
tri_decimals = 18
chef = init_chef()
totalAllocPoint = chef.functions.totalAllocPoint().call()
triPerBlock = chef.functions.triPerBlock().call()
## chefv2 calls
dummyLPPoolId = 7
dummyLPToken = "0x9990a658F71248cc507Ea62946f0EB7728491B70"
dummyLpPoolInfo = chef.functions.poolInfo(dummyLPPoolId).call()
assert dummyLpPoolInfo[0].lower() == dummyLPToken.lower()
dummyLpAllocPoint = dummyLpPoolInfo[1]
dummyLpTotalSecondRewardRate = (
triPerBlock * dummyLpAllocPoint / (totalAllocPoint * 10**tri_decimals)
)
# Chef V2 calls
chefv2 = init_chefv2()
totalAllocPointV2 = chefv2.functions.totalAllocPoint().call()
### Getting initial prices
wnearUsdRatio = getDexTokenUSDRatio(w3, WNEAR_USDC, WNEAR_ADDRESS)
wethUsdRatio = getDexTokenUSDRatio(w3, WETH_USDC, WETH_ADDRESS)
triUsdRatio = getDexTokenUSDRatio(w3, WNEAR_TRI, TRI_ADDRESS, wnearUsdRatio)
for id, address in V1_POOLS.items():
gccPrint(f"V1 Reached here {address}")
# Chef V1
data.append(
getDataV1Pools(
w3,
id,
address,
chef,
triPerBlock,
totalAllocPoint,
tri_decimals,
triUsdRatio,
wnearUsdRatio,
wethUsdRatio,
)
)
for id, pool in V2_POOLS.items():
gccPrint(f"V2 Reached here {id}: {pool['LP']}")
data.append(
getDataV2Pools(
w3,
id,
pool,
chefv2,
dummyLpTotalSecondRewardRate,
totalAllocPointV2,
triUsdRatio,
wnearUsdRatio,
wethUsdRatio,
)
)
fetched_rewarder_configs = getRewarderConfigs()
for rewarder_config in fetched_rewarder_configs:
id, pool = formatRewarderConfigItem(rewarder_config)
gccPrint(f"Fetched V2 Reached here {id}: {pool['LP']}")
if pool["LPType"] == "StableAMM" and (id in V2_STABLEPOOL_METADATA) is False:
gccPrint(f"Skipping pool ID {id}: ID Not Found in V2_STABLEPOOL_METADATA")
continue
data.append(
getDataV2Pools(
w3,
id,
pool,
chefv2,
dummyLpTotalSecondRewardRate,
totalAllocPointV2,
triUsdRatio,
wnearUsdRatio,
wethUsdRatio,
)
)
# mock_data = [
# {
# "LPToken": "0x22E38A04c14624e6deb66762Dc98E793db2C80Cb",
# "isComplexNRewarder": "true",
# "RewardTokens": [
# "0x8BEc47865aDe3B172A928df8f990Bc7f2A3b9f79",
# "0xc21Ff01229e982d7c8b8691163B0A3Cb8F357453",
# ],
# "Rewarder": "0xB247fA13a9BE90123C4B94982A2b30c60E6182ab",
# "RewarderPriceLPs": [AURORA_WNEAR, META_WNEAR],
# "PoolId": 43,
# }
# ]
# for rewarder_config in mock_data:
# id, pool = formatRewarderConfigItem(rewarder_config)
# gccPrint(f"Mock V2 Reached here {id}: {pool['LP']}")
# data.append(
# getDataV2Pools(
# w3,
# id,
# pool,
# chefv2,
# dummyLpTotalSecondRewardRate,
# totalAllocPointV2,
# triUsdRatio,
# wnearUsdRatio,
# wethUsdRatio,
# )
# )
# print(data)
gccPrint("Ending APR BASE")
return data
if __name__ == "__main__":
apr_base()