getMuonPriceRange
Fetch a fresh Muon priceRange attestation for a position over the [t0, t1] window and normalize it to typed fields. This produces the TWAP-style range a partyB needs to validate a forceClosePosition / settleAndForceClosePosition against the configured gap thresholds — it is a time window in unix seconds, not a block range. The oracle URLs and the SYMMIO diamond address are resolved from config; gateways are tried in order until one succeeds.
import { getMuonPriceRange } from "@symmio/trading-core";
const r = await getMuonPriceRange(config, {
t0: 1_700_000_000n,
t1: 1_700_000_900n,
partyA: "0xva...",
partyB: "0xpb...",
symbolId: 1n,
});
console.log(r.lowest, r.highest, r.mean);Parameters
t0bigintrequiredWindow start in unix seconds.
t1bigintrequiredWindow end in unix seconds.
partyAAddressrequiredThe partyA (virtual account for lowcap) to attest.
partyBAddressrequiredThe partyB counterparty of the position.
symbolIdbigintrequiredThe market symbol id the range is computed for.
chainIdnumberoptionalOptional chain override.
Returns
GetMuonPriceRangeReturnTypepartyAAddressThe attested partyA.
partyBAddressThe attested partyB.
symbolIdbigintThe market symbol id the range was computed for.
startTimebigintoptionalWindow start in unix seconds (echoed by the gateway).
endTimebigintoptionalWindow end in unix seconds (echoed by the gateway).
lowestbigintoptionalLowest observed price across the window (18-decimal).
highestbigintoptionalHighest observed price across the window (18-decimal).
meanbigintoptionalTWAP/mean price across the window (18-decimal).
pricebigintoptionalSpot price at the attestation (18-decimal).
uPnlAbigintoptionalPartyA’s unrealized PnL at the attestation (18-decimal, signed).
uPnlBbigintoptionalPartyB’s unrealized PnL at the attestation (18-decimal, signed).
Plus the MuonAttestationBase signature envelope fields.
Query options
import { getMuonPriceRangeQueryOptions } from "@symmio/trading-core";
import { useQuery } from "@tanstack/react-query";
useQuery(getMuonPriceRangeQueryOptions(config, { t0, t1, partyA, partyB, symbolId }));GetMuonPriceRangeOptions requires t0, t1, partyA, partyB, and symbolId; the factory does not accept missing inputs or validate them inside queryFn. The getMuonPriceRangeQueryKey builder still accepts partial inputs for cache matching and invalidation.