Files
DefiLlama-Adapters/projects/edgeprotocol.js
g1nt0ki f9f37f8d82 Tvl-v2 (#9466)
* use tvl function v2

* refactor addFundsInMasterChef

* replace usage of timestamp field

* more refactoring

* more refactoring
2024-03-21 13:56:53 +05:30

32 lines
915 B
JavaScript

const { queryContract, } = require('./helper/chain/cosmos')
async function getMarkets() {
const res = await queryContract({ contract: 'terra1pcxwtrxppj9xj7pq3k95wm2zztfr9kwfkcgq0w', data: { market_lists: {} }, chain: 'terra' })
return res
}
async function tvl(api) {
const markets = await getMarkets()
markets.forEach(m => {
api.add(m.underlying, Math.floor(m.total_credit - m.total_insurance))
});
}
async function borrowed(api) {
const markets = await getMarkets()
markets.forEach(m => {
api.add(m.underlying, Math.floor(m.total_loan))
});
}
module.exports = {
timetravel: false,
methodology: `We query Edge's Genesis Pool smart contracts to get the amount of assets deposited and borrowed, we then use Coingecko to price the assets in USD.`,
terra: {
tvl,
borrowed
},
hallmarks: [
[1651881600, "UST depeg"],
]
};