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 pub minimum_order_size: Decimal,
579 pub minimum_tick_size: Decimal,
580 pub description: String,
581 pub category: Option<String>,
582 pub end_date_iso: Option<String>,
583 pub game_start_time: Option<String>,
584 pub question: String,
585 pub market_slug: String,
586 pub seconds_delay: Decimal,
587 pub icon: String,
588 pub fpmm: String,
589 #[serde(default)]
591 pub enable_order_book: bool,
592 #[serde(default)]
593 pub archived: bool,
594 #[serde(default)]
595 pub accepting_orders: bool,
596 #[serde(default)]
597 pub accepting_order_timestamp: Option<String>,
598 #[serde(default)]
599 pub maker_base_fee: Decimal,
600 #[serde(default)]
601 pub taker_base_fee: Decimal,
602 #[serde(default)]
603 pub notifications_enabled: bool,
604 #[serde(default)]
605 pub neg_risk: bool,
606 #[serde(default)]
607 pub neg_risk_market_id: String,
608 #[serde(default)]
609 pub neg_risk_request_id: String,
610 #[serde(default)]
611 pub image: String,
612 #[serde(default)]
613 pub is_50_50_outcome: bool,
614}
615
616#[derive(Debug, Clone, Serialize, Deserialize)]
618pub struct Token {
619 pub token_id: String,
620 pub outcome: String,
621 pub price: Decimal,
622 #[serde(default)]
623 pub winner: bool,
624}
625
626#[derive(Debug, Clone, Serialize, Deserialize)]
628pub struct ClientConfig {
629 pub base_url: String,
631 pub chain_id: u64,
633 pub private_key: Option<String>,
635 pub api_credentials: Option<ApiCredentials>,
637 pub max_slippage: Option<Decimal>,
639 pub fee_rate: Option<Decimal>,
641 pub timeout: Option<std::time::Duration>,
643 pub max_connections: Option<usize>,
645}
646
647impl Default for ClientConfig {
648 fn default() -> Self {
649 Self {
650 base_url: "https://clob.polymarket.com".to_string(),
651 chain_id: 137, private_key: None,
653 api_credentials: None,
654 timeout: Some(std::time::Duration::from_secs(30)),
655 max_connections: Some(100),
656 max_slippage: None,
657 fee_rate: None,
658 }
659 }
660}
661
662#[derive(Debug, Clone, Serialize, Deserialize)]
664pub struct WssAuth {
665 pub address: String,
667 pub signature: String,
669 pub timestamp: u64,
671 pub nonce: String,
673}
674
675#[derive(Debug, Clone, Serialize, Deserialize)]
677pub struct WssSubscription {
678 pub auth: WssAuth,
680 pub markets: Option<Vec<String>>,
682 pub asset_ids: Option<Vec<String>>,
684 #[serde(rename = "type")]
686 pub channel_type: String,
687}
688
689#[derive(Debug, Clone, Serialize, Deserialize)]
691#[serde(tag = "type")]
692pub enum StreamMessage {
693 #[serde(rename = "book_update")]
694 BookUpdate { data: OrderDelta },
695 #[serde(rename = "trade")]
696 Trade { data: FillEvent },
697 #[serde(rename = "order_update")]
698 OrderUpdate { data: Order },
699 #[serde(rename = "heartbeat")]
700 Heartbeat { timestamp: DateTime<Utc> },
701 #[serde(rename = "user_order_update")]
703 UserOrderUpdate { data: Order },
704 #[serde(rename = "user_trade")]
705 UserTrade { data: FillEvent },
706 #[serde(rename = "market_book_update")]
708 MarketBookUpdate { data: OrderDelta },
709 #[serde(rename = "market_trade")]
710 MarketTrade { data: FillEvent },
711}
712
713#[derive(Debug, Clone, Serialize, Deserialize)]
715pub struct Subscription {
716 pub token_ids: Vec<String>,
717 pub channels: Vec<String>,
718}
719
720#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
722pub enum WssChannelType {
723 #[serde(rename = "USER")]
724 User,
725 #[serde(rename = "MARKET")]
726 Market,
727}
728
729impl WssChannelType {
730 pub fn as_str(&self) -> &'static str {
731 match self {
732 WssChannelType::User => "USER",
733 WssChannelType::Market => "MARKET",
734 }
735 }
736}
737
738#[derive(Debug, Clone, Serialize, Deserialize)]
740pub struct Quote {
741 pub token_id: String,
742 pub side: Side,
743 #[serde(with = "rust_decimal::serde::str")]
744 pub price: Decimal,
745 pub timestamp: DateTime<Utc>,
746}
747
748#[derive(Debug, Clone, Serialize, Deserialize)]
750pub struct Balance {
751 pub token_id: String,
752 pub available: Decimal,
753 pub locked: Decimal,
754 pub total: Decimal,
755}
756
757#[derive(Debug, Clone)]
759pub struct Metrics {
760 pub orders_per_second: f64,
761 pub avg_latency_ms: f64,
762 pub error_rate: f64,
763 pub uptime_pct: f64,
764}
765
766pub type TokenId = String;
768pub type OrderId = String;
769pub type MarketId = String;
770pub type ClientId = String;
771
772#[derive(Debug, Clone)]
774pub struct OpenOrderParams {
775 pub id: Option<String>,
776 pub asset_id: Option<String>,
777 pub market: Option<String>,
778}
779
780impl OpenOrderParams {
781 pub fn to_query_params(&self) -> Vec<(&str, &String)> {
782 let mut params = Vec::with_capacity(3);
783
784 if let Some(x) = &self.id {
785 params.push(("id", x));
786 }
787
788 if let Some(x) = &self.asset_id {
789 params.push(("asset_id", x));
790 }
791
792 if let Some(x) = &self.market {
793 params.push(("market", x));
794 }
795 params
796 }
797}
798
799#[derive(Debug, Clone)]
801pub struct TradeParams {
802 pub id: Option<String>,
803 pub maker_address: Option<String>,
804 pub market: Option<String>,
805 pub asset_id: Option<String>,
806 pub before: Option<u64>,
807 pub after: Option<u64>,
808}
809
810impl TradeParams {
811 pub fn to_query_params(&self) -> Vec<(&str, String)> {
812 let mut params = Vec::with_capacity(6);
813
814 if let Some(x) = &self.id {
815 params.push(("id", x.clone()));
816 }
817
818 if let Some(x) = &self.asset_id {
819 params.push(("asset_id", x.clone()));
820 }
821
822 if let Some(x) = &self.market {
823 params.push(("market", x.clone()));
824 }
825
826 if let Some(x) = &self.maker_address {
827 params.push(("maker_address", x.clone()));
828 }
829
830 if let Some(x) = &self.before {
831 params.push(("before", x.to_string()));
832 }
833
834 if let Some(x) = &self.after {
835 params.push(("after", x.to_string()));
836 }
837
838 params
839 }
840}
841
842#[derive(Debug, Clone, Serialize, Deserialize)]
844pub struct OpenOrder {
845 pub associate_trades: Vec<String>,
846 pub id: String,
847 pub status: String,
848 pub market: String,
849 #[serde(with = "rust_decimal::serde::str")]
850 pub original_size: Decimal,
851 pub outcome: String,
852 pub maker_address: String,
853 pub owner: String,
854 #[serde(with = "rust_decimal::serde::str")]
855 pub price: Decimal,
856 pub side: Side,
857 #[serde(with = "rust_decimal::serde::str")]
858 pub size_matched: Decimal,
859 pub asset_id: String,
860 #[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
861 pub expiration: u64,
862 #[serde(rename = "type")]
863 pub order_type: OrderType,
864 #[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
865 pub created_at: u64,
866}
867
868#[derive(Debug, Clone, Serialize, Deserialize)]
870pub struct BalanceAllowance {
871 pub asset_id: String,
872 #[serde(with = "rust_decimal::serde::str")]
873 pub balance: Decimal,
874 #[serde(with = "rust_decimal::serde::str")]
875 pub allowance: Decimal,
876}
877
878#[derive(Default)]
880pub struct BalanceAllowanceParams {
881 pub asset_type: Option<AssetType>,
882 pub token_id: Option<String>,
883 pub signature_type: Option<u8>,
884}
885
886impl BalanceAllowanceParams {
887 pub fn to_query_params(&self) -> Vec<(&str, String)> {
888 let mut params = Vec::with_capacity(3);
889
890 if let Some(x) = &self.asset_type {
891 params.push(("asset_type", x.to_string()));
892 }
893
894 if let Some(x) = &self.token_id {
895 params.push(("token_id", x.to_string()));
896 }
897
898 if let Some(x) = &self.signature_type {
899 params.push(("signature_type", x.to_string()));
900 }
901 params
902 }
903
904 pub fn set_signature_type(&mut self, s: u8) {
905 self.signature_type = Some(s);
906 }
907}
908
909#[allow(clippy::upper_case_acronyms)]
911pub enum AssetType {
912 COLLATERAL,
913 CONDITIONAL,
914}
915
916impl std::fmt::Display for AssetType {
917 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
918 match self {
919 AssetType::COLLATERAL => write!(f, "COLLATERAL"),
920 AssetType::CONDITIONAL => write!(f, "CONDITIONAL"),
921 }
922 }
923}
924
925#[derive(Debug, Clone, Serialize, Deserialize)]
927pub struct NotificationParams {
928 pub signature: String,
929 pub timestamp: u64,
930}
931
932#[derive(Debug, Clone, Serialize, Deserialize)]
934pub struct BatchMidpointRequest {
935 pub token_ids: Vec<String>,
936}
937
938#[derive(Debug, Clone, Serialize, Deserialize)]
940pub struct BatchMidpointResponse {
941 pub midpoints: std::collections::HashMap<String, Option<Decimal>>,
942}
943
944#[derive(Debug, Clone, Serialize, Deserialize)]
946pub struct BatchPriceRequest {
947 pub token_ids: Vec<String>,
948}
949
950#[derive(Debug, Clone, Serialize, Deserialize)]
952pub struct TokenPrice {
953 pub token_id: String,
954 #[serde(skip_serializing_if = "Option::is_none")]
955 pub bid: Option<Decimal>,
956 #[serde(skip_serializing_if = "Option::is_none")]
957 pub ask: Option<Decimal>,
958 #[serde(skip_serializing_if = "Option::is_none")]
959 pub mid: Option<Decimal>,
960}
961
962#[derive(Debug, Clone, Serialize, Deserialize)]
964pub struct BatchPriceResponse {
965 pub prices: Vec<TokenPrice>,
966}
967
968#[derive(Debug, Deserialize)]
970pub struct ApiKeysResponse {
971 #[serde(rename = "apiKeys")]
972 pub api_keys: Vec<String>,
973}
974
975#[derive(Debug, Deserialize)]
976pub struct MidpointResponse {
977 #[serde(with = "rust_decimal::serde::str")]
978 pub mid: Decimal,
979}
980
981#[derive(Debug, Deserialize)]
982pub struct PriceResponse {
983 #[serde(with = "rust_decimal::serde::str")]
984 pub price: Decimal,
985}
986
987#[derive(Debug, Deserialize)]
988pub struct SpreadResponse {
989 #[serde(with = "rust_decimal::serde::str")]
990 pub spread: Decimal,
991}
992
993#[derive(Debug, Deserialize)]
994pub struct TickSizeResponse {
995 #[serde(with = "rust_decimal::serde::str")]
996 pub minimum_tick_size: Decimal,
997}
998
999#[derive(Debug, Deserialize)]
1000pub struct NegRiskResponse {
1001 pub neg_risk: bool,
1002}
1003
1004#[derive(Debug, Serialize, Deserialize)]
1005pub struct BookParams {
1006 pub token_id: String,
1007 pub side: Side,
1008}
1009
1010#[derive(Debug, Deserialize)]
1011pub struct OrderBookSummary {
1012 pub market: String,
1013 pub asset_id: String,
1014 pub hash: String,
1015 #[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
1016 pub timestamp: u64,
1017 pub bids: Vec<OrderSummary>,
1018 pub asks: Vec<OrderSummary>,
1019}
1020
1021#[derive(Debug, Deserialize)]
1022pub struct OrderSummary {
1023 #[serde(with = "rust_decimal::serde::str")]
1024 pub price: Decimal,
1025 #[serde(with = "rust_decimal::serde::str")]
1026 pub size: Decimal,
1027}
1028
1029#[derive(Debug, Serialize, Deserialize)]
1030pub struct MarketsResponse {
1031 pub limit: usize,
1032 pub count: usize,
1033 pub next_cursor: Option<String>,
1034 pub data: Vec<Market>,
1035}
1036
1037#[derive(Debug, Serialize, Deserialize)]
1038pub struct SimplifiedMarketsResponse {
1039 pub limit: usize,
1040 pub count: usize,
1041 pub next_cursor: Option<String>,
1042 pub data: Vec<SimplifiedMarket>,
1043}
1044
1045#[derive(Debug, Serialize, Deserialize)]
1047pub struct SimplifiedMarket {
1048 pub condition_id: String,
1049 pub tokens: [Token; 2],
1050 pub rewards: Rewards,
1051 pub min_incentive_size: Option<String>,
1052 pub max_incentive_spread: Option<String>,
1053 pub active: bool,
1054 pub closed: bool,
1055}
1056
1057#[derive(Debug, Clone, Serialize, Deserialize)]
1059pub struct Rewards {
1060 pub rates: Option<serde_json::Value>,
1061 pub min_size: Decimal,
1063 pub max_spread: Decimal,
1064 #[serde(default)]
1065 pub event_start_date: Option<String>,
1066 #[serde(default)]
1067 pub event_end_date: Option<String>,
1068 #[serde(skip_serializing_if = "Option::is_none", default)]
1069 pub in_game_multiplier: Option<Decimal>,
1070 #[serde(skip_serializing_if = "Option::is_none", default)]
1071 pub reward_epoch: Option<Decimal>,
1072}
1073
1074pub type ClientResult<T> = anyhow::Result<T>;
1076
1077pub type Result<T> = std::result::Result<T, crate::errors::PolyfillError>;
1079
1080pub type ApiCreds = ApiCredentials;
1082pub type CreateOrderOptions = OrderOptions;
1083pub type OrderArgs = OrderRequest;