LibMuon (0.8.5)
The LibMuon library provides the cryptographic functions that verify signed data for SYMM contracts: uPNL calculations, price data, liquidation events, and settlement data. It relies on trusted Muon signatures (via a TSS mechanism) and gateway signature checks to confirm the data is authentic and unmodified.
Core Functions
getChainId
Returns the chain ID of the network the contract runs on. Used to tie signed data to the correct network.
function getChainId() internal view returns (uint256 id) {
assembly {
id := chainid()
}
}verifyTSSAndGateway
Runs two signature checks:
TSS verification: calls
LibMuonV04ClientBase.muonVerifyto confirm the data hash is signed by the Muon public key.Gateway verification: converts the hash to an Ethereum signed message hash and recovers the signer address, which must match the
validGatewayaddress stored in MuonStorage.
Parameters:
hash: Hash of the data to verify.sign:SchnorrSignstructure holding the TSS signature.gatewaySignature: The gateway signature as a byte array.
verifyPartyBUpnl
Verifies PartyB's uPNL data. Checks the signature has not expired, builds a hash from key parameters (PartyB's nonce, the uPNL value, the current chain ID), then calls verifyTSSAndGateway.
Parameters:
upnlSig:SingleUpnlSigstructure holding uPNL data and signature details.partyB: PartyB address.partyA: PartyA address.
LibMuonAccount
verifyPartyAUpnl
Verifies PartyA's uPNL data. Builds a hash from PartyA's nonce and uPNL value, then validates it through TSS and gateway verification.
Parameters:
upnlSig:SingleUpnlSigstructure.partyA: PartyA address.
verifyPartyBUpnl (LibMuonAccount)
Delegates to LibMuon's verifyPartyBUpnl to validate PartyB's uPNL data.
LibMuonForceActions
verifyHighLowPrice
Verifies that the high, low, current, and average price data in a HighLowPriceSig are authentic and within the valid time window. Builds a hash from nonces and market price data, then verifies the signature.
Parameters:
sig:HighLowPriceSigstructure.partyB: PartyB address.partyA: PartyA address.symbolId: Trading symbol identifier.
LibMuonFundingRate
verifyPairUpnl
Verifies the pair uPNL data used in funding rate calculations. Builds a hash from both PartyB and PartyA uPNL values and their nonces, then verifies the signature.
Parameters:
upnlSig:PairUpnlSigstructure.partyB: PartyB address.partyA: PartyA address.
LibMuonLiquidation
verifyLiquidationSig
Validates the liquidation signal for PartyA. Requires the prices and symbolIds arrays to have matching lengths, builds a hash from key liquidation parameters (liquidation ID, uPNL values, nonce), then verifies it.
Parameters:
liquidationSig:LiquidationSigstructure.partyA: PartyA address.
verifyDeferredLiquidationSig
Verifies a deferred liquidation signature. Includes extra parameters in the hash (liquidation block number, timestamp, allocated balance) so the deferred liquidation data is validated and signed.
Parameters:
liquidationSig:DeferredLiquidationSigstructure.partyA: PartyA address.
verifyQuotePrices
Verifies quote price data. Requires the prices array to match the quoteIds array, builds the corresponding hash, then validates the signatures.
Parameters:
priceSig:QuotePriceSigstructure holding arrays of quote IDs and their prices.
LibMuonPartyB
verifyPairUpnlAndPrice
Verifies combined uPNL and price data for PartyB and PartyA on a given symbol. Builds a hash from the nonces, uPNL values, and price, then validates the signatures.
Parameters:
upnlSig:PairUpnlAndPriceSigstructure.partyB: PartyB address.partyA: PartyA address.symbolId: Trading symbol identifier.
verifyPartyBUpnl (LibMuonPartyB)
Delegates to LibMuon's verifyPartyBUpnl to verify PartyB's uPNL data.
LibMuonSettlement
verifySettlement
Validates settlement data for a set of quotes. Builds a hash aggregating settlement details (quote settlement data, nonces, uPNL values), then verifies the signature through the TSS and gateway checks.
Parameters:
settleSig:SettlementSigstructure containingreqId, an array ofquotesSettlementsData,upnlPartyBs,upnlPartyA,timestamp, and signature data.partyA: PartyA address.
Last updated

