Interacting with Markets

Market Class Properties

A Market exposes all the following instance properties:

{
id: string;
displayName: string;
baseTokenAddress: string;
quoteTokenAddress: string;
baseTokenDecimals: number;
quoteTokenDecimals: number;
minOrderSize: BigNumber;
maxOrderSize: BigNumber;
quoteIncrement: number;
score: number; // A measure of how active the market is.
}

limitOrderAsync(type, quantity, price, expiration)

Place a limit order.

Parameters:

Name

Type

Description

type

UserOrderType

Order type of 'BUY'

quantity

BigNumber

Amount in base token

price

BigNumber

Price in quote

expiration

BigNumber

Order expiration time in seconds

Returns: Promise<Order>

marketOrderAsync(type, amount, opts?)

Execute a market order.

Parameters:

Name

Type

Description

type

UserOrderType

Order type of 'BUY'

amount

BigNumber

Amount in base token

opts

Opts

[Optional] The transaction options

Returns: Promise<TransactionReceiptWithDecodedLogs | string>

cancelOrderAsync(order, opts?)

Cancel an order.

Parameters:

Name

Type

Description

order

SignedOrder

SignedOrder to cancel

opts

Opts

[Optional] The transaction options

Returns: Promise<TransactionReceiptWithDecodedLogs | string>

getFillsAsync()

Get fills for this market.

No parameters.

Returns: Promise<RadarFill[]>

getCandlesAsync()

Get candles for this market.

No parameters.

Returns: Promise<RadarCandle[]>

getTickerAsync()

Get ticker for this market.

No parameters.

Returns: Promise<RadarTicker>

getHistoryAsync()

Get history for this market.

No parameters.

Returns: Promise<RadarHistory>

getStatsAsync()

Get stats for this market.

No parameters.

Returns: Promise<RadarStats>

subscribeAsync(topic, handlerFunc)

Parameters:

Name

Type

Description

topic

WebsocketRequestTopic

The market topic

handlerFunc

(message: any) => void

The subscription handler

Returns:

Promise<{
requestId: number,
subscriptionHandler: (message: any) => void,
unsubscribe: () => void
}>

You can unsubscribe from any previously created subscriptions like so:

subscription.unsubscribe();