Skip to content

Commit 53b17ad

Browse files
authored
feat: subtract the cgUSDT of withdrawal vault to reflect true TVL (DefiLlama#11317)
* feat: subtract the cgUSDT in the withdrawal vault to reflect the true supply * chore: rename balance variable
1 parent b738567 commit 53b17ad

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

projects/cygnus-finance/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ async function getJettonMetadata(addr) {
1313
const res = await get(`https://tonapi.io/v2/jettons/${addr}`)
1414
return res
1515
}
16+
async function getJettonBalance(address, jettonMasterAddress) {
17+
const res = await get(`https://tonapi.io/v2/accounts/${address}/jettons/${jettonMasterAddress}`)
18+
return res.balance
19+
}
1620

1721
async function tonTvl() {
1822
const MINTER_ADDRESS = "EQCfvQW-thWpqKgyqtXCFbYayDlHqS0-frkyP6VD70paLFZa"
1923
const CGUSDT_ADDRESS = 'EQBIBw3mF_TDMJqWAZihVsyUBMWpWw_deftZLiCxTmrCUOKy'
2024

21-
2225
const minterResult = await call({ target: MINTER_ADDRESS, abi: "get_minter_data", stack: [] })
2326
// exchange rate from cgUSDT to USDT: decimal 9
2427
const cgusdtTousdt = (minterResult[5]) / 10 ** 9
@@ -27,8 +30,11 @@ async function tonTvl() {
2730
const jettonResult = await getJettonMetadata(CGUSDT_ADDRESS)
2831
const cgUsdtTotalSupply = jettonResult['total_supply']
2932

33+
// subtract the amount of cgUSDT in the withdrawal vault
34+
const withdrawVaultBalance = await getJettonBalance(MINTER_ADDRESS, CGUSDT_ADDRESS)
35+
3036
// caculate tvl
31-
const tvl = (cgUsdtTotalSupply) / 10 ** 6 * cgusdtTousdt
37+
const tvl = (cgUsdtTotalSupply - withdrawVaultBalance) / 10 ** 6 * cgusdtTousdt
3238
return { "coingecko:tether": tvl }
3339
}
3440

0 commit comments

Comments
 (0)