Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

Client for Monaco Protocol API

REST API for the Monaco Protocol hybrid CLOB exchange.

Version: 1.0.0

Implementations§

Source§

impl Client

Source

pub fn new(baseurl: &str) -> Self

Create a new client.

baseurl is the base URL provided to the internal reqwest::Client, and should include a scheme and hostname, as well as port and a path stem if applicable.

Source

pub fn new_with_client(baseurl: &str, client: Client) -> Self

Construct a new client with an existing reqwest::Client, allowing more control over its configuration.

baseurl is the base URL provided to the internal reqwest::Client, and should include a scheme and hostname, as well as port and a path stem if applicable.

Source§

impl Client

Source

pub async fn get_user_balances<'a>( &'a self, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, ) -> Result<ResponseValue<GetBalancesResponse>, Error<()>>

Get user balances

Get user balances.

Get the current user’s token balances with pagination support. Returns available, locked, and total balance for each token.

Sends a GET request to /api/v1/accounts/balances

Arguments:

  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
Source

pub async fn get_user_balance_by_asset<'a>( &'a self, asset_id: &'a str, ) -> Result<ResponseValue<GetBalanceByAssetResponse>, Error<()>>

Get user balance by asset

Get user balance by asset.

Get the current user’s balance for a specific asset. Returns available, locked, and total balance. If no balance exists for a valid asset, returns zero balances. If the asset ID is invalid or not found, returns 404.

Sends a GET request to /api/v1/accounts/balances/{assetId}

Source

pub async fn list_funding_payments<'a>( &'a self, margin_account_id: Option<&'a str>, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, position_id: Option<&'a str>, trading_pair_id: Option<&'a Uuid>, ) -> Result<ResponseValue<ListFundingPaymentsResponse>, Error<()>>

List funding payments

List funding payment history.

Get the current user’s private funding payment history with pagination and optional filters by market, margin account, and position.

Sends a GET request to /api/v1/accounts/funding-payments

Arguments:

  • margin_account_id
  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
  • position_id
  • trading_pair_id: Trading pair identifier (UUID)
Source

pub async fn get_user_profile<'a>( &'a self, ) -> Result<ResponseValue<GetProfileResponse>, Error<()>>

Get user profile

Get user profile.

Get the current user’s profile with token balances, recent movements, and recent orders. Use source to control data source: hot_storage (fast, real-time), cold_storage (historical), or both (hybrid).

Sends a GET request to /api/v1/accounts/me

Source

pub async fn get_portfolio_stats<'a>( &'a self, period: Option<&'a str>, ) -> Result<ResponseValue<GetPortfolioStatsResponse>, Error<()>>

Get portfolio stats

Get portfolio stats.

Get aggregate portfolio statistics for the authenticated user, scoped by time period. Includes volume, PnL, fees, equity, and win/loss metrics.

Sends a GET request to /api/v1/accounts/me/portfolio

Source

pub async fn get_portfolio_chart<'a>( &'a self, metric: Option<&'a str>, period: Option<&'a str>, ) -> Result<ResponseValue<GetPortfolioChartResponse>, Error<()>>

Get portfolio chart time series

Get portfolio chart time series.

Get bucketed time series data for portfolio charts. Supports volume and PnL metrics with configurable time periods and automatic bucket sizing.

Sends a GET request to /api/v1/accounts/me/portfolio/chart

Source

pub async fn get_user_movements<'a>( &'a self, asset_id: Option<&'a Uuid>, entry_type: Option<GetUserMovementsEntryType>, order_by: Option<GetUserMovementsOrderBy>, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, transaction_type: Option<GetUserMovementsTransactionType>, ) -> Result<ResponseValue<GetMovementsResponse>, Error<()>>

Get user movements

Get user movements.

Get the current user’s ledger movements (transaction history) with pagination and filtering support.

Sends a GET request to /api/v1/accounts/movements

Arguments:

  • asset_id: Asset identifier (UUID)
  • entry_type: Ledger entry type
  • order_by: Sort direction for createdAt
  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
  • transaction_type: Transaction type
Source

pub async fn list_sub_accounts_with_balances<'a>( &'a self, ) -> Result<ResponseValue<ListSubAccountsResponse>, Error<()>>

List sub-accounts with balances

List sub-accounts with balances.

List all sub-accounts with their token balances for a master account. Only returns sub-accounts that belong to the same application as the requesting user.

Sends a GET request to /api/v1/accounts/sub-accounts

Source

pub async fn create_sub_account_limit<'a>( &'a self, body: &'a CreateLimitRequest, ) -> Result<ResponseValue<CreateLimitResponse>, Error<()>>

Create sub-account limit

Create sub-account limit.

Create a new limit for a sub-account. Only master accounts can create limits for their sub-accounts.

Sends a POST request to /api/v1/accounts/sub-accounts/limits

Source

pub async fn get_sub_account_limits<'a>( &'a self, sub_account_id: &'a str, ) -> Result<ResponseValue<GetLimitsResponse>, Error<()>>

Get sub-account limits

Get sub-account limits.

Get all limits for a sub-account. Users can only view limits for their own accounts or their sub-accounts.

Sends a GET request to /api/v1/accounts/sub-accounts/{subAccountId}/limits

Source

pub async fn update_sub_account_limit<'a>( &'a self, sub_account_id: &'a str, asset_id: &'a str, body: &'a UpdateLimitRequest, ) -> Result<ResponseValue<UpdateLimitResponse>, Error<()>>

Update sub-account limit

