-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5ff413
commit 8343d1d
Showing
1 changed file
with
34 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,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) | ||
} |