Liquidate Subaccount
Submits a transaction to liquidate a subaccount's balance for a specified liquidation amount.
Rate limits
30 liquidations/min or 5 liquidations every 10 seconds per wallet. (weight=20)
See more details in API Rate limits.
Request
Request Parameters
tx
object
Yes
tx.sender
string
Yes
Hex string representing the subaccount's 32 bytes (address + subaccount name) of the tx sender.
tx.liquidatee
string
Yes
Hex string representing the subaccount's 32 bytes (address + subaccount name) of the subaccount being liquidated.
tx.productId
number
Yes
Perp Liquidation:
A valid perp product Id.
Spot Liquidation:
A valid spot product Id.
Spread Liquidation:
tx.isEncodedSpread
bool
Yes
When set to true
, the productId
is expected to encode a perp and spot product Ids as follows: (perp_id << 16) | spot_id
tx.amount
string
Yes
The amount to liquidate multiplied by 1e18, sent as a string.
tx.nonce
string
Yes
signature
string
Yes
Signing
See more details and examples in our signing page.
The solidity typed data struct that needs to be signed is:
sender
: a bytes32
sent as a hex string; includes the address and the subaccount identifier.
liquidatee
: a bytes32
sent as a hex string; includes the address and the subaccount identifier.
productId
: The product to liquidate as well as the liquidation mode.
Perp liquidation โ A valid
perp
product id is provided andisEncodedSpread
is set tofalse
.Spot liquidation โ A valid
spot
product id is provided andisEncodedSpread
is set tofalse
Spread Liquidation => If there are perp and spot positions in different directions, liquidate both at the same time. Must be set to a 32 bits integer where the lower 16 bits represent the
spot
product and the higher 16 bits represent theperp
product.isEncodedSpread
must be set totrue
.
Computing productId for Spread Liquidation
isEncodedSpread
: indicates whether productId
encodes both a spot
and a perp
product Id for spread liquidation.
amount
: the amount to liquidate multiplied by 1e18, sent as a string. Can be positive or negative, depending on if the userโs balance is positive or negative.
nonce
: the tx_nonce
. This is an incrementing nonce, can be obtained using the Nonces query.
Note: for signing you should always use the data type specified in the solidity struct which might be different from the type sent in the request e.g: nonce
should be an uint64
for Signing but should be sent as a string
in the final payload.
Response
Success
Failure
Last updated