Muon API

Introduction

The Muon API is a decentralized, off-chain oracle service that provides cryptographic signatures used by both solvers and 3rd party frontend applications for price validations, solvency checks, and liquidation dispute resolutions. Muon signatures are appended to contract calls like sendQuote() and openPosition(), then verified on-chain before execution, ensuring that only validated data triggers on-chain actions.

The signatures returned by the Muon API confirm that the quoted price has been validated by the Muon network and that both counterparties meet the platform’s solvency requirements. These endpoints return structured JSON payloads.

Overview of the Muon API

The Muon API provides a suite of off‑chain services for critical trading operations. Its main capabilities include:

  • Price Validation for a Symbol: Retrieve signed price data for any supported asset symbol, ensuring the price is authenticated by the Muon network.

  • Unrealized Profit and Loss (uPnL) Calculation: Compute uPnL for individual parties (partyAor partyB) or for combined positions.

  • Verification for Settling Prices: Used to settle unrealized PnL, resolve price disputes, and trigger liquidation or settlement functions securely.

API Query Endpoints

The Muon app can be queried using these URLs on all supported chains, if one is unresponsive please try another.

Polygon Chain URL:

[GET] uPnl_A

This endpoint calculates and returns the unrealized profit and loss (uPnL) for partyA. The signature returned by this endpoint is used in the deallocate() function for partyA to ensure that they meet solvency requirements before funds are released.

Contract Struct:

Request URL Example:

Parameters:

  • partyA (address): The address of partyA.

  • chainId (uint): The chain id.

  • symmio (address): The address of the Symmio diamond contract.

Returns:

  • chainId (string): The chain identifier.

  • partyA (address): The address of partyA.

  • symmio (address): Address of the Symmio diamond contract.

  • uPnl (string): The verified unrealized PnL value for partyA.

  • notionalValueSum (string): Sum of notional values for all positions.

  • nonce (string): Unique nonce or address used for replay protection (init.nonceAddress).

  • timestamp (uint): The block timestamp at which the data was generated.

  • symbolIds (string[]): List of symbol IDs involved in the calculation.

  • symbols (string[]): Corresponding asset symbols.

  • symbolIdsPrices (string[]): Price values indexed by symbolIds.

  • quoteIds (string[]): IDs of the quotes used.

  • signature (bytes): Muon-generated signature (signatures[0].signature).

  • owner (address): Address of the signer (signatures[0].owner).

  • nodeSignature (bytes): Gateway signature appended on contracts (signatures[0].nodeSignature).

Output Schema:

[GET] partyA_overview

The signature returned by this endpoint produces a LiquidationSig that is used in the standard liquidation flow via liquidatePartyA() and setSymbolsPrice().

Contract Struct:

circle-info

Important: This method produces signatures verified by LibMuon.verifyLiquidationSig(). It does not produce signatures for the deferred liquidation flow (DeferredLiquidationSig), which requires a separate Muon Endpoint not yet available.

Request URL Example:

Parameters:

  • partyA (address): The address of partyA.

  • chainId (uint): The chain id.

  • symmio (address): The address of the Symmio diamond contract.

Returns :

  • chainId, partyA, symmio, uPnl, notionalValueSum, nonce, timestamp, symbolIds, symbols, symbolIdsPrices, quoteIds (same as uPnl_A).

  • signature (bytes): Muon-generated signature for liquidation (signatures[0].signature).

  • owner (address): Address of the signer (signatures[0].owner).

  • nodeSignature (bytes): Gateway signature appended on contracts.

Response → Struct field mapping:

API Response Field
Struct Field

result.liquidationId

liquidationId

result.uPnl

upnl

result.loss

totalUnrealizedLoss

result.symbolIds

symbolIds

result.symbolIdsPrices

prices

Example API Query

Example Response

[GET] uPnl_A_withSymbolPrice

This endpoint calculates unrealized profit and loss (uPnL) for partyA and fetches the price for a specified symbol in one request. It’s used in the sendQuoteWithAffiliate() flow when Party A initiates a quote to Party B. See how the signature is formatted for this here.

Contract Struct:

Request URL Example:

Parameters:

  • partyA (address): The address of partyA.

  • chainId (uint): The chain id.

  • symbolId (uint): The ID of the asset symbol to fetch the price for.

  • symmio (address): The address of the Symmio diamond contract.

