Skip to content

Commit dee7761

Browse files
authored
Subgraph workaround (#834)
* whitelist * use contract id * formatting * linter fix * use predictoor contract address
1 parent f7dd233 commit dee7761

File tree

4 files changed

+49
-22
lines changed

4 files changed

+49
-22
lines changed

df_py/predictoor/models.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ def from_query_result(cls, prediction_dict: Dict) -> "Prediction":
3838
ValueError: If the input dictionary is invalid.
3939
"""
4040
try:
41-
contract_addr = prediction_dict["slot"]["predictContract"]["token"]["nft"][
42-
"id"
43-
]
41+
contract_addr = prediction_dict["slot"]["predictContract"]["id"]
4442
slot = int(prediction_dict["slot"]["slot"])
4543
if (
4644
prediction_dict["payout"] is not None

df_py/predictoor/queries.py

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,29 @@
88
from df_py.util.graphutil import submit_query
99
from df_py.util.networkutil import DEV_CHAINID
1010

11+
WHITELIST_FEEDS_MAINNET = [
12+
"0x18f54cc21b7a2fdd011bea06bba7801b280e3151",
13+
"0x2d8e2267779d27c2b3ed5408408ff15d9f3a3152",
14+
"0x30f1c55e72fe105e4a1fbecdff3145fc14177695",
15+
"0x31fabe1fc9887af45b77c7d1e13c5133444ebfbd",
16+
"0x3fb744c3702ff2237fc65f261046ead36656f3bc",
17+
"0x55c6c33514f80b51a1f1b63c8ba229feb132cedb",
18+
"0x74a61f733bd9a2ce40d2e39738fe4912925c06dd",
19+
"0x8165caab33131a4ddbf7dc79f0a8a4920b0b2553",
20+
"0x93f9d558ccde9ea371a20d36bd3ba58c7218b48f",
21+
"0x9c4a2406e5aa0f908d6e816e5318b9fc8a507e1f",
22+
"0xa2d9dbbdf21c30bb3e63d16ba75f644ac11a0cf0",
23+
"0xaa6515c138183303b89b98aea756b54f711710c5",
24+
"0xb1c55346023dee4d8b0d7b10049f0c8854823766",
25+
"0xbe09c6e3f2341a79f74898b8d68c4b5818a2d434",
26+
"0xd41ffee162905b45b65fa6b6e4468599f0490065",
27+
"0xd49cbfd694f4556c00023ddd3559c36af3ae0a80",
28+
"0xe66421fd29fc2d27d0724f161f01b8cbdcd69690",
29+
"0xf28c94c55d8c5e1d70ca3a82744225a4f7570b30",
30+
"0xf8c34175fc1f1d373ec67c4fd1f1ce57c69c3fb3",
31+
"0xfa69b2c1224cebb3b6a36fb5b8c3c419afab08dd",
32+
]
33+
1134

1235
@enforce_types
1336
def key_to_725(key: str):
@@ -116,16 +139,15 @@ def query_predictoor_contracts(chain_id: int) -> Dict[str, PredictContract]:
116139
if len(predictoor_contracts) == 0:
117140
break
118141
for contract in predictoor_contracts:
119-
owner = contract["token"]["nft"]["owner"]["id"]
120-
if chain_id != DEV_CHAINID and owner not in DEPLOYER_ADDRS[chain_id]:
121-
continue
142+
if contract["id"] not in WHITELIST_FEEDS_MAINNET:
143+
owner = contract["token"]["nft"]["owner"]["id"]
144+
if chain_id != DEV_CHAINID and owner not in DEPLOYER_ADDRS[chain_id]:
145+
continue
122146

123-
nft_addr = contract["token"]["nft"]["id"]
124-
info725 = contract["token"]["nft"]["nftData"]
125-
info = info_from_725(info725)
126-
pair = info["pair"]
127-
timeframe = info["timeframe"]
128-
source = info["source"]
147+
nft_addr = contract["id"]
148+
pair = contract["token"]["name"].replace("/", "-")
149+
timeframe = "5m" if int(contract["secondsPerEpoch"]) == 300 else "1h"
150+
source = "binance"
129151

130152
asset_name = f"{pair}-{source}-{timeframe}"
131153

@@ -138,6 +160,8 @@ def query_predictoor_contracts(chain_id: int) -> Dict[str, PredictContract]:
138160
contract["secondsPerSubscription"],
139161
)
140162
contracts_dict[nft_addr] = contract_obj
163+
164+
print(contracts_dict)
141165
return contracts_dict
142166

143167

@@ -214,17 +238,22 @@ def query_predictoors(st_ts: int, end_ts: int, chainID: int) -> Dict[str, Predic
214238
raise AssertionError(result)
215239

216240
predictions = result["data"]["predictPredictions"]
241+
print(len(predictoors))
217242
if len(predictions) == 0:
218243
break
219244

220245
for prediction_dict in predictions:
221-
owner = prediction_dict["slot"]["predictContract"]["token"]["nft"]["owner"][
222-
"id"
223-
]
224-
if chainID != DEV_CHAINID:
225-
if owner not in DEPLOYER_ADDRS[chainID]:
226-
print("noowner", owner, chainID, DEPLOYER_ADDRS)
227-
continue
246+
if (
247+
prediction_dict["slot"]["predictContract"]["id"]
248+
not in WHITELIST_FEEDS_MAINNET
249+
):
250+
owner = prediction_dict["slot"]["predictContract"]["token"]["nft"][
251+
"owner"
252+
]["id"]
253+
if chainID != DEV_CHAINID:
254+
if owner not in DEPLOYER_ADDRS[chainID]:
255+
print("noowner", owner, chainID, DEPLOYER_ADDRS)
256+
continue
228257
predictoor_addr = prediction_dict["user"]["id"]
229258

230259
# 0 - Pending

df_py/predictoor/test/test_predictoor_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_prediction_from_query_result():
6363
assert prediction.payout == 1.23
6464
assert prediction.stake == 0.22352
6565
assert prediction.revenue == prediction.payout - prediction.stake
66-
assert prediction.contract_addr == "0x2"
66+
assert prediction.contract_addr == "0x1"
6767
with pytest.raises(ValueError):
6868
prediction_dict = {"slot": {"predictContract": "0x123"}, "payout": "invalid"}
6969
Prediction.from_query_result(prediction_dict)
@@ -83,7 +83,7 @@ def test_prediction_from_query_result_no_payout():
8383
assert prediction.payout == 0.0
8484
assert prediction.stake == 0.22352
8585
assert prediction.revenue == -0.22352
86-
assert prediction.contract_addr == "0x2"
86+
assert prediction.contract_addr == "0x1"
8787
with pytest.raises(ValueError):
8888
prediction_dict = {"slot": {"predictContract": "0x123"}, "payout": "invalid"}
8989
Prediction.from_query_result(prediction_dict)

df_py/util/dftool_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ def do_dispense_active():
515515

516516
print("Distributing VOLUME DF rewards")
517517
rewards = volume_rewards
518-
elif arguments.PREDICTOOR_ROSE is True:
518+
else:
519519
predictoor_rewards = load_predictoor_rewards_csv(arguments.CSV_DIR)
520520
rewards = aggregate_predictoor_rewards(predictoor_rewards)
521521

0 commit comments

Comments
 (0)