Skip to content

Commit

Permalink
feat: add IST adapter (#12765)
Browse files Browse the repository at this point in the history
Co-authored-by: g1nt0ki <[email protected]>
  • Loading branch information
mujahidkay and g1nt0ki authored Dec 19, 2024
1 parent e694cf4 commit 074a69d
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
58 changes: 58 additions & 0 deletions projects/agoric/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const { post } = require('../helper/http')

const query = `
query {
vaultManagerMetrics {
nodes {
liquidatingCollateralBrand
totalCollateral
}
}
oraclePrices {
nodes {
typeInAmount
typeOutAmount
typeInName
}
}
boardAuxes {
nodes {
allegedName
decimalPlaces
}
}
}
`

const coingeckoMapping = {
'stATOM': 'stride-staked-atom',
'stkATOM': 'stkatom',
'ATOM': 'cosmos',
'stOSMO': 'stride-staked-osmo',
'stTIA': 'stride-staked-tia',
}
const decimals = {}

const tvl = async (api) => {
const { data: { vaultManagerMetrics, boardAuxes } } = await post('https://api.subquery.network/sq/agoric-labs/agoric-mainnet-v2', { query })

boardAuxes.nodes.forEach(board => {
decimals[board.allegedName] = 10 ** board.decimalPlaces
})

vaultManagerMetrics.nodes.forEach(vault => {
const key = vault.liquidatingCollateralBrand
if (!coingeckoMapping[key]) {
throw new Error(`Unknown coin ${key} (coingecko mapping is missing)`)
}
const decimal = decimals[key] ?? 1e6
const balance = vault.totalCollateral / decimal
api.addCGToken(coingeckoMapping[key], balance)
})
}

module.exports = {
agoric: {
tvl,
},
}
1 change: 1 addition & 0 deletions projects/helper/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"ace",
"aelf",
"aeternity",
"agoric",
"ailayer",
"airdao",
"alephium",
Expand Down

0 comments on commit 074a69d

Please sign in to comment.