mirror of
https://github.com/floor-licker/polyfill-rs.git
synced 2026-08-23 09:28:05 +00:00
Add missing get_spreads method to achieve complete API parity
Add get_spreads method for batch spread queries to match reference implementation exactly, now have all 42 methods with identical signatures and functionality for true drop-in replacement compatibility.
This commit is contained in:
@@ -190,6 +190,31 @@ impl ClobClient {
|
|||||||
Ok(spread)
|
Ok(spread)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get spreads for multiple tokens (batch)
|
||||||
|
pub async fn get_spreads(&self, token_ids: &[String]) -> Result<std::collections::HashMap<String, Decimal>> {
|
||||||
|
let request_data: Vec<std::collections::HashMap<&str, String>> = token_ids
|
||||||
|
.iter()
|
||||||
|
.map(|id| {
|
||||||
|
let mut map = std::collections::HashMap::new();
|
||||||
|
map.insert("token_id", id.clone());
|
||||||
|
map
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let response = self.http_client
|
||||||
|
.post(&format!("{}/spreads", self.base_url))
|
||||||
|
.json(&request_data)
|
||||||
|
.send()
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
if !response.status().is_success() {
|
||||||
|
return Err(PolyfillError::api(response.status().as_u16(), "Failed to get batch spreads"));
|
||||||
|
}
|
||||||
|
|
||||||
|
response.json::<std::collections::HashMap<String, Decimal>>().await
|
||||||
|
.map_err(|e| PolyfillError::parse(format!("Failed to parse response: {}", e), None))
|
||||||
|
}
|
||||||
|
|
||||||
/// Get price for a token and side
|
/// Get price for a token and side
|
||||||
pub async fn get_price(&self, token_id: &str, side: Side) -> Result<PriceResponse> {
|
pub async fn get_price(&self, token_id: &str, side: Side) -> Result<PriceResponse> {
|
||||||
let response = self.http_client
|
let response = self.http_client
|
||||||
|
|||||||
Reference in New Issue
Block a user