Skip to content

Commit

Permalink
Add Joule Finance Adapter (DefiLlama#11571)
Browse files Browse the repository at this point in the history
  • Loading branch information
void-restack authored Sep 10, 2024
1 parent 841a331 commit 3c767bd
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions projects/joule/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const { getResource } = require("../helper/chain/aptos")

const CONTRACT_ADDRESS = "0x2fe576faa841347a9b1b32c869685deb75a15e3f62dfe37cbd6d52cc403a16f6"

async function getPoolsData() {
const res = await getResource("0x7f83b020b8ab60dbdc4208029fa6aa0804bf5a71eeaca63382d24622b9e6f647", `${CONTRACT_ADDRESS}::pool::PoolConfigsMap`)

const poolConfigsMap = res.pool_configs_map.data;

return poolConfigsMap.map(item => ({
coin: item.key,
total_lend: item.value.total_lend,
total_borrow: item.value.total_borrow
}));
}

module.exports = {
timetravel: false,
methodology:
"Aggregates TVL for all markets in Joule.",
aptos: {
tvl: async (api) => {
const marketsData = await getPoolsData()
marketsData.forEach(({coin, total_lend}) => {
api.add(coin, total_lend)
})
},
borrowed: async (api) => {
const marketsData = await getPoolsData()
marketsData.forEach(({coin, total_borrow}) => {
api.add(coin, total_borrow)
})
},
}
};

0 comments on commit 3c767bd

Please sign in to comment.