forked from DefiLlama/DefiLlama-Adapters
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Joule Finance Adapter (DefiLlama#11571)
- Loading branch information
1 parent
841a331
commit 3c767bd
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
}, | ||
} | ||
}; |