Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: subtract the cgUSDT of withdrawal vault to reflect true TVL #11317

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions projects/cygnus-finance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ async function getJettonMetadata(addr) {
const res = await get(`https://tonapi.io/v2/jettons/${addr}`)
return res
}
async function getJettonBalance(address, jettonMasterAddress) {
const res = await get(`https://tonapi.io/v2/accounts/${address}/jettons/${jettonMasterAddress}`)
return res.balance
}

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


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

// subtract the amount of cgUSDT in the withdrawal vault
const withdrawVaultBalance = await getJettonBalance(MINTER_ADDRESS, CGUSDT_ADDRESS)

// caculate tvl
const tvl = (cgUsdtTotalSupply) / 10 ** 6 * cgusdtTousdt
const tvl = (cgUsdtTotalSupply - withdrawVaultBalance) / 10 ** 6 * cgusdtTousdt
return { "coingecko:tether": tvl }
}

Expand Down
Loading