Skip to content

Commit

Permalink
sum underlyings tokens in vault instead of uniBTC
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpeluche committed Aug 8, 2024
1 parent 9d5a361 commit 5bde5ec
Showing 1 changed file with 34 additions and 36 deletions.
70 changes: 34 additions & 36 deletions projects/unibtc/index.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
const { nullAddress } = require("../helper/tokenMapping");
const ADDRESSES = require('../helper/coreAssets.json')
const defaultVault = '0xF9775085d726E782E83585033B58606f7731AB18'

const uniBTCAddresses = new Map();

uniBTCAddresses.set('bsquared', '0x93919784C523f39CACaa98Ee0a9d96c3F32b593e');
uniBTCAddresses.set('bitlayer', '0x93919784C523f39CACaa98Ee0a9d96c3F32b593e');
uniBTCAddresses.set('merlin', '0x93919784C523f39CACaa98Ee0a9d96c3F32b593e');
uniBTCAddresses.set('ethereum', '0x004E9C3EF86bc1ca1f0bB5C7662861Ee93350568');
uniBTCAddresses.set('mantle', '0x93919784C523f39CACaa98Ee0a9d96c3F32b593e');
uniBTCAddresses.set('optimism', '0x93919784C523f39CACaa98Ee0a9d96c3F32b593e');


function chainTvl(chain) {
return async (api) => {
const totalSupply = await api.call({
abi: 'erc20:totalSupply',
target: uniBTCAddresses.get(chain),
});

api.add(nullAddress, totalSupply)
}
}

module.exports = {
bsquared: {
tvl: chainTvl('bsquared'),
const config = {
ethereum: {
vault: '0x047D41F2544B7F63A8e991aF2068a363d210d6Da',
tokens: [ADDRESSES['ethereum'].WBTC, '0xc96de26018a54d51c097160568752c4e3bd6c364']
},
btr: {
tvl: chainTvl('bitlayer'),
optimism: {
vault: defaultVault,
tokens: [ADDRESSES['optimism'].WBTC]
},
merlin: {
tvl: chainTvl('merlin'),
mantle: {
vault: defaultVault,
tokens: ['0xC96dE26018A54D51c097160568752c4E3BD6C364']
},
ethereum: {
tvl: chainTvl('ethereum'),
bsquared: {
vault: defaultVault,
tokens: ["0x4200000000000000000000000000000000000006"]
},
mantle: {
tvl: chainTvl('mantle'),
merlin: {
vault: defaultVault,
tokens: ['0xB880fd278198bd590252621d4CD071b1842E9Bcd', '0xF6D226f9Dc15d9bB51182815b320D3fBE324e1bA']
},
optimism: {
tvl: chainTvl('optimism'),
btr: {
vault: defaultVault,
tokens: ['0xff204e2681a6fa0e2c3fade68a1b28fb90e4fc5f']
},
}

const tvl = (chainConfig) => {
return async (api) => {
return api.sumTokens({ tokens: chainConfig.tokens, owner: chainConfig.vault })
}
}

Object.keys(config).forEach(chain => {
module.exports[chain] = {
tvl: tvl(config[chain])
}
};
})

0 comments on commit 5bde5ec

Please sign in to comment.