Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
paullinator committed Sep 4, 2024
1 parent 762fda8 commit 8987f89
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/bin/lifiReporter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { asArray, asObject, asString } from 'cleaners'
import fetch from 'node-fetch'

const asIntegrators = asObject({
feeBalances: asArray(
asObject({
tokenBalances: asArray(
asObject({
amountUsd: asString,
token: asObject({
name: asString,
symbol: asString
})
})
)
})
)
})

const main = async (): Promise<void> => {
const response = await fetch('https://li.quest/v1/integrators/edgeapp')
if (!response.ok) {
const text = await response.text()
throw new Error(text)
}

const result = await response.json()
const integrators = asIntegrators(result)
let balUsd = 0
console.log(JSON.stringify(integrators, null, 2))
integrators.feeBalances.forEach(fb => {
fb.tokenBalances.forEach(tb => {
balUsd += Number(tb.amountUsd)
console.log(`${tb.token.name} (${tb.token.symbol}): $${tb.amountUsd}`)
})
})
console.log(`Total: $${balUsd}`)
}

main().catch(e => console.log(e))

0 comments on commit 8987f89

Please sign in to comment.