From 5bde5ec8198006c83af343869f8be54f22bf07ac Mon Sep 17 00:00:00 2001 From: 0xpeluche <0xpeluche@protonmail.com> Date: Thu, 8 Aug 2024 11:24:14 +0200 Subject: [PATCH] sum underlyings tokens in vault instead of uniBTC --- projects/unibtc/index.js | 70 +++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/projects/unibtc/index.js b/projects/unibtc/index.js index 7a9834b5ac81..bd013aa1e752 100644 --- a/projects/unibtc/index.js +++ b/projects/unibtc/index.js @@ -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]) } -}; \ No newline at end of file +})