Returns:

  • chainId (string): The chain identifier.

  • partyA (address): The address of partyA.

  • symbolId (string): The requested symbol ID.

  • price (string): The signed price value for the requested symbol.

  • uPnl (string): The verified unrealized PnL value for partyA.

  • notionalValueSum (string): Sum of notional values for all positions.

  • nonce (string): Unique nonce or address used for replay protection.

  • timestamp (uint): The block timestamp at which the data was generated.

  • symbolIds (string[]): List of all symbol IDs involved in the position.

  • symbols (string[]): Corresponding asset symbols.

  • symbolIdsPrices (string[]): Price values indexed by symbolIds.

  • quoteIds (string[]): IDs of the quotes used.

  • signature (bytes): Muon-generated signature (signatures[0].signature).

  • owner (address): Address of the signer (signatures[0].owner).

  • nodeSignature (bytes): Gateway signature appended on contracts, verified on-chain before execution.

Example Response:

[GET] uPnl_B

This endpoint calculates and returns the unrealized profit and loss (uPnL) for partyB, used in the lockQuote() flow to verify Party B’s solvency before locking their position. See how this is integrated here.

Contract Struct:

Parameters:

  • partyB (address): The Ethereum address of partyB.

  • partyA (address): The Ethereum address of partyA (counterparty).

  • chainId (uint): The chain id.

  • symmio (address): The address of the Symmio diamond contract.

Returns:

  • chainId (string): The chain identifier.

  • partyB (address): The address of partyB.

  • partyA (address): The address of partyA.

  • symmio (address): Address of the Symmio diamond contract.

  • uPnl (string): The verified unrealized PnL value for partyB.

  • notionalValueSum (string): Sum of notional values for all positions.

  • nonce (string): Unique nonce or address used for replay protection.

  • timestamp (uint): The block timestamp at which the data was generated.

  • prices (string[]): Array of price values corresponding to active symbols.

  • quoteIds (string[]): IDs of the quotes used.

  • signature (bytes): Muon-generated signature (signatures[0].signature).

  • owner (address): Address of the signer (signatures[0].owner).

  • nodeSignature (bytes): Gateway signature appended on contracts, verified on-chain before execution.

Example API Query

Example Response:

[GET] uPnl

This endpoint calculates and returns combined unrealized profit and loss (uPnL) data for both parties in a trade, along with individual breakdowns.

Contract Struct:

Parameters:

  • partyB (address): The address of partyB.

  • partyA (address): The address of partyA.

  • chainId (uint): The chain id.

  • symmio (address): The address of the Symmio diamond contract.

Returns (inside result.data.result):

  • chainId (string): The chain identifier.

  • partyB (address): The address of partyB.

  • partyA (address): The address of partyA.

  • symmio (address): Address of the Symmio diamond contract.

  • uPnlB (string): The verified unrealized PnL value for partyB.

  • uPnlA (string): The verified unrealized PnL value for partyA.

  • notionalValueSumB (string): Sum of notional values for partyB’s positions.

  • notionalValueSumA (string): Sum of notional values for partyA’s positions.

  • nonceB (string): Nonce or address used for replay protection for partyB.

  • nonceA (string): Nonce or address used for replay protection for partyA (same field).

  • timestamp (uint): The block timestamp at which the data was generated.

  • pricesMap (object): Map of all symbol price feed values.

  • markPrices (object): Exchange-specific mark prices.

  • pricesB (string[]): Array of price values for partyB.

  • pricesA (string[]): Array of price values for partyA.

  • quoteIdsB (string[]): Quote IDs used for partyB.

  • quoteIdsA (string[]): Quote IDs used for partyA.

  • signature (bytes): Muon-generated signature (signatures[0].signature).

  • owner (address): Address of the signer (signatures[0].owner).

  • nodeSignature (bytes): Gateway signature appended on contracts, verified on-chain before execution.

Example API Query

Example Response:

[GET] uPnlWithSymbolPrice

This endpoint computes unrealized profit and loss (uPnL) for both partyA and partyB and retrieves the price for a specified symbol in a single call. It is used to call openPosition() by solvers to validate asset prices and enforce solvency requirements before executing on-chain transactions.

