use super::super::utils::http_get;
use crate::error::Result;
use std::collections::BTreeMap;
const BASE_URL: &str = "https://api.gateio.ws/api/v4";
pub struct GateSwapRestClient {
_api_key: Option<String>,
_api_secret: Option<String>,
}
impl GateSwapRestClient {
pub fn new(api_key: Option<String>, api_secret: Option<String>) -> Self {
GateSwapRestClient { _api_key: api_key, _api_secret: api_secret }
}
pub fn fetch_l2_snapshot(symbol: &str) -> Result<String> {
let settle = if symbol.ends_with("_USD") {
"btc"
} else if symbol.ends_with("_USDT") {
"usdt"
} else {
panic!("Unknown symbol {symbol}");
};
gen_api!(format!("/futures/{settle}/order_book?contract={symbol}&limit=200"))
}
pub fn fetch_open_interest(symbol: &str) -> Result<String> {
let settle = if symbol.ends_with("_USD") {
"btc"
} else if symbol.ends_with("_USDT") {
"usdt"
} else {
panic!("Unknown symbol {symbol}");
};
gen_api!(format!("/futures/{settle}/contract_stats?contract={symbol}&interval=5m"))
}
}