1- use anyhow:: { Result , Context } ;
1+ use anyhow:: { Context , Result } ;
22use colored:: Colorize ;
33use serde_json:: json;
44
55use crate :: config;
66use crate :: signing;
77
88/// Spot limit buy — price is the maximum price you'll pay per unit
9- pub async fn buy ( symbol : & str , amount_usdc : & str , max_price : & str , json_output : bool ) -> Result < ( ) > {
9+ pub async fn buy (
10+ symbol : & str ,
11+ amount_usdc : & str ,
12+ max_price : & str ,
13+ json_output : bool ,
14+ ) -> Result < ( ) > {
1015 let cfg = config:: load_hl_config ( ) ?;
1116 let symbol = symbol. to_uppercase ( ) ;
1217 let price_f: f64 = max_price. parse ( ) . context ( "Invalid max price" ) ?;
@@ -15,12 +20,15 @@ pub async fn buy(symbol: &str, amount_usdc: &str, max_price: &str, json_output:
1520
1621 if !json_output {
1722 println ! ( ) ;
18- println ! ( " {} Placing spot limit BUY" , "📝 ") ;
23+ println ! ( " 📝 Placing spot limit BUY" ) ;
1924 println ! ( " Symbol: {}" , symbol. cyan( ) ) ;
2025 println ! ( " Size: {:.6}" , size) ;
2126 println ! ( " Max Price: ${}" , max_price) ;
2227 println ! ( " Total: ${}" , amount_usdc) ;
23- println ! ( " Network: {}" , if cfg. testnet { "Testnet" } else { "Mainnet" } ) ;
28+ println ! (
29+ " Network: {}" ,
30+ if cfg. testnet { "Testnet" } else { "Mainnet" }
31+ ) ;
2432 println ! ( ) ;
2533 }
2634
@@ -41,11 +49,11 @@ pub async fn buy(symbol: &str, amount_usdc: &str, max_price: &str, json_output:
4149 } else {
4250 match result {
4351 hyperliquid_rust_sdk:: ExchangeResponseStatus :: Ok ( data) => {
44- println ! ( " {} Spot buy order placed!" , "✅" . green ( ) ) ;
52+ println ! ( " ✅ Spot buy order placed!" ) ;
4553 println ! ( " Response: {:?}" , data) ;
4654 }
4755 hyperliquid_rust_sdk:: ExchangeResponseStatus :: Err ( e) => {
48- println ! ( " {} Order failed: {}" , "❌" . red ( ) , e) ;
56+ println ! ( " ❌ Order failed: {}" , e) ;
4957 }
5058 }
5159 println ! ( ) ;
@@ -63,11 +71,14 @@ pub async fn sell(symbol: &str, amount: &str, min_price: &str, json_output: bool
6371
6472 if !json_output {
6573 println ! ( ) ;
66- println ! ( " {} Placing spot limit SELL" , "📝 ") ;
74+ println ! ( " 📝 Placing spot limit SELL" ) ;
6775 println ! ( " Symbol: {}" , symbol. cyan( ) ) ;
6876 println ! ( " Size: {}" , amount) ;
6977 println ! ( " Min Price: ${}" , min_price) ;
70- println ! ( " Network: {}" , if cfg. testnet { "Testnet" } else { "Mainnet" } ) ;
78+ println ! (
79+ " Network: {}" ,
80+ if cfg. testnet { "Testnet" } else { "Mainnet" }
81+ ) ;
7182 println ! ( ) ;
7283 }
7384
@@ -87,11 +98,11 @@ pub async fn sell(symbol: &str, amount: &str, min_price: &str, json_output: bool
8798 } else {
8899 match result {
89100 hyperliquid_rust_sdk:: ExchangeResponseStatus :: Ok ( data) => {
90- println ! ( " {} Spot sell order placed!" , "✅" . green ( ) ) ;
101+ println ! ( " ✅ Spot sell order placed!" ) ;
91102 println ! ( " Response: {:?}" , data) ;
92103 }
93104 hyperliquid_rust_sdk:: ExchangeResponseStatus :: Err ( e) => {
94- println ! ( " {} Order failed: {}" , "❌" . red ( ) , e) ;
105+ println ! ( " ❌ Order failed: {}" , e) ;
95106 }
96107 }
97108 println ! ( ) ;
0 commit comments