The DEX.AG SDK provides the following functions:
getPrice - get prices for a given to, from, amount
getTrade - get trade details for a given to, from, amount
trade - execute a trade
validate - walk the client through the checkout process
balance check
token allowance
wrapping ETH (Radar Relay)
tracking the tx getting mined
registerStatusHandler - receive status callbacks as the order is executed
Install from NPM
$ npm install dexag-sdk
Example: Buy 1 DAI with ETH
import DEXAG from 'dexag-sdk';const sdk = DEXAG.fromProvider(window.ethereum);// receive status messages as the client executes the tradesdk.registerStatusHandler((status, data)=>{console.log(status, data)});// get priceconst tx = await sdk.getPrice({to: 'DAI', from: 'ETH', toAmount: 1, dex: 'ag'});// get tradeconst tx = await sdk.getTrade({to: 'DAI', from: 'ETH', toAmount: 1, dex: 'ag'});// checkoutconst valid = await sdk.validate(tx);if (valid) {// transaction data is valid, make a tradesdk.trade(tx);}