Class: Exchange
"Exchange".Exchange
The Exchange class contains all methods for making/taking orders, retrieving the orderbook and more.
#
Hierarchy- Exchange
#
Constructors#
constructor+ new Exchange(params
: { currencyNetwork: CurrencyNetwork ; event: Event ; payment: Payment ; provider: TLProvider ; transaction: Transaction ; user: User }): Exchange
Defined in src/Exchange.ts:51
#
Parameters:Name | Type |
---|---|
params | { currencyNetwork: CurrencyNetwork ; event: Event ; payment: Payment ; provider: TLProvider ; transaction: Transaction ; user: User } |
Returns: Exchange
#
Methods#
confirmâ–¸ confirm(rawTx
: RawTxObject): Promise<string>
Defined in src/Exchange.ts:421
Signs a raw transaction object as returned by prepCancelOrder
or prepFillOrder
and sends the signed transaction.
#
Parameters:Name | Type | Description |
---|---|---|
rawTx | RawTxObject | Raw transaction object. |
Returns: Promise<string>
#
getExAddressesâ–¸ getExAddresses(): Promise<string[]>
Defined in src/Exchange.ts:72
Returns all known exchange contract addresses.
Returns: Promise<string[]>
#
getLogsâ–¸ getLogs(exchangeAddress
: string, filter?
: EventFilterOptions): Promise<AnyExchangeEvent[]>
Defined in src/Exchange.ts:432
Returns event logs of the Exchange contract for the loaded user.
#
Parameters:Name | Type | Default value | Description |
---|---|---|---|
exchangeAddress | string | - | Address of Exchange contract. |
filter | EventFilterOptions | {} | Event filter object. See EventFilterOptions for more information. |
Returns: Promise<AnyExchangeEvent[]>
#
getOrderByHashâ–¸ getOrderByHash(orderHash
: string, options?
: OrderOptions): Promise<SignedOrder>
Defined in src/Exchange.ts:85
Returns a specific order by its hash.
#
Parameters:Name | Type | Default value | Description |
---|---|---|---|
orderHash | string | - | keccak-256 hash of order. |
options | OrderOptions | {} | See OrderOptions for more details. |
Returns: Promise<SignedOrder>
#
getOrderbookâ–¸ getOrderbook(baseTokenAddress
: string, quoteTokenAddress
: string, options?
: OrderbookOptions): Promise<Orderbook>
Defined in src/Exchange.ts:155
Returns the orderbook for a given token pair.
#
Parameters:Name | Type | Default value | Description |
---|---|---|---|
baseTokenAddress | string | - | Address of base token. |
quoteTokenAddress | string | - | Address of quote token. |
options | OrderbookOptions | {} | See OrderbookOptions for more details. |
Returns: Promise<Orderbook>
#
getOrdersâ–¸ getOrders(query?
: OrdersQuery): Promise<SignedOrder[]>
Defined in src/Exchange.ts:118
Returns orders that match given query parameters.
#
Parameters:Name | Type | Default value | Description |
---|---|---|---|
query | OrdersQuery | {} | See OrdersQuery for more information. |
Returns: Promise<SignedOrder[]>
#
makeOrderâ–¸ makeOrder(exchangeContractAddress
: string, makerTokenAddress
: string, takerTokenAddress
: string, makerTokenValue
: number | string, takerTokenValue
: number | string, options?
: ExchangeOptions): Promise<SignedOrder>
Defined in src/Exchange.ts:196
Creates an order and posts it to the relay server. If successful, the method returns the created order.
#
Parameters:Name | Type | Default value | Description |
---|---|---|---|
exchangeContractAddress | string | - | Address of exchange contract. |
makerTokenAddress | string | - | Address of token the maker (loaded user) is offering. |
takerTokenAddress | string | - | Address of token the maker (loaded user) is requesting from the taker. |
makerTokenValue | number | string | - | Amount of token the maker (loaded user) is offering. |
takerTokenValue | number | string | - | Amount of token the maker (loaded user) is requesting from the taker. |
options | ExchangeOptions | {} | See ExchangeOptions for more information. |
Returns: Promise<SignedOrder>
#
prepCancelOrderâ–¸ prepCancelOrder(signedOrder
: SignedOrder, cancelTakerTokenValue
: number | string, options?
: ExchangeTxOptions): Promise<TxObject>
Defined in src/Exchange.ts:379
Prepares an ethereum transaction for cancelling an order.
#
Parameters:Name | Type | Default value | Description |
---|---|---|---|
signedOrder | SignedOrder | - | The order to cancel as returned by getOrderbook , getOrders or getOrderByHash . |
cancelTakerTokenValue | number | string | - | Amount of tokens the maker (loaded user) wants to cancel. |
options | ExchangeTxOptions | {} | See ExchangeTxOptions for more information. |
Returns: Promise<TxObject>
#
prepTakeOrderâ–¸ prepTakeOrder(signedOrder
: SignedOrder, fillTakerTokenValue
: number | string, options?
: ExchangeTxOptions): Promise<ExchangeTx>
Defined in src/Exchange.ts:269
Prepares an ethereum transaction object for taking an order.
#
Parameters:Name | Type | Default value | Description |
---|---|---|---|
signedOrder | SignedOrder | - | The order to take as returned by getOrderbook , getOrders or getOrderByHash . |
fillTakerTokenValue | number | string | - | Amount of tokens the taker (loaded user) wants to fill. |
options | ExchangeTxOptions | {} | See ExchangeTxOptions for more information. |
Returns: Promise<ExchangeTx>