1use crate::client::BybitClient;
4use crate::error::Result;
5use crate::models::account::*;
6use crate::models::*;
7
8impl BybitClient {
9 pub async fn get_wallet_balance(&self, account_type: AccountType) -> Result<WalletBalance> {
14 let account_type_str = format!("{:?}", account_type);
15 let params = vec![("accountType", account_type_str.as_str())];
16
17 self.get("/v5/account/wallet-balance", ¶ms).await
18 }
19
20 pub async fn get_account_info(&self) -> Result<AccountInfo> {
22 self.get("/v5/account/info", &[]).await
23 }
24
25 pub async fn get_fee_rate(&self, category: Category, symbol: Option<&str>) -> Result<FeeRates> {
31 let cat_str = category.to_string();
32 let mut params = vec![("category", cat_str.as_str())];
33
34 if let Some(s) = symbol {
35 params.push(("symbol", s));
36 }
37
38 self.get("/v5/account/fee-rate", ¶ms).await
39 }
40
41 pub async fn get_transaction_log(
47 &self,
48 category: Option<Category>,
49 limit: Option<u32>,
50 ) -> Result<TransactionLogs> {
51 let limit_str = limit.unwrap_or(20).to_string();
52 let mut params = vec![("limit", limit_str.as_str())];
53
54 let cat_str;
55 if let Some(c) = category {
56 cat_str = c.to_string();
57 params.push(("category", cat_str.as_str()));
58 }
59
60 self.get("/v5/account/transaction-log", ¶ms).await
61 }
62
63 pub async fn set_margin_mode(&self, margin_mode: MarginMode) -> Result<serde_json::Value> {
68 let mode_str = format!("{:?}", margin_mode);
69 let params = SetMarginModeParams {
70 set_margin_mode: mode_str,
71 };
72
73 self.post("/v5/account/set-margin-mode", ¶ms).await
74 }
75
76 pub async fn get_collateral_info(&self, currency: Option<&str>) -> Result<CollateralInfo> {
81 let mut params = vec![];
82
83 if let Some(c) = currency {
84 params.push(("currency", c));
85 }
86
87 self.get("/v5/account/collateral-info", ¶ms).await
88 }
89
90 pub async fn get_borrow_history(
96 &self,
97 currency: Option<&str>,
98 limit: Option<u32>,
99 ) -> Result<BorrowHistory> {
100 let limit_str = limit.unwrap_or(20).to_string();
101 let mut params = vec![("limit", limit_str.as_str())];
102
103 if let Some(c) = currency {
104 params.push(("currency", c));
105 }
106
107 self.get("/v5/account/borrow-history", ¶ms).await
108 }
109}