1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
use serde::Deserialize;
use serde::Serialize;
/// Detailed information about a candle.
#[derive(Serialize, Deserialize, Debug)]
pub struct CandleDetail {
/// The timestamp of the candle's open time.
#[serde(rename = "d")]
pub timestamp: String,
/// The opening price of the asset at the beginning of the time frame.
#[serde(rename = "o")]
pub open: String,
/// The highest price of the asset during the time frame.
#[serde(rename = "h")]
pub high: String,
/// The lowest price of the asset during the time frame.
#[serde(rename = "l")]
pub low: String,
/// The closing price of the asset at the end of the time frame.
#[serde(rename = "c")]
pub close: String,
/// The total volume of trades (in the base currency) that occurred during the time frame.
#[serde(rename = "v")]
pub volume: String,
}
/// Response containing candle data.
#[derive(Serialize, Deserialize, Debug)]
pub struct CandleResponse {
/// A vector containing detailed information about each candle.
pub data: Vec<CandleDetail>,
/// The current page number in the paginated response.
pub page: i32,
/// The maximum number of items per page in the response.
pub limit: i32,
/// The starting point of the time frame for the candle data.
pub from: String,
/// The ending point of the time frame for the candle data.
pub to: String,
/// The sorting order for the candle data (e.g., "asc" or "desc").
pub sort: String,
}
/// Detailed information about a trade.
#[derive(Serialize, Deserialize, Debug)]
pub struct TradeDetail {
/// The timestamp of the trade.
#[serde(rename = "d")]
pub timestamp: String,
/// The block number in which the trade was recorded.
#[serde(rename = "b")]
pub block_number: i64,
/// The trading pool where the trade occurred.
#[serde(rename = "pool")]
pub pool: String,
/// The trading symbol associated with the trade (e.g., BTC-USDT).
#[serde(rename = "s")]
pub symbol: String,
/// The hash of the transaction related to the trade.
#[serde(rename = "tx")]
pub transaction_hash: String,
/// The maker of the trade (the party who placed the order).
#[serde(rename = "m")]
pub maker: String,
/// The type of trade (e.g., buy or sell).
#[serde(rename = "t")]
pub trade_type: String,
/// The quantity of the base asset traded, in base unit.
#[serde(rename = "bq")]
pub base_quantity: String,
/// The quantity of the quote asset traded, in base unit.
#[serde(rename = "qq")]
pub quote_quantity: String,
/// The price of the trade in the quote asset's unit.
#[serde(rename = "p")]
pub price: String,
}
/// Response containing trade data.
#[derive(Serialize, Deserialize, Debug)]
pub struct TradeResponse {
/// A vector containing detailed information about each trade.
pub data: Vec<TradeDetail>,
/// The current page number in the paginated response.
pub page: i32,
/// The maximum number of items per page in the response.
pub limit: i32,
/// The starting point of the time frame for the trade data.
pub from: String,
/// The ending point of the time frame for the trade data.
pub to: String,
/// The sorting order for the trade data (e.g., "asc" or "desc").
pub sort: String,
}
/// Optional parameters for a candle request.
pub struct CandleOptions {
/// The market type (e.g., spot, futures).
pub market: Option<String>,
/// The interval for the candle data (e.g., 1m, 1h, 1d).
pub interval: Option<String>,
/// The page number for the candle data.
pub page: Option<i32>,
/// The maximum number of items per page in the response.
pub limit: Option<i32>,
/// The starting date & time for the candle data.
pub from: Option<String>,
/// The ending date & time for the candle data.
pub to: Option<String>,
/// The sorting order for the candle data (e.g., "asc" or "desc").
pub sort: Option<String>,
}
impl Default for CandleOptions {
fn default() -> Self {
Self::new()
}
}
/// Provides a builder pattern for setting optional parameters for a candle request.
impl CandleOptions {
/// Creates a new instance of `CandleOptions` with default values.
pub fn new() -> Self {
CandleOptions {
market: None,
interval: None,
page: 1.into(),
limit: 1000.into(),
from: None,
to: None,
sort: Some("desc".into()),
}
}
/// Sets the market for the candle query.
pub fn market(mut self, market: &str) -> Self {
self.market = Some(market.into());
self
}
/// Sets the interval for the candle query.
pub fn interval(mut self, interval: &str) -> Self {
self.interval = Some(interval.into());
self
}
/// Sets the page number for the candle query.
pub fn page(mut self, page: i32) -> Self {
self.page = Some(page);
self
}
/// Sets the limit for the number of results returned.
pub fn limit(mut self, limit: i32) -> Self {
self.limit = Some(limit);
self
}
/// Sets the starting date & time for the candle query.
pub fn from(mut self, from: &str) -> Self {
self.from = Some(from.into());
self
}
/// Sets the ending date & time for the candle query.
pub fn to(mut self, to: &str) -> Self {
self.to = Some(to.into());
self
}
/// Sets the sort order for the candle query (e.g., "asc" or "desc").
pub fn sort(mut self, sort: &str) -> Self {
self.sort = Some(sort.into());
self
}
}
/// Response containing details about symbols.
#[derive(Serialize, Deserialize, Debug)]
pub struct SymbolsResponse {
/// The name of the exchange.
#[serde(rename = "e")]
pub exchange: String,
/// The market type (e.g., spot, futures).
#[serde(rename = "m")]
pub market: String,
/// The base asset of the trading pair.
#[serde(rename = "b")]
pub base: String,
/// The quote asset of the trading pair.
#[serde(rename = "q")]
pub quote: String,
/// The trading symbol (e.g., BTC-USDT).
#[serde(rename = "s")]
pub symbol: String,
/// An optional unique identifier for the symbol.
#[serde(rename = "id")]
pub id: Option<String>,
}
/// Optional parameters for a symbols request.
pub struct SymbolsOptions {
/// The market type (e.g., spot, futures).
pub market: Option<String>,
}
impl Default for SymbolsOptions {
fn default() -> Self {
Self::new()
}
}
impl SymbolsOptions {
/// Creates a new instance of `SymbolsOptions` with default values.
pub fn new() -> Self {
SymbolsOptions { market: None }
}
/// Sets the market for the symbols query.
pub fn market(mut self, market: &str) -> Self {
self.market = Some(market.into());
self
}
}
/// Response containing details about pools.
#[derive(Serialize, Deserialize, Debug)]
pub struct PoolsResponse {
/// The blockchain where the pool is located.
#[serde(rename = "c")]
pub chain: String,
/// The name of the exchange where the pool is available.
#[serde(rename = "e")]
pub exchange: String,
/// The base asset used in the pool.
#[serde(rename = "b")]
pub base: String,
/// The quote asset used in the pool.
#[serde(rename = "q")]
pub quote: String,
/// The address of the base token in the pool.
#[serde(rename = "ba")]
pub baset_address: String,
/// The address of the quote token in the pool.
#[serde(rename = "qa")]
pub quote_address: String,
/// The unique address of the pool.
#[serde(rename = "pa")]
pub pool_address: String,
/// An optional unique identifier for the pool.
#[serde(rename = "id")]
pub id: Option<String>,
}
/// Optional parameters for a trade request.
pub struct TradeOptions {
/// The page number for the trade query.
pub page: Option<i32>,
/// The maximum number of items per page in the response.
pub limit: Option<i32>,
/// The starting date for the trade query.
pub from: Option<String>,
/// The ending date for the trade query.
pub to: Option<String>,
/// The sorting order for the trade query (e.g., "asc" or "desc").
pub sort: Option<String>,
}
impl Default for TradeOptions {
fn default() -> Self {
Self::new()
}
}
/// Provides a builder pattern for setting optional parameters for a trade.
impl TradeOptions {
/// Creates a new instance of `TradeOptions` with default values.
pub fn new() -> Self {
TradeOptions {
page: 1.into(),
limit: 1000.into(),
from: None,
to: None,
sort: Some("desc".into()),
}
}
/// Sets the page number for the trade query.
pub fn page(mut self, page: i32) -> Self {
self.page = Some(page);
self
}
/// Sets the limit for the number of results returned.
pub fn limit(mut self, limit: i32) -> Self {
self.limit = Some(limit);
self
}
/// Sets the starting date for the trade query.
pub fn from(mut self, from: &str) -> Self {
self.from = Some(from.into());
self
}
/// Sets the ending date for the trade query.
pub fn to(mut self, to: &str) -> Self {
self.to = Some(to.into());
self
}
/// Sets the sort order for the trade query (e.g., "asc" or "desc").
pub fn sort(mut self, sort: &str) -> Self {
self.sort = Some(sort.into());
self
}
}
/// Optional parameters for a pools request.
pub struct PoolsOptions {
/// The chain for the pools query.
pub chain: Option<String>,
/// The exchange for the pools query.
pub exchange: Option<String>,
}
impl Default for PoolsOptions {
fn default() -> Self {
Self::new()
}
}
/// Provides a builder pattern for setting optional parameters for a pools request.
impl PoolsOptions {
/// Creates a new instance of `PoolsOptions` with default values.
pub fn new() -> Self {
PoolsOptions {
chain: None,
exchange: None,
}
}
/// Sets the chain for the pools query.
pub fn chain(mut self, chain: &str) -> Self {
self.chain = Some(chain.into());
self
}
/// Sets the exchange for the pools query.
pub fn exchange(mut self, exchange: &str) -> Self {
self.exchange = Some(exchange.into());
self
}
}