From c0074e75f3012a42cb8ad2fcec2a55e55f5670fe Mon Sep 17 00:00:00 2001 From: Wayne Kuo Date: Mon, 13 May 2024 13:54:29 +0800 Subject: [PATCH] Add typus v1 tvl --- projects/typus-finance/index.js | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/projects/typus-finance/index.js b/projects/typus-finance/index.js index e9ca02f4c9b3..a0cad661225b 100644 --- a/projects/typus-finance/index.js +++ b/projects/typus-finance/index.js @@ -2,6 +2,8 @@ const sui = require("../helper/chain/sui"); const SINGLE_DEPOSIT_VAULT_REGISTRY = "0xd67cf93a0df61b4b3bbf6170511e0b28b21578d9b87a8f4adafec96322dd284d"; const fud_token = "0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1::fud::FUD"; +const V1_SINGLE_DEPOSIT_VAULT_REGISTRY = "0x4ae62c4d67f9f5d7077626fcc6d450535c4df710da455a0a2bd2226558832629"; +const V1_SINGLE_BID_VAULT_REGISTRY = "0x2c8cdd00ced47e717420cd2fc54990b3b38e115e34a9209271063a59ddeeb059"; async function tvl(api) { const depositVaultFields = await sui.getDynamicFieldObjects({ @@ -31,6 +33,52 @@ async function tvl(api) { api.add(bid_token, fields.premium_share_supply); } }); + + // Add v1 vaults + + const v1depositVaultFields = await sui.getDynamicFieldObjects({ + parent: V1_SINGLE_DEPOSIT_VAULT_REGISTRY, + }); + + const v1depositVaultIds = v1depositVaultFields.map((item) => item.fields.id.id); + const v1depositVaults = await sui.getObjects(v1depositVaultIds); + + v1depositVaults.forEach( + ({ + type, + fields: { + value: { fields }, + }, + }) => { + const coin = type.replace(">>", "").split(", ")[2]; + api.add(coin, fields.active_sub_vault.fields.balance); + api.add(coin, fields.deactivating_sub_vault.fields.balance); + api.add(coin, fields.inactive_sub_vault.fields.balance); + api.add(coin, fields.warmup_sub_vault.fields.balance); + } + ); + + const v1bidVaultFields = await sui.getDynamicFieldObjects({ + parent: V1_SINGLE_BID_VAULT_REGISTRY, + }); + + const v1bidVaultIds = v1bidVaultFields.map((item) => item.fields.id.id); + + const v1bidVaults = await sui.getObjects(v1bidVaultIds); + + v1bidVaults.forEach( + ({ + type, + fields: { + value: { fields }, + }, + }) => { + const coin = type.replace(">>", "").split(", ")[2]; + api.add(coin, fields.bidder_sub_vault.fields.balance); + api.add(coin, fields.premium_sub_vault.fields.balance); + api.add(coin, fields.performance_fee_sub_vault.fields.balance); + } + ); } module.exports = {