Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/hip-3-pusher/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "hip-3-pusher"
version = "0.2.4"
version = "0.2.5"
description = "Hyperliquid HIP-3 market oracle pusher"
readme = "README.md"
requires-python = "==3.13.*"
Expand Down
84 changes: 84 additions & 0 deletions apps/hip-3-pusher/src/scripts/reserve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import argparse
from pathlib import Path

from eth_account import Account
from hyperliquid.exchange import Exchange
from hyperliquid.utils import constants
from hyperliquid.utils.constants import MAINNET_API_URL
from hyperliquid.utils.signing import get_timestamp_ms, sign_l1_action


def reserve_request_weight(exchange: Exchange, weight: int):
timestamp = get_timestamp_ms()
reserve_action = {
"type": "reserveRequestWeight",
"weight": weight,
}
signature = sign_l1_action(
exchange.wallet,
reserve_action,
exchange.vault_address,
timestamp,
exchange.expires_after,
exchange.base_url == MAINNET_API_URL,
)
return exchange._post_action(
reserve_action,
signature,
timestamp,
)


def main():
parser = argparse.ArgumentParser(
description="Reserve requests for a single account (0.0005 USDC per transaction)"
)
parser.add_argument(
"--private-key-file",
required=True,
help="Path to private key file for account",
)
parser.add_argument(
"--weight",
type=int,
required=True,
help="request weight to reserve",
)
network = parser.add_mutually_exclusive_group(required=True)
network.add_argument(
"--testnet",
action="store_true",
help="Use testnet",
)
network.add_argument(
"--mainnet",
action="store_true",
help="Use mainnet",
)
parser.add_argument(
"--dry-run",
action="store_true",
help="Only show parameters without sending",
)

args = parser.parse_args()

network = "testnet" if args.testnet else "mainnet"
base_url = constants.TESTNET_API_URL if args.testnet else constants.MAINNET_API_URL
print(f"Using {network} URL: {base_url}")

account = Account.from_key(Path(args.private_key_file).read_text().strip())
exchange = Exchange(wallet=account, base_url=base_url)
print("address:", account.address)
weight = args.weight
print("weight:", weight)

if args.dry_run:
print(f"dry run: {network}: would reserve {weight} request weight for account {account.address}")
else:
print("calling reserveRequestWeight...")
print(reserve_request_weight(exchange, weight))


if __name__ == "__main__":
main()
68 changes: 68 additions & 0 deletions apps/hip-3-pusher/src/scripts/send.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import argparse
from pathlib import Path

from eth_account import Account
from hyperliquid.exchange import Exchange
from hyperliquid.utils import constants


def main():
parser = argparse.ArgumentParser(
description="Send USDC from one Hyperliquid account to another (at least 6 to activate new one)"
)
parser.add_argument(
"--private-key-file",
required=True,
help="Path to private key file for account",
)
parser.add_argument(
"--recipient-address",
required=True,
help="Recipient address",
)
parser.add_argument(
"--amount",
type=float,
required=True,
help="Amount to send in USDC",
)
network = parser.add_mutually_exclusive_group(required=True)
network.add_argument(
"--testnet",
action="store_true",
help="Use testnet",
)
network.add_argument(
"--mainnet",
action="store_true",
help="Use mainnet",
)
parser.add_argument(
"--dry-run",
action="store_true",
help="Only show parameters without sending",
)

args = parser.parse_args()

network = "testnet" if args.testnet else "mainnet"
base_url = constants.TESTNET_API_URL if args.testnet else constants.MAINNET_API_URL
print(f"Using {network} URL: {base_url}")

sender_account = Account.from_key(Path(args.private_key_file).read_text().strip())
sender_exchange = Exchange(wallet=sender_account, base_url=base_url)
print("sender address:", sender_account.address)
recipient_address = args.recipient_address
print("recipient address:", recipient_address)
amount = args.amount
print("amount:", amount)

if args.dry_run:
print(f"dry run: {network}: would send {amount} USDC from {sender_account.address} to {recipient_address}")
else:
print("calling usd_transfer...")
print(sender_exchange.usd_transfer(amount=amount, destination=recipient_address))


if __name__ == "__main__":
main()
23 changes: 23 additions & 0 deletions apps/hip-3-pusher/src/scripts/show_address.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import argparse

from eth_account import Account
from pathlib import Path


def main():
parser = argparse.ArgumentParser(
description="Print address of given private key"
)
parser.add_argument(
"--private-key-file",
required=True,
help="Path to private key file",
)

args = parser.parse_args()
account = Account.from_key(Path(args.private_key_file).read_text().strip())
print("address:", account.address)


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion apps/hip-3-pusher/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.