Optional
defaultSubmit an order to the specified market. Keepers will attempt to fill the order
according to the settlement strategy. If desired_fill_price
is provided, the order
will be filled at that price or better. If max_price_impact
is provided, the
desired_fill_price
is calculated from the current market price and the price impact.
The size of the order to submit
The id of the settlement strategy to use
The id of the market to submit the order to. If not provided, marketName
must be provided
The name of the market to submit the order to. If not provided, marketId
must be provided.
The id of the account to submit the order for. Defaults to defaultAccountId
.
The max price for longs and minimum price for shorts. If not provided, one will be calculated based on maxPriceImpact
The maximum price impact to allow when filling the order as a percentage (1.0 = 1%). If not provided, it will inherit the default value from snx.max_price_impact
If true
, submit the transaction to the blockchain
Create a perps account. An account NFT is minted to the sender, who owns the account.
Id of the account. If not passed, default Perps account ID is used
Executes the transaction if true
Transaction hash or transaction data
Optional
marketId: numberOptional
marketName: stringOptional
accountId: bigintOptional
desiredFillPrice: numberOptional
maxPriceImpact: numberFetch a list of perps account_id
owned by an address. Perps accounts
are minted as an NFT to the owner's address. The account_id
is the
token id of the NFTs held by the address.
The address to get accounts for. Uses connected address if not provided.
The default account ID to set after fetching.
A list of account IDs owned by the address
Fetch information about an account's margin requirements and balances.
Accounts must maintain an available_margin
above the maintenance_margin_requirement
to avoid liquidation. Accounts with available_margin
below the initial_margin_requirement
can not interact with their position unless they deposit more collateral.
The id of the account to fetch the margin info for. If not provided, the default account is used
Fetch the ids and summaries for all perps markets. Market summaries include information about the market's price, open interest, funding rate, and skew
Fetch the market summary for a single market, including information about
the market's price, open interest, funding rate, and skew.
Provide either the marketId
or marketName
.
Market id to fetch the summary
Name of the market to fetch summary
Summary of market data fetched from the contract
Fetch the position for a specified account and market. The result includes the unrealized
pnl since the last interaction with this position, any accrued funding, and the position size.
Provide either a marketId
or a marketName
::
The id of the market to fetch the position for.
The name of the market to fetch the position for.
The id of the account to fetch the position for. If not provided, the default account is used.
Fetch positions for an array of specified markets. The result includes the unrealized
pnl since the last interaction with this position, any accrued funding, and the position size.
Provide either an array of marketIds
or a marketNames
::
Array of market ids to fetch the position for.
Array of market names to fetch the position for.
The id of the account to fetch the position for. If not provided, the default account is used.
Fetches the open order for an account. Optionally fetches the settlement strategy, which can be useful for order settlement and debugging.
The id of the account. If not provided, the default account is used
Flag to indicate whether to fetch the settlement strategy
Get a quote for the size of an order in a specified market. The quote includes the provided price
and the fill price of the order after price impact. If a price is not provided, a price will be fetched
from Pyth. Provide either a marketId
or marketName
.
The size of the order to quote.
Optional
price: numberThe price to quote the order at. If not provided, the current market price is used
The id of the market to quote the order for
The name of the market to quote the order for
The id of the account to quote the order for. If not provided, the default account is used
The id of the settlement strategy to use for the settlement reward calculation
If true
, include the required margin for the account in the quote.
Fetch the settlement strategies for an array of market ids. Settlement strategies describe the conditions under which an order can be settled.
Array of marketIds to fetch settlement strategy
Settlement strategy array for markets
Fetch the settlement strategy for a market. Settlement strategies describe the
conditions under which an order can be settled.
Provide either a marketId
or marketName
Id of the market to get settlement strategy
Name of the market to get settlement strategy
Settlement strategy for market
Submit a liquidation for an account, or static call the liquidation function to fetch
the liquidation reward. The static call is important for accounts which have been
partially liquidated. Due to the throughput limit on liquidated value, the static call
returning a nonzero value means more value can be liquidated (and rewards collected).
This function can not be called if submit
and staticCall
are true.
The id of the account to liquidate. If not provided, the default account is used.
If true
, submit the transaction to the blockchain.
If true
, static call the liquidation function to fetch the liquidation reward.
Move collateral in or out of a specified perps account. The market_id
or market_name
must be provided to specify the collateral type.
Provide either a market_id
or a market_name
. Note that the market_id
here refers
to the spot market id, not the perps market id. Make sure to approve the market proxy to transfer
tokens of the collateral type before calling this function.
The amount of collateral to move. Positive values deposit collateral, negative values withdraw collateral
The id of the market to move collateral for
The name of the market to move collateral for.
The id of the account to move collateral for. If not provided, the default account is used.
If True
, submit the transaction to the blockchain.
Pay the debt of a perps account. If no amount is provided, the full debt of the account is repaid. Make sure to approve the proxy to transfer sUSD before calling this function.
The amount of debt to repay. If not provided, the full debt is repaid.
The id of the account to repay the debt for. If not provided, the default account is used.
If true
, submit the transaction to the blockchain. If not provided, transaction object is returned
Prepare a call to the external node with oracle updates for the specified market names. The result can be passed as the first argument to a multicall function to improve performance of ERC-7412 calls. If no market names are provided, all markets are fetched. This is useful for read functions since the user does not pay gas for those oracle calls, and reduces RPC calls and runtime.
An array of market ids to fetch prices for. If not provided, all markets are fetched
Look up the market_id and market_name for a market. If only one is provided, the other is resolved. If both are provided, they are checked for consistency.
Id of the market to resolve
Name of the market to resolve
Settles an order using ERC7412 by handling OracleDataRequired
errors and forming a multicall.
If the order is not yet ready to be settled, this function will wait until the settlement time.
If the transaction fails, this function will retry until the max number of tries is reached with a
configurable delay.
The id of the account to settle. If not provided, the default account is used.
If true
, submit the transaction to the blockchain.
The max number of tries to submit the transaction
The delay in seconds between transaction submissions.
Class for interacting with Synthetix Perps V3 contracts Provides methods for creating and managing accounts, depositing and withdrawing collateral, committing and settling orders, and liquidating accounts.
Use
get
methods to fetch information about accounts, markets, and orders:: const markets = await sdk.perps.getMarkets() const openPositions = await sdk.perps.getOpenPositions() Other methods prepare transactions, and submit them to your RPC:: const createTxHash = await sdk.perps.createAccount(submit=True) const collateralTxHash = await sdk.perps.modifyCollateral(amount=1000, market_name='sUSD', submit=True) const orderTxHash = await sdk.perps.commitOrder(size=10, market_name='ETH', desired_fill_price=2000, submit=True) An instance of this module is available assdk.perps
. If you are using a network without perps deployed, the contracts will be unavailable and the methods will raise an error. The following contracts are required:Param: synthetixSdk
An instance of the Synthetix class