Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typus v1 tvl #10186

Merged
merged 1 commit into from
May 13, 2024
Merged
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: 48 additions & 0 deletions projects/typus-finance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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 = {
Expand Down
Loading