zcash_client_backend/tor/http/cryptex/
mexc.rs1use rust_decimal::Decimal;
2use serde::Deserialize;
3
4use super::{Exchange, ExchangeData, RETRY_LIMIT, retry_filter};
5use crate::tor::{Client, Error};
6
7pub struct Mexc {
9 _private: (),
10}
11
12impl Mexc {
13 pub fn unauthenticated() -> Self {
15 Self { _private: () }
16 }
17}
18
19#[derive(Debug, Deserialize)]
20#[allow(dead_code)]
21#[allow(non_snake_case)]
22struct MexcData {
23 symbol: String,
24 priceChange: Decimal,
25 priceChangePercent: Decimal,
26 prevClosePrice: Decimal,
27 lastPrice: Decimal,
28 bidPrice: Decimal,
29 bidQty: Decimal,
30 askPrice: Decimal,
31 askQty: Decimal,
32 openPrice: Decimal,
33 highPrice: Decimal,
34 lowPrice: Decimal,
35 volume: Decimal,
36 quoteVolume: Decimal,
37 openTime: u64,
38 closeTime: u64,
39}
40
41impl Exchange for Mexc {
42 async fn query_zec_to_usd(&self, client: &Client) -> Result<ExchangeData, Error> {
43 let res = client
46 .http_get_json::<MexcData>(
47 "https://api.mexc.com/api/v3/ticker/24hr?symbol=ZECUSDT"
48 .parse()
49 .unwrap(),
50 |b| b,
51 RETRY_LIMIT,
52 retry_filter,
53 )
54 .await?;
55 let data = res.into_body();
56 Ok(ExchangeData {
57 bid: data.bidPrice,
58 ask: data.askPrice,
59 })
60 }
61}