/*
 * Ethereal Exchange API
 *
 * Ethereal HTTP API for real-time trading, order management, and market data access.
 *
 * The version of the OpenAPI document: 0.1.0
 *
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ProductDto {
    /// Id representing the registered product
    #[serde(rename = "id")]
    pub id: uuid::Uuid,
    /// Product ticker based on the base quote token
    #[serde(rename = "ticker")]
    pub ticker: String,
    /// Product display ticker based on the base quote token
    #[serde(rename = "displayTicker")]
    pub display_ticker: String,
    /// Address of the base token (non-checksummed; zero address if virtual)
    #[serde(rename = "baseTokenAddress")]
    pub base_token_address: String,
    /// Address of quote token (non-checksummed)
    #[serde(rename = "quoteTokenAddress")]
    pub quote_token_address: String,
    /// Name of the base token (e.g. BTC in BTCUSD)
    #[serde(rename = "baseTokenName")]
    pub base_token_name: String,
    /// Name of the quote token (e.g. USD in BTCUSD)
    #[serde(rename = "quoteTokenName")]
    pub quote_token_name: String,
    #[serde(rename = "engineType")]
    pub engine_type: models::EngineTypeEnum,
    /// The productId generated onchain after registering for the first time
    #[serde(rename = "onchainId")]
    pub onchain_id: i64,
    #[serde(rename = "status")]
    pub status: models::ProductDtoOrderStatus,
    /// Block number this product was registered on
    #[serde(rename = "blockNumber")]
    pub block_number: String,
    /// Cumulative funding in USD of the product (precision: 9)
    #[serde(rename = "cumulativeFundingUsd")]
    pub cumulative_funding_usd: String,
    /// Product creation timestamp (ms since Unix Epoch)
    #[serde(rename = "createdAt")]
    pub created_at: i64,
    /// Unix timestamp when funding was last updated
    #[serde(rename = "fundingUpdatedAt", skip_serializing_if = "Option::is_none")]
    pub funding_updated_at: Option<i64>,
    /// The minimum order quantity in native units expressed as a decimal (precision: 9)
    #[serde(rename = "minQuantity")]
    pub min_quantity: String,
    /// Quantity must be divisible by the lotSize in expressed as a decimal (precision: 9)
    #[serde(rename = "lotSize")]
    pub lot_size: String,
    /// Minimum price increment (tickSize) expressed as a decimal (precision: 9)
    #[serde(rename = "tickSize")]
    pub tick_size: String,
    /// Fee charged to the maker on order trades expressed as a decimal (precision: 9)
    #[serde(rename = "makerFee")]
    pub maker_fee: String,
    /// Fee charged to the taker on order trades expressed as a decimal (precision: 9)
    #[serde(rename = "takerFee")]
    pub taker_fee: String,
    /// Max quantity per order in native units expressed as a decimal (precision: 9)
    #[serde(rename = "maxQuantity")]
    pub max_quantity: String,
    /// Min price in USD expressed as a decimal (precision: 9)
    #[serde(rename = "minPrice")]
    pub min_price: String,
    /// Max price in USD expressed as a decimal (precision: 9)
    #[serde(rename = "maxPrice")]
    pub max_price: String,
    /// 24h volume in base token native units expressed as a decimal (precision: 9)
    #[serde(rename = "volume24h")]
    pub volume24h: String,
    /// Maximum leverage allowed for the product
    #[serde(rename = "maxLeverage")]
    pub max_leverage: f64,
    /// Pyth price feed id
    #[serde(rename = "pythFeedId")]
    pub pyth_feed_id: i64,
    /// Last computed hourly funding rate expressed as a decimal (precision: 9)
    #[serde(rename = "fundingRate1h")]
    pub funding_rate1h: String,
    /// OI of both sides in native units expressed as a decimal (precision: 9)
    #[serde(rename = "openInterest")]
    pub open_interest: String,
    /// Max OI of one side in USD expressed as a decimal (precision: 9)
    #[serde(rename = "maxOpenInterestUsd")]
    pub max_open_interest_usd: String,
    /// Max position notional value, in USD expressed as a decimal (precision: 9)
    #[serde(rename = "maxPositionNotionalUsd")]
    pub max_position_notional_usd: String,
    /// Funding clamp APR expressed as a decimal (precision: 9)
    #[serde(rename = "fundingClampApr")]
    pub funding_clamp_apr: String,
    /// Funding baseline APR expressed as a decimal (precision: 9)
    #[serde(rename = "fundingBaselineApr")]
    pub funding_baseline_apr: String,
    /// Maximum funding APR expressed as a decimal, e.g. 2.0 = 200% (precision: 9)
    #[serde(rename = "fundingMaxApr")]
    pub funding_max_apr: String,
}

impl ProductDto {
    pub fn new(
        id: uuid::Uuid,
        ticker: String,
        display_ticker: String,
        base_token_address: String,
        quote_token_address: String,
        base_token_name: String,
        quote_token_name: String,
        engine_type: models::EngineTypeEnum,
        onchain_id: i64,
        status: models::ProductDtoOrderStatus,
        block_number: String,
        cumulative_funding_usd: String,
        created_at: i64,
        min_quantity: String,
        lot_size: String,
        tick_size: String,
        maker_fee: String,
        taker_fee: String,
        max_quantity: String,
        min_price: String,
        max_price: String,
        volume24h: String,
        max_leverage: f64,
        pyth_feed_id: i64,
        funding_rate1h: String,
        open_interest: String,
        max_open_interest_usd: String,
        max_position_notional_usd: String,
        funding_clamp_apr: String,
        funding_baseline_apr: String,
        funding_max_apr: String,
    ) -> ProductDto {
        ProductDto {
            id,
            ticker,
            display_ticker,
            base_token_address,
            quote_token_address,
            base_token_name,
            quote_token_name,
            engine_type,
            onchain_id,
            status,
            block_number,
            cumulative_funding_usd,
            created_at,
            funding_updated_at: None,
            min_quantity,
            lot_size,
            tick_size,
            maker_fee,
            taker_fee,
            max_quantity,
            min_price,
            max_price,
            volume24h,
            max_leverage,
            pyth_feed_id,
            funding_rate1h,
            open_interest,
            max_open_interest_usd,
            max_position_notional_usd,
            funding_clamp_apr,
            funding_baseline_apr,
            funding_max_apr,
        }
    }
}
