crypto_pay_api/models/
exchange_rate.rs

1use crate::utils::{deserialize_decimal, serialize_decimal_to_string};
2use rust_decimal::Decimal;
3use serde::{Deserialize, Serialize};
4
5use super::{CryptoCurrencyCode, FiatCurrencyCode};
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct ExchangeRate {
9    /// True, if the received rate is up-to-date.
10    pub is_valid: bool,
11    /// True, if the source currency is a cryptocurrency.
12    pub is_crypto: bool,
13    /// True, if the source is the fiat currency.
14    pub is_fiat: bool,
15    /// Cryptocurrency alphabetic code. Currently, can be “USDT”, “TON”, “BTC”, “ETH”, “LTC”, “BNB”, “TRX” and “USDC”.
16    pub source: CryptoCurrencyCode,
17    /// Fiat currency code. Currently, can be “USD”, “EUR”, “RUB”, “BYN”, “UAH”, “GBP”, “CNY”, “KZT”, “UZS”, “GEL”, “TRY”, “AMD”, “THB”, “INR”, “BRL”, “IDR”, “AZN”, “AED”, “PLN” and “ILS".
18    pub target: FiatCurrencyCode,
19    /// The current rate of the source asset valued in the target currency.
20    #[serde(deserialize_with = "deserialize_decimal")]
21    #[serde(serialize_with = "serialize_decimal_to_string")]
22    pub rate: Decimal, // 1 source = rate target
23}