Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: stakewise v2 #12664

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 34 additions & 36 deletions projects/stakewise/index.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,50 @@
const ADDRESSES = require('../helper/coreAssets.json')
const sdk = require('@defillama/sdk');
const { getLogs } = require('../helper/cache/getLogs')

async function tvl(api) {
const lsBals = await api.multiCall({ abi: 'erc20:totalSupply', calls: ['0x20BC832ca081b91433ff6c17f85701B6e92486c5', '0xFe2e637202056d30016725477c5da089Ab0A043A']})
const CONFIG = {
ethereum: {
rETH2: '0x20BC832ca081b91433ff6c17f85701B6e92486c5',
sETH2: '0xFe2e637202056d30016725477c5da089Ab0A043A',
validator: '0xEadCBA8BF9ACA93F627F31fB05470F5A0686CEca',
factory: '0x3a0008a588772446f6e656133c2d5029cc4fc20e',
blacklist: ['0x09e84205df7c68907e619d07afd90143c5763605']
},
xdai: {
GNO: '0x9c58bacc331c9aa871afd802db6379a98e80cedb',
sGNO: '0xA4eF9Da5BA71Cc0D2e5E877a910A37eC43420445'
}
}

const solosValidators = await getLogs({
target: '0xEadCBA8BF9ACA93F627F31fB05470F5A0686CEca',
topic: 'ValidatorRegistered(bytes32,bytes,uint256,address)',
fromBlock: 11726299,
api
})
const topic = {
validatorRegistered: 'ValidatorRegistered(bytes32,bytes,uint256,address)',
vaultAdded: 'VaultAdded(address,address)'
}

const ethTvl = async (api) => {
const { rETH2, sETH2, validator, factory, blacklist } = CONFIG[api.chain]
const lsBals = await api.multiCall({ abi: 'erc20:totalSupply', calls: [rETH2, sETH2]})
const solosValidators = await getLogs({ api, target: validator, topic: topic.validatorRegistered, fromBlock: 11726299 })
lsBals.push(solosValidators.length * 32e18)
const vaults = await getLogs({
target: '0x3a0008a588772446f6e656133c2d5029cc4fc20e',
topic: 'VaultAdded(address,address)',
fromBlock: 18470078,
api
})
const vaults = await getLogs({ api, target: factory, topic: topic.vaultAdded, fromBlock: 18470078 })

const assets = await api.multiCall({
calls: vaults.map(v=>({target:"0x"+v.topics[2].slice(26)})),
calls: vaults
.map(v => ({ target: "0x" + v.topics[2].slice(26) }))
.filter(call => !blacklist.includes(call.target.toLowerCase())),
abi: "uint256:totalAssets"
})

api.add(ADDRESSES.ethereum.WETH, assets.concat(lsBals))
}

async function xdaiTvl(timestamp, ethBlock, { xdai: block }) {
const chain = "xdai"
const supply = await sdk.api.erc20.totalSupply({
target: '0xA4eF9Da5BA71Cc0D2e5E877a910A37eC43420445',
block,
chain
})

return {
[ADDRESSES.ethereum.GNO]: supply.output
}
const xdaiTvl = async (api) => {
const { GNO, sGNO } = CONFIG[api.chain]
const supply = await api.call({ target: sGNO, abi: 'erc20:totalSupply' })
api.add(GNO, supply)
}



module.exports = {
methodology: 'Counts ETH staked',
ethereum: {
tvl,
},
xdai:{
tvl: xdaiTvl
}
}
ethereum: { tvl: ethTvl },
xdai: { tvl: xdaiTvl }
}
Loading