Skip to content

Commit 761f60b

Browse files
fix: script subgraph endpoints
1 parent 5e9dd19 commit 761f60b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

trades.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
"""This script queries the OMEN subgraph to obtain the trades of a given address."""
2222

2323
import datetime
24+
import os
2425
import re
2526
from argparse import Action, ArgumentError, ArgumentParser, Namespace
2627
from collections import defaultdict
28+
from dotenv import load_dotenv
2729
from enum import Enum
2830
from pathlib import Path
2931
from string import Template
@@ -57,12 +59,16 @@
5759
SCRIPT_PATH = Path(__file__).resolve().parent
5860
STORE_PATH = Path(SCRIPT_PATH, ".trader_runner")
5961
RPC_PATH = Path(STORE_PATH, "rpc.txt")
62+
ENV_FILE = Path(STORE_PATH, ".env")
6063
WXDAI_CONTRACT_ADDRESS = "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d"
6164
SCRIPT_PATH = Path(__file__).resolve().parent
6265
STORE_PATH = Path(SCRIPT_PATH, ".trader_runner")
6366
SAFE_ADDRESS_PATH = Path(STORE_PATH, "service_safe_address.txt")
6467

6568

69+
load_dotenv(ENV_FILE)
70+
71+
6672
headers = {
6773
"Accept": "application/json, multipart/mixed",
6874
"Content-Type": "application/json",
@@ -323,7 +329,8 @@ def _query_omen_xdai_subgraph( # pylint: disable=too-many-locals
323329
fpmm_to_timestamp: float = DEFAULT_TO_TIMESTAMP,
324330
) -> Dict[str, Any]:
325331
"""Query the subgraph."""
326-
url = "https://api.thegraph.com/subgraphs/name/protofire/omen-xdai"
332+
subgraph_api_key = os.getenv('SUBGRAPH_API_KEY')
333+
url = f"https://gateway-arbitrum.network.thegraph.com/api/{subgraph_api_key}/subgraphs/id/9fUVQpFwzpdWS9bq5WkAnmKbNNcoBwatMR4yZq81pbbz"
327334

328335
grouped_results = defaultdict(list)
329336
creationTimestamp_gt = "0"
@@ -368,7 +375,8 @@ def _query_omen_xdai_subgraph( # pylint: disable=too-many-locals
368375

369376
def _query_conditional_tokens_gc_subgraph(creator: str) -> Dict[str, Any]:
370377
"""Query the subgraph."""
371-
url = "https://api.thegraph.com/subgraphs/name/gnosis/conditional-tokens-gc"
378+
subgraph_api_key = os.getenv('SUBGRAPH_API_KEY')
379+
url = f"https://gateway-arbitrum.network.thegraph.com/api/{subgraph_api_key}/subgraphs/id/7s9rGBffUTL8kDZuxvvpuc46v44iuDarbrADBFw5uVp2"
372380

373381
all_results: Dict[str, Any] = {"data": {"user": {"userPositions": []}}}
374382
userPositions_id_gt = ""

0 commit comments

Comments
 (0)