Skip to main content

fyuz/models/
meta.rs

1//! Service metadata: liveness and chain configuration.
2
3use serde::Deserialize;
4
5/// Response of `GET /health`.
6#[derive(Debug, Clone, Deserialize)]
7#[serde(rename_all = "camelCase")]
8pub struct HealthStatus {
9    /// `"ok"` when the API is serving.
10    pub status: String,
11}
12
13/// One chain the Fyuz deployment is configured for.
14///
15/// The live service returns additional operational fields (RPC URL, explorer
16/// URL, contract address); only the two documented in the OpenAPI contract are
17/// modelled here. Unknown fields are ignored rather than rejected, so this stays
18/// forward compatible.
19/// `Default` is derived so the trading layer can build one of these from the
20/// compile-time address book without inventing values for the operational
21/// fields `/config` would have carried — they stay `None`, meaning unknown.
22#[derive(Debug, Clone, Default, Deserialize)]
23#[serde(rename_all = "camelCase")]
24pub struct ChainInfo {
25    /// Human-readable chain name, e.g. `"BNB Smart Chain"`.
26    pub name: String,
27    /// EVM chain id, e.g. `56` for BNB Smart Chain mainnet.
28    pub chain_id: i64,
29    /// Chain slug used everywhere else in the API, e.g. `"bsc"`.
30    #[serde(default)]
31    pub network: Option<String>,
32    /// The Fyuz launchpad on this chain — the `to` of every swap.
33    ///
34    /// Read from here rather than hardcoded anywhere in this crate: it sits
35    /// behind an upgradeable proxy, and a new chain should not need a release.
36    #[serde(default)]
37    pub contract_address: Option<String>,
38    /// A JSON-RPC endpoint, as configured by the API operator.
39    ///
40    /// Treat it as a default, not an entitlement: it is shared by every caller
41    /// and can change without notice. Set your own with
42    /// [`FyuzClientBuilder::rpc_url`](crate::FyuzClientBuilder::rpc_url) for
43    /// anything in production.
44    #[serde(default)]
45    pub rpc_url: Option<String>,
46    /// WebSocket sibling of [`ChainInfo::rpc_url`].
47    #[serde(default)]
48    pub ws_url: Option<String>,
49    /// Native gas currency symbol, e.g. `"BNB"`.
50    #[serde(default)]
51    pub currency: Option<String>,
52    /// Block explorer root, e.g. `"https://bscscan.com"`.
53    #[serde(default)]
54    pub explorer_url: Option<String>,
55    /// DEX venues a graduated token can end up on.
56    #[serde(default)]
57    pub pools: Vec<String>,
58    /// USD market cap at which a token graduates off the curve.
59    #[serde(default)]
60    pub target_market_cap: Option<f64>,
61    /// Tokens minted per launch.
62    #[serde(default)]
63    pub total_supply: Option<f64>,
64    /// Virtual native reserve a new curve starts with.
65    #[serde(default)]
66    pub virtual_eth_amount: Option<f64>,
67    /// Virtual token reserve a new curve starts with.
68    #[serde(default)]
69    pub virtual_token_amount: Option<f64>,
70    /// First block the indexer reads.
71    #[serde(default)]
72    pub start_block: Option<i64>,
73}
74
75/// Response of `GET /config`.
76#[derive(Debug, Clone, Deserialize)]
77#[serde(rename_all = "camelCase")]
78pub struct ChainConfig {
79    /// Chains this deployment serves. Currently a single entry, `bsc`.
80    pub chains: Vec<ChainInfo>,
81}