Create an Omniston instance, specifying the API URL.
The constructor takes the following parameters:
client
ApiClient | undefined
Optional. Provide this if you want to override the default API client. By default, this will be an ApiClient
using ReconnectingTransport
apiUrl
URL | string
Omniston WebSocket API URL.
Send a request for quote to swap an asset to another asset.
A QuoteRequest
has the following properties:
settlementMethods
SettlementMethod[]
Supported methods of swap settlement
askAssetAddress
Address
Blockchain-specific address of ask asset
offerAssetAddress
Address
Blockchain-specific address of offer asset
amount
{ offerUnits: string } | { askUnits: string }
Either the amount of offer asset or ask asset
amount.offerUnits
string
The amount of offer asset the trader wants to pay, including all fees, in base asset units
amount.askUnits
string
The amount of ask asset the trader wants to get after all fees, in base asset units
referrerAddress
Address | undefined
The address of referrer that will receive the fees
referrerFeeBps
number | undefined
The amount of fees required by the referrer in basis points (1/10000 or 0.01%)
settlementParams
RequestSettlementParams | undefined
Additional parameters of RFQ related to settlement. See the table below.
RequestSettlementParams
Note: Some parameters in RequestSettlementParams
may only be relevant for certain blockchains or certain settlement methods. If your settlement method or wallet does not require them, you can omit them or set them to default values.
The server returns Observable<QuoteResponseEvent>
, which is a stream of quote updates.
A QuoteResponseEvent
might be one of the following:
{ type: "quoteUpdated"; quote: Quote; }
{ type: "noQuote"; }
{ type: "unsubscribed"; }
A Quote
has the following properties:
Now that we have a quote, we should request a server to build a transaction to initiate the trade that the user can verify and sign.
The buildTransfer
method takes a TransactionRequest
object as a parameter, having the following properties:
After the user has signed and initiated the transaction, we can track the trade status.
The trackTrade
method has the following parameters:
It returns Observable<TrackTradeStatus>
. For the different trade status values, see the source code. We are interested in the trade result enum which can be read from status.tradeSettled?.result?
field. The enum has the following values: