mirror of
https://github.com/alexgo-io/DefiLlama-Adapters.git
synced 2026-04-28 21:05:32 +08:00
* algodex adapter file created * comments added * work in progress * comments added * tvl function completed * price=0 for asset not found on tinyman * modifications * test * tvl function call removed * Update tvl function * Remove unnecessary call * Update TVL endpoint Co-authored-by: Imran Zahoor <imran-zahoor@outlook.com> Co-authored-by: Imran <sp18-rcs-007@cuilahore.edu.pk>
30 lines
869 B
JavaScript
30 lines
869 B
JavaScript
const { fetchURL } = require('./helper/utils')
|
|
const { toUSDTBalances } = require('./helper/balances')
|
|
|
|
const usdPriceUrl = "https://mainnet.analytics.tinyman.org/api/v1/current-asset-prices/"
|
|
const assetTVLURL = "https://app.algodex.com/api/v2/orders/tvl"
|
|
|
|
async function fetch() {
|
|
const tvlData = await fetchURL(assetTVLURL)
|
|
const usdPriceData = await fetchURL(usdPriceUrl)
|
|
|
|
const total_liquidity_in_usd = tvlData.data.reduce((sum, asset) => {
|
|
var assetPrice = 0
|
|
if (usdPriceData.data.hasOwnProperty(asset.assetId)) {
|
|
assetPrice = usdPriceData.data[asset.assetId].price
|
|
} else {
|
|
// price for some asset is not found on tinyman then
|
|
// set its price to zero
|
|
assetPrice = 0
|
|
}
|
|
|
|
sum += assetPrice * asset.asaAmountTotal
|
|
return sum
|
|
}, 0)
|
|
return total_liquidity_in_usd
|
|
}
|
|
// tvl in USD
|
|
module.exports = {
|
|
fetch
|
|
}
|