mirror of
https://github.com/alexgo-io/DefiLlama-Adapters.git
synced 2026-01-12 16:53:02 +08:00
Update volo (#16808)
This commit is contained in:
@@ -1,51 +1,38 @@
|
||||
const sui = require('../helper/chain/sui')
|
||||
const USDC_COIN = '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC'
|
||||
const axios = require('axios')
|
||||
|
||||
const VAULTS = [
|
||||
'0x6e53ffe5b77a85ff609b0813955866ec98a072e4aaf628108e717143ec907bd8',
|
||||
'0x041b49dc6625e074f452b9bc60a9a828aebfbef29bcba119ad90a4b11ba405bf',
|
||||
'0xa97cc9a63710f905deb2da40d6548ce7a75ee3dfe4be0c1d553553d2059c31a3',
|
||||
'0x27936e146ec8c695d14a3b900d21a495d2396c0a99e3c6766f86d15fe91d3897',
|
||||
{ address: '0x6e53ffe5b77a85ff609b0813955866ec98a072e4aaf628108e717143ec907bd8', gecko_id: 'bitcoin' },
|
||||
{ address: '0x041b49dc6625e074f452b9bc60a9a828aebfbef29bcba119ad90a4b11ba405bf', gecko_id: 'okx-wrapped-btc' },
|
||||
{ address: '0xa97cc9a63710f905deb2da40d6548ce7a75ee3dfe4be0c1d553553d2059c31a3', gecko_id: 'usd-coin' },
|
||||
{ address: '0x27936e146ec8c695d14a3b900d21a495d2396c0a99e3c6766f86d15fe91d3897', gecko_id: 'usd-coin' },
|
||||
]
|
||||
|
||||
async function liquidStakingTVL() {
|
||||
const obj = await sui.getObject('0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5')
|
||||
const totalSuiSupply = +obj.fields.validator_pool.fields.total_sui_supply
|
||||
return totalSuiSupply
|
||||
const ENDPOINT = 'https://vault-api.volosui.com/api/v1/vaults'
|
||||
|
||||
const getVaults = async (api) => {
|
||||
const { data } = await axios.get(ENDPOINT)
|
||||
const vaults = data.data
|
||||
|
||||
for (const { id, totalStaked } of vaults) {
|
||||
const match = VAULTS.find(v => v.address.toLowerCase() === id.toLowerCase())
|
||||
if (match) api.addCGToken(match.gecko_id, totalStaked)
|
||||
}
|
||||
}
|
||||
|
||||
async function getVaultTVL(api) {
|
||||
for (const address of VAULTS) {
|
||||
const vaultObj = await sui.getObject(address);
|
||||
const assetsValueTableId = vaultObj.fields.assets_value.fields.id.id;
|
||||
const assetTypes = vaultObj.fields.asset_types;
|
||||
|
||||
let totalUsdValue = 0;
|
||||
|
||||
for (const assetType of assetTypes) {
|
||||
const assetValueObj = await sui.getDynamicFieldObject(
|
||||
assetsValueTableId,
|
||||
assetType,
|
||||
{ idType: '0x1::ascii::String' }
|
||||
);
|
||||
|
||||
totalUsdValue += +assetValueObj.fields.value;
|
||||
}
|
||||
|
||||
api.add(USDC_COIN, totalUsdValue / 1e3);
|
||||
}
|
||||
const getStakingTvl = async (api) => {
|
||||
const obj = await sui.getObject('0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5')
|
||||
const totalSuiSupply = +obj.fields.validator_pool.fields.total_sui_supply
|
||||
api.add('0x2::sui::SUI', totalSuiSupply)
|
||||
}
|
||||
|
||||
async function tvl(api) {
|
||||
api.add('0x2::sui::SUI', await liquidStakingTVL())
|
||||
await getVaultTVL(api)
|
||||
const tvl = async (api) => {
|
||||
await getStakingTvl(api)
|
||||
await getVaults(api)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
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.",
|
||||
misrepresentedTokens: true,
|
||||
sui: {
|
||||
tvl: tvl,
|
||||
},
|
||||
}
|
||||
|
||||
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.",
|
||||
misrepresentedTokens: true,
|
||||
sui: { tvl }
|
||||
}
|
||||
Reference in New Issue
Block a user