3131 sign_token_delegate_action ,
3232 sign_usd_class_transfer_action ,
3333 sign_usd_transfer_action ,
34+ sign_user_dex_abstraction_action ,
35+ sign_user_set_abstraction_action ,
3436 sign_withdraw_from_bridge_action ,
3537)
3638from hyperliquid .utils .types import (
39+ Abstraction ,
40+ AgentAbstraction ,
3741 Any ,
3842 BuilderInfo ,
3943 Cloid ,
@@ -1089,67 +1093,37 @@ def multi_sig(self, multi_sig_user, inner_action, signatures, nonce, vault_addre
10891093 signature ,
10901094 nonce ,
10911095 )
1092-
1093- def enable_user_dex_abstraction (self , enabled : bool ) -> Any :
1094- """
1095- Enable or disable HIP-3 DEX abstraction.
10961096
1097- If set, actions on HIP-3 perps will automatically transfer collateral from
1098- validator-operated USDC perps balance for HIP-3 DEXs where USDC is the collateral token,
1099- and spot otherwise.
1100- """
1097+ def use_big_blocks (self , enable : bool ) -> Any :
11011098 timestamp = get_timestamp_ms ()
1102- is_mainnet = self .base_url == MAINNET_API_URL
1103-
1104- # Determine Chain IDs and Names based on environment
1105- # Mainnet -> Arbitrum One (42161 -> 0xa4b1)
1106- # Testnet -> Arbitrum Sepolia (421614 -> 0x66eee)
1107- signature_chain_id = "0xa4b1" if is_mainnet else "0x66eee"
1108- hyperliquid_chain = "Mainnet" if is_mainnet else "Testnet"
1109-
1110- # Determine the target user address
1111- # Priority: Vault Address (Sub-account) > Account Address > Wallet Address
1112- user_address = self .wallet .address
1113- if self .account_address :
1114- user_address = self .account_address
1115- if self .vault_address :
1116- user_address = self .vault_address
1117-
11181099 action = {
1119- "type" : "userDexAbstraction" ,
1120- "hyperliquidChain" : hyperliquid_chain ,
1121- "signatureChainId" : signature_chain_id ,
1122- "user" : user_address ,
1123- "enabled" : enabled ,
1124- "nonce" : timestamp ,
1100+ "type" : "evmUserModify" ,
1101+ "usingBigBlocks" : enable ,
11251102 }
1126-
1127- # Sign the action
11281103 signature = sign_l1_action (
11291104 self .wallet ,
11301105 action ,
1131- None ,
1106+ None ,
11321107 timestamp ,
11331108 self .expires_after ,
1134- is_mainnet ,
1109+ self . base_url == MAINNET_API_URL ,
11351110 )
1136-
11371111 return self ._post_action (
11381112 action ,
11391113 signature ,
11401114 timestamp ,
11411115 )
1142-
1143- def use_big_blocks (self , enable : bool ) -> Any :
1116+
1117+ def agent_set_abstraction (self , abstraction : AgentAbstraction ) -> Any :
11441118 timestamp = get_timestamp_ms ()
11451119 action = {
1146- "type" : "evmUserModify " ,
1147- "usingBigBlocks " : enable ,
1120+ "type" : "agentSetAbstraction " ,
1121+ "abstraction " : abstraction ,
11481122 }
11491123 signature = sign_l1_action (
11501124 self .wallet ,
11511125 action ,
1152- None ,
1126+ self . vault_address ,
11531127 timestamp ,
11541128 self .expires_after ,
11551129 self .base_url == MAINNET_API_URL ,
@@ -1160,6 +1134,36 @@ def use_big_blocks(self, enable: bool) -> Any:
11601134 timestamp ,
11611135 )
11621136
1137+ def user_dex_abstraction (self , user : str , enabled : bool ) -> Any :
1138+ timestamp = get_timestamp_ms ()
1139+ action = {
1140+ "type" : "userDexAbstraction" ,
1141+ "user" : user .lower (),
1142+ "enabled" : enabled ,
1143+ "nonce" : timestamp ,
1144+ }
1145+ signature = sign_user_dex_abstraction_action (self .wallet , action , self .base_url == MAINNET_API_URL )
1146+ return self ._post_action (
1147+ action ,
1148+ signature ,
1149+ timestamp ,
1150+ )
1151+
1152+ def user_set_abstraction (self , user : str , abstraction : Abstraction ) -> Any :
1153+ timestamp = get_timestamp_ms ()
1154+ action = {
1155+ "type" : "userSetAbstraction" ,
1156+ "user" : user .lower (),
1157+ "abstraction" : abstraction ,
1158+ "nonce" : timestamp ,
1159+ }
1160+ signature = sign_user_set_abstraction_action (self .wallet , action , self .base_url == MAINNET_API_URL )
1161+ return self ._post_action (
1162+ action ,
1163+ signature ,
1164+ timestamp ,
1165+ )
1166+
11631167 def noop (self , nonce ):
11641168 action = {"type" : "noop" }
11651169 signature = sign_l1_action (
0 commit comments