Version: 0.13.7

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:#

NameType
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:#

NameTypeDescription
rawTxRawTxObjectRaw 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:#

NameTypeDefault valueDescription
exchangeAddressstring-Address of Exchange contract.
filterEventFilterOptions{}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:#

NameTypeDefault valueDescription
orderHashstring-keccak-256 hash of order.
optionsOrderOptions{}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:#

NameTypeDefault valueDescription
baseTokenAddressstring-Address of base token.
quoteTokenAddressstring-Address of quote token.
optionsOrderbookOptions{}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:#

NameTypeDefault valueDescription
queryOrdersQuery{}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:#

NameTypeDefault valueDescription
exchangeContractAddressstring-Address of exchange contract.
makerTokenAddressstring-Address of token the maker (loaded user) is offering.
takerTokenAddressstring-Address of token the maker (loaded user) is requesting from the taker.
makerTokenValuenumber | string-Amount of token the maker (loaded user) is offering.
takerTokenValuenumber | string-Amount of token the maker (loaded user) is requesting from the taker.
optionsExchangeOptions{}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:#

NameTypeDefault valueDescription
signedOrderSignedOrder-The order to cancel as returned by getOrderbook, getOrders or getOrderByHash.
cancelTakerTokenValuenumber | string-Amount of tokens the maker (loaded user) wants to cancel.
optionsExchangeTxOptions{}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:#

NameTypeDefault valueDescription
signedOrderSignedOrder-The order to take as returned by getOrderbook, getOrders or getOrderByHash.
fillTakerTokenValuenumber | string-Amount of tokens the taker (loaded user) wants to fill.
optionsExchangeTxOptions{}See ExchangeTxOptions for more information.

Returns: Promise<ExchangeTx>