use serde::{Deserialize, Serialize};

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

/// Represents the registration of a spot market
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct SpotMarketRegistration {
    /// Identifier for the spot market
    pub identifier: MarketIdentifier,

    /// Quantity of the base asset
    pub base_asset_quantity: AssetAmount,

    /// Quantity of the quote asset
    pub quote_asset_quantity: AssetAmount,

    /// Trading settings for the market
    pub trading_settings: SpotMarketTradingSettings,
}

/// Represents an update to the trading settings of a spot market
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct UpdateSpotMarketTradingSettings {
    /// Identifier for the spot market
    pub market_id: SpotMarketId,

    /// New trading settings for the market
    pub trading_settings: SpotMarketTradingSettings,
}

/// Represents an update to the initial trading fee of a spot market
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct UpdateSpotMarketInitialTradingFee {
    /// New trading fee
    pub fee: SpotMarketTradingFee,
}

/// Represents an update to the royalty of a spot market
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct UpdateSpotMarketRoyalty {
    /// Identifier for the spot market
    pub market_id: SpotMarketId,

    /// New royalty settings
    pub royalty: SpotMarketRoyalty,
}

/// Represents a claim for the trading fee of a spot market
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct ClaimSpotMarketTradingFee {
    /// Identifier for the spot market
    pub market_id: SpotMarketId,

    /// Amount of the base asset fee
    pub base: AssetAmount,

    /// Amount of the quote asset fee
    pub quote: AssetAmount,
}

/// Represents a claim for the royalty of a spot market
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct ClaimSpotMarketRoyalty {
    /// Identifier for the spot market
    pub market_id: SpotMarketId,

    /// Amount of the base asset royalty
    pub base: AssetAmount,

    /// Amount of the quote asset royalty
    pub quote: AssetAmount,
}

/// Represents an update to the initial fee recipient of a spot market
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct UpdateSpotMarketInitialFeeTo {
    /// New fee recipient
    pub fee_to: WalletRegisterId,
}

/// Represents an update to the fee recipient of a spot market
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct UpdateSpotMarketFeeTo {
    /// Identifier for the spot market
    pub market_id: SpotMarketId,

    /// New fee recipient
    pub fee_to: WalletRegisterId,
}

/// Represents an update to the trading fee of a spot market
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
pub struct UpdateSpotMarketTradingFee {
    /// Identifier for the spot market
    pub market_id: SpotMarketId,

    /// New trading fee
    pub fee: SpotMarketTradingFee,
}

#[cfg(test)]
mod tests;