If you are unable to close your position for any reason, you can close it via contract interaction. It is highly recommended to practice this method before trading in size, in order to have it as a backup trading method.
Note: You will need xDAI to pay for the transaction.
Go to the Perpetual Protocol clearinghouse contract on Blockscout (verify the address in the metadata json linked in step 1)
Go to the Write Proxy tab
3. closePosition enter the AMM address from step 1
_quoteAssetAmountLimit - this limits the amount of slippage you will accept. In a severe emergency, consider entering 0 (allow 100% slippage).
Take the USDC value of your margin and multiply by
1 - % of slippage. E.g. to allow up to 0.5% slippage with $1000 worth of margin,
1000 * (1-0.5) = 995.
Multiply the result by 10^18. E.g.
995 * 10^18 = 995000000000000000000
Enter this amount for
Write to the contract to close the position.
Choose an 'emergency' level gas price - you can see gas prices for recent successful transactions by clicking transaction times shown in the history on perp.exchange. Alternatively, enter a very high number keeping in mind that on xDai, 1000 gwei is $1.00, 2500 gwei is $2.50, etc.
Set a leaner gas limit - the default is 3.8m which is very conservative (ie. very high). Nodes may process this later, favoring smaller transactions. Try lower gas limits, e.g. 2m, 1.5m, etc.
Also practice with
_side refers to short (0) and long (1), and
_baseAssetAmountLimit is the minimum position size (to control slippage - value must be multiplied by 10^18).