-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
13 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,18 @@ | ||
const { default: BigNumber } = require("bignumber.js"); | ||
|
||
const contracts = [ | ||
"0x951d1571C75C519Cc3D09b6B71595C6aCe1c06dB", | ||
"0x165D74d2DEFe37794371eB63c63999ab5620DBfB" | ||
]; | ||
const { sumTokensExport } = require('../helper/unwrapLPs') | ||
|
||
const TOKENS = [ | ||
//"0x829e43f497b8873fA5c83FcF665b96A39a1FBeD6", // MCT doesn't support on Defillama | ||
"0x80b5a32E4F032B2a058b4F29EC95EEfEEB87aDcd", // axlUSDC on Haqq | ||
"0x0CE35b0D42608Ca54Eb7bcc8044f7087C18E7717" // USDC on Haqq | ||
]; | ||
|
||
async function tvl(api) { | ||
const balancesMap = {}; | ||
|
||
for (let token of TOKENS) { | ||
for (let contract of contracts) { | ||
try { | ||
const balance = await api.call({ | ||
abi: 'erc20:balanceOf', | ||
target: token, | ||
params: [contract] | ||
}); | ||
|
||
if (!balancesMap[token]) balancesMap[token] = BigNumber(0); | ||
balancesMap[token] = balancesMap[token].plus(BigNumber(balance)); | ||
} catch (error) { | ||
console.error(`Failed to fetch balance for token ${token} at contract ${contract}:`, error); | ||
} | ||
} | ||
} | ||
'0x80b5a32E4F032B2a058b4F29EC95EEfEEB87aDcd', | ||
'0x0CE35b0D42608Ca54Eb7bcc8044f7087C18E7717', | ||
] | ||
|
||
Object.entries(balancesMap).forEach(([token, balance]) => { | ||
api.add(token, balance.toString()); | ||
}); | ||
|
||
return api.getBalances(); | ||
} | ||
const INVESTMENT_CONTRACT = '0x951d1571C75C519Cc3D09b6B71595C6aCe1c06dB' | ||
const PROFIT_SHARE_CONTRACT = '0x165D74d2DEFe37794371eB63c63999ab5620DBfB' | ||
|
||
module.exports = { | ||
methodology: "TVL counts the tokens deposited in the MCT pools.", | ||
islm: { tvl }, | ||
}; | ||
islm: { | ||
tvl: sumTokensExport({ | ||
owners: [INVESTMENT_CONTRACT, PROFIT_SHARE_CONTRACT], | ||
tokens: TOKENS | ||
}), | ||
}, | ||
} |