Skip to content

Conversation

@BillyWooo
Copy link
Contributor

Implement sendAsset functionality using proper EIP-712 typed data signing, aligned with the Hyperliquid API and hyperliquid-python-sdk specification.

Key changes:

  • Add SendAsset struct with EIP-712 implementation
  • Implement send_asset() method using sign_typed_data
  • Support all required parameters: destination, sourceDex, destinationDex, token, amount
  • Handle fromSubAccount for vault/subaccount transfers
  • Support mainnet/testnet chain selection
  • Set vault_address to None for sendAsset actions (handled in post method)
  • Add comprehensive tests for signing with mainnet/testnet and vault scenarios

This follows the same pattern as usdClassTransfer, replacing legacy L1 action signing with EIP-712 typed data for proper API compatibility.

Implement sendAsset functionality using proper EIP-712 typed data signing,
aligned with the Hyperliquid API and hyperliquid-python-sdk specification.

Key changes:
- Add SendAsset struct with EIP-712 implementation
- Implement send_asset() method using sign_typed_data
- Support all required parameters: destination, sourceDex, destinationDex, token, amount
- Handle fromSubAccount for vault/subaccount transfers
- Support mainnet/testnet chain selection
- Set vault_address to None for sendAsset actions (handled in post method)
- Add comprehensive tests for signing with mainnet/testnet and vault scenarios

This follows the same pattern as usdClassTransfer, replacing legacy L1 action
signing with EIP-712 typed data for proper API compatibility.

// Build fromSubAccount string (similar to Python SDK)
let from_sub_account = if let Some(vault_addr) = self.vault_address {
format!("{:?}", vault_addr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: `format!("{vault_addr:?}")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this can be written as self.vault_address.map_or(String::new(), format!("{vault_addr:?}")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for your feedback.
It would be nice if you can also review #147 and #148 .

@lmlmt lmlmt merged commit 922844f into hyperliquid-dex:master Oct 20, 2025
@BillyWooo BillyWooo deleted the send_asset branch October 22, 2025 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants