fix broken adapters

This commit is contained in:
g1nt0ki
2024-04-24 23:16:43 +02:00
parent 285460f645
commit e9cb9e6466
6 changed files with 32 additions and 24 deletions

View File

@@ -53,11 +53,14 @@ async function tvl(api) {
}
async function addEquityValuationToBalances(address, api) {
var usdc_balance = await api.call({
var [usdc_balance] = await api.multiCall({
target: address,
abi: "function getEquityValuation(bool startIndex_, bool endIndex_) view returns (uint256)",
params: [true, false],
calls: [{ params: [true, false] }],
permitFailure: true,
})
if (!usdc_balance)
return
api.add(USDC_TOKEN_CONTRACT, usdc_balance)
}

View File

@@ -1,17 +1,11 @@
const { sumTokensExport } = require('./helper/chain/ergo')
const { sumTokensExport: steCardano } = require('./helper/chain/cardano')
const utils = require('./helper/utils');
const { get } = require('./helper/http');
async function cardanoTVL() {
let response = await utils.fetchURL('https://analytics-balanced.spectrum.fi/cardano/pools/overview?after=0')
let data = response.data;
let totalTvl = 0;
for(let i=0; i<data.length; i++) {
totalTvl += data[i].tvl;
}
let { tvlAda } = await get('https://api.splash.trade/platform-api/v1/platform/stats')
return {cardano:totalTvl};
return { cardano: tvlAda };
}
module.exports = {

View File

@@ -35,7 +35,7 @@ async function adaTvl() {
// fetch the prices of each traded token first
const adaPrices = new Map(Object.entries((await fetchURL("https://api.muesliswap.com/defillama/prices")).data))
// then first accumulate over the legacy orderbook
/* // then first accumulate over the legacy orderbook
const orderbookV1 = (await fetchURL("https://orders.muesliswap.com/all-orderbooks")).data
const vOrderbookV1 = orderbookV1.map(ob => {
if (ob.fromToken === ".") {
@@ -59,7 +59,7 @@ async function adaTvl() {
return (totalBuy * fromPrice + totalSell * toPrice)
}
})
totalAda += vOrderbookV1.reduce((p, c) => p + c, 0)
totalAda += vOrderbookV1.reduce((p, c) => p + c, 0) */
// then accumulate over the orderbooks
const orderbookV2 = (await fetchURL("https://onchain.muesliswap.com/all-orderbooks")).data
@@ -101,7 +101,7 @@ module.exports = {
methodology: "The factory addresses are used to find the LP pairs on Smart BCH and Milkomeda. For Cardano we calculate the tokens on resting orders on the order book contracts. TVL is equal to the liquidity on the AMM plus the open orders in the order book",
cardano: {
tvl: adaTvl,
staking
// staking
},
milkomeda: {
tvl: getUniTVL({ factory: '0x57A8C24B2B0707478f91D3233A264eD77149D408', useDefaultCoreAssets: true }),

View File

@@ -11,6 +11,7 @@ const coinGeckoIds = {
ujuno: "juno-network",
ustars: "stargaze",
usaga: "saga-2",
ubld: "agoric",
};
async function tvl() {

View File

@@ -21,7 +21,7 @@ async function getExchanges(factory, data) {
sdk.log(factory, exchanges.length, pools.length, hasMore)
pools.push(...exchanges)
const { errors } = await PromisePool.withConcurrency(1)
const { errors } = await PromisePool.withConcurrency(10)
.for(exchanges)
.process(async (i) => {
let { address, contract } = i
@@ -36,8 +36,9 @@ async function getExchanges(factory, data) {
await sleep(1000)
})
if (errors && errors.length)
throw errors[0]
console.log(errors, errors.length, factory, exchanges.length, pools.length, hasMore)
// if (errors && errors.length)
// throw errors[0]
} while (hasMore)
}

View File

@@ -1,9 +1,18 @@
module.exports={
ethereum:{
tvl: async (_t, _b, _c, {api})=>{
const tranches = await api.fetchList({ lengthAbi: 'deployedCount', itemAbi: 'deployedAt', target: "0x82a91a0d599a45d8e9af781d67f695d7c72869bd" })
const bonds = await api.multiCall({ abi: 'address:bond', calls: tranches })
return api.sumTokens({ tokens: ["0xd46ba6d942050d489dbd938a2c909a5d5039a161"], owners: [...bonds, "0x82A91a0D599A45d8E9Af781D67f695d7C72869Bd"] })
}
const { getLogs2 } = require('../helper/cache/getLogs')
module.exports = {
ethereum: {
tvl: async (api) => {
const logs = await getLogs2({
api,
factory: '0xeca709A67E8e774c827547D900e01B763f77E99f',
eventAbi: 'event TrancheCreated(address newTrancheAddress)',
fromBlock: 15800076,
})
// const tranches = await api.fetchList({ lengthAbi: 'deployedCount', itemAbi: 'deployedAt', target: "0x82a91a0d599a45d8e9af781d67f695d7c72869bd" })
// const bonds = await api.multiCall({ abi: 'address:bond', calls: tranches })
const bonds = logs.map(log => log.newTrancheAddress)
return api.sumTokens({ tokens: ["0xd46ba6d942050d489dbd938a2c909a5d5039a161"], owners: [...bonds, "0x82A91a0D599A45d8E9Af781D67f695d7C72869Bd"] })
}
}
}