use std::sync::Arc;
use crate::client::HttpCore;
use crate::error::Result;
use crate::types::*;
#[derive(Debug, Clone)]
pub struct Wallet {
pub(crate) core: Arc<HttpCore>,
}
impl Wallet {
pub async fn profile(&self, address: &str) -> Result<WalletProfileResponse> {
self.core.get(&format!("/rhc/wallet/{address}"), &()).await
}
pub async fn pnl(&self, address: &str) -> Result<WalletPnlResponse> {
self.core.get(&format!("/rhc/wallet/{address}/pnl"), &()).await
}
pub async fn positions(&self, address: &str) -> Result<WalletPositionsResponse> {
self.core.get(&format!("/rhc/wallet/{address}/positions"), &()).await
}
pub async fn trades(
&self,
address: &str,
params: &WalletTradesParams,
) -> Result<WalletTradesResponse> {
self.core.get(&format!("/rhc/wallet/{address}/trades"), params).await
}
pub async fn watchlist(&self) -> Result<WalletTrackerListResponse> {
self.core.get("/rhc/wallet-tracker/watchlist", &()).await
}
pub async fn track(
&self,
params: &WalletTrackerAddParams,
) -> Result<WalletTrackerWalletResponse> {
self.core.post("/rhc/wallet-tracker/watchlist", params).await
}
pub async fn untrack(&self, address: &str) -> Result<WalletTrackerRemovedResponse> {
self.core.delete(&format!("/rhc/wallet-tracker/watchlist/{address}")).await
}
pub async fn relabel(
&self,
address: &str,
label: Option<&str>,
) -> Result<WalletTrackerWalletResponse> {
#[derive(serde::Serialize)]
struct Body<'a> {
label: Option<&'a str>,
}
self.core
.patch(&format!("/rhc/wallet-tracker/watchlist/{address}"), &Body { label })
.await
}
pub async fn tracked_trades(
&self,
params: &WalletTrackerTradesParams,
) -> Result<WalletTrackerTradesResponse> {
self.core.get("/rhc/wallet-tracker/trades", params).await
}
pub async fn tracked_summary(
&self,
params: &WalletTrackerSummaryParams,
) -> Result<WalletTrackerSummaryResponse> {
self.core.get("/rhc/wallet-tracker/summary", params).await
}
}