DEX.AG
Search…
getTrade
API wrapper function to get trade details for a given trading pair and amount
getTrade
1
sdk.getTrade({to: '', from: '', toAmount: 1, dex: 'ag'})
Copied!
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:
1
sdk.getTrade({to: 'DAI', from: 'ETH', toAmount: 1, dex: 'ag'})
Copied!
Example: Get the price from Bancor for 1 DAI with ETH:
1
sdk.getTrade({to: 'DAI', from: 'ETH', toAmount: 1, dex: 'ag'})
Copied!
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
Max allowed gas price for exchanges with a gas price cap, e.g. Bancor. Note: This is NOT the suggested gas price, it's the maximum that the exchange in question will allow.
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
Last modified 1yr ago
Copy link