Skip to content

Commit 269f25a

Browse files
authored
Update volo (#16808)
1 parent a080f73 commit 269f25a

File tree

1 file changed

+25
-38
lines changed

1 file changed

+25
-38
lines changed

projects/volo-vsui/index.js

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,38 @@
11
const sui = require('../helper/chain/sui')
2-
const USDC_COIN = '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC'
2+
const axios = require('axios')
33

44
const VAULTS = [
5-
'0x6e53ffe5b77a85ff609b0813955866ec98a072e4aaf628108e717143ec907bd8',
6-
'0x041b49dc6625e074f452b9bc60a9a828aebfbef29bcba119ad90a4b11ba405bf',
7-
'0xa97cc9a63710f905deb2da40d6548ce7a75ee3dfe4be0c1d553553d2059c31a3',
8-
'0x27936e146ec8c695d14a3b900d21a495d2396c0a99e3c6766f86d15fe91d3897',
5+
{ address: '0x6e53ffe5b77a85ff609b0813955866ec98a072e4aaf628108e717143ec907bd8', gecko_id: 'bitcoin' },
6+
{ address: '0x041b49dc6625e074f452b9bc60a9a828aebfbef29bcba119ad90a4b11ba405bf', gecko_id: 'okx-wrapped-btc' },
7+
{ address: '0xa97cc9a63710f905deb2da40d6548ce7a75ee3dfe4be0c1d553553d2059c31a3', gecko_id: 'usd-coin' },
8+
{ address: '0x27936e146ec8c695d14a3b900d21a495d2396c0a99e3c6766f86d15fe91d3897', gecko_id: 'usd-coin' },
99
]
1010

11-
async function liquidStakingTVL() {
12-
const obj = await sui.getObject('0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5')
13-
const totalSuiSupply = +obj.fields.validator_pool.fields.total_sui_supply
14-
return totalSuiSupply
15-
}
16-
17-
async function getVaultTVL(api) {
18-
for (const address of VAULTS) {
19-
const vaultObj = await sui.getObject(address);
20-
const assetsValueTableId = vaultObj.fields.assets_value.fields.id.id;
21-
const assetTypes = vaultObj.fields.asset_types;
22-
23-
let totalUsdValue = 0;
11+
const ENDPOINT = 'https://vault-api.volosui.com/api/v1/vaults'
2412

25-
for (const assetType of assetTypes) {
26-
const assetValueObj = await sui.getDynamicFieldObject(
27-
assetsValueTableId,
28-
assetType,
29-
{ idType: '0x1::ascii::String' }
30-
);
13+
const getVaults = async (api) => {
14+
const { data } = await axios.get(ENDPOINT)
15+
const vaults = data.data
3116

32-
totalUsdValue += +assetValueObj.fields.value;
33-
}
34-
35-
api.add(USDC_COIN, totalUsdValue / 1e3);
36-
}
17+
for (const { id, totalStaked } of vaults) {
18+
const match = VAULTS.find(v => v.address.toLowerCase() === id.toLowerCase())
19+
if (match) api.addCGToken(match.gecko_id, totalStaked)
20+
}
3721
}
3822

39-
async function tvl(api) {
40-
api.add('0x2::sui::SUI', await liquidStakingTVL())
41-
await getVaultTVL(api)
23+
const getStakingTvl = async (api) => {
24+
const obj = await sui.getObject('0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5')
25+
const totalSuiSupply = +obj.fields.validator_pool.fields.total_sui_supply
26+
api.add('0x2::sui::SUI', totalSuiSupply)
4227
}
4328

44-
module.exports = {
45-
methodology: "Calculates the amount of SUI staked in Volo liquid staking contracts and tokens in Volo vaults. TVL includes LST (Liquid Staking) and all vault types combined.",
46-
misrepresentedTokens: true,
47-
sui: {
48-
tvl: tvl,
49-
},
29+
const tvl = async (api) => {
30+
await getStakingTvl(api)
31+
await getVaults(api)
5032
}
5133

34+
module.exports = {
35+
methodology: "Calculates the amount of SUI staked in Volo liquid staking contracts and tokens in Volo vaults. TVL includes LST (Liquid Staking) and all vault types combined.",
36+
misrepresentedTokens: true,
37+
sui: { tvl }
38+
}

0 commit comments

Comments
 (0)