Files
DefiLlama-Adapters/projects/algodex.js
Alexander Trefonas f7433f8552 Update TVL endpoint for Algodex (#4606)
* 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>
2022-11-11 02:13:19 +05:30

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
}