Muon API Queries
Introduction
The Muon API is designed to provide signed data for SYMM 3rd Party frontends, a platform that enables users to trade assets and perpetual contracts (perps) without the need for Know Your Customer (KYC) procedures. By utilizing their Ethereum wallet, users can participate in trading activities on Cloverfield.
Muon acts as an intermediary service, facilitating the generation and signing of data that is required for trading. This documentation will provide an overview of the app codebase, explaining its key components and functionalities.
Overview of the Muon API
The Muon API is designed to provide various data related to parties, unrealized profit and loss (uPnl) and price data. It offers separate uPnl calculations for individual parties, namely "partyA" and "partyB," as well as combined uPnl calculations for both parties together. Additionally, the API allows fetching the prices of given quotes. The following sections provide technical documentation of each method.
API Query Endpoints
The Muon app can be queried using specific URLs, each corresponding to different networks:
https://muon-oracle1.rasa.capital/v1/: Arbitrum
https://muon-oracle2.rasa.capital/v1/: Base, Mantle
https://muon-oracle3.rasa.capital/v1/: BSC, Blast
https://muon-oracle4.rasa.capital/v1/: BSC, Blast
uPnl_A
uPnl_A
The uPnl_A
method in the Muon app is designed to verify and validate the unrealized profit and loss (uPnl) for partyA
based on a set tolerance level.
Input Parameters
partyA
: The address of partyA.chainId
: The chain identifier.symmio
: Address of the Symmio diamond.latestBlockNumber
: The latest block number to fetch data for.
Returned Data Structure
symmio
: Address of the Symmio diamond.partyA
: The address of partyA.nonce
: Unique nonce for the transaction to prevent replay attacks.uPnl
: The verified uPnl value for partyA as obtained from the request data.timestamp
: The blockchain timestamp at which the request data was generated.chainId
: The chain identifier.
Example API Query
Example Response
partyA_overview
partyA_overview
The partyA_overview
method in the Muon API provides a comprehensive overview of partyA
's trading status, including the unrealized profit and loss (uPnl), loss, notional value sum, and other relevant financial data. This method ensures detailed insight into partyA
's trading performance and current market position.
Input Parameters
partyA
: The address of partyA.chainId
: The chain identifier.symmio
: Address of the Symmio diamond.latestBlockNumber
: The latest block number to fetch data for.
Returned Data Structure
symmio
: Address of the Symmio diamond.partyA
: The address of partyA.nonce
: Unique nonce for the transaction to prevent replay attacks.uPnl
: The verified uPnl value for partyA as obtained from the request data.timestamp
: The blockchain timestamp at which the request data was generated.
Example API Query
Example Response
uPnl_A_withSymbolPrice
uPnl_A_withSymbolPrice
The uPnl_A_withSymbolPrice
method in the Muon API calculates the unrealized profit and loss (uPnl) for partyA
and fetches the current price of a specified symbol.
Input Parameters
partyA
: The address of partyA.chainId
: The chain identifier.symbolId
: The identifier of the trading symbol.symmio
: Address of the Symmio diamond.latestBlockNumber
: The latest block number to fetch data for.
Returned Data Structure
chainId
: The chain identifier.partyA
: The address of partyA.symbolId
: The identifier of the trading symbol.price
: The current price of the specified symbol.symmio
: Address of the Symmio diamond.latestBlockNumber
: The latest block number at the time of the query.Additional data included as the
result
.
Example API Query
Example Response:
uPnl_B
uPnl_B
The uPnl_B
method within the Muon API calculates the unrealized profit and loss (uPnl) specifically for partyB
in relation to partyA
.
Input Parameters
partyB
: The address of partyB.partyA
: The address of partyA.chainId
: The chain identifier.symmio
: Address of the Symmio diamond.latestBlockNumber
: The latest block number to fetch data for.
Returned Data Structure
chainId
: The chain identifier.partyB
: The address of partyB.partyA
: The address of partyA.symmio
: Address of the Symmio diamond.latestBlockNumber
: The latest block number at the time of the query.Additional data included as the
result
.
Example API Query
Example Response:
uPnl
uPnl
The uPnl
method within the Muon API calculates the combined unrealized profit and loss (uPnl) for both partyB
and partyA
. This method provides a comprehensive view of the financial performance and interactions between the two parties.
Input Parameters
partyB
: The address of partyB.partyA
: The address of partyA.chainId
: The chain identifier.symmio
: Address of the Symmio diamond.latestBlockNumber
: The latest block number to fetch data for.
Returned Data Structure
chainId
: The chain identifier.partyB
: The address of partyB.partyA
: The address of partyA.symmio
: Address of the Symmio diamond.latestBlockNumber
: The latest block number at the time of the query.Additional data included as the
result
.
Example API Query
Example Response:
uPnlWithSymbolPrice
The uPnlWithSymbolPrice
method within the Muon API calculates the combined unrealized profit and loss (uPnl) for both partyB
and partyA
and fetches the current price of a specified symbol. This method provides comprehensive financial performance metrics for both parties and the latest symbol price.
Input Parameters
partyB
: The address of partyB.partyA
: The address of partyA.chainId
: The chain identifier.symbolId
: The identifier of the trading symbol.symmio
: Address of the Symmio diamond.latestBlockNumber
: The latest block number to fetch data for.
Returned Data Structure
chainId
: The chain identifier.partyB
: The address of partyB.partyA
: The address of partyA.symbolId
: The identifier of the trading symbol.price
: The current price of the specified symbol.symmio
: Address of the Symmio diamond.latestBlockNumber
: The latest block number at the time of the query.Additional data included as the
result
.
Example API Query
Example Response
price
price
The price
method within the Muon API fetches the current prices of specified quotes. This method provides up-to-date pricing information for a list of trading symbols.
Input Parameters
quoteIds
: A JSON-formatted list of quote identifiers.chainId
: The chain identifier.symmio
: Address of the Symmio diamond.latestBlockNumber
: The latest block number to fetch data for.
Returned Data Structure
chainId
: The chain identifier.quoteIds
: The list of quote identifiers.symmio
: Address of the Symmio diamond.latestBlockNumber
: The latest block number at the time of the query.Additional price data as included in the
result
fromfetchPrices
.
Example API Query
Example Response:
settle_upnl
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.
Input Parameters
partyA
: The address of partyA for whom the settlement calculation is performed.chainId
: The chain identifier.symmio
: Address of the Symmio diamond.quoteIds
: A JSON-formatted list of quote identifiers to be settled (e.g.,"[18068]"
).
Note:
latestBlockNumber
is not explicitly required in the example. The Muon backend will fetch the appropriate block data internally.
Returned Data Structure
chainId
: The chain identifier.partyA
: The address of partyA.symmio
: Address of the Symmio diamond.latestBlockNumber
: The latest block number at the time of the query.quoteSettlementData
: An array containing settlement information for eachquoteId
.Each item includes:
quoteId
currentPrice
partyBUpnlIndex
uPnlA
: The finalized unrealized profit/loss for partyA across all settled quotes.upnlPartyBs
: An array of the finalized unrealized PnL values for each corresponding counterparty.notionalValueSumA
: The total notional value of all positions held by partyA.notionalValueSumBs
: An array of the total notional values for each corresponding partyB.nonceA
: The updated nonce for partyA after settlement.noncePartyBs
: An array of updated nonces for each corresponding partyB.signParams
: An array containing the parameters used to sign and verify the settlement on-chain.
Example API Query
Example Response
Last updated