ethereal_rust_sdk 0.1.22

Trading client for Ethereal exchange
Documentation
/*
 * 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 SubaccountBalanceDto {
    /// Id representing the subaccount
    #[serde(rename = "subaccountId")]
    pub subaccount_id: uuid::Uuid,
    /// Id representing the token
    #[serde(rename = "tokenId")]
    pub token_id: uuid::Uuid,
    /// ERC20 deposited token address (non-checksummed, zero address if virtual)
    #[serde(rename = "tokenAddress")]
    pub token_address: String,
    /// The unique exchange defined token name driven by addToken onchain
    #[serde(rename = "tokenName")]
    pub token_name: String,
    /// Token balance in native units expressed as a decimal (precision: 9)
    #[serde(rename = "amount")]
    pub amount: rust_decimal::Decimal,
    /// Portion of balance transferrable in native units expressed as a decimal (precision: 9)
    #[serde(rename = "available")]
    pub available: rust_decimal::Decimal,
    /// Portion of balance non-transferrable in native units expressed as a decimal (precision: 9)
    #[serde(rename = "totalUsed")]
    pub total_used: rust_decimal::Decimal,
    /// Token balance last updated timestamp (ms since Unix Epoch)
    #[serde(rename = "updatedAt")]
    pub updated_at: f64,
}

impl SubaccountBalanceDto {
    pub fn new(
        subaccount_id: uuid::Uuid,
        token_id: uuid::Uuid,
        token_address: String,
        token_name: String,
        amount: rust_decimal::Decimal,
        available: rust_decimal::Decimal,
        total_used: rust_decimal::Decimal,
        updated_at: f64,
    ) -> SubaccountBalanceDto {
        SubaccountBalanceDto {
            subaccount_id,
            token_id,
            token_address,
            token_name,
            amount,
            available,
            total_used,
            updated_at,
        }
    }
}