diff --git a/projects/d8x/index.js b/projects/d8x/index.js index 4acc89d80f5..0c891e74978 100644 --- a/projects/d8x/index.js +++ b/projects/d8x/index.js @@ -1,23 +1,27 @@ const abi = require("./abi-poolInfo.json"); +const { sumTokens2 } = require('../helper/unwrapLPs') -const D8X_PERPETUALS_CONTRACT = "0xaB7794EcD2c8e9Decc6B577864b40eBf9204720f"; +const config = { + polygon_zkevm: { factory: "0xaB7794EcD2c8e9Decc6B577864b40eBf9204720f", }, + xlayer: { factory: "0xb24dB543749277E8625a59C061aE7574C8235475", }, +}; async function tvl(api) { + const { factory } = config[api.chain]; const exchangeInfo = await api.call({ abi: abi.getPoolStaticInfo, - target: D8X_PERPETUALS_CONTRACT, + target: factory, params: [1, 255], }); const marginTokens = exchangeInfo[2]; - return api.sumTokens({ owner: D8X_PERPETUALS_CONTRACT, tokens: marginTokens }); + return sumTokens2({ api, owner: factory, tokens: marginTokens, }); } module.exports = { - methodology: - "adds up the balances of all liquidity pools in the D8X exchange", - start: 6182628, - polygon_zkevm: { - tvl, - }, + methodology: "adds up the balances of all liquidity pools in the D8X exchange", }; + +Object.keys(config).forEach(chain => { + module.exports[chain] = { tvl }; +}); \ No newline at end of file