Contracts
Contracts · Flow

Margin

Allocate a subaccount's balance into tradeable margin, and add or remove margin on a virtual account — including the Muon uPnL signature removeMargin requires.

Wallet
Not connected

getDeallocateUpnlSig
read
Fetch the Muon uPnl_A attestation removeMargin requires, assembled into a contract-ready SingleUpnlSig. Off-chain Muon oracle read — no ABI.

The Muon partyA the uPnL attestation is for. The signature is short-lived — fetch it immediately before a removeMargin.

Enter a virtual account and fetch its uPnL signature.
getWithdrawCooldownOf
read
Read when a subaccount was last deallocated or credited to withdrawable balance, and when it can deallocate next.
Run the read to see the subaccount’s cooldown timestamp.
getDeallocateDebounceTime
read
Read the minimum time the protocol enforces between two deallocations of the same account.
Run the read to see the deallocate debounce.

allocate
write
Move a subaccount's available balance into allocated (tradeable) margin (routed via AccountLayer _call).
Fill the fields above and submit.
deallocate
write
Move a subaccount's allocated (tradeable) balance back into its available balance (routed via AccountLayer _call). Sending fetches a fresh Muon uPnL signature automatically; subject to the on-chain deallocate debounce.
Fill the fields above and submit.
addMargin
write
Add margin to a virtual account — move collateral from the parent subaccount's available balance into the VA. No signature required.
Fill the fields above and submit.
removeMargin
write
Remove margin from a virtual account (deallocate). Sending fetches a fresh Muon uPnL signature automatically; subject to the on-chain deallocate debounce.
Fill the fields above and submit.
executeAccountCalls
write
Run several SYMMIO core writes as one subaccount, in one atomic transaction. Reference only: this card explains the call and sends nothing.

How it works

  1. Pass a subaccount and an ordered list of { functionName, args }. Each name must be a write in the SDK’s SYMMIO core ABI, with its own units.
  2. The SDK encodes every call first, so a wrong name or argument fails before any wallet prompt.
  3. From the wallet, the calls go out as one AccountLayer _call transaction, simulated first. If one call reverts, none of them happen.
  4. Gasless, every call is relayed in order as one request. With gasless: true, a list holding a call the relayer cannot carry is refused instead of going to the wallet.
  5. Nothing is inferred: no request ids, and no call’s return value is fed into the next. Read what you need before you build the list.

Why this card cannot send it

This app uses the SDK only through @symmio/trading-react, and that package has no hook for this call: the calls are arbitrary core writes, so no fixed set of reads can be refreshed after them. For a withdrawal you do not need it: the useWithdraw flow already deallocates and initiates in one atomic transaction on a cross-margin subaccount.

In a React app

import { executeAccountCallsMutationOptions } from "@symmio/trading-core";
import { useSymmioConfig } from "@symmio/trading-react";
import { useMutation } from "@tanstack/react-query";

const config = useSymmioConfig();
const { mutate } = useMutation(executeAccountCallsMutationOptions(config));

mutate({
  account: subAccount,
  calls: [
    { functionName: "deallocate", args: [amount18, upnlSig] },
    { functionName: "initiateWithdraw", args: [parts, false, providerData] },
  ],
});
// Wait for the receipt, then refresh the reads these calls changed.

Full reference: SDK docs → Core → SYMMIO contract → executeAccountCalls.