File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,15 @@ async function getJettonMetadata(addr) {
13
13
const res = await get ( `https://tonapi.io/v2/jettons/${ addr } ` )
14
14
return res
15
15
}
16
+ async function getJettonBalance ( address , jettonMasterAddress ) {
17
+ const res = await get ( `https://tonapi.io/v2/accounts/${ address } /jettons/${ jettonMasterAddress } ` )
18
+ return res . balance
19
+ }
16
20
17
21
async function tonTvl ( ) {
18
22
const MINTER_ADDRESS = "EQCfvQW-thWpqKgyqtXCFbYayDlHqS0-frkyP6VD70paLFZa"
19
23
const CGUSDT_ADDRESS = 'EQBIBw3mF_TDMJqWAZihVsyUBMWpWw_deftZLiCxTmrCUOKy'
20
24
21
-
22
25
const minterResult = await call ( { target : MINTER_ADDRESS , abi : "get_minter_data" , stack : [ ] } )
23
26
// exchange rate from cgUSDT to USDT: decimal 9
24
27
const cgusdtTousdt = ( minterResult [ 5 ] ) / 10 ** 9
@@ -27,8 +30,11 @@ async function tonTvl() {
27
30
const jettonResult = await getJettonMetadata ( CGUSDT_ADDRESS )
28
31
const cgUsdtTotalSupply = jettonResult [ 'total_supply' ]
29
32
33
+ // subtract the amount of cgUSDT in the withdrawal vault
34
+ const withdrawVaultBalance = await getJettonBalance ( MINTER_ADDRESS , CGUSDT_ADDRESS )
35
+
30
36
// caculate tvl
31
- const tvl = ( cgUsdtTotalSupply ) / 10 ** 6 * cgusdtTousdt
37
+ const tvl = ( cgUsdtTotalSupply - withdrawVaultBalance ) / 10 ** 6 * cgusdtTousdt
32
38
return { "coingecko:tether" : tvl }
33
39
}
34
40
You can’t perform that action at this time.
0 commit comments