getTrade

API wrapper function to get the best price and trade details for a given trading pair and amount
getTrade
sdk.getTrade({to: '', from: '', toAmount: 1, dex: 'ag'})

Value

Description

to

The token you want to receive (Output)

from

The token you want to send (Input)

toAmount

The amount of "to" token you want to receive

fromAmount

The amount of "from" token you want to receive

limitAmount

Slippage - The limit of "from" token to still execute the trade

discluded

Dex's to disclude from the aggregator. Eg discluded=bancor

dex

Specify a DEX instead of searching for the best price (Uniswap), ag (aggregator)

proxy (optional)

Address of the proxy contract

Example: Get the best price for 1 DAI with ETH:

sdk.getTrade({to: 'DAI', from: 'ETH', toAmount: 1, dex: 'ag'})

Example: Get the price from Bancor for 1 DAI with ETH:

sdk.getTrade({to: 'DAI', from: 'ETH', toAmount: 1, dex: 'ag'})

Response: order details containing the DEX, price, total cost, and encoded ABI to pass into the web3 browser to execute via sdk.tradeOrder()

Value

Description

data

Encoded ABI data to execute trade on smart contract function

to

Exchanges contract address

value

ETH amount being sent

metadata

gasPrice

Suggested gas price from strict exchanges like Bancor

source

dex

DEX containing the best price (eg Uniswap)

price

Price denoted in the "from" token (eg ETH)

totalCost

The total cost for the best price and amoun