Contract Struct:

Parameters:

  • partyB (address): The address of partyB.

  • partyA (address): The address of partyA.

  • chainId (uint): The blockchain network identifier.

  • symmio (address): The address of the Symmio diamond contract.

  • symbolId (uint): The ID of the asset symbol for which to retrieve the price.

Returns:

  • chainId (string): The chain identifier.

  • partyB (address): The address of partyB.

  • partyA (address): The address of partyA.

  • symbolId (string): The requested symbol ID.

  • price (string): The signed price value for the requested symbol.

  • uPnlA (string): The verified unrealized PnL value for partyA.

  • uPnlB (string): The verified unrealized PnL value for partyB.

  • notionalValueSumA (string): Sum of notional values for partyA’s positions.

  • notionalValueSumB (string): Sum of notional values for partyB’s positions.

  • nonceA (string): Nonce or address used for replay protection for partyA .

  • nonceB (string): Nonce or address used for replay protection for partyB (same field).

  • timestamp (uint): The block timestamp at which the data was generated.

  • pricesMap (object): Map of all symbol price feed values.

  • markPrices (object): Exchange-specific mark prices.

  • pricesA (string[]): Array of active price values for partyA.

  • pricesB (string[]): Array of active price values for partyB.

  • quoteIdsA (string[]): Quote IDs used for partyA.

  • quoteIdsB (string[]): Quote IDs used for partyB.

  • signature (bytes): Muon-generated signature (signatures[0].signature).

  • owner (address): Address of the signer (signatures[0].owner).

  • nodeSignature (bytes): Gateway signature appended on contracts, verified on-chain before execution.

Example API Query

Example Response

[GET] price

The price method retrieves and validates the prices of one or more quotes by their quote IDs. It fetches the current mark prices for the symbols underlying each quote and validates them across multiple exchange sources (Binance, Kucoin, Mexc) within tolerance limits. The signature returned by this endpoint produces a QuotePriceSig .

This is used in the partyB liquidation flow — specifically liquidatePositionsPartyB(), where after partyB has been marked as liquidated, individual positions need to be closed at verified market prices. The QuotePriceSig provides the attested prices for each quote being liquidated, and the contract validates that the signature timestamp falls within the liquidation timeout window.

Contract Struct:

Parameters:

  • quoteIds (uint[]): Array of quote identifiers to fetch prices for.

  • chainId (uint): The blockchain network identifier.

  • symmio (address): The address of the Symmio diamond contract.

Returns:

  • chainId (string): The chain identifier.

  • quoteIds (number[]): The array of requested quote IDs.

  • symmio (address): Address of the Symmio diamond contract.

  • symbols (string[]): The asset symbols corresponding to each quote.

  • prices (string[]): Signed price values for each requested quote.

  • pricesMap (object): Map of all symbol price feed values.

  • markPrices (object): Exchange-specific mark prices.

  • maxLeverages (object): Maximum leverage settings per symbol (if any).

  • signature (bytes): Muon-generated signature (signatures[0].signature).

  • owner (address): Address of the signer (signatures[0].owner).

  • nodeSignature (bytes): Gateway signature appended on contracts, verified on-chain before execution.

Example API Query

Example Response:

[GET] settle_upnl

The settle_upnl method is used to verify settlement calculations for one or more open positions (represented by quoteIds) for a given party. It finalizes the unrealized profit and loss (uPnl) for these positions and returns the settlement data, including the updated uPnl values, notional sums, and nonces required for verification and on-chain settlement. You can read more about settleUpnl() here.

Contract Struct:

Parameters:

  • partyA (address): The address of partyA.

  • chainId (uint): The chainId.

  • symmio (address): The address of the Symmio diamond contract.

  • quoteIds (uint[]): JSON-formatted list of quote IDs to be settled (e.g., [23249]).

Note: latestBlockNumber is not explicitly required in the example. The Muon backend will fetch the appropriate block data internally.


Returns:

  • chainId (string): The chain id.

  • partyA (address): The address of partyA.

  • symmio (address): Address of the Symmio diamond contract.

quoteSettlementData: An array containing settlement information for each quoteId.

  • Each item includes:

    • quoteId

    • currentPrice

    • partyBUpnlIndex

  • uPnlA (string): Finalized unrealized PnL for partyA.

  • upnlPartyBs (array): Finalized uPnL values for each counterparty.

  • notionalValueSumA (string): Sum of notional values for partyA’s settled positions.

  • notionalValueSumBs (array): Notional sums for each counterparty.

  • nonceA (string): Nonce or address used for replay protection for partyA (init.nonceAddress).

  • noncePartyBs (array): Nonces for each counterparty.

  • timestamp (uint): The block timestamp at which the data was generated.

  • signature (bytes): Muon-generated signature (signatures[0].signature).

  • owner (address): Address of the signer (signatures[0].owner).

  • nodeSignature (bytes): Gateway signature appended on contracts, verified on-chain before execution.


Example API Query


Example Response

[GET] priceRange

This endpoint returns a TWAP-style price range (highest, lowest, average) for a given symbol over a specified time window, along with both parties' uPnL. The signature returned by this endpoint is used in the forceClosePosition() and settleAndForceClosePosition() functions to validate the price conditions required for a force close.

The time window (t0, t1) must satisfy the force close cooldown constraints defined on-chain: t0 must be >= quote.statusModifyTimestamp + forceCloseFirstCooldown, and t1 must be <= min(quote.deadline, block.timestamp - forceCloseSecondCooldown). Both should be rounded to the nearest minute (start up, end down).

Contract Struct:

Request URL Example:

Parameters:

  • t0 (uint): Start of the price observation window.

  • t1 (uint): End of the price observation window .

  • partyA (address): The address of partyA.

  • partyB (address): The address of partyB.

  • chainId (uint): The chain id.

  • symmio (address): The address of the Symmio diamond contract.

  • symbolId (uint): The symbol ID for the asset being priced.

Returns:

  • chainId (string): The chain identifier.

  • partyA (address): The address of partyA.

  • partyB (address): The address of partyB.

  • symmio (address): Address of the Symmio diamond contract.

  • symbolId (string): The symbol ID for the priced asset.

  • startTime (uint): Start of the observation window.

  • endTime (uint): End of the observation window.

  • lowest (string): Lowest price observed in the time window.

  • highest (string): Highest price observed in the time window.

  • mean (string): Average price over the time window. Maps to averagePrice in the contract struct.

  • price (string): Current price at the time of the signature. Maps to currentPrice in the contract struct.

  • uPnlB (string): PartyB's unrealized PnL.

  • uPnlA (string): PartyA's unrealized PnL.

  • notionalValueSumB (string): Sum of notional values for partyB's positions.

  • notionalValueSumA (string): Sum of notional values for partyA's positions.

  • nonceB (string): PartyB's nonce.

  • nonceA (string): PartyA's nonce.

  • pricesB (string[]): Price values for partyB's positions.

  • pricesA (string[]): Price values for partyA's positions.

  • quoteIdsB (string[]): Quote IDs for partyB's positions.

  • quoteIdsA (string[]): Quote IDs for partyA's positions.

  • nonce (string): Unique nonce or address used for replay protection (init.nonceAddress).

  • timestamp (uint): The block timestamp at which the data was generated.

  • signature (bytes): Muon-generated signature (signatures[0].signature).

  • owner (address): Address of the signer (signatures[0].owner).

  • nodeSignature (bytes): Gateway signature appended on contracts (nodeSignature).

Contract Struct:

Example Response:

Contract Structs Without API Endpoints

The following signature structs are defined in MuonStorage but do not currently have corresponding Muon API methods. They are documented here for reference.

DeferredLiquidationSig

Used for deferred liquidation — proving a user was insolvent at a specific historical block, even after the standard upnlValidTime window has expired (provided the user's nonce hasn't changed). This is an extended version of LiquidationSig with three additional fields capturing the state at the point of insolvency. Read more in the 0.8.3 changelog.

Used by: deferredLiquidatePartyA(), deferredSetSymbolsPrice()


UnifiedSettlementSig

Used for unified settlement across multiple partyAs against a single partyB.

PairUpnlAndPricesSig

Both parties' uPnl with prices for multiple symbols (arrays).

SingleUpnlWithPendingBalanceSig

Extends SingleUpnlSig with a pending balance field.

Last updated