remove fetch

This commit is contained in:
g1nt0ki
2025-06-25 15:41:35 +02:00
parent 5d42a03706
commit 39a44cf812
6 changed files with 24 additions and 34 deletions

View File

@@ -1,5 +1,4 @@
const ADDRESSES = require('../helper/coreAssets.json')
const utils = require("../helper/utils");
const { staking } = require("../helper/staking");
const stakingContract_BSC = "0x75A2145510b7CeefB812d5Afa1b20f94eC0BAf57";
@@ -9,23 +8,16 @@ const stakingContract_Harmony = "0x3b441bf2522927BCf41c1c24786E7a8E9a56B234";
const DFL = "0xD675fF2B0ff139E14F86D87b7a6049ca7C66d76e";
const DFL_Harmony = ADDRESSES.arbitrum.MIM;
const fetch = async () => {
return 0
/*
const tvl = (await utils.fetchURL("https://api.defily.io/v1/statistics")).data
.payload.totalValueLocked.total;
return tvl; */
};
module.exports = {
bsc: {
tvl: () => ({}),
staking: staking(stakingContract_BSC, DFL),
},
kardia: {
staking: staking(stakingContract_KARDIA, DFL),
},
harmony: {
staking: staking(stakingContract_Harmony, DFL_Harmony, "harmony", `kardia:${DFL}`),
staking: staking(stakingContract_Harmony, DFL_Harmony),
},
fetch,
deadFrom: '2024-10-01',
};

View File

@@ -1,3 +1,2 @@
module.exports = {
fetch: () => 0
}

View File

@@ -8,7 +8,7 @@ function integerPriceToNominal(price, market) {
return price * market.tick_size * Math.pow(10, market.base_decimals) / market.lot_size / Math.pow(10, market.quote_decimals)
}
async function getTvl() {
async function getTvl(api) {
const markets = (await axios.get(`${URL}/markets?${USDC_FILTER}&order=market_id.asc`)).data;
const tvls = (await axios.get(`${URL}/tvl_per_market?${USDC_FILTER}&order=market_id.asc`)).data;
@@ -26,14 +26,12 @@ async function getTvl() {
}
}))
const tvl = convertedTvls.reduce((p, c) => p + c, 0);
return tvl;
api.addUSDValue(convertedTvls.reduce((a, b) => +a + +b, 0));
}
module.exports = {
misrepresentedTokens: true,
aptos: {
fetch: getTvl
tvl: getTvl
},
fetch: getTvl
}

View File

@@ -10,28 +10,29 @@
const { fetchBaseAABalances, fetchOswapExchangeRates, fetchOswapAssets, summingBaseAABalancesToTvl } = require('../helper/chain/obyte')
// TODO support time travel for the exchange rate, currently it always returns the latest rates
async function tvl({ timestamp }) {
async function tvl(api) {
const timestamp = api.timestamp
const [exchangeRates, assetMetadata] = await Promise.all([
fetchOswapExchangeRates(),
fetchOswapAssets()
])
return Promise.all([
const usdValue = await Promise.all([
fetchBaseAABalances(timestamp, "GS23D3GQNNMNJ5TL4Z5PINZ5626WASMA"), // Oswap v1
fetchBaseAABalances(timestamp, "2JYYNOSRFGLI3TBI4FVSE6GFBUAZTTI3"), // Oswap v2
fetchBaseAABalances(timestamp, "DYZOJKX4MJOQRAUPX7K6WCEV5STMKOHI") // Oswap v2.1
]).then(baseAABalances => {
return baseAABalances.reduce(summingBaseAABalancesToTvl(assetMetadata, exchangeRates), 0)
})
api.addUSDValue(usdValue)
}
module.exports = {
timetravel: false,
misrepresentedTokens: true,
misrepresentedTokens: true,
methodology:
"The TVL is the USD value of the all non-self issued assets locked into the autonomous agents extending the Oswap protocol.",
obyte: {
fetch: tvl
tvl
},
fetch: tvl
}

View File

@@ -2,20 +2,20 @@ const utils = require("../helper/utils");
// https://paycashswap.com
// https://api.paycashswap.com
async function eos() {
async function eos(api) {
const data = {
operationName: "TotalLiquidity",
variables: {},
query: "query TotalLiquidity { totalLiquidityChart { value24h } }"
query: "query TotalLiquidity { totalLiquidityChart { value24h } token(id:100) {liquidity} }"
}
const response = await utils.postURL("https://api.paycashswap.com/", data);
return response.data.data.totalLiquidityChart.value24h;
const { data: { data: { totalLiquidityChart: { value24h }, token: { liquidity } } } } = await utils.postURL("https://api.paycashswap.com/", data);
api.addUSDValue(value24h - liquidity) // exclude self-issued tokens
}
module.exports = {
misrepresentedTokens: true,
methodology: `PayCash Swap TVL is achieved by making a call to its PayCash Swap API.`,
eos: {
fetch: eos
tvl: eos
},
fetch: eos,
}

View File

@@ -11,7 +11,8 @@ const BASE_AA = "A336I77COVXUCN3L2YOYVIZF7PKMFCAV";
const STAKING_BASE_AA = "HPJQ6ZCB2T3JTIVAMDM5QESZWNJNJERO";
// TODO support time travel for the exchange rate, currently it always returns the latest rates
async function tvl({ timestamp }) {
async function tvl(api) {
const timestamp = api.timestamp;
const [exchangeRates, assetMetadata] = await Promise.all([
fetchOswapExchangeRates(),
fetchOswapAssets()
@@ -29,16 +30,15 @@ async function tvl({ timestamp }) {
return baseAABalances.reduce(summingBaseAABalancesToTvl(assetMetadata, exchangeRates), 0)
});
return baseAASumBalances + stakingBaseAASumBalances;
api.addUSDValue(baseAASumBalances + stakingBaseAASumBalances);
}
module.exports = {
timetravel: false,
misrepresentedTokens: true,
misrepresentedTokens: true,
methodology:
"The TVL is the USD value of the assets locked into the autonomous agents that implement the Pythagorean protocol.",
obyte: {
fetch: tvl
tvl
},
fetch: tvl
}