asterdex_sdk/futures/endpoints/
asset.rs1use crate::futures::models::account::{WalletTransferParams, WalletTransferResponse};
4use crate::rest::client::RestClient;
5use crate::rest::error::AsterDexError;
6use crate::rest::response::ApiResponse;
7
8impl RestClient {
9 pub async fn wallet_transfer(
20 &self,
21 params: WalletTransferParams,
22 ) -> Result<ApiResponse<WalletTransferResponse>, AsterDexError> {
23 let transfer_type_str = params.transfer_type.to_string();
24 self.signed_post(
25 "/fapi/v3/asset/wallet/transfer",
26 &[
27 ("asset", params.asset.as_str()),
28 ("amount", params.amount.as_str()),
29 ("type", &transfer_type_str),
30 ],
31 )
32 .await
33 }
34
35 pub async fn sub_account_bind(
46 &self,
47 sub_uid: &str,
48 ) -> Result<ApiResponse<serde_json::Value>, AsterDexError> {
49 self.signed_post("/fapi/v3/apiKeySubAccountBindings", &[("subUid", sub_uid)])
50 .await
51 }
52}
53
54#[cfg(test)]
55mod tests {
56 use super::*;
57
58 #[tokio::test]
60 async fn wallet_transfer_without_credentials_returns_config_error() {
61 let server = mockito::Server::new_async().await;
62 let client = RestClient::new_public(&server.url()).unwrap();
64 let params = WalletTransferParams {
65 asset: "USDT".to_string(),
66 amount: "100.0".to_string(),
67 transfer_type: 1,
68 };
69 let result = client.wallet_transfer(params).await;
70 assert!(
71 matches!(result, Err(AsterDexError::ConfigError { .. })),
72 "expected ConfigError, got: {:?}",
73 result
74 );
75 drop(server);
76 }
77}