Skip to content

Commit

Permalink
Update Cygnus Finance with adding TON TVL (DefiLlama#11021)
Browse files Browse the repository at this point in the history
* feat: add ton TVL of Cygnus Finance

* feat: adjust tvl methodology
  • Loading branch information
greatpie authored Jul 17, 2024
1 parent 6790b12 commit 43750bb
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions projects/cygnus-finance/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,45 @@
const CGUSD_CONTRACT = "0xCa72827a3D211CfD8F6b00Ac98824872b72CAb49";
const START_TIME = 1708351200;
const { call } = require("../helper/chain/ton")
const { get } = require('../helper/http')

async function tvl(api) {
await api.erc4626Sum({ calls: [CGUSD_CONTRACT], balanceAbi: 'getTotalPooledAssets', tokenAbi: "asset" });
const CGUSD_CONTRACT = "0xCa72827a3D211CfD8F6b00Ac98824872b72CAb49"
const START_TIME = 1708351200

async function baseTvl(api) {
await api.erc4626Sum({ calls: [CGUSD_CONTRACT], balanceAbi: 'getTotalPooledAssets', tokenAbi: "asset" })
}

// helper function of getting jetton metadata
async function getJettonMetadata(addr) {
const res = await get(`https://tonapi.io/v2/jettons/${addr}`)
return res
}

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

// cgUSDT total supply: decimal 6
const jettonResult = await getJettonMetadata(CGUSDT_ADDRESS)
const cgUsdtTotalSupply = jettonResult['total_supply']

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


module.exports = {
methodology: "Calculates the total cgUSD Supply",
methodology: "Calculates the total cgUSD and cgUSDT Supply",
start: START_TIME,
base: {
tvl,
tvl: baseTvl,
},
ton: {
tvl: tonTvl
}
};

0 comments on commit 43750bb

Please sign in to comment.