Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"changellyApiKey": "xxx",
"changenowApiKey": "xxx",
"changellyApiSecret": "xxx",
"exolixApiKey" : "xxx",
"faastAffiliateId": "xxx",
"faastSecret": "xxx",
"totleApiKey": "xxx",
Expand Down
83 changes: 83 additions & 0 deletions src/exolix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// @flow
import type { StandardTx, SwapFuncParams } from './checkSwapService.js'
const js = require('jsonfile')
const fetch = require('node-fetch')
const confFileName = './config.json'
const config = js.readFileSync(confFileName)
const { checkSwapService } = require('./checkSwapService.js')

const EXOLIX_CACHE = './cache/exRaw.json'

const PER_PAGE = 100

async function doExolix (swapFuncParams: SwapFuncParams) {
return checkSwapService(fetchExolix,
EXOLIX_CACHE,
'EX',
swapFuncParams
)
}

async function fetchExolix (swapFuncParams: SwapFuncParams) {
if (!swapFuncParams.useCache) {
console.log('Fetching Exolix...')
}
let diskCache = { txs: [] }
try {
diskCache = js.readFileSync(EXOLIX_CACHE)
} catch (e) {}
let page = diskCache.page ? diskCache.page : 1

const ssFormatTxs: Array<StandardTx> = []

while (1 && !swapFuncParams.useCache) {
const response = await fetch(
`https://exolix.com/api/history?page=${page}&per_page=${PER_PAGE}`,
{
Authorization: config.exolixApiKey
}
)
const result = await response.json()

const txs = result.data

if (!txs.length) {
return {}
}

for (const tx of txs) {
if (tx.status === 'success') {
const ssTx: StandardTx = {
status: 'complete',
inputTXID: tx.input_hash,
inputAddress: tx.deposit_address,
inputCurrency: tx.coin_from.toUpperCase(),
inputAmount: tx.amount_from,
outputAddress: tx.destination_address,
outputCurrency: tx.coin_to.toUpperCase(),
outputAmount: tx.amount_to,
timestamp: tx.created_at
}
ssFormatTxs.push(ssTx)
}
}

if (result.total < PER_PAGE) {
break
}

page++

if (result.last_page < page) {
break
}
}

const out = {
diskCache,
newTransactions: ssFormatTxs
}
return out
}

module.exports = { doExolix }
15 changes: 15 additions & 0 deletions src/reporter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import type { SwapFuncParams, TxDataMap } from './checkSwapService.js'
const { doExolix } = require('./exolix.js')
const { doShapeShift } = require('./shapeshift.js')
const { doChangelly } = require('./changelly.js')
const { doLibertyX } = require('./libertyx.js')
Expand All @@ -25,6 +26,10 @@ const config = require('../config.json')
const { sprintf } = require('sprintf-js')

async function main (swapFuncParams: SwapFuncParams) {
const rEx = await doExolix(swapFuncParams).catch(e => {
console.error('doExolix failed')
return {}
})
const rChn = await doChangenow(swapFuncParams).catch(e => {
console.error('doChangenow failed')
return {}
Expand Down Expand Up @@ -112,6 +117,7 @@ async function main (swapFuncParams: SwapFuncParams) {
return {}
})

printTxDataMap('EX', rEx)
printTxDataMap('CHN', rChn)
printTxDataMap('CHA', rCha)
printTxDataMap('FAA', rFaa)
Expand Down Expand Up @@ -265,6 +271,9 @@ async function report (argv: Array<any>) {
const fiatResults: { [string]: TxDataMap } = {}

// swaps (crypto-to-crypto)
const exResults = config.exolixApiKey
? await doSummaryFunction(doExolix)
: {}
const cnResults = config.changenowApiKey
? await doSummaryFunction(doChangenow)
: {}
Expand Down Expand Up @@ -325,6 +334,7 @@ async function report (argv: Array<any>) {
const banResults = await doSummaryFunction(doBanxa)
const bityResults = await doSummaryFunction(doBity)

combineResults(results, exResults)
combineResults(results, cnResults)
combineResults(results, chResults)
combineResults(results, faResults)
Expand All @@ -335,6 +345,11 @@ async function report (argv: Array<any>) {
combineResults(results, gxResults)
combineResults(results, swResults)

console.log('\n***** Exolix Daily *****')
printTxDataMap('EX', exResults.daily)
console.log('\n***** Exolix monthly *****')
printTxDataMap('EX', exResults.monthly)

console.log('\n***** Change NOW Daily *****')
printTxDataMap('CHN', cnResults.daily)
console.log('\n***** Change NOW monthly *****')
Expand Down