2
2
const { callCadence } = require ( "../helper/chain/flow" ) ;
3
3
4
4
let queryTVLCode = `
5
- import LiquidStaking from 0xd6f80565193ad727
6
- import stFlowToken from 0xd6f80565193ad727
7
- // Fixes Imports
8
- import FRC20AccountsPool from 0xd2abb5dbf5e08666
9
- import FixesFungibleTokenInterface from 0xd2abb5dbf5e08666
10
- import FixesTokenLockDrops from 0xd2abb5dbf5e08666
11
- import FixesTradablePool from 0xd2abb5dbf5e08666
12
- import FRC20Indexer from 0xd2abb5dbf5e08666
5
+ import FixesTVL from 0xd2abb5dbf5e08666
13
6
14
7
access(all)
15
8
fun main(): UFix64 {
16
- // singleton resource and constants
17
- let acctsPool = FRC20AccountsPool.borrowAccountsPool()
18
- let frc20Indexer = FRC20Indexer.getIndexer()
19
- let stFlowTokenKey = "@".concat(Type<@stFlowToken.Vault>().identifier)
20
-
21
- // dictionary of addresses
22
- let addrsDict = acctsPool.getAddresses(type: FRC20AccountsPool.ChildAccountType.FungibleToken)
23
- // dictionary of tickers and total locked token balances
24
- let tickerTotal: {String: UFix64} = {}
25
- // This is the soft burned LP value which is fully locked in the BlackHole Vault
26
- var flowLockedInBondingCurve = 0.0
27
- addrsDict.forEachKey(fun (key: String): Bool {
28
- if let addr = addrsDict[key] {
29
- // sum up all locked token balances in LockDrops Pool
30
- if let dropsPool = FixesTokenLockDrops.borrowDropsPool(addr) {
31
- let lockedTokenSymbol = dropsPool.getLockingTokenTicker()
32
- tickerTotal[lockedTokenSymbol] = (tickerTotal[lockedTokenSymbol] ?? 0.0) + dropsPool.getTotalLockedTokenBalance()
33
- }
34
- // sum up all burned LP value in Tradable Pool
35
- if let tradablePool = FixesTradablePool.borrowTradablePool(addr) {
36
- flowLockedInBondingCurve = flowLockedInBondingCurve + tradablePool.getFlowBalanceInPool()
37
- }
38
- }
39
- return true
40
- })
41
- // sum up all locked token balances in LockDrops Pool
42
- var totalLockingTokenTVL = 0.0
43
- tickerTotal.forEachKey(fun (key: String): Bool {
44
- let lockedAmount = tickerTotal[key]!
45
- if key == "" {
46
- // this is locked FLOW
47
- totalLockingTokenTVL = totalLockingTokenTVL + lockedAmount
48
- } else if key == "fixes" {
49
- // this is locked FIXES
50
- let price = frc20Indexer.getBenchmarkValue(tick: "fixes")
51
- totalLockingTokenTVL = totalLockingTokenTVL + lockedAmount * price
52
- } else if key == stFlowTokenKey {
53
- // this is locked stFlow
54
- totalLockingTokenTVL = totalLockingTokenTVL + LiquidStaking.calcFlowFromStFlow(stFlowAmount: lockedAmount)
55
- }
56
- return true
57
- })
58
- return totalLockingTokenTVL + flowLockedInBondingCurve
9
+ return FixesTVL.getAllLockedCoinFlowValue()
59
10
}
60
11
` ;
61
12
@@ -64,7 +15,7 @@ async function tvl() {
64
15
const flowTokenTVL = await callCadence ( queryTVLCode , true ) ;
65
16
return { flow : flowTokenTVL } ;
66
17
} catch ( error ) {
67
- throw new Error ( "Couln't query scripts of Fixes coins" , error ) ;
18
+ throw new Error ( "Couln't query scripts of Fixes coins. Error: " + error . message ) ;
68
19
}
69
20
}
70
21
0 commit comments