Update sub-account limit.

Update an existing limit for a sub-account. Only master accounts can update limits for their sub-accounts.

Sends a PUT request to /api/v1/accounts/sub-accounts/{subAccountId}/limits/{assetId}

Source

pub async fn delete_sub_account_limit<'a>( &'a self, sub_account_id: &'a str, asset_id: &'a str, limit_id: Option<&'a Uuid>, ) -> Result<ResponseValue<DeleteLimitResponse>, Error<()>>

Delete sub-account limit

Delete sub-account limit.

Delete a limit for a sub-account. Only master accounts can delete limits for their sub-accounts.

Sends a DELETE request to /api/v1/accounts/sub-accounts/{subAccountId}/limits/{assetId}

Arguments:

  • sub_account_id
  • asset_id
  • limit_id: Limit identifier (UUID)
Source

pub async fn get_user_trades<'a>( &'a self, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, trading_pair_id: Option<&'a Uuid>, ) -> Result<ResponseValue<GetUserTradesResponse>, Error<()>>

Get user trade history

Get user trades.

Get the authenticated user’s trade history with pagination. Returns trades where the user was either maker or taker, with user-specific side and fee information.

Sends a GET request to /api/v1/accounts/trades

Arguments:

  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
  • trading_pair_id: Trading pair identifier (UUID)
Source

pub async fn list_application_balances<'a>( &'a self, asset_id: Option<&'a Uuid>, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, user_id: Option<&'a Uuid>, ) -> Result<ResponseValue<ListAppBalancesResponse>, Error<()>>

List application balances

List application balances.

Returns a paginated list of all user balances for this application. Requires backend authentication via secret key.

Sends a GET request to /api/v1/applications/balances

Arguments:

  • asset_id: Asset identifier (UUID)
  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
  • user_id: User identifier (UUID)
Source

pub async fn get_application_config<'a>( &'a self, ) -> Result<ResponseValue<GetConfigResponse>, Error<()>>

Get application configuration

Get application configuration.

Returns the configuration for the authenticated application including allowed origins, webhook URL, and vault contract address.

Sends a GET request to /api/v1/applications/config

Source

pub async fn list_application_movements<'a>( &'a self, asset_id: Option<&'a Uuid>, entry_type: Option<ListApplicationMovementsEntryType>, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, transaction_type: Option<ListApplicationMovementsTransactionType>, user_id: Option<&'a Uuid>, ) -> Result<ResponseValue<ListAppMovementsResponse>, Error<()>>

List application movements

List application movements.

Returns a paginated list of all ledger movements (deposits, withdrawals, trades, etc.) for this application. Requires backend authentication via secret key.

Sends a GET request to /api/v1/applications/movements

Arguments:

  • asset_id: Asset identifier (UUID)
  • entry_type: Ledger entry type
  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
  • transaction_type: Transaction type
  • user_id: User identifier (UUID)
Source

pub async fn list_application_orders<'a>( &'a self, order_type: Option<ListApplicationOrdersOrderType>, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, side: Option<ListApplicationOrdersSide>, status: Option<&'a ListApplicationOrdersStatus>, trading_pair_id: Option<&'a Uuid>, user_id: Option<&'a Uuid>, ) -> Result<ResponseValue<ListAppOrdersResponse>, Error<()>>

List application orders

List application orders.

Returns a paginated list of all orders for this application. Requires backend authentication via secret key.

Sends a GET request to /api/v1/applications/orders

Arguments:

  • order_type: Order type
  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
  • side: Order side
  • status: Order status (single value or comma-separated list)
  • trading_pair_id: Trading pair identifier (UUID)
  • user_id: User identifier (UUID)
Source

pub async fn get_application_stats<'a>( &'a self, since: Option<&'a str>, ) -> Result<ResponseValue<GetAppStatsResponse>, Error<()>>

Get application stats

Get application stats.

Returns aggregate volume and fee stats for this application. Stats are scoped to trades where the application’s users were the taker. Requires backend authentication via secret key.

Sends a GET request to /api/v1/applications/stats

Source

pub async fn list_application_users<'a>( &'a self, account_type: Option<ListApplicationUsersAccountType>, address: &'a ListApplicationUsersAddress, is_active: Option<bool>, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, ) -> Result<ResponseValue<ListAppUsersResponse>, Error<()>>

List application users

List application users.

Returns a paginated list of all users for this application. Requires backend authentication via secret key.

Sends a GET request to /api/v1/applications/users

Arguments:

  • account_type: Account type filter
  • address: Wallet address
  • is_active
  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
Source

pub async fn authenticate_backend<'a>( &'a self, body: &'a BackendAuthRequest, ) -> Result<ResponseValue<BackendAuthResponse>, Error<()>>

Backend service authentication

Backend service authentication.

Authenticate a backend service using a secret key. Returns a long-lived access token for server-to-server API access.

Sends a POST request to /api/v1/auth/backend

Source

pub async fn create_challenge<'a>( &'a self, body: &'a ChallengeRequest, ) -> Result<ResponseValue<ChallengeResponse>, Error<()>>

Create authentication challenge

Create authentication challenge.

Generate a cryptographic challenge (nonce) for wallet-based authentication. The user must sign the returned message with their private key to prove ownership of the wallet.

Sends a POST request to /api/v1/auth/challenge

Source

pub async fn refresh_session<'a>( &'a self, body: &'a RefreshRequest, ) -> Result<ResponseValue<RefreshResponse>, Error<()>>

Refresh session expiry

Refresh session expiry.

Extends the expiration of the current session. The request must be signed by the session private key (standard X-Monaco-* headers); no body is required.

Sends a POST request to /api/v1/auth/refresh

Source

pub async fn revoke_session<'a>( &'a self, body: &'a RevokeRequest, ) -> Result<ResponseValue<RevokeResponse>, Error<()>>

Revoke current session

Revoke current session.

Revoke the current authenticated session. The request must be signed by the session private key (standard X-Monaco-* headers). The user will need to authenticate again to obtain a new session.

Sends a POST request to /api/v1/auth/revoke

Source

pub async fn verify_signature<'a>( &'a self, body: &'a VerifyRequest, ) -> Result<ResponseValue<VerifyResponse>, Error<()>>

Verify signature and authenticate

Verify signature and authenticate.

Verify the signed challenge message and create an authenticated session. Binds the caller-provided ed25519 session public key to the new session; subsequent requests are signed with the matching private key.

Sends a POST request to /api/v1/auth/verify

Source

pub async fn list_delegated_agents<'a>( &'a self, ) -> Result<ResponseValue<ListDelegatedAgentsResponse>, Error<()>>

List delegated agents

List the calling owner’s delegated agents.

Master accounts only. Returns every agent the calling account owns, each with its policy.

Sends a GET request to /api/v1/delegated-agents

Source

pub async fn upsert_delegated_agent<'a>( &'a self, body: &'a UpsertDelegatedAgentRequest, ) -> Result<ResponseValue<DelegatedAgent>, Error<()>>

Upsert delegated agent

Register or update a delegated agent.

Master accounts only. Creates (or updates, keyed on agent_address) a delegation linking the calling owner to an agent wallet, together with the policy that constrains what the agent may do on the owner’s behalf.

Sends a POST request to /api/v1/delegated-agents

Source

pub async fn list_delegated_agent_owners<'a>( &'a self, ) -> Result<ResponseValue<ListDelegatedAgentOwnersResponse>, Error<()>>

List delegating owners

List the owners that have delegated to the calling agent.

Reverse lookup keyed on the caller’s own wallet address: an agent that has authenticated with its own session key can discover which owners it may act on behalf of, and the owner_user_id to pass to CreateDelegatedSession. Returns only active (non-revoked, non-expired) delegations.

Sends a GET request to /api/v1/delegated-agents/owners

Source

pub async fn create_delegated_session<'a>( &'a self, body: &'a CreateDelegatedSessionRequest, ) -> Result<ResponseValue<CreateDelegatedSessionResponse>, Error<()>>

Create delegated session

Exchange the agent’s session for an owner-scoped delegated session.

The agent authenticates with its own session key, then calls this with the owner_user_id it wants to act for (discover it via ListDelegatedAgentOwners) and a freshly generated session public key. The new session acts as the owner but records the agent’s address for policy enforcement. Requires an active delegation for the (owner, agent) pair.

Sends a POST request to /api/v1/delegated-agents/sessions

Source

pub async fn revoke_delegated_agent<'a>( &'a self, delegated_agent_id: &'a str, ) -> Result<ResponseValue<RevokeDelegatedAgentResponse>, Error<()>>

Revoke delegated agent

Revoke a delegated agent.

Master accounts only. Revokes the delegation identified by delegated_agent_id. Existing delegated sessions are not invalidated; only future session creation is blocked.

Sends a DELETE request to /api/v1/delegated-agents/{delegatedAgentId}

Source

pub async fn mint_tokens<'a>( &'a self, ) -> Result<ResponseValue<MintTokensResponse>, Error<()>>

Mint all testnet tokens

Mint all testnet tokens.

Mint all available testnet tokens to the authenticated user’s address. Rate limited per 24 hours.

Sends a POST request to /api/v1/faucet/mint

Source

pub async fn simulate_fees<'a>( &'a self, order_type: Option<SimulateFeesOrderType>, price: &'a SimulateFeesPrice, quantity: &'a SimulateFeesQuantity, side: SimulateFeesSide, slippage_tolerance_bps: Option<i32>, trading_pair_id: &'a Uuid, ) -> Result<ResponseValue<SimulateFeesResponse>, Error<()>>

Simulate fees for a potential order

Simulate fees for a potential order.

Returns exact fee breakdown for a specific order before placing it, including Monaco protocol fees, application fees, total amounts, and the maximum quantity affordable at the given price.

Sends a GET request to /api/v1/fees/simulate

Arguments:

  • order_type: Order type
  • price: Price as decimal string
  • quantity: Quantity as decimal string
  • side: Order side
  • slippage_tolerance_bps
  • trading_pair_id: Trading pair identifier (UUID)
Source

pub async fn get_my_fee_tier<'a>( &'a self, trading_pair_id: Option<&'a Uuid>, ) -> Result<ResponseValue<GetMyFeeTierResponse>, Error<()>>

Get my fee tier and pair schedule

Return the caller’s current fee tier, rolling 14-day volumes, and a pair’s schedule.

Sends a GET request to /api/v1/fees/tier

Arguments:

  • trading_pair_id: Trading pair identifier (UUID)
Source

pub async fn list_margin_accounts<'a>( &'a self, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, state: Option<&'a str>, trading_pair_id: Option<&'a Uuid>, ) -> Result<ResponseValue<ListMarginAccountsResponse>, Error<()>>

Sends a GET request to /api/v1/margin/accounts

Arguments:

  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
  • state
  • trading_pair_id: Trading pair identifier (UUID)
Source

pub async fn get_margin_account_summary<'a>( &'a self, margin_account_id: &'a str, trading_pair_id: Option<&'a Uuid>, ) -> Result<ResponseValue<GetMarginAccountSummaryResponse>, Error<()>>

Sends a GET request to /api/v1/margin/accounts/{marginAccountId}

Arguments:

  • margin_account_id: Margin account UUID for the current isolated bucket.
  • trading_pair_id: Trading pair identifier (UUID)
Source

pub async fn transfer_collateral_to_margin_account<'a>( &'a self, margin_account_id: &'a str, body: &'a TransferCollateralToMarginAccountRequest, ) -> Result<ResponseValue<TransferCollateralToMarginAccountResponse>, Error<()>>

Sends a POST request to /api/v1/margin/accounts/{marginAccountId}/collateral/transfer-in

Arguments:

  • margin_account_id: Parent margin account UUID that receives collateral.
  • body
Source

pub async fn transfer_collateral_from_margin_account<'a>( &'a self, margin_account_id: &'a str, body: &'a TransferCollateralFromMarginAccountRequest, ) -> Result<ResponseValue<TransferCollateralFromMarginAccountResponse>, Error<()>>

Sends a POST request to /api/v1/margin/accounts/{marginAccountId}/collateral/transfer-out

Arguments:

  • margin_account_id: Parent margin account UUID that releases collateral.
  • body
Source

pub async fn get_margin_account_movements<'a>( &'a self, margin_account_id: &'a str, movement_type: Option<&'a str>, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, ) -> Result<ResponseValue<GetMarginAccountMovementsResponse>, Error<()>>

Sends a GET request to /api/v1/margin/accounts/{marginAccountId}/movements

Arguments:

  • margin_account_id: Margin account UUID for the current isolated bucket.
  • movement_type
  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
Source

pub async fn simulate_order_risk<'a>( &'a self, margin_account_id: &'a str, body: &'a SimulateOrderRiskRequest, ) -> Result<ResponseValue<SimulateOrderRiskResponse>, Error<()>>

Sends a POST request to /api/v1/margin/accounts/{marginAccountId}/simulate-order-risk

Arguments:

  • margin_account_id: Margin account UUID for the isolated bucket being simulated.
  • body
Source

pub async fn get_available_collateral<'a>( &'a self, asset: Option<&'a str>, ) -> Result<ResponseValue<GetAvailableCollateralResponse>, Error<()>>

Sends a GET request to /api/v1/margin/collateral/available

Source

pub async fn get_parent_margin_account_summary<'a>( &'a self, trading_pair_id: Option<&'a Uuid>, ) -> Result<ResponseValue<GetMarginAccountSummaryResponse>, Error<()>>

Sends a GET request to /api/v1/margin/parent-margin-account

Arguments:

  • trading_pair_id: Trading pair identifier (UUID)
Source

pub async fn transfer_collateral_to_parent_margin_account<'a>( &'a self, body: &'a TransferCollateralToParentMarginAccountRequest, ) -> Result<ResponseValue<TransferCollateralToMarginAccountResponse>, Error<()>>

Sends a POST request to /api/v1/margin/parent-margin-account/collateral/transfer-in

Source

pub async fn transfer_collateral_from_parent_margin_account<'a>( &'a self, body: &'a TransferCollateralFromParentMarginAccountRequest, ) -> Result<ResponseValue<TransferCollateralFromMarginAccountResponse>, Error<()>>

Sends a POST request to /api/v1/margin/parent-margin-account/collateral/transfer-out

Source

pub async fn get_parent_margin_account_movements<'a>( &'a self, movement_type: Option<&'a str>, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, ) -> Result<ResponseValue<GetMarginAccountMovementsResponse>, Error<()>>

Sends a GET request to /api/v1/margin/parent-margin-account/movements

Arguments:

  • movement_type
  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
Source

pub async fn simulate_parent_margin_order_risk<'a>( &'a self, body: &'a SimulateParentMarginOrderRiskRequest, ) -> Result<ResponseValue<SimulateOrderRiskResponse>, Error<()>>

Sends a POST request to /api/v1/margin/parent-margin-account/simulate-order-risk

Source

pub async fn transfer_collateral_to_risk_bucket<'a>( &'a self, body: &'a TransferCollateralToRiskBucketRequest, ) -> Result<ResponseValue<TransferCollateralToMarginAccountResponse>, Error<()>>

Sends a POST request to /api/v1/margin/risk-buckets/collateral/transfer-in

Source

pub async fn simulate_risk_bucket_order_risk<'a>( &'a self, body: &'a SimulateRiskBucketOrderRiskRequest, ) -> Result<ResponseValue<SimulateOrderRiskResponse>, Error<()>>

Sends a POST request to /api/v1/margin/risk-buckets/simulate-order-risk

Source

pub async fn list_trading_pairs<'a>( &'a self, base_token: Option<&'a str>, category: Option<&'a str>, is_active: Option<bool>, market_type: Option<ListTradingPairsMarketType>, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, quote_token: Option<&'a str>, ) -> Result<ResponseValue<ListTradingPairsResponse>, Error<()>>

Trading Pairs

Trading Pairs

Get paginated list of trading pairs with optional filtering by market type, base token, quote token, and active status.

Sends a GET request to /api/v1/market/pairs

Arguments:

  • base_token
  • category
  • is_active
  • market_type: Filter by market type
  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
  • quote_token
Source

pub async fn get_candles<'a>( &'a self, trading_pair_id: &'a str, interval: &'a str, end_time: Option<i64>, limit: Option<NonZeroU32>, start_time: Option<i64>, ) -> Result<ResponseValue<GetCandlesResponse>, Error<()>>

Candlestick Data

Candlestick Data

Get OHLCV (Open, High, Low, Close, Volume) candlestick data for a trading pair with configurable interval and time range.

Sends a GET request to /api/v1/market/pairs/charts/candlestick/{tradingPairId}/{interval}

Arguments:

  • trading_pair_id
  • interval
  • end_time: End time as Unix timestamp (milliseconds)
  • limit: Max candles to return (max 1000)
  • start_time: Start time as Unix timestamp (milliseconds)
Source

pub async fn get_trading_pair_by_id<'a>( &'a self, trading_pair_id: &'a str, ) -> Result<ResponseValue<GetTradingPairResponse>, Error<()>>

Trading Pair By ID

Trading Pair By ID

Get a specific trading pair by its UUID.

Sends a GET request to /api/v1/market/pairs/{tradingPairId}

Source

pub async fn get_funding_state<'a>( &'a self, trading_pair_id: &'a str, ) -> Result<ResponseValue<GetFundingStateResponse>, Error<()>>

Funding state for a perp market.

Sends a GET request to /api/v1/market/pairs/{tradingPairId}/funding

Source

pub async fn list_funding_history<'a>( &'a self, trading_pair_id: &'a str, end_time: Option<i64>, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, start_time: Option<i64>, ) -> Result<ResponseValue<ListFundingHistoryResponse>, Error<()>>

Historical funding settlements for a perp market.

Sends a GET request to /api/v1/market/pairs/{tradingPairId}/funding/history

Arguments:

  • trading_pair_id
  • end_time: End time as Unix timestamp (milliseconds)
  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
  • start_time: Start time as Unix timestamp (milliseconds)
Source

pub async fn get_index_price<'a>( &'a self, trading_pair_id: &'a str, ) -> Result<ResponseValue<GetIndexPriceResponse>, Error<()>>

Current index/oracle price for a perp market.

Sends a GET request to /api/v1/market/pairs/{tradingPairId}/index-price

Source

pub async fn get_mark_price<'a>( &'a self, trading_pair_id: &'a str, ) -> Result<ResponseValue<GetMarkPriceResponse>, Error<()>>

Current mark price for a perp market.

Sends a GET request to /api/v1/market/pairs/{tradingPairId}/mark-price

Source

pub async fn get_market_metadata<'a>( &'a self, trading_pair_id: &'a str, ) -> Result<ResponseValue<GetMarketMetadataResponse>, Error<()>>

Market Metadata

Market Metadata

Returns current price (from latest candle), 24h statistics (high, low, volume, change), and market initialization timestamp. 24h fields will be null if less than 24 hours of data available.

Sends a GET request to /api/v1/market/pairs/{tradingPairId}/metadata

Source

pub async fn get_open_interest<'a>( &'a self, trading_pair_id: &'a str, ) -> Result<ResponseValue<GetOpenInterestResponse>, Error<()>>

Open Interest

Open interest for a perp market.

Sends a GET request to /api/v1/market/pairs/{tradingPairId}/open-interest

Source

pub async fn get_perp_market_config<'a>( &'a self, trading_pair_id: &'a str, ) -> Result<ResponseValue<GetPerpMarketConfigResponse>, Error<()>>

Perp market risk/config parameters.

Sends a GET request to /api/v1/market/pairs/{tradingPairId}/perp/config

Source

pub async fn get_perp_market_summary<'a>( &'a self, trading_pair_id: &'a str, ) -> Result<ResponseValue<GetPerpMarketSummaryResponse>, Error<()>>

Perp market summary combining public candles, risk marks, funding, and open interest.

Sends a GET request to /api/v1/market/pairs/{tradingPairId}/perp/summary

Source

pub async fn get_screener<'a>( &'a self, category: Option<&'a str>, is_active: Option<bool>, market_type: Option<GetScreenerMarketType>, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, ) -> Result<ResponseValue<GetScreenerResponse>, Error<()>>

Market Screener

Market Screener

Single-call aggregate of per-pair market stats across all trading pairs. Returns current price plus quote-volume and percent price change for 1h / 24h / 7d windows, and a 7-point UTC-day snapshot for sparkline rendering. Window fields are independently null when a pair lacks sufficient history. Results sorted by quoteVolume24h descending (nulls last) and paginated.

Sends a GET request to /api/v1/market/screener

Arguments:

  • category
  • is_active
  • market_type: Filter by market type
  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
Source

pub async fn get_market_stats<'a>( &'a self, ) -> Result<ResponseValue<GetMarketStatsResponse>, Error<()>>

Market Stats

Market Stats

Exchange-wide life-to-date (since-inception) cumulative totals across all trading pairs: total quote-token volume and total number of trades. No auth required.

Sends a GET request to /api/v1/market/stats

Source

pub async fn get_orderbook_snapshot<'a>( &'a self, trading_pair_id: &'a str, denomination: Option<GetOrderbookSnapshotDenomination>, levels: Option<NonZeroU32>, magnitude: Option<GetOrderbookSnapshotMagnitude>, trading_mode: Option<GetOrderbookSnapshotTradingMode>, ) -> Result<ResponseValue<GetOrderbookResponse>, Error<()>>

Orderbook Snapshot

Orderbook Snapshot

Get the complete orderbook snapshot for a trading pair showing all bids and asks with their price levels. This is a public endpoint that does not require authentication.

Sends a GET request to /api/v1/orderbook/{tradingPairId}

Arguments:

  • trading_pair_id
  • denomination: Price denomination
  • levels: Number of price levels (max 100)
  • magnitude: Price grouping magnitude
  • trading_mode: Trading mode
Source

pub async fn get_orders<'a>( &'a self, margin_account_id: Option<&'a str>, order_by: Option<GetOrdersOrderBy>, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, status: Option<&'a GetOrdersStatus>, trading_mode: Option<GetOrdersTradingMode>, trading_pair_id: Option<&'a Uuid>, ) -> Result<ResponseValue<ListOrdersResponse>, Error<()>>

Get user orders

Get user orders.

Get orders for the authenticated user with pagination and optional filtering by status and trading pair.

Sends a GET request to /api/v1/orders

Arguments:

  • margin_account_id
  • order_by: Sort direction for createdAt
  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
  • status: Order status (single value or comma-separated list)
  • trading_mode: Trading mode
  • trading_pair_id: Trading pair identifier (UUID)
Source

pub async fn create_order<'a>( &'a self, body: &'a CreateOrderRequest, ) -> Result<ResponseValue<CreateOrderResponse>, Error<()>>

Create new order

Create new order.

Create a new order and process it through the matching engine. The order will be matched against existing orders in the orderbook.

Sends a POST request to /api/v1/orders

Source

pub async fn batch_cancel_orders<'a>( &'a self, body: &'a BatchCancelOrdersRequest, ) -> Result<ResponseValue<BatchCancelOrdersResponse>, Error<()>>

Batch cancel specific orders

Batch cancel specific orders.

Cancel multiple specific orders by their IDs. For canceling all orders, use /batch-cancel-all or /batch-cancel-all/{tradingPairId}.

Sends a POST request to /api/v1/orders/batch-cancel

Source

pub async fn batch_cancel_all<'a>( &'a self, ) -> Result<ResponseValue<BatchCancelAllResponse>, Error<()>>

Cancel all orders

Cancel all orders.

Cancel all active orders for the authenticated user. To cancel orders for a specific trading pair, use /batch-cancel-all/{tradingPairId}.

Sends a POST request to /api/v1/orders/batch-cancel-all

Source

pub async fn batch_cancel_all_by_pair<'a>( &'a self, trading_pair_id: &'a str, ) -> Result<ResponseValue<BatchCancelAllResponse>, Error<()>>

Cancel all orders for a trading pair

Cancel all orders for a trading pair.

Cancel all active orders for the authenticated user on a specific trading pair.

Sends a POST request to /api/v1/orders/batch-cancel-all/{tradingPairId}

Source

pub async fn batch_create_orders<'a>( &'a self, body: &'a BatchCreateOrdersRequest, ) -> Result<ResponseValue<BatchCreateOrdersResponse>, Error<()>>

Batch create orders

Batch create orders.

Create multiple orders in a single batch. Each order is processed sequentially through the matching engine.

Sends a POST request to /api/v1/orders/batch-create

Source

pub async fn batch_replace_orders<'a>( &'a self, body: &'a BatchReplaceOrdersRequest, ) -> Result<ResponseValue<BatchReplaceOrdersResponse>, Error<()>>

Batch replace orders

Batch replace orders.

Replace multiple orders in a single batch. Each order is processed sequentially through the matching engine.

Sends a POST request to /api/v1/orders/batch-replace

Source

pub async fn cancel_order<'a>( &'a self, body: &'a CancelOrderRequest, ) -> Result<ResponseValue<CancelOrderResponse>, Error<()>>

Cancel existing order

Cancel existing order.

Cancel an existing order and unlock the reserved funds. Only orders that are not yet filled can be cancelled.

Sends a POST request to /api/v1/orders/cancel

Source

pub async fn list_conditional_orders<'a>( &'a self, margin_account_id: Option<&'a str>, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, state: Option<&'a str>, trading_pair_id: Option<&'a Uuid>, ) -> Result<ResponseValue<ListConditionalOrdersResponse>, Error<()>>

List conditional TP/SL orders for the authenticated user.

Sends a GET request to /api/v1/orders/conditional

Arguments:

  • margin_account_id
  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
  • state
  • trading_pair_id: Trading pair identifier (UUID)
Source

pub async fn get_conditional_order<'a>( &'a self, conditional_order_id: &'a str, ) -> Result<ResponseValue<ConditionalOrder>, Error<()>>

Get a single conditional (TP/SL) order by its UUID.

Sends a GET request to /api/v1/orders/conditional/{conditionalOrderId}

Source

pub async fn cancel_conditional_order<'a>( &'a self, conditional_order_id: &'a str, ) -> Result<ResponseValue<CancelConditionalOrderResponse>, Error<()>>

Cancel conditional TP/SL order.

Sends a DELETE request to /api/v1/orders/conditional/{conditionalOrderId}

Source

pub async fn get_order_by_id<'a>( &'a self, order_id: &'a str, ) -> Result<ResponseValue<GetOrderResponse>, Error<()>>

Get order by ID

Get order by ID.

Get a single order by its ID. Users can only access their own orders.

Sends a GET request to /api/v1/orders/{orderId}

Source

pub async fn replace_order<'a>( &'a self, order_id: &'a str, body: &'a ReplaceOrderRequest, ) -> Result<ResponseValue<ReplaceOrderResponse>, Error<()>>

Replace existing order

Replace existing order.

Replaces an existing order with new parameters by canceling the original order and creating a new one with the updated price/quantity. Priority is lost in the order book.

Sends a PUT request to /api/v1/orders/{orderId}

Source

pub async fn get_my_trader_code<'a>( &'a self, ) -> Result<ResponseValue<TraderCodeResponse>, Error<()>>

Get your TraderCode

Claim your TraderCode.

Get your TraderCode.

Return the authenticated caller’s TraderCode, which is derived from their wallet address (rendered Monaco - <address> by clients). Never 404s — the code always exists for a signed-in wallet — and ensures the backing row so referrals attributed to this wallet have a code to link.

Sends a GET request to /api/v1/pitpass/codes/me

Source

pub async fn get_trader_code_info<'a>( &'a self, code: &'a str, ) -> Result<ResponseValue<GetTraderCodeInfoResponse>, Error<()>>

Look up a TraderCode

Look up a TraderCode (public).

Public, unauthenticated lookup used to validate a referral code at signup. The code is a wallet address; returns the normalized code when it resolves to a known wallet. Returns 404 when the code does not resolve to a user.

Sends a GET request to /api/v1/pitpass/codes/{code}

Source

pub async fn get_rewards_balance<'a>( &'a self, ) -> Result<ResponseValue<GetRewardsBalanceResponse>, Error<()>>

Get your rewards balance

Read accrued PitPass rewards balance.

Return the caller’s current rewards-bucket balances across all reward tokens. Rewards accumulate here as referred users trade; call TransferRewards to move them into a tradeable balance. Returns an empty list when no rewards have been earned yet.

Sends a GET request to /api/v1/pitpass/rewards/balance

Source

pub async fn transfer_rewards<'a>( &'a self, body: &'a TransferRewardsRequest, ) -> Result<ResponseValue<TransferRewardsResponse>, Error<()>>

Transfer rewards into a trading balance

Transfer earned rewards into a trading balance.

Move spendable PitPass reward balance from your rewards bucket into a trading balance under the authenticated application, making it tradeable immediately. Ledger-only (one shared vault + one backend ledger) — no on-chain transaction and no gas. Fails with 402 when the rewards balance is insufficient.

Sends a POST request to /api/v1/pitpass/rewards/transfer

Source

pub async fn list_positions<'a>( &'a self, margin_account_id: Option<&'a str>, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, status: Option<&'a ListPositionsStatus>, trading_pair_id: Option<&'a Uuid>, ) -> Result<ResponseValue<ListPositionsResponse>, Error<()>>

Sends a GET request to /api/v1/positions

Arguments:

  • margin_account_id: Optional isolated bucket filter.
  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
  • status: Order status (single value or comma-separated list)
  • trading_pair_id: Trading pair identifier (UUID)
Source

pub async fn batch_close_all_positions<'a>( &'a self, body: &'a BatchCloseAllRequest, ) -> Result<ResponseValue<BatchCloseAllResponse>, Error<()>>

Close all open positions in a single batch (“panic close”).

Submits a MARKET reduce-only close for every open position owned by the caller, optionally filtered to a single trading pair. Best-effort and partial: each position closes independently and per-position failures are reported in results rather than aborting the batch.

Sends a POST request to /api/v1/positions/batch-close-all

Source

pub async fn list_position_history<'a>( &'a self, margin_account_id: Option<&'a str>, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, position_id: Option<&'a str>, trading_pair_id: Option<&'a Uuid>, ) -> Result<ResponseValue<ListPositionHistoryResponse>, Error<()>>

Sends a GET request to /api/v1/positions/history

Arguments:

  • margin_account_id
  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
  • position_id
  • trading_pair_id: Trading pair identifier (UUID)
Source

pub async fn get_position<'a>( &'a self, position_id: &'a str, ) -> Result<ResponseValue<GetPositionResponse>, Error<()>>

Sends a GET request to /api/v1/positions/{positionId}

Source

pub async fn close_position<'a>( &'a self, position_id: &'a str, body: &'a ClosePositionRequest, ) -> Result<ResponseValue<ClosePositionResponse>, Error<()>>

Sends a POST request to /api/v1/positions/{positionId}/close

Source

pub async fn add_position_margin<'a>( &'a self, position_id: &'a str, body: &'a AddPositionMarginRequest, ) -> Result<ResponseValue<AddPositionMarginResponse>, Error<()>>

Sends a POST request to /api/v1/positions/{positionId}/margin/add

Arguments:

  • position_id: Position UUID for the isolated bucket being adjusted.
  • body
Source

pub async fn reduce_position_margin<'a>( &'a self, position_id: &'a str, body: &'a ReducePositionMarginRequest, ) -> Result<ResponseValue<ReducePositionMarginResponse>, Error<()>>

Sends a POST request to /api/v1/positions/{positionId}/margin/reduce

Arguments:

  • position_id: Position UUID for the isolated bucket being adjusted.
  • body
Source

pub async fn get_position_pnl_history<'a>( &'a self, position_id: &'a str, end_time: Option<i64>, interval: GetPositionPnlHistoryInterval, start_time: Option<i64>, ) -> Result<ResponseValue<GetPositionPnlHistoryResponse>, Error<()>>

Get position PnL history

Get bucketed PnL history for one position.

Time series of PnL state samples (quantity, entry, mark, unrealized, cumulative realized/funding/fees) for a position the caller owns, at the requested interval. Buckets between samples are forward-filled; buckets before the position’s first sample are omitted. Distinct from ListPositionHistory, which returns lifecycle events.

