Instant Withdrawal
Prerequisites
Before you run the instant‐withdrawal script, make sure you have everything in place:
Install Node.js
Download and install Node.js v16+ (comes with
npm) from https://nodejs.org/.
Create a project directory
mkdir symmio-instant-withdrawal cd symmio-instant-withdrawalInitialize a new
package.jsonnpm init -yInstall required NPM packages The script uses:
dotenvfor environment‐variable loadingaxiosfor HTTP callsethersfor EVM wallet + RPCweb3for the multi‐account wrapper calls
Run:
npm install dotenv axios ethers web3ABI files Make sure you have the two ABI JSON files in
./abi/:DIAMOND_ABI.json(your Symmio Diamond)MULTI_ACCOUNT_ABI.json(ABI for the deployed MultiAccount)
Prepare your
.envIn the project root, create a.envfile containing exactly the variables from our guide (see next section).
Once these steps are done, you’re ready to configure your environment variables and move on to the login & withdrawal flow.
Environment Variables
Instant Withdrawal Flow
SIWE Login
Before you can call any of the Instant-Withdrawal API endpoints, you must authenticate yourself and prove ownership of your Ethereum wallet. We use Sign-In With Ethereum (SIWE) to:
Verify that you control the private key for your
ACTIVE_ACCOUNTIssue a short-lived JSON Web Token (JWT) that the API will accept as proof of identity on subsequent calls
Below is an example script that obtains the access token:
What You Get
accessToken(JWT): A bearer token you must include on every HTTP request:Expiration: The token is valid until the
expclaim in its payload. SIWE messages themselves can also include a customexpirationTimeto limit replay window.
Lock & Fetch Fee Options
Before touching any on-chain collateral, you first ask the backend to compute and reserve your available instant-withdrawal policies for the exact amount you want. This call is purely off-chain—no transactions are sent, and no gas is spent—but it locks those policies for a short window (typically ~30 seconds) so you can finalize on-chain steps without worrying the fee or cooldown will change mid-flow.
HTTP Request
Query Parameters
account(string): your sub-account address (checksum)amount(integer): the withdrawal amount in token units (wei for 6-decimals USDC! e.g.1000000for 1 USDC)
Headers
Authorization: Bearer <accessToken>(from your SIWE login)
Body
Empty. (Axios will send
{}if you pass an empty object—no other fields required.)
Example Code
Sample Response
Picking your Policy
Of this set of options, you can pick the policy with the lowest cooldown like this:
Deallocating Funds
Before you can instantly withdraw, you must deallocate (i.e. free) the amount of collateral you previously allocated to trading. Symmio requires a uPNL signature from Muon to verify that you maintain sufficient margin for your currently open positions; this happens off-chain via a Muon oracle call.
Flow
Fetch a Muon signature that attests to your current
uPnl.Format that signature into the
SingleUpnlSigstruct the contract expects.ABI-encode the
deallocate(uint256 amount, SingleUpnlSig upnlSig)call.Wrap it in your multi-account proxy (
_call) so thatmsg.senderis your sub-account.Estimate gas (with a buffer) and send the transaction (paid by your EOA).
Sample Script
Implementation
Transfer to Bridge On-Chain
After freeing your collateral, the next on-chain step is to transfer that free balance into the Instant-Withdrawal bridge, bypassing any further cooldown. This creates a bridge transaction from which you will then select your fee policy.
Sample Script
When you call the wrapped _call(...).send(), the Symmio Diamond contract will emit a TransferToBridge event that includes your new transactionId. This is the ID you’ll need in the final step to select your fee policy.
Event signature
Fetching Pending Fee Policies
After your on-chain bridge transaction is mined, you can once again retrieve the exact fee/cooldown options that were locked earlier by your /fee-options call. These are exposed via a dedicated endpoint:
GET /v1/pending-fee-policy/{account}
Sample Script
Submit Fee Policy Selection
With your on‐chain bridge transaction done and your fastest policy chosen, the final step is to tell the backend “yes, I agree to pay this fee after this cooldown.” The server will validate your choice, call the on‐chain selectFeePolicyForBridge action, and schedule processWithdrawal(bridgeId) for you.
Implementation
Reference Implementation
This repository contains a python script showcasing the full flow for Instant Withdrawal.
Last updated
