Files
DefiLlama-Adapters/projects/hyperpie/index.js
2025-03-27 11:25:39 +00:00

29 lines
753 B
JavaScript

const config = require("./config")
const mHYPEAbi = require("./abis/mHYPE.json");
const WEI_DECIMALS = 18;
async function tvl(api) {
const { mHYPE, HYPE, HYPE_DECIMALS } = config[api.chain]
const exchangeRateToHype = await api.call({
abi: mHYPEAbi.exchangeRate,
target: mHYPE
});
const totalsupplyMHYPE = await api.call({
abi: mHYPEAbi.totalSupply,
target: mHYPE
});
const totalSupplyHypeInWei = totalsupplyMHYPE * exchangeRateToHype / 10 ** WEI_DECIMALS;
const totalSupplyHype = (totalSupplyHypeInWei * (10 ** HYPE_DECIMALS)) / 10 ** WEI_DECIMALS;
api.add(HYPE, totalSupplyHype);
}
Object.keys(config).forEach((chain) => {
module.exports[chain] = {
tvl,
}
});