DEX Class
Constructor
Instances of DEX
cannot be constructed manually. They are only accessible as a return value of SDK.init()
. Each instance of the DEX class represents a connection to a particular instance of the Portal DEX network for a particular user.
The DEX instance returned by SDK.init()
contains no assets. Before any trades are executed on that instance, assets must be transferred into it using DEX.xfer()
.
Instance Properties
Returns the assets and their quantities currently available. The elements of the Array are Objects with format: { asset: String, qty: Number }
.
Instance Methods
Transfers one or more assets into the receiver from the specified source. Instances of DEX initially contain no assets and this method must be called before any trades are executed.
Argument | Type and Semantics |
---|---|
| Object. Specifies the source of the assets and the parameters necessary for transferring them. Format depends on the source. |
| Array. Specifies quantities of assets to transfer. The elements of the Array are Objects with format: |
DEX.xfer
()
returns an Array whose elements are Objects with format:
Performs a swap of the specified assets under the specified conditions. Returns an instance of the Trade class. Will throw an exception if there are any errors in the arguments - thus it is advisable to call this function in a try/catch block.
Argument | Type and semantics |
---|---|
| String (case sensitive). A user-defined identifier of this trade. Stored in the instance and returned on every method call to that instance. |
| String (case insensitive). One of: "limit" or "market". |
goals | Object. |
| String (case insensitive). One of: "BTC" or "ETH". |
| Number |
| Object. Format is dependent on the values of |
Close the connection to receiver. Returns true
if successful else false
.
Returns the instance of Trade with the specified order_id
or undefined
if no trade with that order_id
was executed on the receiver.
Last updated