Files
DefiLlama-Adapters/projects/factor/index.js
slasher125 102433e7a7 graphql-migration (#10635)
* ic

* revert package lock change

* bump version

---------

Co-authored-by: 0xngmi <0xngmi@protonmail.com>
2024-06-13 22:50:55 +05:30

29 lines
1.1 KiB
JavaScript

const sdk = require("@defillama/sdk");
const { staking } = require("../helper/staking");
const { sumTokens2 } = require('../helper/unwrapLPs');
const { cachedGraphQuery } = require('../helper/cache');
const FCTR = "0x6dD963C510c2D2f09d5eDdB48Ede45FeD063Eb36"
const veFCTR = "0xA032082B08B2EF5A6C3Ea80DaEac58300F68FB73"
async function tvl(api) {
const endpoint = sdk.graph.modifyEndpoint('2ZavYD1JPYUy8HMheuYcyKCswHR5djpEq2xuWs7PzPRe')
const res = await cachedGraphQuery('factor-v1', endpoint, `{vaultGeneses { id }}`)
const indices = res.vaultGeneses.map(v => v.id)
const uBalances = await api.multiCall({ abi: 'uint256[]:underlyingAssetsBalance', calls: indices })
const calls = []
uBalances.forEach((v, i) => {
v.forEach((_, j) => calls.push({ target: indices[i], params: j }))
})
const uData = await api.multiCall({ abi: 'function underlyingAssets(uint256) view returns (address,uint256,uint256)', calls })
const tokensAndOwners = uData.map((v, i) => [v[0], calls[i].target])
await sumTokens2({ api, tokensAndOwners })
}
module.exports = {
arbitrum: {
tvl,
staking: staking(veFCTR, FCTR)
}
}