Skip to content

Commit

Permalink
grace: add ethereum chain (#10799)
Browse files Browse the repository at this point in the history
  • Loading branch information
nourharidy authored Jun 27, 2024
1 parent cc06062 commit b17649b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions projects/grace/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
const CORE_CONTRACT = '0x1522ad0a3250eb0f64e0acfe090ca40949330cc1';
const CORE_CONTRACTS = {
base:'0x1522ad0a3250eb0f64e0acfe090ca40949330cc1',
ethereum:'0x164dd1f4174020642967bea521e56fc776742b49'
}

async function tvl(api) {
const pools = await api.fetchList({ lengthAbi: 'poolCount', itemAbi: 'poolList', target: CORE_CONTRACT })
const collaterals = await api.fetchList({ lengthAbi: 'collateralCount', itemAbi: 'collateralList', target: CORE_CONTRACT })
const pools = await api.fetchList({ lengthAbi: 'poolCount', itemAbi: 'poolList', target: CORE_CONTRACTS[api.chain] })
const collaterals = await api.fetchList({ lengthAbi: 'collateralCount', itemAbi: 'collateralList', target: CORE_CONTRACTS[api.chain] })
const poolUnderlyings = await api.multiCall({ abi: 'address:asset', calls: pools })
const collateralUnderlyings = await api.multiCall({ abi: 'address:asset', calls: collaterals })
return api.sumTokens({ tokensAndOwners2: [[...poolUnderlyings, ...collateralUnderlyings], [...pools, ...collaterals]] })
}

async function borrowed(api) {
const pools = await api.fetchList({ lengthAbi: 'poolCount', itemAbi: 'poolList', target: CORE_CONTRACT })
const pools = await api.fetchList({ lengthAbi: 'poolCount', itemAbi: 'poolList', target: CORE_CONTRACTS[api.chain] })
const poolUnderlyings = await api.multiCall({ abi: 'address:asset', calls: pools })
const borrowed = await api.multiCall({ abi: 'uint256:totalDebt', calls: pools })
api.add(poolUnderlyings, borrowed)
Expand All @@ -20,5 +23,8 @@ module.exports = {
start: 14684731,
base: {
tvl, borrowed
}
},
ethereum: {
tvl, borrowed
},
};

0 comments on commit b17649b

Please sign in to comment.