mirror of
https://github.com/floor-licker/polyfill-rs.git
synced 2026-08-04 16:27:44 +00:00
fix: omit duplicate methods
This commit is contained in:
+7
-95
@@ -1152,107 +1152,19 @@ impl ClobClient {
|
||||
}
|
||||
}
|
||||
|
||||
// Response types for API calls
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct MarketsResponse {
|
||||
pub limit: Decimal,
|
||||
pub count: Decimal,
|
||||
pub next_cursor: Option<String>,
|
||||
pub data: Vec<Market>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct Market {
|
||||
pub condition_id: String,
|
||||
pub tokens: [Token; 2],
|
||||
pub rewards: Rewards,
|
||||
pub min_incentive_size: Option<String>,
|
||||
pub max_incentive_spread: Option<String>,
|
||||
pub active: bool,
|
||||
pub closed: bool,
|
||||
pub question_id: String,
|
||||
pub minimum_order_size: Decimal,
|
||||
pub minimum_tick_size: Decimal,
|
||||
pub description: String,
|
||||
pub category: Option<String>,
|
||||
pub end_date_iso: Option<String>,
|
||||
pub game_start_time: Option<String>,
|
||||
pub question: String,
|
||||
pub market_slug: String,
|
||||
pub seconds_delay: Decimal,
|
||||
pub icon: String,
|
||||
pub fpmm: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct Token {
|
||||
pub token_id: String,
|
||||
pub outcome: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct Rewards {
|
||||
pub rates: Option<serde_json::Value>,
|
||||
pub min_size: Decimal,
|
||||
pub max_spread: Decimal,
|
||||
pub event_start_date: Option<String>,
|
||||
pub event_end_date: Option<String>,
|
||||
pub in_game_multiplier: Option<Decimal>,
|
||||
pub reward_epoch: Option<Decimal>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct OrderBookSummary {
|
||||
pub market: String,
|
||||
pub asset_id: String,
|
||||
pub hash: String,
|
||||
#[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
|
||||
pub timestamp: u64,
|
||||
pub bids: Vec<OrderSummary>,
|
||||
pub asks: Vec<OrderSummary>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct OrderSummary {
|
||||
#[serde(with = "rust_decimal::serde::str")]
|
||||
pub price: Decimal,
|
||||
#[serde(with = "rust_decimal::serde::str")]
|
||||
pub size: Decimal,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct MidpointResponse {
|
||||
pub mid: Decimal,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct SpreadResponse {
|
||||
pub spread: Decimal,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct PriceResponse {
|
||||
pub price: Decimal,
|
||||
}
|
||||
|
||||
// Additional types for full compatibility with polymarket-rs-client
|
||||
pub use crate::types::{ExtraOrderArgs, MarketOrderArgs};
|
||||
// Re-export types from the canonical location in types.rs
|
||||
pub use crate::types::{
|
||||
ExtraOrderArgs, MarketOrderArgs, OrderBookSummary, OrderSummary,
|
||||
MidpointResponse, SpreadResponse, PriceResponse, TickSizeResponse,
|
||||
NegRiskResponse, MarketsResponse, Market, Token, Rewards,
|
||||
};
|
||||
|
||||
// Compatibility types that need to stay in client.rs
|
||||
#[derive(Debug, Default)]
|
||||
pub struct CreateOrderOptions {
|
||||
pub tick_size: Option<Decimal>,
|
||||
pub neg_risk: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct TickSizeResponse {
|
||||
pub minimum_tick_size: Decimal,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct NegRiskResponse {
|
||||
pub neg_risk: bool,
|
||||
}
|
||||
|
||||
// Re-export for compatibility
|
||||
pub type PolyfillClient = ClobClient;
|
||||
+1
-1
@@ -101,7 +101,7 @@ pub use crate::types::{
|
||||
// Additional compatibility types
|
||||
ApiKeysResponse, MidpointResponse, PriceResponse, SpreadResponse, TickSizeResponse,
|
||||
NegRiskResponse, BookParams, MarketsResponse, SimplifiedMarketsResponse, Market,
|
||||
SimplifiedMarket, Token, Rewards, ClientResult,
|
||||
SimplifiedMarket, Token, Rewards, ClientResult, OrderBookSummary, OrderSummary,
|
||||
};
|
||||
|
||||
// Re-export client
|
||||
|
||||
+67
-57
@@ -861,6 +861,52 @@ pub struct BalanceAllowance {
|
||||
pub allowance: Decimal,
|
||||
}
|
||||
|
||||
/// Parameters for balance allowance queries (from reference implementation)
|
||||
#[derive(Default)]
|
||||
pub struct BalanceAllowanceParams {
|
||||
pub asset_type: Option<AssetType>,
|
||||
pub token_id: Option<String>,
|
||||
pub signature_type: Option<u8>,
|
||||
}
|
||||
|
||||
impl BalanceAllowanceParams {
|
||||
pub fn to_query_params(&self) -> Vec<(&str, String)> {
|
||||
let mut params = Vec::with_capacity(3);
|
||||
|
||||
if let Some(x) = &self.asset_type {
|
||||
params.push(("asset_type", x.to_string()));
|
||||
}
|
||||
|
||||
if let Some(x) = &self.token_id {
|
||||
params.push(("token_id", x.to_string()));
|
||||
}
|
||||
|
||||
if let Some(x) = &self.signature_type {
|
||||
params.push(("signature_type", x.to_string()));
|
||||
}
|
||||
params
|
||||
}
|
||||
|
||||
pub fn set_signature_type(&mut self, s: u8) {
|
||||
self.signature_type = Some(s);
|
||||
}
|
||||
}
|
||||
|
||||
/// Asset type enum for balance allowance queries
|
||||
pub enum AssetType {
|
||||
COLLATERAL,
|
||||
CONDITIONAL,
|
||||
}
|
||||
|
||||
impl ToString for AssetType {
|
||||
fn to_string(&self) -> String {
|
||||
match self {
|
||||
AssetType::COLLATERAL => "COLLATERAL".to_string(),
|
||||
AssetType::CONDITIONAL => "CONDITIONAL".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Notification preferences
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct NotificationParams {
|
||||
@@ -946,6 +992,25 @@ pub struct BookParams {
|
||||
pub side: Side,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct OrderBookSummary {
|
||||
pub market: String,
|
||||
pub asset_id: String,
|
||||
pub hash: String,
|
||||
#[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
|
||||
pub timestamp: u64,
|
||||
pub bids: Vec<OrderSummary>,
|
||||
pub asks: Vec<OrderSummary>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct OrderSummary {
|
||||
#[serde(with = "rust_decimal::serde::str")]
|
||||
pub price: Decimal,
|
||||
#[serde(with = "rust_decimal::serde::str")]
|
||||
pub size: Decimal,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct MarketsResponse {
|
||||
#[serde(with = "rust_decimal::serde::str")]
|
||||
@@ -966,63 +1031,8 @@ pub struct SimplifiedMarketsResponse {
|
||||
pub data: Vec<SimplifiedMarket>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Market {
|
||||
pub condition_id: String,
|
||||
pub tokens: [Token; 2],
|
||||
pub rewards: Rewards,
|
||||
pub min_incentive_size: Option<String>,
|
||||
pub max_incentive_spread: Option<String>,
|
||||
pub active: bool,
|
||||
pub closed: bool,
|
||||
pub question_id: String,
|
||||
#[serde(with = "rust_decimal::serde::str")]
|
||||
pub minimum_order_size: Decimal,
|
||||
#[serde(with = "rust_decimal::serde::str")]
|
||||
pub minimum_tick_size: Decimal,
|
||||
pub description: String,
|
||||
pub category: Option<String>,
|
||||
pub end_date_iso: Option<String>,
|
||||
pub game_start_time: Option<String>,
|
||||
pub question: String,
|
||||
pub market_slug: String,
|
||||
#[serde(with = "rust_decimal::serde::str")]
|
||||
pub seconds_delay: Decimal,
|
||||
pub icon: String,
|
||||
pub fpmm: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct SimplifiedMarket {
|
||||
pub condition_id: String,
|
||||
pub tokens: [Token; 2],
|
||||
pub rewards: Rewards,
|
||||
pub min_incentive_size: Option<String>,
|
||||
pub max_incentive_spread: Option<String>,
|
||||
pub active: bool,
|
||||
pub closed: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Token {
|
||||
pub token_id: String,
|
||||
pub outcome: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Rewards {
|
||||
pub rates: Option<serde_json::Value>,
|
||||
#[serde(with = "rust_decimal::serde::str")]
|
||||
pub min_size: Decimal,
|
||||
#[serde(with = "rust_decimal::serde::str")]
|
||||
pub max_spread: Decimal,
|
||||
pub event_start_date: Option<String>,
|
||||
pub event_end_date: Option<String>,
|
||||
#[serde(with = "rust_decimal::serde::str", skip_serializing_if = "Option::is_none")]
|
||||
pub in_game_multiplier: Option<Decimal>,
|
||||
#[serde(with = "rust_decimal::serde::str", skip_serializing_if = "Option::is_none")]
|
||||
pub reward_epoch: Option<Decimal>,
|
||||
}
|
||||
// Note: Market, Token, Rewards, and SimplifiedMarket are already defined above in this file
|
||||
// These duplicate definitions have been removed to avoid conflicts
|
||||
|
||||
// For compatibility with reference implementation
|
||||
pub type ClientResult<T> = anyhow::Result<T>;
|
||||
|
||||
Reference in New Issue
Block a user