Skip to content

Commit 2be9c23

Browse files
authored
Sample config and more utility scripts (#3321)
1 parent 9825470 commit 2be9c23

File tree

5 files changed

+237
-43
lines changed

5 files changed

+237
-43
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
stale_price_threshold_seconds = 5
2+
prometheus_port = 9090
3+
4+
[hyperliquid]
5+
hyperliquid_ws_urls = ["wss://api.hyperliquid-testnet.xyz/ws"]
6+
market_name = "pyth"
7+
asset_context_symbols = ["BTC", "pyth:BTC", "pyth:PYTH", "pyth:FOGO"]
8+
use_testnet = true
9+
oracle_pusher_key_path = "oracle-updater-subdeployer-private-key.txt"
10+
publish_interval = 3.0
11+
publish_timeout = 5.0
12+
enable_publish = true
13+
14+
[multisig]
15+
enable_multisig = false
16+
17+
[kms]
18+
enable_kms = false
19+
20+
[lazer]
21+
lazer_urls = ["wss://pyth-lazer-0.dourolabs.app/v1/stream", "wss://pyth-lazer-1.dourolabs.app/v1/stream"]
22+
lazer_api_key = "<some lazer api key>"
23+
feed_ids = [1, 3, 8] # BTC, PYTH, USDT
24+
exponents = [-8, -8, -8]
25+
26+
[hermes]
27+
hermes_urls = ["wss://hermes.pyth.network/ws"]
28+
feed_ids = [
29+
"e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43", # BTC
30+
"0bbf28e9a841a1cc788f6a361b17ca072d0ea3098a1e5df1c3922d06719579ff", # PYTH
31+
"2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b" # USDT
32+
]
33+
exponents = [-8, -8, -8]
34+
35+
[seda]
36+
url = "https://fast-api.testnet.seda.xyz/execute"
37+
poll_interval = 2
38+
poll_failure_interval = 1
39+
poll_timeout = 3
40+
41+
[price.oracle]
42+
BTC = [
43+
{ source_type = "single", source = { source_name = "hl_oracle", source_id = "BTC" } },
44+
{ source_type = "pair", base_source = { source_name = "lazer", source_id = 1, exponent = -8 }, quote_source = { source_name = "lazer", source_id = 8, exponent = -8 } },
45+
{ source_type = "pair", base_source = { source_name = "hermes", source_id = "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43", exponent = -8 }, quote_source = { source_name = "hermes", source_id = "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b", exponent = -8 } },
46+
]
47+
PYTH = [
48+
{ source_type = "pair", base_source = { source_name = "lazer", source_id = 3, exponent = -8 }, quote_source = { source_name = "lazer", source_id = 8, exponent = -8 } },
49+
{ source_type = "pair", base_source = { source_name = "hermes", source_id = "0bbf28e9a841a1cc788f6a361b17ca072d0ea3098a1e5df1c3922d06719579ff", exponent = -8 }, quote_source = { source_name = "hermes", source_id = "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b", exponent = -8 } },
50+
]
51+
FOGO = [{ source_type = "constant", value = "0.0100" }]
52+
53+
[price.mark]
54+
BTC = [{ source_type = "oracle_mid_average", symbol = "pyth:BTC" }]
55+
PYTH = [{ source_type = "oracle_mid_average", symbol = "pyth:PYTH" }]
56+
FOGO = [{ source_type = "oracle_mid_average", symbol = "pyth:FOGO" }]
57+
58+
[price.external]
59+
BTC = [{ source_type = "single", source = { source_name = "hl_mark", source_id = "BTC" } }]
60+
PYTH = [{ source_type = "constant", value = "0.10" },]
61+
FOGO = [{ source_type = "constant", value = "0.0100" },]

apps/hip-3-pusher/config/config.sample.toml

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import argparse
2+
3+
from eth_account import Account
4+
5+
6+
def main():
7+
parser = argparse.ArgumentParser(
8+
description="Create new key"
9+
)
10+
output = parser.add_mutually_exclusive_group(required=True)
11+
output.add_argument(
12+
"--output-file",
13+
metavar="PATH",
14+
help="Write the private key (in hex) to a file",
15+
)
16+
output.add_argument(
17+
"--stdout",
18+
action="store_true",
19+
help="Print the private key to stdout",
20+
)
21+
22+
args = parser.parse_args()
23+
account = Account.create()
24+
print("address:", account.address)
25+
private_key_hex = account.key.hex()
26+
if args.stdout:
27+
print("private key:", private_key_hex)
28+
else:
29+
open(args.output_file, "w").write(private_key_hex)
30+
print("wrote private key to file:", args.output_file)
31+
32+
33+
if __name__ == "__main__":
34+
main()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import argparse
2+
3+
from hyperliquid.info import Info
4+
from hyperliquid.utils import constants
5+
6+
7+
def main():
8+
parser = argparse.ArgumentParser(
9+
description="Check user rate limit"
10+
)
11+
parser.add_argument(
12+
"--address",
13+
required=True,
14+
help="Address",
15+
)
16+
network = parser.add_mutually_exclusive_group(required=True)
17+
network.add_argument(
18+
"--testnet",
19+
action="store_true",
20+
help="Use testnet",
21+
)
22+
network.add_argument(
23+
"--mainnet",
24+
action="store_true",
25+
help="Use mainnet",
26+
)
27+
28+
args = parser.parse_args()
29+
30+
network = "testnet" if args.testnet else "mainnet"
31+
base_url = constants.TESTNET_API_URL if args.testnet else constants.MAINNET_API_URL
32+
print(f"Using {network} URL: {base_url}")
33+
print("address:", args.address)
34+
35+
info = Info(base_url=base_url, skip_ws=True)
36+
print("calling userRateLimit...")
37+
print(info.user_rate_limit(args.address))
38+
39+
40+
if __name__ == "__main__":
41+
main()
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import argparse
2+
from pathlib import Path
3+
4+
from eth_account import Account
5+
from hyperliquid.exchange import Exchange
6+
from hyperliquid.utils import constants
7+
from hyperliquid.utils.signing import get_timestamp_ms, sign_l1_action
8+
9+
10+
def main():
11+
parser = argparse.ArgumentParser(
12+
description="Permission/depermission subdeployer account for setOracle for HIP-3 dex"
13+
)
14+
parser.add_argument(
15+
"--private-key-file",
16+
required=True,
17+
help="Path to private key file for deployer account",
18+
)
19+
parser.add_argument(
20+
"--dex",
21+
required=True,
22+
help="HIP-3 dex name (should be short string)"
23+
)
24+
parser.add_argument(
25+
"--subdeployer-address",
26+
required=True,
27+
help="Subdeployer address",
28+
)
29+
enable_disable = parser.add_mutually_exclusive_group(required=True)
30+
enable_disable.add_argument(
31+
"--enable",
32+
action="store_true",
33+
help="Enable subdeployer for setOracle",
34+
)
35+
enable_disable.add_argument(
36+
"--disable",
37+
action="store_true",
38+
help="Disable subdeployer for setOracle",
39+
)
40+
network = parser.add_mutually_exclusive_group(required=True)
41+
network.add_argument(
42+
"--testnet",
43+
action="store_true",
44+
help="Use testnet",
45+
)
46+
network.add_argument(
47+
"--mainnet",
48+
action="store_true",
49+
help="Use mainnet",
50+
)
51+
parser.add_argument(
52+
"--dry-run",
53+
action="store_true",
54+
help="Only show parameters without sending",
55+
)
56+
57+
args = parser.parse_args()
58+
59+
network = "testnet" if args.testnet else "mainnet"
60+
base_url = constants.TESTNET_API_URL if args.testnet else constants.MAINNET_API_URL
61+
print(f"Using {network} URL: {base_url}")
62+
63+
deployer_account = Account.from_key(Path(args.private_key_file).read_text().strip())
64+
deployer_exchange = Exchange(wallet=deployer_account, base_url=base_url)
65+
print("deployer address:", deployer_account.address)
66+
subdeployer_address = args.subdeployer_address
67+
print("dex:", args.dex)
68+
print("subdeployer address:", subdeployer_address)
69+
mode = "enable" if args.enable else "disable"
70+
print("mode:", mode)
71+
72+
if args.dry_run:
73+
print(f"dry run: {network}: would {mode} setOracle for {subdeployer_address} in dex {args.dex}")
74+
else:
75+
timestamp = get_timestamp_ms()
76+
sub_deployer = {
77+
"variant": "setOracle",
78+
"user": subdeployer_address.lower(),
79+
"allowed": True if args.enable else False,
80+
}
81+
action = {
82+
"type": "perpDeploy",
83+
"setSubDeployers": {
84+
"dex": args.dex,
85+
"subDeployers": [sub_deployer]
86+
}
87+
}
88+
signature = sign_l1_action(
89+
deployer_exchange.wallet,
90+
action,
91+
deployer_exchange.vault_address,
92+
timestamp,
93+
deployer_exchange.expires_after,
94+
deployer_exchange.base_url == constants.MAINNET_API_URL,
95+
)
96+
print("calling perpDeploy.setSubdeployers...")
97+
print(deployer_exchange._post_action(action, signature, timestamp))
98+
99+
100+
if __name__ == "__main__":
101+
main()

0 commit comments

Comments
 (0)