Skip to content

Commit

Permalink
Add Enclabs adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
EnclabsTechIntern committed Jan 28, 2025
1 parent d5ff413 commit 8343d1d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions projects/enclabs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const sdk = require("@defillama/sdk");
const { cachedGraphQuery } = require('../helper/cache')
const { compoundExports2 } = require('../helper/compound')
const config = {
sonic: {
endpoint: sdk.graph.modifyEndpoint('Ha7WNTEk2U1MvMUVMmmv8e7uZxJUYY4n8r57iJHYyYcJ'),
},

}

Object.keys(config).forEach(chain => {
module.exports[chain] = { tvl, borrowed, }
})

async function getPools(api) {
const { endpoint, corePools } = config[api.chain]
const poolSet = new Set(corePools.map(i=>i.toLowerCase()))
const { pools } = await cachedGraphQuery('enclabs/'+api.chain, endpoint, `{ pools { id }}`)
return pools.map(i => i.id).filter(i => !poolSet.has(i.toLowerCase()))
}

async function tvl(...args) {
const [api] = args
const pools = await getPools(api)
const tvls = pools.map(i => compoundExports2({ comptroller: i}))
return sdk.util.sumChainTvls(tvls.map(i => i.tvl))(...args)
}

async function borrowed(...args) {
const [api] = args
const pools = await getPools(api)
const tvls = pools.map(i => compoundExports2({ comptroller: i}))
return sdk.util.sumChainTvls(tvls.map(i => i.borrowed))(...args)
}

0 comments on commit 8343d1d

Please sign in to comment.