use serde::{Deserialize, Serialize};

use crate::market::{
    SpotMarketIdentifier, SpotMarketRoyalty, SpotMarketTradingFee, SpotMarketTradingSettings,
};
use crate::{AssetAmount, SpotMarketId, WalletRegisterId};

/// Register market
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct SpotMarketRegistration {
    /// Spot market identifier
    pub identifier: SpotMarketIdentifier,

    /// Base asset quantity
    pub base_asset_quantity: AssetAmount,

    /// Quote asset quantity
    pub quote_asset_quantity: AssetAmount,

    /// Market trading settings
    pub trading_settings: SpotMarketTradingSettings,
}

/// Update spot market trading settings
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct UpdateSpotMarketTradingSettings {
    /// Market id
    pub market_id: SpotMarketId,

    /// Market trading settings
    pub trading_settings: SpotMarketTradingSettings,
}

/// Update spot market initial trading fee
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct UpdateSpotMarketInitialTradingFee {
    /// Fee
    pub fee: SpotMarketTradingFee,
}

/// Update spot market royalty
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct UpdateSpotMarketRoyalty {
    /// Market id
    pub market_id: SpotMarketId,

    /// Royalty
    pub royalty: SpotMarketRoyalty,
}

/// Claim spot market trading fee
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct ClaimSpotMarketTradingFee {
    /// Spot market id
    pub market_id: SpotMarketId,

    /// Base asset fee
    pub base: AssetAmount,

    /// Quote asset fee
    pub quote: AssetAmount,
}

/// Claim spot market royalty
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct ClaimSpotMarketRoyalty {
    /// Spot market id
    pub market_id: SpotMarketId,

    /// Royalty amount of base asset
    pub base: AssetAmount,

    /// Royalty amount of quote asset
    pub quote: AssetAmount,
}

/// Update spot market initial fee to
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct UpdateSpotMarketInitialFeeTo {
    /// Fee to
    pub fee_to: WalletRegisterId,
}

/// Update spot market fee to
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct UpdateSpotMarketFeeTo {
    /// Market id
    pub market_id: SpotMarketId,

    /// Fee to
    pub fee_to: WalletRegisterId,
}

/// Update market fee
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct UpdateSpotMarketTradingFee {
    /// Market id
    pub market_id: SpotMarketId,

    /// Fee
    pub fee: SpotMarketTradingFee,
}
