Skip to content

Commit eccec31

Browse files
committed
Add Historical Orders to info client
1 parent 8cae88c commit eccec31

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/bin/info.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ async fn main() {
2525
spot_meta_and_asset_contexts_example(&info_client).await;
2626
query_order_by_oid_example(&info_client).await;
2727
query_referral_state_example(&info_client).await;
28+
historical_orders_example(&info_client).await;
2829
}
2930

3031
fn address() -> H160 {
@@ -174,3 +175,11 @@ async fn query_referral_state_example(info_client: &InfoClient) {
174175
info_client.query_referral_state(user).await.unwrap()
175176
);
176177
}
178+
179+
async fn historical_orders_example(info_client: &InfoClient) {
180+
let user = address();
181+
info!(
182+
"Historical orders for {user}: {:?}",
183+
info_client.historical_orders(user).await.unwrap()
184+
);
185+
}

src/info/info_client.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
info::{
33
CandlesSnapshotResponse, FundingHistoryResponse, L2SnapshotResponse, OpenOrdersResponse,
4-
RecentTradesResponse, UserFillsResponse, UserStateResponse,
4+
OrderInfo, RecentTradesResponse, UserFillsResponse, UserStateResponse,
55
},
66
meta::{Meta, SpotMeta, SpotMetaAndAssetCtxs},
77
prelude::*,
@@ -84,6 +84,9 @@ pub enum InfoRequest {
8484
Referral {
8585
user: H160,
8686
},
87+
HistoricalOrders {
88+
user: H160,
89+
},
8790
}
8891

8992
#[derive(Debug)]
@@ -287,4 +290,9 @@ impl InfoClient {
287290
let input = InfoRequest::Referral { user: address };
288291
self.send_info_request(input).await
289292
}
293+
294+
pub async fn historical_orders(&self, address: H160) -> Result<Vec<OrderInfo>> {
295+
let input = InfoRequest::HistoricalOrders { user: address };
296+
self.send_info_request(input).await
297+
}
290298
}

0 commit comments

Comments
 (0)