monaco_sdk/lib.rs
1//! # Monaco SDK
2//!
3//! Typed Rust client for the [Monaco DEX](https://github.com/Monaco-Research/monaco-core)
4//! REST API — auto-generated from the OpenAPI specification via
5//! [progenitor](https://docs.rs/progenitor).
6//!
7//! ## Quick start
8//!
9//! ```rust,no_run
10//! #[tokio::main]
11//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
12//! let client = monaco_sdk::Client::new("https://develop.apimonaco.xyz");
13//!
14//! // Public endpoints (no auth required)
15//! let health = client.health_check().await?.into_inner();
16//! println!("Status: {:?}", health.status);
17//!
18//! let pairs = client
19//! .list_trading_pairs(None, None, Some(true), None, None, None, None)
20//! .await?
21//! .into_inner();
22//! println!("Trading pairs: {:?}", pairs.trading_pairs);
23//!
24//! Ok(())
25//! }
26//! ```
27//!
28//! ## Authentication
29//!
30//! Monaco uses noncustodial session-key auth. At login the client generates a
31//! random ed25519 keypair locally and registers the public key through the
32//! challenge → wallet-sign → verify flow (the wallet signature authorizes the
33//! session public key). Every authenticated request is then signed with the
34//! session private key and carries `X-Monaco-PublicKey`, `X-Monaco-Timestamp`,
35//! and `X-Monaco-Signature` headers over
36//! `METHOD\nPATH_WITH_QUERY\nTIMESTAMP_MS\nSHA256_BODY_HEX`.
37//!
38//! Per-request signing requires a request-signing layer that this generated
39//! client does not yet provide; until it lands, sign requests yourself (e.g.
40//! a reqwest layer that injects the headers above) when calling authenticated
41//! endpoints. The public challenge/verify endpoints work out of the box.
42//!
43//! ## API coverage
44//!
45//! The client exposes every operation from the Monaco REST API:
46//!
47//! | Category | Methods |
48//! |----------|---------|
49//! | **Market data** | `list_trading_pairs`, `get_trading_pair_by_id`, `get_market_metadata`, `get_candles`, `get_screener`, `get_open_interest` |
50//! | **Perp markets** | `get_perp_market_config`, `get_perp_market_summary`, `get_mark_price`, `get_index_price`, `get_funding_state`, `list_funding_history` |
51//! | **Orderbook** | `get_orderbook_snapshot` |
52//! | **Trades** | `get_trades`, `get_trade_by_id`, `get_user_trades` |
53//! | **Orders** | `create_order`, `replace_order`, `cancel_order`, `get_orders`, `get_order_by_id` |
54//! | **Conditional orders** | `cancel_conditional_order`, `list_conditional_orders` |
55//! | **Batch orders** | `batch_create_orders`, `batch_replace_orders`, `batch_cancel_orders`, `batch_cancel_all`, `batch_cancel_all_by_pair` |
56//! | **Accounts** | `get_user_profile`, `get_user_balances`, `get_user_balance_by_asset`, `get_user_movements`, `list_funding_payments`, `get_portfolio_stats`, `get_portfolio_chart` |
57//! | **Sub-accounts** | `list_sub_accounts_with_balances`, `create_sub_account_limit`, `get_sub_account_limits`, `update_sub_account_limit`, `delete_sub_account_limit` |
58//! | **Margin accounts** | `list_margin_accounts`, `get_margin_account_summary`, `get_margin_account_movements`, `get_available_collateral`, `transfer_collateral_to_margin_account`, `transfer_collateral_from_margin_account`, `transfer_collateral_to_parent_margin_account`, `transfer_collateral_from_parent_margin_account`, `transfer_collateral_to_risk_bucket`, `simulate_order_risk`, `simulate_risk_bucket_order_risk` |
59//! | **Positions** | `list_positions`, `get_position`, `close_position`, `get_position_risk`, `add_position_margin`, `reduce_position_margin`, `list_position_history`, `attach_position_tp_sl` |
60//! | **Delegated agents** | `upsert_delegated_agent`, `list_delegated_agents`, `list_delegated_agent_owners`, `revoke_delegated_agent`, `create_delegated_session` |
61//! | **Applications** | `get_application_config`, `get_application_stats`, `list_application_orders`, `list_application_users`, `list_application_movements`, `list_application_balances` |
62//! | **Auth** | `create_challenge`, `verify_signature`, `refresh_session`, `revoke_session`, `authenticate_backend` |
63//! | **Fees** | `simulate_fees` |
64//! | **Whitelist** | `submit_whitelist` |
65//! | **Faucet** | `mint_tokens` |
66//! | **Health** | `health_check` |
67//!
68//! All request/response types live in the [`types`] module.
69
70// The client below is generated verbatim by progenitor from openapi/openapi.yaml
71// at build time and `include!`d here (see build.rs). It is not hand-maintained
72// and cannot be edited, so the pedantic/nursery lints it trips are suppressed
73// crate-wide rather than per-item:
74// - default_trait_access / use_self : progenitor's codegen style
75// - match_same_arms / items_after_statements : shape of the generated impls
76// - must_use_candidate / doc_markdown
77// / too_long_first_doc_paragraph : generated builder docs
78#![allow(
79 clippy::default_trait_access,
80 clippy::use_self,
81 clippy::match_same_arms,
82 clippy::items_after_statements,
83 clippy::must_use_candidate,
84 clippy::doc_markdown,
85 clippy::too_long_first_doc_paragraph
86)]
87
88include!(concat!(env!("OUT_DIR"), "/api.rs"));