Skip to content
Open
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ target/
# pyenv
.python-version

# poetry
# poetry / python virtual environment
.venv

# pipenv
Expand Down
8 changes: 4 additions & 4 deletions examples/example_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from hyperliquid.info import Info


def setup(base_url=None, skip_ws=False, perp_dexs=None):
config_path = os.path.join(os.path.dirname(__file__), "config.json")
def setup(base_url=None, skip_ws=False, perp_dexs=None, file_name="config.json"):
config_path = os.path.join(os.path.dirname(__file__), file_name)
with open(config_path) as f:
config = json.load(f)
account: LocalAccount = eth_account.Account.from_key(get_secret_key(config))
Expand Down Expand Up @@ -52,8 +52,8 @@ def get_secret_key(config):
return secret_key


def setup_multi_sig_wallets():
config_path = os.path.join(os.path.dirname(__file__), "config.json")
def setup_multi_sig_wallets(file_name="config.json"):
config_path = os.path.join(os.path.dirname(__file__), file_name)
with open(config_path) as f:
config = json.load(f)

Expand Down
52 changes: 52 additions & 0 deletions examples/multi_sig_validator_delist_vote.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import example_utils

from hyperliquid.utils import constants
from hyperliquid.utils.signing import sign_multi_sig_l1_action_payload, get_timestamp_ms

def main():
address, info, exchange = example_utils.setup(constants.TESTNET_API_URL, skip_ws=True, perp_dexs=None, file_name="config.json")
multi_sig_wallets = example_utils.setup_multi_sig_wallets(file_name="config.json")

# The outer signer is required to be an authorized user or an agent of the authorized user of the multi-sig user.

# Address of the multi-sig user that the action will be executed for
# Executing the action requires at least the specified threshold of signatures
# required for that multi-sig user
multi_sig_user = "0x0000000000000000000000000000000000000005"

timestamp = get_timestamp_ms()

# Perp name to delist
prep_name = ""

# Define the multi-sig inner action
action = {
"type": "validatorL1Vote",
"D": prep_name
}

signatures = []

# Collect signatures from each wallet in multi_sig_wallets. Each wallet must belong to a user.
for wallet in multi_sig_wallets:
# Sign the action with each wallet
signature = sign_multi_sig_l1_action_payload(
wallet,
action,
exchange.base_url == constants.MAINNET_API_URL,
None,
timestamp,
exchange.expires_after,
multi_sig_user,
address,
)
signatures.append(signature)

# Execute the multi-sig action with all collected signatures
# This will only succeed if enough valid signatures are provided
multi_sig_result = exchange.multi_sig(multi_sig_user, action, signatures, timestamp)
print(multi_sig_result)


if __name__ == "__main__":
main()