Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 43 additions & 5 deletions projects/volo-vsui/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const sui = require('../helper/chain/sui')
const axios = require("axios");
const ADDRESSES = require('../helper/coreAssets.json');

async function tvl() {
const naviApiURL = 'https://open-api.naviprotocol.io';

async function liquidStakingTVL() {
const nativePoolObj = await sui.getObject('0x7fa2faa111b8c65bea48a23049bfd81ca8f971a262d981dcd9a17c3825cb5baf');

const totalStakedValue = +(await sui.getDynamicFieldObject(
Expand All @@ -15,14 +19,48 @@ async function tvl() {

const totalStakedSui = totalStakedValue + totalPendingRewards - unstakeTicketsSupply;

return {
sui: totalStakedSui / 1e9,
return totalStakedSui;
}

async function getVaultTVL() {
const response = await axios.get(`${naviApiURL}/api/volo/volo-vaults?type=tvl`);

if (response.data && response.data.code === 0 && response.data.data) {
return response.data.data;
}

return {};
}

async function tvl(api) {
const lstTVL = await liquidStakingTVL();
api.add(ADDRESSES.sui.SUI, lstTVL);

const vaultData = await getVaultTVL();

for (const [tokenAddress, tvlValue] of Object.entries(vaultData)) {
if (tvlValue && tvlValue > 0) {
let adjustedValue = tvlValue;

if (tokenAddress.includes('usdc::USDC')) {
adjustedValue = tvlValue * 1e6;
} else if (tokenAddress.includes('xbtc::XBTC')) {
adjustedValue = tvlValue * 1e8;
} else if (tokenAddress.includes('btc::BTC')) {
adjustedValue = tvlValue * 1e8;
}

api.add(tokenAddress, adjustedValue);
}
}
}



module.exports = {
methodology: "Calculates the amount of SUI staked in Volo liquid staking contracts.",
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.",
sui: {
tvl,
tvl: tvl
}
}

Loading