pub struct Exchange {
pub client: Client,
pub chain: Chain,
}
Expand description
Endpoint to interact with and trade on the Hyperliquid chain.
Fields§
§client: Client
§chain: Chain
Implementations§
Source§impl Exchange
impl Exchange
Sourcepub async fn place_order(
&self,
wallet: Arc<LocalWallet>,
orders: Vec<OrderRequest>,
vault_address: Option<Address>,
) -> Result<Response>
pub async fn place_order( &self, wallet: Arc<LocalWallet>, orders: Vec<OrderRequest>, vault_address: Option<Address>, ) -> Result<Response>
Place an order
§Arguments
wallet
- The wallet to sign the order withorders
- The orders to placevault_address
- If trading on behalf of a vault, its onchain address in 42-character hexadecimal format e.g.0x0000000000000000000000000000000000000000
§Note
cloid
in argumentorder
is an optional 128 bit hex string, e.g.0x1234567890abcdef1234567890abcdef
Examples found in repository?
168async fn order_status(info: &Info, exchange: &Exchange, wallet: Arc<LocalWallet>) {
169 let user = wallet.address();
170 let vault_address = None;
171 let cloid = Uuid::new_v4();
172 let order = OrderRequest {
173 asset: 4,
174 is_buy: true,
175 reduce_only: false,
176 limit_px: parse_price(2800.0),
177 sz: parse_size(0.0331, 4),
178 order_type: OrderType::Limit(Limit { tif: Tif::Gtc }),
179 cloid: Some(cloid),
180 };
181
182 println!("Placing order with cloid: {}{SEP}", cloid.simple());
183 let response = exchange
184 .place_order(wallet, vec![order], vault_address)
185 .await
186 .expect("Failed to place order");
187
188 println!("Response: {:?}", response);
189
190 tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;
191
192 let order_status = info.order_status(user, Oid::Cloid(cloid)).await.unwrap();
193
194 println!(
195 "Order status for {} \n{:?}{SEP}",
196 cloid.simple(),
197 order_status
198 );
199}
More examples
20async fn main() {
21 // Key was randomly generated for testing and shouldn't be used with any real funds
22 let wallet: Arc<LocalWallet> = Arc::new(
23 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
24 .parse()
25 .unwrap(),
26 );
27
28 let exchange: Exchange = Hyperliquid::new(Chain::ArbitrumTestnet);
29
30 // Create a new wallet with the agent. This agent can't transfer or withdraw funds
31 // but can place orders.
32
33 let agent = Arc::new(LocalWallet::new(&mut thread_rng()));
34
35 let agent_address = agent.address();
36
37 println!("Agent address: {:?}", agent_address);
38
39 let res = exchange
40 .approve_agent(wallet.clone(), agent_address, Some("WETH".to_string()))
41 .await
42 .unwrap();
43
44 println!("Response: {:?}", res);
45
46 // place order with agent
47 let order_type = OrderType::Limit(Limit { tif: Tif::Gtc });
48 let order = OrderRequest {
49 asset: 4,
50 is_buy: true,
51 reduce_only: false,
52 limit_px: "1700".to_string(),
53 sz: "0.1".to_string(),
54 order_type,
55 cloid: None,
56 };
57 let vault_address = None;
58
59 println!("Placing order with agent...");
60
61 let response = exchange
62 .place_order(agent.clone(), vec![order], vault_address)
63 .await
64 .expect("Failed to place order");
65
66 println!("Response: {:?}", response);
67}
17async fn main() {
18 // Key was randomly generated for testing and shouldn't be used with any real funds
19 let wallet: Arc<LocalWallet> = Arc::new(
20 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
21 .parse()
22 .unwrap(),
23 );
24
25 let exchange: Exchange = Hyperliquid::new(Chain::Dev);
26 let info: Info = Hyperliquid::new(Chain::Dev);
27
28 let asset = 4;
29 let sz_decimals = 4;
30
31 let order_type = OrderType::Limit(Limit { tif: Tif::Gtc });
32
33 let order = OrderRequest {
34 asset,
35 is_buy: true,
36 reduce_only: false,
37 limit_px: parse_price(2800.0),
38 sz: parse_size(0.0331, sz_decimals),
39 order_type,
40 cloid: None,
41 };
42
43 let vault_address = None;
44
45 println!("Placing order...");
46 let response = exchange
47 .place_order(wallet.clone(), vec![order], vault_address)
48 .await
49 .expect("Failed to place order");
50
51 let response = match response {
52 Response::Ok(order) => order,
53 Response::Err(error) => panic!("Failed to place order: {:?}", error),
54 };
55
56 println!("Response: {:?}", response.data);
57
58 let status_type = &response.data.unwrap();
59
60 let status = match status_type {
61 StatusType::Statuses(statuses) => &statuses[0],
62 _ => {
63 panic!("Failed to place order: {:?}", status_type);
64 }
65 };
66
67 let oid = match status {
68 Status::Filled(order) => order.oid,
69 Status::Resting(order) => order.oid,
70 _ => panic!("Order is not filled or resting"),
71 };
72
73 println!("-----------------");
74
75 println!("Fetching order {} status...", oid);
76
77 let status = info
78 .order_status(wallet.address(), Oid::Order(oid))
79 .await
80 .expect("Failed to fetch order status");
81
82 println!("Order status: {:#?}", status.order);
83}
17async fn main() {
18 // Key was randomly generated for testing and shouldn't be used with any real funds
19 let wallet: Arc<LocalWallet> = Arc::new(
20 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
21 .parse()
22 .unwrap(),
23 );
24
25 let exchange: Exchange = Hyperliquid::new(Chain::Dev);
26
27 let order_type = OrderType::Limit(Limit { tif: Tif::Gtc });
28 let cloid = Uuid::new_v4();
29
30 let order = OrderRequest {
31 asset: 4,
32 is_buy: true,
33 reduce_only: false,
34 limit_px: "1800".to_string(),
35 sz: "0.1".to_string(),
36 order_type,
37 cloid: Some(cloid),
38 };
39
40 let vault_address = None;
41
42 println!("Placing order...");
43 let response = exchange
44 .place_order(wallet.clone(), vec![order], vault_address)
45 .await
46 .expect("Failed to place order");
47
48 let response = match response {
49 Response::Ok(order) => order,
50 Response::Err(error) => panic!("Failed to place order: {:?}", error),
51 };
52
53 let status_type = &response.data.unwrap();
54
55 let status = match status_type {
56 StatusType::Statuses(statuses) => &statuses[0],
57 _ => {
58 panic!("Failed to place order: {:?}", status_type);
59 }
60 };
61
62 let oid = match status {
63 Status::Filled(order) => order.oid,
64 Status::Resting(order) => order.oid,
65 _ => panic!("Order is not filled or resting"),
66 };
67
68 println!("Order placed: {:?}", oid);
69
70 tokio::time::sleep(std::time::Duration::from_secs(5)).await;
71
72 let limit_px = "1710".to_string();
73 // Modifying the order
74 println!("Modifying order {oid} limit price to {limit_px}.");
75
76 let order = OrderRequest {
77 asset: 4,
78 is_buy: true,
79 reduce_only: false,
80 limit_px,
81 sz: "0.1".to_string(),
82 order_type: OrderType::Limit(Limit { tif: Tif::Gtc }),
83 cloid: Some(cloid),
84 };
85
86 let order = ModifyRequest { order, oid };
87
88 let response = exchange
89 .modify_order(wallet.clone(), order, vault_address)
90 .await
91 .expect("Failed to modify order");
92
93 println!("Response: {:?}", response);
94}
15async fn main() {
16 // Key was randomly generated for testing and shouldn't be used with any real funds
17 let wallet: Arc<LocalWallet> = Arc::new(
18 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
19 .parse()
20 .unwrap(),
21 );
22
23 let exchange: Exchange = Hyperliquid::new(Chain::Dev);
24
25 let asset = 4;
26 let sz_decimals = 4;
27
28 let order_type = OrderType::Limit(Limit { tif: Tif::Gtc });
29
30 let order = OrderRequest {
31 asset,
32 is_buy: true,
33 reduce_only: false,
34 limit_px: parse_price(2800.0),
35 sz: parse_size(0.0331, sz_decimals),
36 order_type,
37 cloid: None,
38 };
39
40 let vault_address = None;
41
42 println!("Placing order...");
43 let response = exchange
44 .place_order(wallet.clone(), vec![order], vault_address)
45 .await
46 .expect("Failed to place order");
47
48 println!("Response: {:?}", response);
49
50 println!("-----------------");
51 println!("Placing an order with cloid...");
52
53 let order_type = OrderType::Limit(Limit { tif: Tif::Gtc });
54
55 let cloid = Uuid::new_v4();
56
57 let order = OrderRequest {
58 asset,
59 is_buy: true,
60 reduce_only: false,
61 limit_px: parse_price(2800.0),
62 sz: parse_size(0.0331, sz_decimals),
63 order_type,
64 cloid: Some(cloid),
65 };
66
67 let response = exchange
68 .place_order(wallet.clone(), vec![order], vault_address)
69 .await
70 .expect("Failed to place order");
71
72 println!("Response: {:?}", response);
73
74 println!("-----------------");
75 println!("Placing a trigger order with tpsl...");
76
77 let order_type = OrderType::Trigger(Trigger {
78 is_market: false,
79 trigger_px: parse_price(2800.0),
80 tpsl: TpSl::Tp,
81 });
82
83 let order = OrderRequest {
84 asset,
85 is_buy: true,
86 reduce_only: false,
87 limit_px: parse_price(2800.0),
88 sz: parse_size(0.0331, sz_decimals),
89 order_type,
90 cloid: Some(cloid),
91 };
92
93 let response = exchange
94 .place_order(wallet.clone(), vec![order], vault_address)
95 .await
96 .expect("Failed to place order");
97
98 println!("Response: {:?}", response);
99}
17async fn main() {
18 // Key was randomly generated for testing and shouldn't be used with any real funds
19 let wallet: Arc<LocalWallet> = Arc::new(
20 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
21 .parse()
22 .unwrap(),
23 );
24
25 let exchange: Exchange = Hyperliquid::new(Chain::Dev);
26
27 let order_type = OrderType::Limit(Limit { tif: Tif::Gtc });
28
29 let order = OrderRequest {
30 asset: 4,
31 is_buy: true,
32 reduce_only: false,
33 limit_px: "1800".to_string(),
34 sz: "0.1".to_string(),
35 order_type,
36 cloid: None,
37 };
38
39 let vault_address = None;
40
41 println!("Placing order...");
42 let response = exchange
43 .place_order(wallet.clone(), vec![order], vault_address)
44 .await
45 .expect("Failed to place order");
46
47 let response = match response {
48 Response::Ok(order) => order,
49 Response::Err(error) => panic!("Failed to place order: {:?}", error),
50 };
51
52 let status_type = &response.data.unwrap();
53
54 let status = match status_type {
55 StatusType::Statuses(statuses) => &statuses[0],
56 _ => {
57 panic!("Failed to place order: {:?}", status_type);
58 }
59 };
60
61 let oid = match status {
62 Status::Filled(order) => order.oid,
63 Status::Resting(order) => order.oid,
64 _ => {
65 panic!("Order is not filled or resting, status: {:?}", status);
66 }
67 };
68
69 println!("Order placed: {:?}", oid);
70
71 tokio::time::sleep(std::time::Duration::from_secs(5)).await;
72
73 // Cancel order
74
75 println!("Cancelling order with oid {oid}.");
76 let cancel = CancelRequest { asset: 4, oid };
77
78 let vault_address = None;
79
80 let response = exchange
81 .cancel_order(wallet.clone(), vec![cancel], vault_address)
82 .await
83 .expect("Failed to cancel order");
84
85 println!("Response: {:?}", response);
86
87 let cloid = Uuid::new_v4();
88
89 println!("Placing order with cloid: {}", cloid.simple());
90
91 let order_type = OrderType::Limit(Limit { tif: Tif::Gtc });
92
93 let order = OrderRequest {
94 asset: 4,
95 is_buy: true,
96 reduce_only: false,
97 limit_px: "1700".to_string(),
98 sz: "0.1".to_string(),
99 order_type,
100 cloid: Some(cloid),
101 };
102
103 let vault_address = None;
104
105 let response = exchange
106 .place_order(wallet.clone(), vec![order], vault_address)
107 .await
108 .expect("Failed to place order");
109
110 let response = match response {
111 Response::Ok(order) => order,
112 Response::Err(error) => panic!("Failed to place order: {:?}", error),
113 };
114
115 let data = &response.data.unwrap();
116 let status = match data {
117 StatusType::Statuses(statuses) => &statuses[0],
118 _ => {
119 panic!("Failed to place order: {:?}", data);
120 }
121 };
122
123 let oid = match status {
124 Status::Filled(order) => order.oid,
125 Status::Resting(order) => order.oid,
126 _ => panic!("Order is not filled or resting"),
127 };
128
129 println!("Order placed: {:?}", oid);
130
131 tokio::time::sleep(std::time::Duration::from_secs(5)).await;
132
133 println!("Cancelling order with cloid: {}", cloid.simple());
134 let cancel = CancelByCloidRequest { asset: 4, cloid };
135
136 let response = exchange
137 .cancel_order_by_cloid(wallet.clone(), vec![cancel], vault_address)
138 .await
139 .expect("Failed to cancel order");
140
141 println!("Response: {:?}", response);
142}
Sourcepub async fn normal_tpsl(
&self,
wallet: Arc<LocalWallet>,
orders: Vec<OrderRequest>,
vault_address: Option<Address>,
) -> Result<Response>
pub async fn normal_tpsl( &self, wallet: Arc<LocalWallet>, orders: Vec<OrderRequest>, vault_address: Option<Address>, ) -> Result<Response>
Place a normal order with tpsl order
§Arguments
wallet
- The wallet to sign the order withorders
- The orders to placevault_address
- If trading on behalf of a vault, its onchain address in 42-character hexadecimal format e.g.0x0000000000000000000000000000000000000000
§Note
cloid
in argumentorder
is an optional 128 bit hex string, e.g.0x1234567890abcdef1234567890abcdef
Examples found in repository?
13async fn main() {
14 // Key was randomly generated for testing and shouldn't be used with any real funds
15 let wallet: Arc<LocalWallet> = Arc::new(
16 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
17 .parse()
18 .unwrap(),
19 );
20
21 let exchange: Exchange = Hyperliquid::new(Chain::Dev);
22
23 let asset = 4;
24 let sz_decimals = 4;
25
26 let normal = OrderRequest {
27 asset,
28 is_buy: true,
29 reduce_only: false,
30 limit_px: parse_price(2800.0),
31 sz: parse_size(0.0331, sz_decimals),
32 order_type: OrderType::Limit(Limit { tif: Tif::Gtc }),
33 cloid: None,
34 };
35
36 let tp = OrderRequest {
37 asset,
38 is_buy: false,
39 reduce_only: true,
40 limit_px: parse_price(2810.0),
41 sz: parse_size(0.0331, sz_decimals),
42 order_type: OrderType::Trigger(Trigger {
43 is_market: true,
44 trigger_px: parse_price(2810.0),
45 tpsl: TpSl::Tp,
46 }),
47 cloid: None,
48 };
49
50 let sl = OrderRequest {
51 asset,
52 is_buy: false,
53 reduce_only: true,
54 limit_px: parse_price(2750.0),
55 sz: parse_size(0.0331, sz_decimals),
56 order_type: OrderType::Trigger(Trigger {
57 is_market: true,
58 trigger_px: parse_price(2750.0),
59 tpsl: TpSl::Tp,
60 }),
61 cloid: None,
62 };
63
64 let vault_address = None;
65
66 println!("Placing normal tpsl order...");
67 let response = exchange
68 .normal_tpsl(wallet.clone(), vec![normal, tp, sl], vault_address)
69 .await
70 .expect("Failed to place order");
71
72 println!("Response: {:?}", response);
73
74 println!("-----------------");
75}
Sourcepub async fn cancel_order(
&self,
wallet: Arc<LocalWallet>,
cancels: Vec<CancelRequest>,
vault_address: Option<Address>,
) -> Result<Response>
pub async fn cancel_order( &self, wallet: Arc<LocalWallet>, cancels: Vec<CancelRequest>, vault_address: Option<Address>, ) -> Result<Response>
Cancel an order
§Arguments
wallet
- The wallet to sign the order withcancels
- The orders to cancelvault_address
- If trading on behalf of a vault, its onchain address in 42-character hexadecimal format e.g.0x0000000000000000000000000000000000000000
Examples found in repository?
17async fn main() {
18 // Key was randomly generated for testing and shouldn't be used with any real funds
19 let wallet: Arc<LocalWallet> = Arc::new(
20 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
21 .parse()
22 .unwrap(),
23 );
24
25 let exchange: Exchange = Hyperliquid::new(Chain::Dev);
26
27 let order_type = OrderType::Limit(Limit { tif: Tif::Gtc });
28
29 let order = OrderRequest {
30 asset: 4,
31 is_buy: true,
32 reduce_only: false,
33 limit_px: "1800".to_string(),
34 sz: "0.1".to_string(),
35 order_type,
36 cloid: None,
37 };
38
39 let vault_address = None;
40
41 println!("Placing order...");
42 let response = exchange
43 .place_order(wallet.clone(), vec![order], vault_address)
44 .await
45 .expect("Failed to place order");
46
47 let response = match response {
48 Response::Ok(order) => order,
49 Response::Err(error) => panic!("Failed to place order: {:?}", error),
50 };
51
52 let status_type = &response.data.unwrap();
53
54 let status = match status_type {
55 StatusType::Statuses(statuses) => &statuses[0],
56 _ => {
57 panic!("Failed to place order: {:?}", status_type);
58 }
59 };
60
61 let oid = match status {
62 Status::Filled(order) => order.oid,
63 Status::Resting(order) => order.oid,
64 _ => {
65 panic!("Order is not filled or resting, status: {:?}", status);
66 }
67 };
68
69 println!("Order placed: {:?}", oid);
70
71 tokio::time::sleep(std::time::Duration::from_secs(5)).await;
72
73 // Cancel order
74
75 println!("Cancelling order with oid {oid}.");
76 let cancel = CancelRequest { asset: 4, oid };
77
78 let vault_address = None;
79
80 let response = exchange
81 .cancel_order(wallet.clone(), vec![cancel], vault_address)
82 .await
83 .expect("Failed to cancel order");
84
85 println!("Response: {:?}", response);
86
87 let cloid = Uuid::new_v4();
88
89 println!("Placing order with cloid: {}", cloid.simple());
90
91 let order_type = OrderType::Limit(Limit { tif: Tif::Gtc });
92
93 let order = OrderRequest {
94 asset: 4,
95 is_buy: true,
96 reduce_only: false,
97 limit_px: "1700".to_string(),
98 sz: "0.1".to_string(),
99 order_type,
100 cloid: Some(cloid),
101 };
102
103 let vault_address = None;
104
105 let response = exchange
106 .place_order(wallet.clone(), vec![order], vault_address)
107 .await
108 .expect("Failed to place order");
109
110 let response = match response {
111 Response::Ok(order) => order,
112 Response::Err(error) => panic!("Failed to place order: {:?}", error),
113 };
114
115 let data = &response.data.unwrap();
116 let status = match data {
117 StatusType::Statuses(statuses) => &statuses[0],
118 _ => {
119 panic!("Failed to place order: {:?}", data);
120 }
121 };
122
123 let oid = match status {
124 Status::Filled(order) => order.oid,
125 Status::Resting(order) => order.oid,
126 _ => panic!("Order is not filled or resting"),
127 };
128
129 println!("Order placed: {:?}", oid);
130
131 tokio::time::sleep(std::time::Duration::from_secs(5)).await;
132
133 println!("Cancelling order with cloid: {}", cloid.simple());
134 let cancel = CancelByCloidRequest { asset: 4, cloid };
135
136 let response = exchange
137 .cancel_order_by_cloid(wallet.clone(), vec![cancel], vault_address)
138 .await
139 .expect("Failed to cancel order");
140
141 println!("Response: {:?}", response);
142}
Sourcepub async fn cancel_order_by_cloid(
&self,
wallet: Arc<LocalWallet>,
cancels: Vec<CancelByCloidRequest>,
vault_address: Option<Address>,
) -> Result<Response>
pub async fn cancel_order_by_cloid( &self, wallet: Arc<LocalWallet>, cancels: Vec<CancelByCloidRequest>, vault_address: Option<Address>, ) -> Result<Response>
Cancel order(s) by client order id (cloid)
§Arguments
wallet
- The wallet to sign the order withcancels
- The client orders to cancelvault_address
- If trading on behalf of a vault, its onchain address in 42-character hexadecimal format e.g.0x0000000000000000000000000000000000000000
Note: cloid
in argument cancel
is a 128 bit hex string, e.g. 0x1234567890abcdef1234567890abcdef
Examples found in repository?
17async fn main() {
18 // Key was randomly generated for testing and shouldn't be used with any real funds
19 let wallet: Arc<LocalWallet> = Arc::new(
20 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
21 .parse()
22 .unwrap(),
23 );
24
25 let exchange: Exchange = Hyperliquid::new(Chain::Dev);
26
27 let order_type = OrderType::Limit(Limit { tif: Tif::Gtc });
28
29 let order = OrderRequest {
30 asset: 4,
31 is_buy: true,
32 reduce_only: false,
33 limit_px: "1800".to_string(),
34 sz: "0.1".to_string(),
35 order_type,
36 cloid: None,
37 };
38
39 let vault_address = None;
40
41 println!("Placing order...");
42 let response = exchange
43 .place_order(wallet.clone(), vec![order], vault_address)
44 .await
45 .expect("Failed to place order");
46
47 let response = match response {
48 Response::Ok(order) => order,
49 Response::Err(error) => panic!("Failed to place order: {:?}", error),
50 };
51
52 let status_type = &response.data.unwrap();
53
54 let status = match status_type {
55 StatusType::Statuses(statuses) => &statuses[0],
56 _ => {
57 panic!("Failed to place order: {:?}", status_type);
58 }
59 };
60
61 let oid = match status {
62 Status::Filled(order) => order.oid,
63 Status::Resting(order) => order.oid,
64 _ => {
65 panic!("Order is not filled or resting, status: {:?}", status);
66 }
67 };
68
69 println!("Order placed: {:?}", oid);
70
71 tokio::time::sleep(std::time::Duration::from_secs(5)).await;
72
73 // Cancel order
74
75 println!("Cancelling order with oid {oid}.");
76 let cancel = CancelRequest { asset: 4, oid };
77
78 let vault_address = None;
79
80 let response = exchange
81 .cancel_order(wallet.clone(), vec![cancel], vault_address)
82 .await
83 .expect("Failed to cancel order");
84
85 println!("Response: {:?}", response);
86
87 let cloid = Uuid::new_v4();
88
89 println!("Placing order with cloid: {}", cloid.simple());
90
91 let order_type = OrderType::Limit(Limit { tif: Tif::Gtc });
92
93 let order = OrderRequest {
94 asset: 4,
95 is_buy: true,
96 reduce_only: false,
97 limit_px: "1700".to_string(),
98 sz: "0.1".to_string(),
99 order_type,
100 cloid: Some(cloid),
101 };
102
103 let vault_address = None;
104
105 let response = exchange
106 .place_order(wallet.clone(), vec![order], vault_address)
107 .await
108 .expect("Failed to place order");
109
110 let response = match response {
111 Response::Ok(order) => order,
112 Response::Err(error) => panic!("Failed to place order: {:?}", error),
113 };
114
115 let data = &response.data.unwrap();
116 let status = match data {
117 StatusType::Statuses(statuses) => &statuses[0],
118 _ => {
119 panic!("Failed to place order: {:?}", data);
120 }
121 };
122
123 let oid = match status {
124 Status::Filled(order) => order.oid,
125 Status::Resting(order) => order.oid,
126 _ => panic!("Order is not filled or resting"),
127 };
128
129 println!("Order placed: {:?}", oid);
130
131 tokio::time::sleep(std::time::Duration::from_secs(5)).await;
132
133 println!("Cancelling order with cloid: {}", cloid.simple());
134 let cancel = CancelByCloidRequest { asset: 4, cloid };
135
136 let response = exchange
137 .cancel_order_by_cloid(wallet.clone(), vec![cancel], vault_address)
138 .await
139 .expect("Failed to cancel order");
140
141 println!("Response: {:?}", response);
142}
Sourcepub async fn modify_order(
&self,
wallet: Arc<LocalWallet>,
order: ModifyRequest,
vault_address: Option<Address>,
) -> Result<Response>
pub async fn modify_order( &self, wallet: Arc<LocalWallet>, order: ModifyRequest, vault_address: Option<Address>, ) -> Result<Response>
Modify an order
§Arguments
wallet
- The wallet to sign the order withorder
- The orders to modifyvault_address
- If trading on behalf of a vault, its onchain address in 42-character hexadecimal format e.g.0x0000000000000000000000000000000000000000
Note: cloid
in argument order
is an optional 128 bit hex string, e.g. 0x1234567890abcdef1234567890abcdef
Examples found in repository?
17async fn main() {
18 // Key was randomly generated for testing and shouldn't be used with any real funds
19 let wallet: Arc<LocalWallet> = Arc::new(
20 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
21 .parse()
22 .unwrap(),
23 );
24
25 let exchange: Exchange = Hyperliquid::new(Chain::Dev);
26
27 let order_type = OrderType::Limit(Limit { tif: Tif::Gtc });
28 let cloid = Uuid::new_v4();
29
30 let order = OrderRequest {
31 asset: 4,
32 is_buy: true,
33 reduce_only: false,
34 limit_px: "1800".to_string(),
35 sz: "0.1".to_string(),
36 order_type,
37 cloid: Some(cloid),
38 };
39
40 let vault_address = None;
41
42 println!("Placing order...");
43 let response = exchange
44 .place_order(wallet.clone(), vec![order], vault_address)
45 .await
46 .expect("Failed to place order");
47
48 let response = match response {
49 Response::Ok(order) => order,
50 Response::Err(error) => panic!("Failed to place order: {:?}", error),
51 };
52
53 let status_type = &response.data.unwrap();
54
55 let status = match status_type {
56 StatusType::Statuses(statuses) => &statuses[0],
57 _ => {
58 panic!("Failed to place order: {:?}", status_type);
59 }
60 };
61
62 let oid = match status {
63 Status::Filled(order) => order.oid,
64 Status::Resting(order) => order.oid,
65 _ => panic!("Order is not filled or resting"),
66 };
67
68 println!("Order placed: {:?}", oid);
69
70 tokio::time::sleep(std::time::Duration::from_secs(5)).await;
71
72 let limit_px = "1710".to_string();
73 // Modifying the order
74 println!("Modifying order {oid} limit price to {limit_px}.");
75
76 let order = OrderRequest {
77 asset: 4,
78 is_buy: true,
79 reduce_only: false,
80 limit_px,
81 sz: "0.1".to_string(),
82 order_type: OrderType::Limit(Limit { tif: Tif::Gtc }),
83 cloid: Some(cloid),
84 };
85
86 let order = ModifyRequest { order, oid };
87
88 let response = exchange
89 .modify_order(wallet.clone(), order, vault_address)
90 .await
91 .expect("Failed to modify order");
92
93 println!("Response: {:?}", response);
94}
Sourcepub async fn batch_modify_orders(
&self,
wallet: Arc<LocalWallet>,
orders: Vec<ModifyRequest>,
vault_address: Option<Address>,
) -> Result<Response>
pub async fn batch_modify_orders( &self, wallet: Arc<LocalWallet>, orders: Vec<ModifyRequest>, vault_address: Option<Address>, ) -> Result<Response>
Batch modify orders
§Arguments
wallet
- The wallet to sign the order withorders
- The orders to modifyvault_address
- If trading on behalf of a vault, its onchain address in 42-character hexadecimal format e.g.0x0000000000000000000000000000000000000000
Sourcepub async fn update_leverage(
&self,
wallet: Arc<LocalWallet>,
leverage: u32,
asset: u32,
is_cross: bool,
) -> Result<Response>
pub async fn update_leverage( &self, wallet: Arc<LocalWallet>, leverage: u32, asset: u32, is_cross: bool, ) -> Result<Response>
Update cross or isolated leverage on a coin
§Arguments
wallet
- The wallet to sign the order withleverage
- The new leverage to setasset
- The asset to set the leverage foris_cross
- true if cross leverage, false if isolated leverage
Examples found in repository?
7async fn main() {
8 // Key was randomly generated for testing and shouldn't be used with any real funds
9 let wallet: Arc<LocalWallet> = Arc::new(
10 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
11 .parse()
12 .unwrap(),
13 );
14
15 let exchange: Exchange = Hyperliquid::new(Chain::Dev);
16
17 let leverage = 2;
18 let asset = 4;
19 let is_cross = false;
20
21 println!("Updating leverage to {}x ...", leverage);
22
23 let res = exchange
24 .update_leverage(wallet.clone(), leverage, asset, is_cross)
25 .await
26 .unwrap();
27
28 println!("Response: {:?}", res);
29
30 let margin = 1;
31
32 println!("--\nUpdating isolated margin for ETH to {margin}% ...");
33
34 let res = exchange
35 .update_isolated_margin(wallet.clone(), asset, true, margin)
36 .await
37 .unwrap();
38
39 println!("Response: {:?}", res);
40
41 let info: Info = Hyperliquid::new(Chain::Dev);
42
43 // user state
44 let res = info.user_state(wallet.address()).await.unwrap();
45
46 println!("--\nUser state: {:?}", res);
47}
Sourcepub async fn update_isolated_margin(
&self,
wallet: Arc<LocalWallet>,
asset: u32,
is_buy: bool,
ntli: i64,
) -> Result<Response>
pub async fn update_isolated_margin( &self, wallet: Arc<LocalWallet>, asset: u32, is_buy: bool, ntli: i64, ) -> Result<Response>
Add or remove margin from isolated position
§Arguments
wallet
- The wallet to sign the order withasset
- The asset to set the margin foris_buy
- true if adding margin, false if removing marginntli
- The new margin to set
Examples found in repository?
7async fn main() {
8 // Key was randomly generated for testing and shouldn't be used with any real funds
9 let wallet: Arc<LocalWallet> = Arc::new(
10 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
11 .parse()
12 .unwrap(),
13 );
14
15 let exchange: Exchange = Hyperliquid::new(Chain::Dev);
16
17 let leverage = 2;
18 let asset = 4;
19 let is_cross = false;
20
21 println!("Updating leverage to {}x ...", leverage);
22
23 let res = exchange
24 .update_leverage(wallet.clone(), leverage, asset, is_cross)
25 .await
26 .unwrap();
27
28 println!("Response: {:?}", res);
29
30 let margin = 1;
31
32 println!("--\nUpdating isolated margin for ETH to {margin}% ...");
33
34 let res = exchange
35 .update_isolated_margin(wallet.clone(), asset, true, margin)
36 .await
37 .unwrap();
38
39 println!("Response: {:?}", res);
40
41 let info: Info = Hyperliquid::new(Chain::Dev);
42
43 // user state
44 let res = info.user_state(wallet.address()).await.unwrap();
45
46 println!("--\nUser state: {:?}", res);
47}
Sourcepub async fn twap_order(
&self,
wallet: Arc<LocalWallet>,
twap: TwapRequest,
vault_address: Option<Address>,
) -> Result<Response>
pub async fn twap_order( &self, wallet: Arc<LocalWallet>, twap: TwapRequest, vault_address: Option<Address>, ) -> Result<Response>
Place a TWAP order
§Arguments
wallet
- The wallet to sign the order withtwap
- The twap order to placevault_address
- If trading on behalf of a vault, its onchain address in 42-character hexadecimal format e.g.0x0000000000000000000000000000000000000000
Examples found in repository?
11async fn main() {
12 // Key was randomly generated for testing and shouldn't be used with any real funds
13 let wallet: Arc<LocalWallet> = Arc::new(
14 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
15 .parse()
16 .unwrap(),
17 );
18
19 let exchange: Exchange = Hyperliquid::new(Chain::Dev);
20
21 let asset = 0;
22 let sz_decimals = 2;
23
24 let twap = TwapRequest {
25 asset,
26 is_buy: true,
27 reduce_only: false,
28 duration: 10,
29 sz: parse_size(13.85, sz_decimals),
30 randomize: true,
31 };
32
33 let vault_address = None;
34
35 println!("Placing a TWAP order...");
36 let response = exchange
37 .twap_order(wallet.clone(), twap, vault_address)
38 .await
39 .expect("Failed to place twap order");
40
41 println!("Response: {:?}", response);
42}
Sourcepub async fn usdc_transfer(
&self,
from: Arc<LocalWallet>,
destination: Address,
amount: String,
) -> Result<Response>
pub async fn usdc_transfer( &self, from: Arc<LocalWallet>, destination: Address, amount: String, ) -> Result<Response>
Send usd to another address. This transfer does not touch the EVM bridge. The signature format is human readable for wallet interfaces.
§Arguments
from
- The wallet to sign the transfer withdestination
- The address to send the usd toamount
- The amount of usd to send
Examples found in repository?
7async fn main() {
8 // Key was randomly generated for testing and shouldn't be used with any real funds
9 let wallet: Arc<LocalWallet> = Arc::new(
10 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
11 .parse()
12 .unwrap(),
13 );
14
15 let exchange: Exchange = Hyperliquid::new(Chain::ArbitrumTestnet);
16
17 let destination = "0x0D1d9635D0640821d15e323ac8AdADfA9c111414"
18 .parse()
19 .expect("Invalid address");
20
21 let amount = "1".to_string(); // USD
22
23 println!(
24 "Transferring ${} from {:?} to {:?}",
25 amount,
26 wallet.address(),
27 destination
28 );
29
30 let res = exchange
31 .usdc_transfer(wallet.clone(), destination, amount)
32 .await
33 .unwrap();
34
35 println!("Response: {:?}", res);
36}
Sourcepub async fn withdraw_from_bridge(
&self,
wallet: Arc<LocalWallet>,
destination: Address,
amount: String,
) -> Result<Response>
pub async fn withdraw_from_bridge( &self, wallet: Arc<LocalWallet>, destination: Address, amount: String, ) -> Result<Response>
Withdraw from bridge
§Arguments
wallet
- The wallet to sign the withdrawal withdestination
- The address to send the usd toamount
- The amount of usd to send
Examples found in repository?
7async fn main() {
8 // Key was randomly generated for testing and shouldn't be used with any real funds
9 let wallet: Arc<LocalWallet> = Arc::new(
10 "8547bf37e4ac35e85d1e8afc2a2ba5c7f352b8a11ae916e9f14737737e8e0e47"
11 .parse()
12 .unwrap(),
13 );
14
15 let exchange: Exchange = Hyperliquid::new(Chain::ArbitrumGoerli);
16
17 let destination = "0x0D1d9635D0640821d15e323ac8AdADfA9c111414"
18 .parse()
19 .expect("Invalid address");
20
21 let usd = "10".to_string(); // USD
22
23 println!("Withdrawing ${} from bridge to {:?}", usd, destination);
24
25 let res = exchange
26 .withdraw_from_bridge(wallet.clone(), destination, usd)
27 .await
28 .unwrap();
29
30 println!("Response: {:?}", res);
31}
Sourcepub async fn approve_agent(
&self,
wallet: Arc<LocalWallet>,
agent_address: Address,
agent_name: Option<String>,
) -> Result<Response>
pub async fn approve_agent( &self, wallet: Arc<LocalWallet>, agent_address: Address, agent_name: Option<String>, ) -> Result<Response>
Approve an agent to trade on behalf of the user
§Arguments
wallet
- The wallet to sign the approval withagent_address
- The address of the agent to approveagent_name
- An optional name for the agent
Examples found in repository?
20async fn main() {
21 // Key was randomly generated for testing and shouldn't be used with any real funds
22 let wallet: Arc<LocalWallet> = Arc::new(
23 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
24 .parse()
25 .unwrap(),
26 );
27
28 let exchange: Exchange = Hyperliquid::new(Chain::ArbitrumTestnet);
29
30 // Create a new wallet with the agent. This agent can't transfer or withdraw funds
31 // but can place orders.
32
33 let agent = Arc::new(LocalWallet::new(&mut thread_rng()));
34
35 let agent_address = agent.address();
36
37 println!("Agent address: {:?}", agent_address);
38
39 let res = exchange
40 .approve_agent(wallet.clone(), agent_address, Some("WETH".to_string()))
41 .await
42 .unwrap();
43
44 println!("Response: {:?}", res);
45
46 // place order with agent
47 let order_type = OrderType::Limit(Limit { tif: Tif::Gtc });
48 let order = OrderRequest {
49 asset: 4,
50 is_buy: true,
51 reduce_only: false,
52 limit_px: "1700".to_string(),
53 sz: "0.1".to_string(),
54 order_type,
55 cloid: None,
56 };
57 let vault_address = None;
58
59 println!("Placing order with agent...");
60
61 let response = exchange
62 .place_order(agent.clone(), vec![order], vault_address)
63 .await
64 .expect("Failed to place order");
65
66 println!("Response: {:?}", response);
67}
Sourcepub async fn create_sub_account(
&self,
wallet: Arc<LocalWallet>,
name: String,
) -> Result<Response>
pub async fn create_sub_account( &self, wallet: Arc<LocalWallet>, name: String, ) -> Result<Response>
Create subaccount for the user
§Arguments
wallet
- The wallet to create the subaccount withname
- The name of the subaccount
Examples found in repository?
13async fn main() {
14 // Key was randomly generated for testing and shouldn't be used with any real funds
15 let wallet: Arc<LocalWallet> = Arc::new(
16 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
17 .parse()
18 .unwrap(),
19 );
20
21 let exchange: Exchange = Hyperliquid::new(Chain::ArbitrumTestnet);
22
23 println!("Creating subaccount...");
24 let name = {
25 let suffix = timestamp().to_string();
26
27 // slice the last 4 characters
28 let suffix = &suffix[suffix.len() - 4..];
29
30 format!("Acc-{}", suffix)
31 };
32
33 let response = exchange
34 .create_sub_account(wallet.clone(), name.clone())
35 .await
36 .expect("Failed to create subaccount");
37
38 let response = match response {
39 Response::Ok(sub_account) => sub_account,
40 Response::Err(error) => {
41 panic!("Failed to create subaccount: {:?}", error)
42 }
43 };
44
45 let sub_account_user = match response.data {
46 Some(StatusType::Address(address)) => address,
47 _ => panic!("Failed to get subaccount address: {:?}", response),
48 };
49
50 println!(
51 "Subaccount created with name {} and user address: {:x} ✓",
52 name, sub_account_user
53 );
54
55 tokio::time::sleep(std::time::Duration::from_secs(10)).await;
56
57 let new_name = {
58 let suffix = timestamp().to_string();
59
60 // slice the last 4 characters
61 let suffix = &suffix[suffix.len() - 4..];
62
63 format!("Acc-{}", suffix)
64 };
65
66 println!("Renaming subaccount to: {}", new_name);
67
68 let response = exchange
69 .sub_account_modify(wallet.clone(), new_name, sub_account_user)
70 .await
71 .expect("Failed to rename subaccount");
72
73 let response = match response {
74 Response::Ok(sub_account) => sub_account,
75 Response::Err(error) => {
76 panic!("Failed to rename subaccount: {:?}", error)
77 }
78 };
79
80 println!("Subaccount rename response: {:?} ✓", response);
81
82 tokio::time::sleep(std::time::Duration::from_secs(5)).await;
83
84 println!("Depositing 1 USD to subaccount...");
85
86 let usd = 1_000_000;
87
88 let is_deposit = true;
89
90 let response = exchange
91 .sub_account_transfer(wallet.clone(), is_deposit, sub_account_user, usd)
92 .await
93 .expect("Failed to deposit funds");
94
95 let response = match response {
96 Response::Ok(response) => response,
97 Response::Err(error) => {
98 panic!("Failed to deposit funds: {:?}", error)
99 }
100 };
101
102 println!("Deposit response: {:?} ✓", response);
103
104 tokio::time::sleep(std::time::Duration::from_secs(10)).await;
105
106 println!("Withdrawing funds from subaccount...");
107
108 let response = exchange
109 .sub_account_transfer(wallet.clone(), !is_deposit, sub_account_user, usd)
110 .await
111 .expect("Failed to withdraw funds");
112
113 let response = match response {
114 Response::Ok(response) => response,
115 Response::Err(error) => {
116 panic!("Failed to withdraw funds: {:?}", error)
117 }
118 };
119
120 println!("Withdraw response: {:?} ✓", response);
121}
Sourcepub async fn sub_account_modify(
&self,
wallet: Arc<LocalWallet>,
name: String,
sub_account_user: Address,
) -> Result<Response>
pub async fn sub_account_modify( &self, wallet: Arc<LocalWallet>, name: String, sub_account_user: Address, ) -> Result<Response>
Rename subaccount
§Arguments
wallet
- The wallet to sign the rename withname
- The new name of the subaccountsub_account_user
- The address of the subaccount to rename
Examples found in repository?
13async fn main() {
14 // Key was randomly generated for testing and shouldn't be used with any real funds
15 let wallet: Arc<LocalWallet> = Arc::new(
16 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
17 .parse()
18 .unwrap(),
19 );
20
21 let exchange: Exchange = Hyperliquid::new(Chain::ArbitrumTestnet);
22
23 println!("Creating subaccount...");
24 let name = {
25 let suffix = timestamp().to_string();
26
27 // slice the last 4 characters
28 let suffix = &suffix[suffix.len() - 4..];
29
30 format!("Acc-{}", suffix)
31 };
32
33 let response = exchange
34 .create_sub_account(wallet.clone(), name.clone())
35 .await
36 .expect("Failed to create subaccount");
37
38 let response = match response {
39 Response::Ok(sub_account) => sub_account,
40 Response::Err(error) => {
41 panic!("Failed to create subaccount: {:?}", error)
42 }
43 };
44
45 let sub_account_user = match response.data {
46 Some(StatusType::Address(address)) => address,
47 _ => panic!("Failed to get subaccount address: {:?}", response),
48 };
49
50 println!(
51 "Subaccount created with name {} and user address: {:x} ✓",
52 name, sub_account_user
53 );
54
55 tokio::time::sleep(std::time::Duration::from_secs(10)).await;
56
57 let new_name = {
58 let suffix = timestamp().to_string();
59
60 // slice the last 4 characters
61 let suffix = &suffix[suffix.len() - 4..];
62
63 format!("Acc-{}", suffix)
64 };
65
66 println!("Renaming subaccount to: {}", new_name);
67
68 let response = exchange
69 .sub_account_modify(wallet.clone(), new_name, sub_account_user)
70 .await
71 .expect("Failed to rename subaccount");
72
73 let response = match response {
74 Response::Ok(sub_account) => sub_account,
75 Response::Err(error) => {
76 panic!("Failed to rename subaccount: {:?}", error)
77 }
78 };
79
80 println!("Subaccount rename response: {:?} ✓", response);
81
82 tokio::time::sleep(std::time::Duration::from_secs(5)).await;
83
84 println!("Depositing 1 USD to subaccount...");
85
86 let usd = 1_000_000;
87
88 let is_deposit = true;
89
90 let response = exchange
91 .sub_account_transfer(wallet.clone(), is_deposit, sub_account_user, usd)
92 .await
93 .expect("Failed to deposit funds");
94
95 let response = match response {
96 Response::Ok(response) => response,
97 Response::Err(error) => {
98 panic!("Failed to deposit funds: {:?}", error)
99 }
100 };
101
102 println!("Deposit response: {:?} ✓", response);
103
104 tokio::time::sleep(std::time::Duration::from_secs(10)).await;
105
106 println!("Withdrawing funds from subaccount...");
107
108 let response = exchange
109 .sub_account_transfer(wallet.clone(), !is_deposit, sub_account_user, usd)
110 .await
111 .expect("Failed to withdraw funds");
112
113 let response = match response {
114 Response::Ok(response) => response,
115 Response::Err(error) => {
116 panic!("Failed to withdraw funds: {:?}", error)
117 }
118 };
119
120 println!("Withdraw response: {:?} ✓", response);
121}
Sourcepub async fn sub_account_transfer(
&self,
wallet: Arc<LocalWallet>,
is_deposit: bool,
sub_account_user: Address,
usd: u64,
) -> Result<Response>
pub async fn sub_account_transfer( &self, wallet: Arc<LocalWallet>, is_deposit: bool, sub_account_user: Address, usd: u64, ) -> Result<Response>
Transfer funds between subaccounts
§Arguments
wallet
- The wallet to sign the transfer withfrom
- The subaccount to transfer from
Examples found in repository?
13async fn main() {
14 // Key was randomly generated for testing and shouldn't be used with any real funds
15 let wallet: Arc<LocalWallet> = Arc::new(
16 "e908f86dbb4d55ac876378565aafeabc187f6690f046459397b17d9b9a19688e"
17 .parse()
18 .unwrap(),
19 );
20
21 let exchange: Exchange = Hyperliquid::new(Chain::ArbitrumTestnet);
22
23 println!("Creating subaccount...");
24 let name = {
25 let suffix = timestamp().to_string();
26
27 // slice the last 4 characters
28 let suffix = &suffix[suffix.len() - 4..];
29
30 format!("Acc-{}", suffix)
31 };
32
33 let response = exchange
34 .create_sub_account(wallet.clone(), name.clone())
35 .await
36 .expect("Failed to create subaccount");
37
38 let response = match response {
39 Response::Ok(sub_account) => sub_account,
40 Response::Err(error) => {
41 panic!("Failed to create subaccount: {:?}", error)
42 }
43 };
44
45 let sub_account_user = match response.data {
46 Some(StatusType::Address(address)) => address,
47 _ => panic!("Failed to get subaccount address: {:?}", response),
48 };
49
50 println!(
51 "Subaccount created with name {} and user address: {:x} ✓",
52 name, sub_account_user
53 );
54
55 tokio::time::sleep(std::time::Duration::from_secs(10)).await;
56
57 let new_name = {
58 let suffix = timestamp().to_string();
59
60 // slice the last 4 characters
61 let suffix = &suffix[suffix.len() - 4..];
62
63 format!("Acc-{}", suffix)
64 };
65
66 println!("Renaming subaccount to: {}", new_name);
67
68 let response = exchange
69 .sub_account_modify(wallet.clone(), new_name, sub_account_user)
70 .await
71 .expect("Failed to rename subaccount");
72
73 let response = match response {
74 Response::Ok(sub_account) => sub_account,
75 Response::Err(error) => {
76 panic!("Failed to rename subaccount: {:?}", error)
77 }
78 };
79
80 println!("Subaccount rename response: {:?} ✓", response);
81
82 tokio::time::sleep(std::time::Duration::from_secs(5)).await;
83
84 println!("Depositing 1 USD to subaccount...");
85
86 let usd = 1_000_000;
87
88 let is_deposit = true;
89
90 let response = exchange
91 .sub_account_transfer(wallet.clone(), is_deposit, sub_account_user, usd)
92 .await
93 .expect("Failed to deposit funds");
94
95 let response = match response {
96 Response::Ok(response) => response,
97 Response::Err(error) => {
98 panic!("Failed to deposit funds: {:?}", error)
99 }
100 };
101
102 println!("Deposit response: {:?} ✓", response);
103
104 tokio::time::sleep(std::time::Duration::from_secs(10)).await;
105
106 println!("Withdrawing funds from subaccount...");
107
108 let response = exchange
109 .sub_account_transfer(wallet.clone(), !is_deposit, sub_account_user, usd)
110 .await
111 .expect("Failed to withdraw funds");
112
113 let response = match response {
114 Response::Ok(response) => response,
115 Response::Err(error) => {
116 panic!("Failed to withdraw funds: {:?}", error)
117 }
118 };
119
120 println!("Withdraw response: {:?} ✓", response);
121}
Sourcepub async fn set_referrer(
&self,
wallet: Arc<LocalWallet>,
code: String,
) -> Result<Response>
pub async fn set_referrer( &self, wallet: Arc<LocalWallet>, code: String, ) -> Result<Response>
Set referrer for the user
§Arguments
wallet
- The wallet to sign the transfer withcode
- The referrer code
Sourcepub async fn schedule_cancel(
&self,
wallet: Arc<LocalWallet>,
time: Option<u64>,
) -> Result<Response>
pub async fn schedule_cancel( &self, wallet: Arc<LocalWallet>, time: Option<u64>, ) -> Result<Response>
Schedule a time in (UTC ms) to cancel all open orders
§Arguments
wallet
- The wallet to sign the transaction withtime
- Optional time in milliseconds to cancel all open orders
§Note
- If
time
isNone
, then unsets any cancel time in the future.time
must be atleast 5 seconds after the current time - Once the time is reached, all open orders will be cancelled and trigger count will be incremented. The max number of triggers is 10 per day. Trigger count resets at 00:00 UTC
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Exchange
impl !RefUnwindSafe for Exchange
impl Send for Exchange
impl Sync for Exchange
impl Unpin for Exchange
impl !UnwindSafe for Exchange
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.