Optional
defaultApprove an address to transfer a specified synth from the connected address.
Approves the targetAddress
to transfer up to the amount
from your account.
If amount
is undefined
, approves the maximum possible amount.
Requires either a marketId
or marketName
to be provided to resolve the market.
The address to approve.
Optional
amount: numberThe amount in ether to approve. Default is max uint256.
Optional
marketId: numberThe ID of the market.
Optional
marketName: stringThe name of the market.
Whether to broadcast the transaction.
Execute an atomic order on the spot market.
Atomically executes a buy or sell order for the given size.
Amounts are transferred directly, no need to settle later. This function
is useful for swapping sUSDC with sUSD on Base Andromeda contracts. The default
slippage is set to zero, since sUSDC and sUSD can be swapped 1:1
For example:
const tx = await atomicOrder(Side.BUY, 100, 0, undefined, undefined, "sUSDC");
Requires either a market_id
or market_name
to be provided to resolve the market.
The side of the order (buy/sell).
The order size in ether.
The slippage tolerance for the order as a percentage (0.01 = 1%). Default is 0.
Optional
minAmountReceived: numberThe minimum amount to receive in ether units. This will override the slippage_tolerance.
Optional
marketId: numberThe ID of the market.
Optional
marketName: stringThe name of the market.
Whether to broadcast the transaction.
Commit an async order to the spot market.
Commits a buy or sell order of the given size. The order will be settled
according to the settlement strategy.
Requires either a marketId
or marketName
to be provided to resolve the market.
The side of the order (buy/sell).
The order size in ether. If side
is "buy", this is the amount
of the synth to buy. If side
is "sell", this is the amount of the synth to sell.
The slippage tolerance for the order as a percentage (0.01 = 1%). Default is 0.
Optional
minAmountReceived: numberThe minimum amount to receive in ether units. This will override the slippage_tolerance.
The settlement strategy ID. Default 2.
Optional
marketId: numberThe ID of the market.
Optional
marketName: stringThe name of the market.
Whether to broadcast the transaction.
Format the size of a synth for an order. This is used for synths whose base asset does not use 18 decimals. For example, USDC uses 6 decimals, so we need to handle size differently from other assets.
The size as an ether value (e.g. 100).
The id of the market.
The formatted size in wei. (e.g. 100 = 100000000000000000000)
Get the allowance for a target_address
to transfer from address
. Provide either
a marketId
or marketName
to choose the synth.
The address for which to check allowance.
Optional
address: stringThe owner address to check allowance for.
Optional
marketId: numberThe id of the market.
Optional
marketName: stringThe name of the market.
The allowance in ether.
Get the balance of a spot synth. Provide either a marketId
or marketName
to choose the synth.
Optional
address: stringThe address to check the balance of. If not provided, the current account will be used.
Optional
marketId: numberThe id of the market.
Optional
marketName: stringThe name of the market.
The balance of the synth in ether.
Fetches contracts and metadata about all spot markets on the network. This includes
the market id, synth name, contract address, and the underlying synth contract. Each
synth is an ERC20 token, so these contracts can be used for transfers and allowances.
The metadata is also used to simplify interactions in the SDK by mapping market ids
and names to their metadata
For example:
sdk.spot.wrap(100, market_name='sUSDC', submit=True)
This will look up the market id for the sUSDC market and use that to wrap 100 USDC into sUSDC.
The market metadata is returned from the method as a mapping object of two dictionaries/records.
The first is keyed by marketsById
and the second is keyed by marketsByName
For example: sdk.spot.marketsByName
Response: {
'sUSD' => {
marketId: 0,
marketName: 'sUSD',
contractAddress: '0x682f0d17feDC62b2a0B91f8992243Bf44cAfeaaE'
},
Example: sdk.spot.marketsById Response: { 0 => { marketId: 0, marketName: 'sUSD', contractAddress: '0x682f0d17feDC62b2a0B91f8992243Bf44cAfeaaE' },...
Get details about an async order by its ID.
Retrieves order details like owner, amount escrowed, settlement strategy, etc.
Can also fetch the full settlement strategy parameters if fetchSettlementStrategy
is true
.
Requires either a market_id
or market_name
to be provided to resolve the market.
The ID of the async order to retrieve.
Optional
marketId: numberThe ID of the market.
Optional
marketName: stringThe name of the market.
Whether to fetch the full settlement strategy parameters. Default is true.
The order details.
Fetch the settlement strategies for all spot markets.
The id of the settlement strategy to retrieve.
Array of marketIds to fetch settlement strategy
Settlement strategy array for markets
Fetch the settlement strategy for a spot market.
The id of the settlement strategy to retrieve.
The id of the market.
The name of the market.
Fetch the underlying synth contract for a market. Synths are represented as an ERC20 token,
so this is useful to do things like check allowances or transfer tokens.
This method requires a marketId
or marketName
to be provided.
Optional
marketId: numberThe id of the market.
Optional
marketName: stringThe name of the market
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
Settle an async Pyth order after price data is available.
Fetches the price for the order from Pyth and settles the order.
Retries up to maxTxTries
times on failure with a delay of txDelay
seconds.
Requires either a marketId
or marketName
to be provided to resolve the market.
The ID of the async order to settle.
Optional
marketId: numberThe ID of the market
Optional
marketName: stringThe name of the market.
Max retry attempts if price fetch fails.
Seconds to wait between retries.
Whether to broadcast the transaction.
Wrap an underlying asset into a synth or unwrap back to the asset.
Wraps an asset into a synth if size > 0, unwraps if size < 0.
The default slippage is set to zero, since the synth and asset can be swapped 1:1.
For example:
const tx = wrap(100, undefined, "sUSDC") # wrap 100 USDC into sUSDC
const tx = wrap(-100, undefined, "sUSDC") # unwrap 100 sUSDC into USDC
Requires either a market_id
or market_name
to be provided to resolve the market.
The amount of the asset to wrap/unwrap.
Optional
marketId: numberThe ID of the market.
Optional
marketName: stringThe name of the market.
Whether to broadcast the transaction.
Class for interacting with Synthetix V3 spot market contracts. Provider methods for wrapping and unwrapping assets, approvals, atomic orders, and async orders. Use
get
methods to fetch information about balances, allowances, and markets const { marketsById, marketsByName } = await sdk.perps.getMarkets();Other methods prepare transactions, and submit them to your RPC. An instance of this module is available as
sdk.spot
. If you are using a network without spot contracts deployed, the contracts will be unavailable and the methods will raise an error. The following contracts are required: