'use strict';
const request = require('superagent');
run()
.then(() => console.log('done'))
.catch(err => console.error(err))
.then(() => process.exit(0));
async function run() {
let response = await request.get('https://api.simpleswap.io/get_all_currencies');
let currencies = response.body;
console.log(`total ${currencies.length} currencies\n`);
let promises = currencies.map(async (from, i) => {
try {
console.log(`[${i + 1}/${currencies.length}] ${from.symbol}:`);
let min = await request.get(`https://api.simpleswap.io/get_min?currency_from=${from.symbol}¤cy_to=btc`);
console.log(`[${i + 1}/${currencies.length}] ${from.symbol}\t\tmin: ${min.body}`);
let estimated = await request.get(`https://api.simpleswap.io/get_estimated?currency_from=${from.symbol}¤cy_to=btc&amount=${min}`);
console.log(`[${i + 1}/${currencies.length}] ${from.symbol}\t\testimated (->btc): ${estimated.body}`);
} catch (err) {
console.error('catched', err);
}
});
await Promise.all(promises);
}