zcash_client_backend/tor/http/cryptex/
coinbase.rs1use rust_decimal::Decimal;
2use serde::Deserialize;
3
4use super::{Exchange, ExchangeData, RETRY_LIMIT, retry_filter};
5use crate::tor::{Client, Error};
6
7pub struct Coinbase {
9 _private: (),
10}
11
12impl Coinbase {
13 pub fn unauthenticated() -> Self {
15 Self { _private: () }
16 }
17}
18
19#[derive(Debug, Deserialize)]
20#[allow(dead_code)]
21struct CoinbaseData {
22 ask: Decimal,
23 bid: Decimal,
24 volume: Decimal,
25 trade_id: u32,
26 price: Decimal,
27 size: Decimal,
28 time: String,
29 rfq_volume: Option<Decimal>,
30 conversions_volume: Option<Decimal>,
31}
32
33impl Exchange for Coinbase {
34 #[allow(dead_code)]
35 async fn query_zec_to_usd(&self, client: &Client) -> Result<ExchangeData, Error> {
36 let res = client
39 .http_get_json::<CoinbaseData>(
40 "https://api.exchange.coinbase.com/products/ZEC-USD/ticker"
41 .parse()
42 .unwrap(),
43 |b| b,
44 RETRY_LIMIT,
45 retry_filter,
46 )
47 .await?;
48 let data = res.into_body();
49 Ok(ExchangeData {
50 bid: data.bid,
51 ask: data.ask,
52 })
53 }
54}