Sends a GET request to /api/v1/positions/{positionId}/pnl/history

Arguments:

  • position_id
  • end_time: End time as Unix timestamp (milliseconds)
  • interval: Sample interval
  • start_time: Start time as Unix timestamp (milliseconds)
Source

pub async fn get_position_risk<'a>( &'a self, position_id: &'a str, ) -> Result<ResponseValue<GetPositionRiskResponse>, Error<()>>

Sends a GET request to /api/v1/positions/{positionId}/risk

Source

pub async fn attach_position_tp_sl<'a>( &'a self, position_id: &'a str, body: &'a AttachPositionTpSlRequest, ) -> Result<ResponseValue<AttachPositionTpSlResponse>, Error<()>>

Sends a POST request to /api/v1/positions/{positionId}/tp-sl

Source

pub async fn get_trade_by_id<'a>( &'a self, trade_id: &'a str, ) -> Result<ResponseValue<GetTradeByIdResponse>, Error<()>>

Get Trade by ID

Get Trade by ID

Retrieve a single trade by its unique identifier.

Sends a GET request to /api/v1/trades/by-id/{tradeId}

Source

pub async fn get_trades<'a>( &'a self, trading_pair_id: &'a str, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, ) -> Result<ResponseValue<GetTradesResponse>, Error<()>>

Recent Trades

Recent Trades

Get recent trades for a trading pair sorted by execution time.

Sends a GET request to /api/v1/trades/{tradingPairId}

Arguments:

  • trading_pair_id
  • page: Page number (1-indexed)
  • page_size: Max trades to return (max 100)
Source

pub async fn submit_whitelist<'a>( &'a self, body: &'a SubmitWhitelistRequest, ) -> Result<ResponseValue<SubmitWhitelistResponse>, Error<()>>

Submit whitelist application

Submit whitelist application.

Submit a whitelist application to join Monaco Protocol. The user will be created with is_active = false and will need to be approved by an admin.

Sends a POST request to /api/v1/whitelist

Source

pub async fn list_pending_withdrawals<'a>( &'a self, page: Option<NonZeroU32>, page_size: Option<NonZeroU32>, ) -> Result<ResponseValue<ListPendingWithdrawalsResponse>, Error<()>>

List pending withdrawals

List the caller’s pending withdrawals.

Authenticated. Returns the caller’s withdrawals that are still awaiting on-chain root confirmation (status pending) — i.e. those for which the merkle proof, and therefore the executable calldata from GetWithdrawal, is not available yet. Scoped to the authenticated account: only withdrawals owned by the caller’s user + application are returned. Newest first, paged.

Sends a GET request to /api/v1/withdrawals

Arguments:

  • page: Page number (1-indexed)
  • page_size: Items per page (max 100)
Source

pub async fn initiate_withdrawal<'a>( &'a self, body: &'a InitiateWithdrawalRequest, ) -> Result<ResponseValue<Withdrawal>, Error<()>>

Initiate withdrawal

Initiate a withdrawal.

Master accounts with the withdraw permission only. Routes through the matching engine to debit the balance and allocate a withdrawal_index, then returns it plus the target vault address. The calldata field is empty: executeWithdrawal requires the merkle proof, which only exists after the withdrawal’s root is confirmed on-chain. Poll GetWithdrawal to obtain the calldata once it is ready.

Sends a POST request to /api/v1/withdrawals

Source

pub async fn get_withdrawal<'a>( &'a self, withdrawal_index: &'a str, ) -> Result<ResponseValue<Withdrawal>, Error<()>>

Get withdrawal

Fetch a withdrawal’s executable calldata by index.

Public lookup — no auth. Returns the vault address and ABI-encoded executeWithdrawal(...) calldata for a previously-initiated withdrawal_index. The calldata is bound to the fixed (index, metadata, owner, destination, token, amount) tuple persisted for the withdrawal, so re-fetching it cannot redirect funds. Returns 409 while the withdrawal’s root has not been confirmed on-chain yet (proof not available) — clients poll this endpoint until it succeeds.

Sends a GET request to /api/v1/withdrawals/{withdrawalIndex}

Source

pub async fn health_check<'a>( &'a self, ) -> Result<ResponseValue<PublicHealthCheckResponse>, Error<()>>

Health check

Health check.

Returns the current health status of the API gateway and its connected services. Can be used for monitoring and load balancer health checks.

Sends a GET request to /health

Trait Implementations§

Source§

impl ClientHooks for &Client

Source§

async fn pre<E>( &self, request: &mut Request, info: &OperationInfo, ) -> Result<(), Error<E>>

Runs prior to the execution of the request. This may be used to modify the request before it is transmitted.
Source§

async fn post<E>( &self, result: &Result<Response, Error>, info: &OperationInfo, ) -> Result<(), Error<E>>

Runs after completion of the request.
Source§

async fn exec( &self, request: Request, info: &OperationInfo, ) -> Result<Response, Error>

Execute the request. Note that for almost any reasonable implementation this will include code equivalent to this: Read more
Source§

impl ClientInfo<()> for Client

Source§

fn api_version() -> &'static str

Get the version of this API. Read more
Source§

fn baseurl(&self) -> &str

Get the base URL to which requests are made.
Source§

fn client(&self) -> &Client

Get the internal reqwest::Client used to make requests.
Source§

fn inner(&self) -> &()

Get the inner value of type T if one is specified.
Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more