From 1bffc8e022b2401430876fb95a2aab4bc57c6f0d Mon Sep 17 00:00:00 2001 From: BillyWooo Date: Wed, 22 Oct 2025 17:34:18 +0200 Subject: [PATCH 1/2] use new sdk branch --- tee-worker/omni-executor/Cargo.lock | 2 +- tee-worker/omni-executor/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tee-worker/omni-executor/Cargo.lock b/tee-worker/omni-executor/Cargo.lock index 54e5472deb..ab1b755208 100644 --- a/tee-worker/omni-executor/Cargo.lock +++ b/tee-worker/omni-executor/Cargo.lock @@ -5293,7 +5293,7 @@ dependencies = [ [[package]] name = "hyperliquid_rust_sdk" version = "0.6.0" -source = "git+https://github.com/BillyWooo/hyperliquid-rust-sdk?branch=usdClassTransfer_sendAsset#74973595c6ad81d2539356dc813592b450c7eb54" +source = "git+https://github.com/BillyWooo/hyperliquid-rust-sdk?branch=fork_new_feature#aa6887692561dce5bf2187d401d543c3c921add3" dependencies = [ "alloy", "chrono", diff --git a/tee-worker/omni-executor/Cargo.toml b/tee-worker/omni-executor/Cargo.toml index 1bd7ea0126..849b228659 100644 --- a/tee-worker/omni-executor/Cargo.toml +++ b/tee-worker/omni-executor/Cargo.toml @@ -58,7 +58,7 @@ hex = "0.4" hex-literal = "0.4" hmac = "0.12.1" http = "1.3.1" -hyperliquid_rust_sdk = { git = "https://github.com/BillyWooo/hyperliquid-rust-sdk", branch = "usdClassTransfer_sendAsset" } +hyperliquid_rust_sdk = { git = "https://github.com/BillyWooo/hyperliquid-rust-sdk", branch = "fork_new_feature" } jsonrpsee = { version = "0.24.9", features = ["server"] } jsonwebtoken = "9.3.0" libsecp256k1 = "0.7.1" From 4a4e91e360331c949cb009f75d94cd55f16a1416 Mon Sep 17 00:00:00 2001 From: BillyWooo Date: Wed, 22 Oct 2025 20:01:51 +0200 Subject: [PATCH 2/2] extend HyperliquidAction with UserDexAbstraction variant Add support for the UserDexAbstraction action type in the Hyperliquid signature data generation. Changes: - Import UserDexAbstraction from hyperliquid-rust-sdk - Add UserDexAbstraction variant to HyperliquidActionType enum with user address and enabled flag - Add UserDexAbstraction variant to HyperliquidAction enum - Implement handling logic with address validation and EIP-712 signature generation - Add comprehensive unit tests for signature generation and JSON deserialization This extends the existing Hyperliquid action support to enable DEX abstraction functionality, following the same pattern as ApproveAgent, Withdraw3, ApproveBuilderFee, and SendAsset. --- .../omni/get_hyperliquid_signature_data.rs | 71 ++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/tee-worker/omni-executor/rpc-server/src/methods/omni/get_hyperliquid_signature_data.rs b/tee-worker/omni-executor/rpc-server/src/methods/omni/get_hyperliquid_signature_data.rs index 677f4b66e6..28ea0ca5ef 100644 --- a/tee-worker/omni-executor/rpc-server/src/methods/omni/get_hyperliquid_signature_data.rs +++ b/tee-worker/omni-executor/rpc-server/src/methods/omni/get_hyperliquid_signature_data.rs @@ -11,7 +11,9 @@ use executor_core::intent_executor::IntentExecutor; use executor_primitives::{ to_omni_auth, utils::hex::hex_encode, ChainId, ClientAuth, Identity, UserAuth, UserId, }; -use hyperliquid_rust_sdk::{ApproveAgent, ApproveBuilderFee, Eip712, SendAsset, Withdraw3}; +use hyperliquid_rust_sdk::{ + ApproveAgent, ApproveBuilderFee, Eip712, SendAsset, UserDexAbstraction, Withdraw3, +}; use jsonrpsee::{types::ErrorObject, RpcModule}; use pumpx::pubkey_to_address; use serde::{Deserialize, Serialize}; @@ -52,6 +54,10 @@ pub enum HyperliquidActionType { amount: String, from_sub_account: String, }, + UserDexAbstraction { + user: String, + enabled: bool, + }, } #[derive(Serialize, Clone)] @@ -74,6 +80,7 @@ pub enum HyperliquidAction { Withdraw3(Withdraw3), ApproveBuilderFee(ApproveBuilderFee), SendAsset(SendAsset), + UserDexAbstraction(UserDexAbstraction), } fn is_testnet_chain(chain_id: ChainId) -> bool { @@ -347,6 +354,19 @@ pub fn register_get_hyperliquid_signature_data< generate_eip712_signature(&ctx, &action, omni_account.as_ref()).await?; (HyperliquidAction::SendAsset(action), signature) }, + HyperliquidActionType::UserDexAbstraction { user, enabled } => { + let action = UserDexAbstraction { + signature_chain_id: params.chain_id, + hyperliquid_chain, + user: validate_ethereum_address(&user, "user") + .map_err(|e| e.to_error_object())?, + enabled, + nonce, + }; + let signature = + generate_eip712_signature(&ctx, &action, omni_account.as_ref()).await?; + (HyperliquidAction::UserDexAbstraction(action), signature) + }, }; Ok(GetHyperliquidSignatureDataResponse { @@ -650,6 +670,55 @@ mod tests { )); } + #[test] + fn test_user_dex_abstraction_action_signature() { + let action = UserDexAbstraction { + signature_chain_id: 1, + hyperliquid_chain: "Mainnet".to_string(), + user: Address::from_str("0x1234567890123456789012345678901234567890").unwrap(), + enabled: true, + nonce: 1234567890, + }; + + // Test domain generation + let domain = action.domain(); + assert_eq!(domain.name, Some("HyperliquidSignTransaction".into())); + assert_eq!(domain.version, Some("1".into())); + assert_eq!(domain.chain_id, Some(alloy::primitives::U256::from(1))); + + // Test struct hash generation + let struct_hash = action.struct_hash(); + assert_eq!(struct_hash.len(), 32); + + // Test EIP-712 signing hash generation + let signing_hash = action.eip712_signing_hash(); + assert_eq!(signing_hash.len(), 32); + } + + #[test] + fn test_params_deserialization_user_dex_abstraction() { + let json = r#"{ + "user_id": {"type": "email", "value": "test@example.com"}, + "user_auth": {"type": "email", "value": "123456"}, + "client_id": "test_client", + "action_type": { + "type": "user_dex_abstraction", + "user": "0x742d35Cc6634C0532925a3b844Bc9e7595f02A10", + "enabled": true + }, + "chain_id": 42161 + }"#; + + let params: GetHyperliquidSignatureDataParams = serde_json::from_str(json).unwrap(); + + assert!(matches!( + params.action_type, + HyperliquidActionType::UserDexAbstraction { user, enabled } + if user == "0x742d35Cc6634C0532925a3b844Bc9e7595f02A10" && enabled == true + )); + assert_eq!(params.chain_id, 42161); + } + #[test] fn test_is_testnet_chain() { // Test mainnet chain IDs