Liquidators
Liquidators are participants that liquidate underfunded positions and earn a fee. LiquidatorTool is the relevant SDK component.
LiquidatorTool ⇐ WriteAccessHandler
WriteAccessHandler
Functions to liquidate traders. This class requires a private key and executes smart-contract interactions that require gas-payments.
Kind: global class
Extends: WriteAccessHandler
LiquidatorTool ⇐
WriteAccessHandler
new LiquidatorTool(config, signer)
.liquidateTrader(symbol, traderAddr, [liquidatorAddr], priceFeedData) ⇒
.isMaintenanceMarginSafe(symbol, traderAddr, indexPrices) ⇒
boolean
.countActivePerpAccounts(symbol) ⇒
number
.getActiveAccountsByChunks(symbol, from, to) ⇒
Array.<string>
.getAllActiveAccounts(symbol) ⇒
Array.<string>
new LiquidatorTool(config, signer)
Constructs a LiquidatorTool instance for a given configuration and private key.
Param | Type | Description |
---|---|---|
config |
| Configuration object, see PerpetualDataHandler. readSDKConfig. |
signer |
| Private key or ethers Signer of the account |
Example
liquidatorTool.liquidateTrader(symbol, traderAddr, [liquidatorAddr], priceFeedData) ⇒
Liquidate a trader.
Kind: instance method of LiquidatorTool
Returns:
Transaction object.
Param | Type | Description |
---|---|---|
symbol |
| Symbol of the form ETH-USD-MATIC. |
traderAddr |
| Address of the trader to be liquidated. |
[liquidatorAddr] |
| Address to be credited if the liquidation succeeds. |
priceFeedData |
| optional. VAA and timestamps for oracle. If not provided will query from REST API. Defaults to the wallet used to execute the liquidation. |
Example
liquidatorTool.isMaintenanceMarginSafe(symbol, traderAddr, indexPrices) ⇒ boolean
boolean
Check if the collateral of a trader is above the maintenance margin ("maintenance margin safe"). If not, the position can be liquidated.
Kind: instance method of LiquidatorTool
Returns: boolean
-
True if the trader is maintenance margin safe in the perpetual. False means that the trader's position can be liquidated.
Param | Type | Description |
---|---|---|
symbol |
| Symbol of the form ETH-USD-MATIC. |
traderAddr |
| Address of the trader whose position you want to assess. |
indexPrices |
| optional, index price S2/S3 for which we test |
Example
liquidatorTool.countActivePerpAccounts(symbol) ⇒ number
number
Total number of active accounts for this symbol, i.e. accounts with positions that are currently open.
Kind: instance method of LiquidatorTool
Returns: number
-
Number of active accounts.
Param | Type | Description |
---|---|---|
symbol |
| Symbol of the form ETH-USD-MATIC. |
Example
liquidatorTool.getActiveAccountsByChunks(symbol, from, to) ⇒ Array.<string>
Array.<string>
Get addresses of active accounts by chunks.
Kind: instance method of LiquidatorTool
Returns: Array.<string>
-
Array of addresses at locations 'from', 'from'+1 ,..., 'to'-1.
Param | Type | Description |
---|---|---|
symbol |
| Symbol of the form ETH-USD-MATIC. |
from |
| From which account we start counting (0-indexed). |
to |
| Until which account we count, non inclusive. |
Example
liquidatorTool.getAllActiveAccounts(symbol) ⇒ Array.<string>
Array.<string>
Addresses for all the active accounts in this perpetual symbol.
Kind: instance method of LiquidatorTool
Returns: Array.<string>
-
Array of addresses.
Param | Type | Description |
---|---|---|
symbol |
| Symbol of the form ETH-USD-MATIC. |
Example