1use alloy_primitives::{Address, U256};
7use chrono::{DateTime, Utc};
8use rust_decimal::prelude::ToPrimitive;
9use rust_decimal::Decimal;
10use serde::{Deserialize, Serialize};
11
12pub type Price = u32;
43
44pub type Qty = i64;
56
57pub const SCALE_FACTOR: i64 = 10_000;
63
64pub const MAX_PRICE_TICKS: Price = Price::MAX;
67
68pub const MIN_PRICE_TICKS: Price = 1;
70
71pub const MAX_QTY: Qty = Qty::MAX / 2; pub fn decimal_to_price(decimal: Decimal) -> std::result::Result<Price, &'static str> {
93 let scaled = decimal * Decimal::from(SCALE_FACTOR);
95
96 let rounded = scaled.round();
98
99 let as_u64 = rounded.to_u64().ok_or("Price too large or negative")?;
101
102 if as_u64 < MIN_PRICE_TICKS as u64 {
104 return Ok(MIN_PRICE_TICKS); }
106 if as_u64 > MAX_PRICE_TICKS as u64 {
107 return Err("Price exceeds maximum");
108 }
109
110 Ok(as_u64 as Price)
111}
112
113pub fn price_to_decimal(ticks: Price) -> Decimal {
122 Decimal::from(ticks) / Decimal::from(SCALE_FACTOR)
123}
124
125pub fn decimal_to_qty(decimal: Decimal) -> std::result::Result<Qty, &'static str> {
134 let scaled = decimal * Decimal::from(SCALE_FACTOR);
135 let rounded = scaled.round();
136
137 let as_i64 = rounded.to_i64().ok_or("Quantity too large")?;
138
139 if as_i64.abs() > MAX_QTY {
140 return Err("Quantity exceeds maximum");
141 }
142
143 Ok(as_i64)
144}
145
146pub fn qty_to_decimal(units: Qty) -> Decimal {
152 Decimal::from(units) / Decimal::from(SCALE_FACTOR)
153}
154
155pub fn is_price_tick_aligned(decimal: Decimal, tick_size_decimal: Decimal) -> bool {
165 let tick_size_ticks = match decimal_to_price(tick_size_decimal) {
167 Ok(ticks) => ticks,
168 Err(_) => return false,
169 };
170
171 let price_ticks = match decimal_to_price(decimal) {
173 Ok(ticks) => ticks,
174 Err(_) => return false,
175 };
176
177 if tick_size_ticks == 0 {
180 return true;
181 }
182
183 price_ticks % tick_size_ticks == 0
184}
185
186#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
188#[allow(clippy::upper_case_acronyms)]
189pub enum Side {
190 BUY = 0,
191 SELL = 1,
192}
193
194impl Side {
195 pub fn as_str(&self) -> &'static str {
196 match self {
197 Side::BUY => "BUY",
198 Side::SELL => "SELL",
199 }
200 }
201
202 pub fn opposite(&self) -> Self {
203 match self {
204 Side::BUY => Side::SELL,
205 Side::SELL => Side::BUY,
206 }
207 }
208}
209
210#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
212#[allow(clippy::upper_case_acronyms)]
213pub enum OrderType {
214 GTC,
215 FOK,
216 GTD,
217}
218
219impl OrderType {
220 pub fn as_str(&self) -> &'static str {
221 match self {
222 OrderType::GTC => "GTC",
223 OrderType::FOK => "FOK",
224 OrderType::GTD => "GTD",
225 }
226 }
227}
228
229#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
231pub enum OrderStatus {
232 #[serde(rename = "LIVE")]
233 Live,
234 #[serde(rename = "CANCELLED")]
235 Cancelled,
236 #[serde(rename = "FILLED")]
237 Filled,
238 #[serde(rename = "PARTIAL")]
239 Partial,
240 #[serde(rename = "EXPIRED")]
241 Expired,
242}
243
244#[derive(Debug, Clone, Serialize, Deserialize)]
246pub struct MarketSnapshot {
247 pub token_id: String,
248 pub market_id: String,
249 pub timestamp: DateTime<Utc>,
250 pub bid: Option<Decimal>,
251 pub ask: Option<Decimal>,
252 pub mid: Option<Decimal>,
253 pub spread: Option<Decimal>,
254 pub last_price: Option<Decimal>,
255 pub volume_24h: Option<Decimal>,
256}
257
258#[derive(Debug, Clone, Serialize, Deserialize)]
263pub struct BookLevel {
264 #[serde(with = "rust_decimal::serde::str")]
265 pub price: Decimal,
266 #[serde(with = "rust_decimal::serde::str")]
267 pub size: Decimal,
268}
269
270#[derive(Debug, Clone, Copy, PartialEq, Eq)]
281pub struct FastBookLevel {
282 pub price: Price, pub size: Qty, }
285
286impl FastBookLevel {
287 pub fn new(price: Price, size: Qty) -> Self {
289 Self { price, size }
290 }
291
292 pub fn to_book_level(self) -> BookLevel {
295 BookLevel {
296 price: price_to_decimal(self.price),
297 size: qty_to_decimal(self.size),
298 }
299 }
300
301 pub fn from_book_level(level: &BookLevel) -> std::result::Result<Self, &'static str> {
304 let price = decimal_to_price(level.price)?;
305 let size = decimal_to_qty(level.size)?;
306 Ok(Self::new(price, size))
307 }
308
309 pub fn notional(self) -> i64 {
316 let price_i64 = self.price as i64;
318 (price_i64 * self.size) / SCALE_FACTOR
320 }
321}
322
323#[derive(Debug, Clone, Serialize, Deserialize)]
325pub struct OrderBook {
326 pub token_id: String,
328 pub timestamp: DateTime<Utc>,
330 pub bids: Vec<BookLevel>,
332 pub asks: Vec<BookLevel>,
334 pub sequence: u64,
336}
337
338#[derive(Debug, Clone, Serialize, Deserialize)]
343pub struct OrderDelta {
344 pub token_id: String,
345 pub timestamp: DateTime<Utc>,
346 pub side: Side,
347 pub price: Decimal,
348 pub size: Decimal, pub sequence: u64,
350}
351
352#[derive(Debug, Clone, Copy, PartialEq, Eq)]
363pub struct FastOrderDelta {
364 pub token_id_hash: u64, pub timestamp: DateTime<Utc>,
366 pub side: Side,
367 pub price: Price, pub size: Qty, pub sequence: u64,
370}
371
372impl FastOrderDelta {
373 pub fn from_order_delta(
379 delta: &OrderDelta,
380 tick_size: Option<Decimal>,
381 ) -> std::result::Result<Self, &'static str> {
382 if let Some(tick_size) = tick_size {
384 if !is_price_tick_aligned(delta.price, tick_size) {
385 return Err("Price not aligned to tick size");
386 }
387 }
388
389 let price = decimal_to_price(delta.price)?;
391 let size = decimal_to_qty(delta.size)?;
392
393 let token_id_hash = {
396 use std::collections::hash_map::DefaultHasher;
397 use std::hash::{Hash, Hasher};
398 let mut hasher = DefaultHasher::new();
399 delta.token_id.hash(&mut hasher);
400 hasher.finish()
401 };
402
403 Ok(Self {
404 token_id_hash,
405 timestamp: delta.timestamp,
406 side: delta.side,
407 price,
408 size,
409 sequence: delta.sequence,
410 })
411 }
412
413 pub fn to_order_delta(self, token_id: String) -> OrderDelta {
416 OrderDelta {
417 token_id,
418 timestamp: self.timestamp,
419 side: self.side,
420 price: price_to_decimal(self.price),
421 size: qty_to_decimal(self.size),
422 sequence: self.sequence,
423 }
424 }
425
426 pub fn is_removal(self) -> bool {
428 self.size == 0
429 }
430}
431
432#[derive(Debug, Clone, Serialize, Deserialize)]
434pub struct FillEvent {
435 pub id: String,
436 pub order_id: String,
437 pub token_id: String,
438 pub side: Side,
439 pub price: Decimal,
440 pub size: Decimal,
441 pub timestamp: DateTime<Utc>,
442 pub maker_address: Address,
443 pub taker_address: Address,
444 pub fee: Decimal,
445}
446
447#[derive(Debug, Clone)]
449pub struct OrderRequest {
450 pub token_id: String,
451 pub side: Side,
452 pub price: Decimal,
453 pub size: Decimal,
454 pub order_type: OrderType,
455 pub expiration: Option<DateTime<Utc>>,
456 pub client_id: Option<String>,
457}
458
459#[derive(Debug, Clone)]
461pub struct MarketOrderRequest {
462 pub token_id: String,
463 pub side: Side,
464 pub amount: Decimal, pub slippage_tolerance: Option<Decimal>,
466 pub client_id: Option<String>,
467}
468
469#[derive(Debug, Clone, Serialize, Deserialize)]
471pub struct Order {
472 pub id: String,
473 pub token_id: String,
474 pub side: Side,
475 pub price: Decimal,
476 pub original_size: Decimal,
477 pub filled_size: Decimal,
478 pub remaining_size: Decimal,
479 pub status: OrderStatus,
480 pub order_type: OrderType,
481 pub created_at: DateTime<Utc>,
482 pub updated_at: DateTime<Utc>,
483 pub expiration: Option<DateTime<Utc>>,
484 pub client_id: Option<String>,
485}
486
487#[derive(Debug, Clone, Serialize, Deserialize, Default)]
489pub struct ApiCredentials {
490 #[serde(rename = "apiKey")]
491 pub api_key: String,
492 pub secret: String,
493 pub passphrase: String,
494}
495
496#[derive(Debug, Clone)]
498pub struct OrderOptions {
499 pub tick_size: Option<Decimal>,
500 pub neg_risk: Option<bool>,
501 pub fee_rate_bps: Option<u32>,
502}
503
504#[derive(Debug, Clone)]
506pub struct ExtraOrderArgs {
507 pub fee_rate_bps: u32,
508 pub nonce: U256,
509 pub taker: String,
510}
511
512impl Default for ExtraOrderArgs {
513 fn default() -> Self {
514 Self {
515 fee_rate_bps: 0,
516 nonce: U256::ZERO,
517 taker: "0x0000000000000000000000000000000000000000".to_string(),
518 }
519 }
520}
521
522#[derive(Debug, Clone)]
524pub struct MarketOrderArgs {
525 pub token_id: String,
526 pub amount: Decimal,
527}
528
529#[derive(Debug, Clone, Serialize, Deserialize)]
531#[serde(rename_all = "camelCase")]
532pub struct SignedOrderRequest {
533 pub salt: u64,
534 pub maker: String,
535 pub signer: String,
536 pub taker: String,
537 pub token_id: String,
538 pub maker_amount: String,
539 pub taker_amount: String,
540 pub expiration: String,
541 pub nonce: String,
542 pub fee_rate_bps: String,
543 pub side: String,
544 pub signature_type: u8,
545 pub signature: String,
546}
547
548#[derive(Debug, Serialize)]
550#[serde(rename_all = "camelCase")]
551pub struct PostOrder {
552 pub order: SignedOrderRequest,
553 pub owner: String,
554 pub order_type: OrderType,
555}
556
557impl PostOrder {
558 pub fn new(order: SignedOrderRequest, owner: String, order_type: OrderType) -> Self {
559 Self {
560 order,
561 owner,
562 order_type,
563 }
564 }
565}
566
567#[derive(Debug, Clone, Serialize, Deserialize)]
569pub struct Market {
570 pub condition_id: String,
571 pub tokens: [Token; 2],
572 pub rewards: Rewards,
573 pub min_incentive_size: Option<String>,
574 pub max_incentive_spread: Option<String>,
575 pub active: bool,
576 pub closed: bool,
577 pub question_id: String,
578 #[serde(with = "rust_decimal::serde::str")]
579 pub minimum_order_size: Decimal,
580 #[serde(with = "rust_decimal::serde::str")]
581 pub minimum_tick_size: Decimal,
582 pub description: String,
583 pub category: Option<String>,
584 pub end_date_iso: Option<String>,
585 pub game_start_time: Option<String>,
586 pub question: String,
587 pub market_slug: String,
588 #[serde(with = "rust_decimal::serde::str")]
589 pub seconds_delay: Decimal,
590 pub icon: String,
591 pub fpmm: String,
592}
593
594#[derive(Debug, Clone, Serialize, Deserialize)]
596pub struct Token {
597 pub token_id: String,
598 pub outcome: String,
599}
600
601#[derive(Debug, Clone, Serialize, Deserialize)]
603pub struct ClientConfig {
604 pub base_url: String,
606 pub chain_id: u64,
608 pub private_key: Option<String>,
610 pub api_credentials: Option<ApiCredentials>,
612 pub max_slippage: Option<Decimal>,
614 pub fee_rate: Option<Decimal>,
616 pub timeout: Option<std::time::Duration>,
618 pub max_connections: Option<usize>,
620}
621
622impl Default for ClientConfig {
623 fn default() -> Self {
624 Self {
625 base_url: "https://clob.polymarket.com".to_string(),
626 chain_id: 137, private_key: None,
628 api_credentials: None,
629 timeout: Some(std::time::Duration::from_secs(30)),
630 max_connections: Some(100),
631 max_slippage: None,
632 fee_rate: None,
633 }
634 }
635}
636
637#[derive(Debug, Clone, Serialize, Deserialize)]
639pub struct WssAuth {
640 pub address: String,
642 pub signature: String,
644 pub timestamp: u64,
646 pub nonce: String,
648}
649
650#[derive(Debug, Clone, Serialize, Deserialize)]
652pub struct WssSubscription {
653 pub auth: WssAuth,
655 pub markets: Option<Vec<String>>,
657 pub asset_ids: Option<Vec<String>>,
659 #[serde(rename = "type")]
661 pub channel_type: String,
662}
663
664#[derive(Debug, Clone, Serialize, Deserialize)]
666#[serde(tag = "type")]
667pub enum StreamMessage {
668 #[serde(rename = "book_update")]
669 BookUpdate { data: OrderDelta },
670 #[serde(rename = "trade")]
671 Trade { data: FillEvent },
672 #[serde(rename = "order_update")]
673 OrderUpdate { data: Order },
674 #[serde(rename = "heartbeat")]
675 Heartbeat { timestamp: DateTime<Utc> },
676 #[serde(rename = "user_order_update")]
678 UserOrderUpdate { data: Order },
679 #[serde(rename = "user_trade")]
680 UserTrade { data: FillEvent },
681 #[serde(rename = "market_book_update")]
683 MarketBookUpdate { data: OrderDelta },
684 #[serde(rename = "market_trade")]
685 MarketTrade { data: FillEvent },
686}
687
688#[derive(Debug, Clone, Serialize, Deserialize)]
690pub struct Subscription {
691 pub token_ids: Vec<String>,
692 pub channels: Vec<String>,
693}
694
695#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
697pub enum WssChannelType {
698 #[serde(rename = "USER")]
699 User,
700 #[serde(rename = "MARKET")]
701 Market,
702}
703
704impl WssChannelType {
705 pub fn as_str(&self) -> &'static str {
706 match self {
707 WssChannelType::User => "USER",
708 WssChannelType::Market => "MARKET",
709 }
710 }
711}
712
713#[derive(Debug, Clone, Serialize, Deserialize)]
715pub struct Quote {
716 pub token_id: String,
717 pub side: Side,
718 #[serde(with = "rust_decimal::serde::str")]
719 pub price: Decimal,
720 pub timestamp: DateTime<Utc>,
721}
722
723#[derive(Debug, Clone, Serialize, Deserialize)]
725pub struct Balance {
726 pub token_id: String,
727 pub available: Decimal,
728 pub locked: Decimal,
729 pub total: Decimal,
730}
731
732#[derive(Debug, Clone)]
734pub struct Metrics {
735 pub orders_per_second: f64,
736 pub avg_latency_ms: f64,
737 pub error_rate: f64,
738 pub uptime_pct: f64,
739}
740
741pub type TokenId = String;
743pub type OrderId = String;
744pub type MarketId = String;
745pub type ClientId = String;
746
747#[derive(Debug, Clone)]
749pub struct OpenOrderParams {
750 pub id: Option<String>,
751 pub asset_id: Option<String>,
752 pub market: Option<String>,
753}
754
755impl OpenOrderParams {
756 pub fn to_query_params(&self) -> Vec<(&str, &String)> {
757 let mut params = Vec::with_capacity(3);
758
759 if let Some(x) = &self.id {
760 params.push(("id", x));
761 }
762
763 if let Some(x) = &self.asset_id {
764 params.push(("asset_id", x));
765 }
766
767 if let Some(x) = &self.market {
768 params.push(("market", x));
769 }
770 params
771 }
772}
773
774#[derive(Debug, Clone)]
776pub struct TradeParams {
777 pub id: Option<String>,
778 pub maker_address: Option<String>,
779 pub market: Option<String>,
780 pub asset_id: Option<String>,
781 pub before: Option<u64>,
782 pub after: Option<u64>,
783}
784
785impl TradeParams {
786 pub fn to_query_params(&self) -> Vec<(&str, String)> {
787 let mut params = Vec::with_capacity(6);
788
789 if let Some(x) = &self.id {
790 params.push(("id", x.clone()));
791 }
792
793 if let Some(x) = &self.asset_id {
794 params.push(("asset_id", x.clone()));
795 }
796
797 if let Some(x) = &self.market {
798 params.push(("market", x.clone()));
799 }
800
801 if let Some(x) = &self.maker_address {
802 params.push(("maker_address", x.clone()));
803 }
804
805 if let Some(x) = &self.before {
806 params.push(("before", x.to_string()));
807 }
808
809 if let Some(x) = &self.after {
810 params.push(("after", x.to_string()));
811 }
812
813 params
814 }
815}
816
817#[derive(Debug, Clone, Serialize, Deserialize)]
819pub struct OpenOrder {
820 pub associate_trades: Vec<String>,
821 pub id: String,
822 pub status: String,
823 pub market: String,
824 #[serde(with = "rust_decimal::serde::str")]
825 pub original_size: Decimal,
826 pub outcome: String,
827 pub maker_address: String,
828 pub owner: String,
829 #[serde(with = "rust_decimal::serde::str")]
830 pub price: Decimal,
831 pub side: Side,
832 #[serde(with = "rust_decimal::serde::str")]
833 pub size_matched: Decimal,
834 pub asset_id: String,
835 #[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
836 pub expiration: u64,
837 #[serde(rename = "type")]
838 pub order_type: OrderType,
839 #[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
840 pub created_at: u64,
841}
842
843#[derive(Debug, Clone, Serialize, Deserialize)]
845pub struct BalanceAllowance {
846 pub asset_id: String,
847 #[serde(with = "rust_decimal::serde::str")]
848 pub balance: Decimal,
849 #[serde(with = "rust_decimal::serde::str")]
850 pub allowance: Decimal,
851}
852
853#[derive(Default)]
855pub struct BalanceAllowanceParams {
856 pub asset_type: Option<AssetType>,
857 pub token_id: Option<String>,
858 pub signature_type: Option<u8>,
859}
860
861impl BalanceAllowanceParams {
862 pub fn to_query_params(&self) -> Vec<(&str, String)> {
863 let mut params = Vec::with_capacity(3);
864
865 if let Some(x) = &self.asset_type {
866 params.push(("asset_type", x.to_string()));
867 }
868
869 if let Some(x) = &self.token_id {
870 params.push(("token_id", x.to_string()));
871 }
872
873 if let Some(x) = &self.signature_type {
874 params.push(("signature_type", x.to_string()));
875 }
876 params
877 }
878
879 pub fn set_signature_type(&mut self, s: u8) {
880 self.signature_type = Some(s);
881 }
882}
883
884#[allow(clippy::upper_case_acronyms)]
886pub enum AssetType {
887 COLLATERAL,
888 CONDITIONAL,
889}
890
891impl std::fmt::Display for AssetType {
892 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
893 match self {
894 AssetType::COLLATERAL => write!(f, "COLLATERAL"),
895 AssetType::CONDITIONAL => write!(f, "CONDITIONAL"),
896 }
897 }
898}
899
900#[derive(Debug, Clone, Serialize, Deserialize)]
902pub struct NotificationParams {
903 pub signature: String,
904 pub timestamp: u64,
905}
906
907#[derive(Debug, Clone, Serialize, Deserialize)]
909pub struct BatchMidpointRequest {
910 pub token_ids: Vec<String>,
911}
912
913#[derive(Debug, Clone, Serialize, Deserialize)]
915pub struct BatchMidpointResponse {
916 pub midpoints: std::collections::HashMap<String, Option<Decimal>>,
917}
918
919#[derive(Debug, Clone, Serialize, Deserialize)]
921pub struct BatchPriceRequest {
922 pub token_ids: Vec<String>,
923}
924
925#[derive(Debug, Clone, Serialize, Deserialize)]
927pub struct TokenPrice {
928 pub token_id: String,
929 #[serde(skip_serializing_if = "Option::is_none")]
930 pub bid: Option<Decimal>,
931 #[serde(skip_serializing_if = "Option::is_none")]
932 pub ask: Option<Decimal>,
933 #[serde(skip_serializing_if = "Option::is_none")]
934 pub mid: Option<Decimal>,
935}
936
937#[derive(Debug, Clone, Serialize, Deserialize)]
939pub struct BatchPriceResponse {
940 pub prices: Vec<TokenPrice>,
941}
942
943#[derive(Debug, Deserialize)]
945pub struct ApiKeysResponse {
946 #[serde(rename = "apiKeys")]
947 pub api_keys: Vec<String>,
948}
949
950#[derive(Debug, Deserialize)]
951pub struct MidpointResponse {
952 #[serde(with = "rust_decimal::serde::str")]
953 pub mid: Decimal,
954}
955
956#[derive(Debug, Deserialize)]
957pub struct PriceResponse {
958 #[serde(with = "rust_decimal::serde::str")]
959 pub price: Decimal,
960}
961
962#[derive(Debug, Deserialize)]
963pub struct SpreadResponse {
964 #[serde(with = "rust_decimal::serde::str")]
965 pub spread: Decimal,
966}
967
968#[derive(Debug, Deserialize)]
969pub struct TickSizeResponse {
970 #[serde(with = "rust_decimal::serde::str")]
971 pub minimum_tick_size: Decimal,
972}
973
974#[derive(Debug, Deserialize)]
975pub struct NegRiskResponse {
976 pub neg_risk: bool,
977}
978
979#[derive(Debug, Serialize, Deserialize)]
980pub struct BookParams {
981 pub token_id: String,
982 pub side: Side,
983}
984
985#[derive(Debug, Deserialize)]
986pub struct OrderBookSummary {
987 pub market: String,
988 pub asset_id: String,
989 pub hash: String,
990 #[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
991 pub timestamp: u64,
992 pub bids: Vec<OrderSummary>,
993 pub asks: Vec<OrderSummary>,
994}
995
996#[derive(Debug, Deserialize)]
997pub struct OrderSummary {
998 #[serde(with = "rust_decimal::serde::str")]
999 pub price: Decimal,
1000 #[serde(with = "rust_decimal::serde::str")]
1001 pub size: Decimal,
1002}
1003
1004#[derive(Debug, Serialize, Deserialize)]
1005pub struct MarketsResponse {
1006 #[serde(with = "rust_decimal::serde::str")]
1007 pub limit: Decimal,
1008 #[serde(with = "rust_decimal::serde::str")]
1009 pub count: Decimal,
1010 pub next_cursor: Option<String>,
1011 pub data: Vec<Market>,
1012}
1013
1014#[derive(Debug, Serialize, Deserialize)]
1015pub struct SimplifiedMarketsResponse {
1016 #[serde(with = "rust_decimal::serde::str")]
1017 pub limit: Decimal,
1018 #[serde(with = "rust_decimal::serde::str")]
1019 pub count: Decimal,
1020 pub next_cursor: Option<String>,
1021 pub data: Vec<SimplifiedMarket>,
1022}
1023
1024#[derive(Debug, Serialize, Deserialize)]
1026pub struct SimplifiedMarket {
1027 pub condition_id: String,
1028 pub tokens: [Token; 2],
1029 pub rewards: Rewards,
1030 pub min_incentive_size: Option<String>,
1031 pub max_incentive_spread: Option<String>,
1032 pub active: bool,
1033 pub closed: bool,
1034}
1035
1036#[derive(Debug, Clone, Serialize, Deserialize)]
1038pub struct Rewards {
1039 pub rates: Option<serde_json::Value>,
1040 #[serde(with = "rust_decimal::serde::str")]
1041 pub min_size: Decimal,
1042 #[serde(with = "rust_decimal::serde::str")]
1043 pub max_spread: Decimal,
1044 pub event_start_date: Option<String>,
1045 pub event_end_date: Option<String>,
1046 #[serde(skip_serializing_if = "Option::is_none")]
1047 pub in_game_multiplier: Option<Decimal>,
1048 #[serde(skip_serializing_if = "Option::is_none")]
1049 pub reward_epoch: Option<Decimal>,
1050}
1051
1052pub type ClientResult<T> = anyhow::Result<T>;
1054
1055pub type Result<T> = std::result::Result<T, crate::errors::PolyfillError>;
1057
1058pub type ApiCreds = ApiCredentials;
1060pub type CreateOrderOptions = OrderOptions;
1061pub type OrderArgs = OrderRequest;