Skip to content

Commit

Permalink
Update D8X exchange TVL calculation (DefiLlama#10026)
Browse files Browse the repository at this point in the history
* d8x: track xlayer (#2)

Co-authored-by: m66260 <[email protected]>

* minor refactor

---------

Co-authored-by: c40003141 <[email protected]>
Co-authored-by: m66260 <[email protected]>
Co-authored-by: m66260 <[email protected]>
  • Loading branch information
4 people authored Apr 29, 2024
1 parent 8218e94 commit 9246170
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions projects/d8x/index.js
Original file line number Diff line number Diff line change
@@ -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 };
});

0 comments on commit 9246170

Please sign in to comment.