Skip to content

Commit

Permalink
feat: add adapter for origami (#10168)
Browse files Browse the repository at this point in the history
* feat: add adapter for origami

* code refactor

---------

Co-authored-by: 0xl2 <[email protected]>
Co-authored-by: g1nt0ki <[email protected]>
  • Loading branch information
3 people authored May 13, 2024
1 parent de8114c commit 976ed71
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions projects/origami/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const { cachedGraphQuery } = require('../helper/cache')

const GRAPH_URLS = {
ethereum: "https://api.thegraph.com/subgraphs/name/templedao/origami-mainnet", // ethereum
arbitrum: "https://api.thegraph.com/subgraphs/name/templedao/origami-arb", // arbitrum
}

module.exports = {
doublecounted: true,
}

Object.keys(GRAPH_URLS).forEach(chain => {
const endpoint = GRAPH_URLS[chain]
module.exports[chain] = {
tvl: async (api) => {
const { metrics: [{ investmentVaults }] } = await cachedGraphQuery('origami/' + chain, endpoint, '{ metrics { investmentVaults { id } } }')
const vaults = investmentVaults.map(vault => vault.id)
let tokens = await api.multiCall({ abi: 'address:reserveToken', calls: vaults })
if (chain === 'arbitrum')
tokens = await api.multiCall({ abi: 'address:baseToken', calls: tokens })

const decimals = await api.multiCall({ abi: 'uint8:decimals', calls: vaults })
const supplies = await api.multiCall({ abi: 'uint256:totalSupply', calls: vaults })
const reserves = await api.multiCall({ abi: 'uint256:reservesPerShare', calls: vaults })
const bals = reserves.map((reserve, i) => reserve * supplies[i] / 10 ** decimals[i])
console.log(tokens, bals, vaults, api.chain)
api.add(tokens, bals)
}
}
})

0 comments on commit 976ed71

Please sign in to comment.