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