File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
apps/hip-3-pusher/src/pusher Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 1
- from pydantic import BaseModel , Field
1
+ from hyperliquid .utils .constants import MAINNET_API_URL , TESTNET_API_URL
2
+ from pydantic import BaseModel , model_validator
2
3
from typing import Optional
3
4
4
5
STALE_TIMEOUT_SECONDS = 5
@@ -28,14 +29,20 @@ class HermesConfig(BaseModel):
28
29
29
30
class HyperliquidConfig (BaseModel ):
30
31
hyperliquid_ws_urls : list [str ]
31
- backup_push_urls : Optional [list [str ]] = Field ( default_factory = list )
32
+ push_urls : Optional [list [str ]] = None
32
33
market_name : str
33
34
market_symbol : str
34
35
use_testnet : bool
35
36
oracle_pusher_key_path : str
36
37
publish_interval : float
37
38
enable_publish : bool
38
39
40
+ @model_validator (mode = "after" )
41
+ def set_default_urls (self ):
42
+ if self .push_urls is None :
43
+ self .push_urls = [TESTNET_API_URL ] if self .use_testnet else [MAINNET_API_URL ]
44
+ return self
45
+
39
46
40
47
class Config (BaseModel ):
41
48
stale_price_threshold_seconds : int
Original file line number Diff line number Diff line change 5
5
from eth_account import Account
6
6
from eth_account .signers .local import LocalAccount
7
7
from hyperliquid .exchange import Exchange
8
- from hyperliquid .utils .constants import TESTNET_API_URL , MAINNET_API_URL
9
8
10
9
from pusher .config import Config
11
10
from pusher .kms_signer import KMSSigner
@@ -22,7 +21,7 @@ class Publisher:
22
21
def __init__ (self , config : Config , price_state : PriceState , metrics : Metrics ):
23
22
self .publish_interval = float (config .hyperliquid .publish_interval )
24
23
self .use_testnet = config .hyperliquid .use_testnet
25
- self .push_urls = [ TESTNET_API_URL if self . use_testnet else MAINNET_API_URL ] + config .hyperliquid .backup_push_urls
24
+ self .push_urls = config .hyperliquid .push_urls
26
25
27
26
self .kms_signer = None
28
27
self .enable_kms = False
You can’t perform that action at this time.
0 commit comments