UNPKG

@byzantine/vault-sdk

Version:

Byzantine Vault SDK for creating and managing vaults on Ethereum for restaking strategies

74 lines (73 loc) 2.84 kB
"use strict"; // Functions for interacting with vault share information // Get isTokenized - Whether the vault's shares can be transferred like ERC20 tokens // Get name - The name of the vault share token // Get symbol - The symbol of the vault share token Object.defineProperty(exports, "__esModule", { value: true }); exports.isTokenized = isTokenized; exports.getSharesName = getSharesName; exports.getSharesSymbol = getSharesSymbol; exports.getTotalShares = getTotalShares; exports.getSharesBalance = getSharesBalance; exports.convertToShares = convertToShares; exports.convertToAssets = convertToAssets; const utils_1 = require("../../utils"); /** * Check if the vault's shares are tokenized (transferable like ERC20) * @param vaultContract - The vault contract instance * @returns True if the vault's shares are tokenized */ async function isTokenized(vaultContract) { return await (0, utils_1.callContractMethod)(vaultContract, "isTokenized"); } /** * Get the name of the vault share token * @param vaultContract - The vault contract instance * @returns The name of the vault share token */ async function getSharesName(vaultContract) { return await (0, utils_1.callContractMethod)(vaultContract, "name"); } /** * Get the symbol of the vault share token * @param vaultContract - The vault contract instance * @returns The symbol of the vault share token */ async function getSharesSymbol(vaultContract) { return await (0, utils_1.callContractMethod)(vaultContract, "symbol"); } /** * Get the total supply of vault shares * @param vaultContract - The vault contract instance * @returns The total supply of shares */ async function getTotalShares(vaultContract) { return await (0, utils_1.callContractMethod)(vaultContract, "totalSupply"); } /** * Get the balance of shares for a specific address * @param vaultContract - The vault contract instance * @param address - The address to check * @returns The balance of shares for the address */ async function getSharesBalance(vaultContract, address) { return await (0, utils_1.callContractMethod)(vaultContract, "balanceOf", address); } /** * Convert a given amount of assets to shares * @param vaultContract - The vault contract instance * @param assets - The amount of assets to convert * @returns The equivalent amount of shares */ async function convertToShares(vaultContract, assets) { return await (0, utils_1.callContractMethod)(vaultContract, "convertToShares", assets); } /** * Convert a given amount of shares to assets * @param vaultContract - The vault contract instance * @param shares - The amount of shares to convert * @returns The equivalent amount of assets */ async function convertToAssets(vaultContract, shares) { return await (0, utils_1.callContractMethod)(vaultContract, "convertToAssets", shares); }