Get the best price, execute trades, and validate the clients web3 browser in javascript

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 trade
sdk.registerStatusHandler((status, data)=>{
console.log(status, data)
// get price
const tx = await sdk.getPrice({to: 'DAI', from: 'ETH', toAmount: 1, dex: 'ag'});
// get trade
const tx = await sdk.getTrade({to: 'DAI', from: 'ETH', toAmount: 1, dex: 'ag'});
// checkout
const valid = await sdk.validate(tx);
if (valid) {
// transaction data is valid, make a trade;