getDeallocateUpnlSig
Fetch a fresh Muon uPnL (uPnl_A) attestation for a virtual account, assembled into the contract-ready SingleUpnlSig that removeMargin / deallocate require. This is the short-lived uPnl_A signature those writes need to prove the virtual account stays solvent after the deallocation — the attestation is timestamped and short-lived, so fetch it immediately before submitting, not ahead of time. For the raw, un-assembled attestation (all returned fields), use getMuonUpnlA instead. The oracle URLs and the SYMMIO diamond address are resolved from config; gateways are tried in order until one succeeds.
import { getDeallocateUpnlSig, removeMargin } from "@symmio/trading-core";
const upnlSig = await getDeallocateUpnlSig(config, { virtualAccount: "0xva..." });
await removeMargin(config, {
virtualAccount: "0xva...",
amount: 50_000000000000000000n,
upnlSig,
});Parameters
virtualAccountAddressrequiredThe virtual account (Muon partyA) the uPnL attestation is for.
chainIdnumberoptionalOptional chain override.
Returns
Unlike the other Muon reads, this returns a contract-ready struct — not a MuonAttestationBase subtype. It mirrors the on-chain SingleUpnlSig tuple field-for-field so it encodes directly as the contract argument.
SingleUpnlSigreqIdHexMuon request id (opaque bytes).
timestampbigintAttestation timestamp (seconds).
upnlbigintSigned unrealized PnL of the party, int256 (may be negative).
gatewaySignatureHexMuon gateway signature over the request (opaque bytes).
sigsSchnorrSignThe Schnorr TSS signature pieces (signature, owner, nonce).
Query options
import { getDeallocateUpnlSigQueryOptions } from "@symmio/trading-core";
import { useQuery } from "@tanstack/react-query";
useQuery(getDeallocateUpnlSigQueryOptions(config, { virtualAccount }));GetDeallocateUpnlSigOptions requires virtualAccount; the factory does not accept missing inputs or validate them inside queryFn. The getDeallocateUpnlSigQueryKey builder still accepts partial inputs for cache matching and invalidation. Because the signature is short-lived, prefer fetching on demand right before the write over serving a cached one.