UNPKG

@byzantine/vault-sdk

Version:

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

680 lines (679 loc) 30.3 kB
/** * ByzantineClient * * Client for interacting with the Byzantine contract * Provides methods to create different types of vaults: * - Eigenlayer ERC20 vaults * - Eigenlayer Native vaults * - Symbiotic ERC20 vaults * - SuperVault ERC20 vaults */ import { ethers, TransactionResponse } from "ethers"; import { ByzantineClientOptions, EigenlayerVault, NativeEigenlayerVault, SymbioticVault, SuperVault, ChainsOptions, Metadata, RestakingProtocol, DelegatorType } from "../types"; import { RoleType } from "./curators"; export declare class ByzantineClient { private provider; private signer?; private readonly publicClient?; readonly chainId: ChainsOptions; readonly contractAddress: string; private contract; private depositClient; private withdrawClient; private eigenLayerClient; private symbioticClient; private vaultTypeClient; private accessControlClient; /** * Initialize a new ByzantineClient * @param options Client configuration options */ constructor(options: ByzantineClientOptions); /** * Create an Eigenlayer ERC20 vault * @param params The vault parameters * @param options Optional transaction options to override defaults * @returns Transaction response */ createEigenlayerERC20Vault(params: EigenlayerVault, options?: Partial<ethers.TransactionRequest>): Promise<TransactionResponse>; /** * Create an Eigenlayer Native vault * @param params The vault parameters * @param options Optional transaction options to override defaults * @returns Transaction response */ createEigenlayerNativeVault(params: NativeEigenlayerVault, options?: Partial<ethers.TransactionRequest>): Promise<TransactionResponse>; /** * Create a Symbiotic ERC20 vault * @param params The vault parameters * @param options Optional transaction options to override defaults * @returns Transaction response */ createSymbioticERC20Vault(params: SymbioticVault, options?: Partial<ethers.TransactionRequest>): Promise<TransactionResponse>; /** * Create a SuperVault ERC20 vault * @param params The vault parameters * @param options Optional transaction options to override defaults * @returns Transaction response */ createSuperVaultERC20(params: SuperVault, options?: Partial<ethers.TransactionRequest>): Promise<TransactionResponse>; /** * Set the token to Eigen strategy mapping * @param tokens The array of ERC20 token addresses * @param strategies The array of EigenLayer strategy addresses * @param options Optional transaction options * @returns Transaction response */ setTokenToEigenStrategy(tokens: string[], strategies: string[], options?: Partial<ethers.TransactionRequest>): Promise<TransactionResponse>; /** * Get a vault contract instance * @param vaultAddress The address of the vault * @returns Vault contract instance */ getVaultContract(vaultAddress: string): ethers.Contract; /** * Check if an address is whitelisted for a vault * @param vaultAddress The address of the vault * @param address The address to check * @returns True if the address is whitelisted */ isAddressWhitelisted(vaultAddress: string, address: string): Promise<boolean>; /** * Check if a vault is private * @param vaultAddress The address of the vault * @returns True if the vault is private */ isVaultPrivate(vaultAddress: string): Promise<boolean>; /** * Set whitelist status for multiple addresses * @param vaultAddress The address of the vault * @param addresses The addresses to update * @param canDeposit Whether the addresses can deposit * @returns Transaction response */ setAddressesWhitelistStatus(vaultAddress: string, addresses: string[], canDeposit: boolean): Promise<TransactionResponse>; /** * Set the private status of a vault * @param vaultAddress The address of the vault * @param isPrivate Whether the vault should be private * @returns Transaction response */ setVaultPrivateStatus(vaultAddress: string, isPrivate: boolean): Promise<TransactionResponse>; /** * Get the deposit limit of a vault * @param vaultAddress The address of the vault * @returns The deposit limit */ getVaultDepositLimit(vaultAddress: string): Promise<bigint>; /** * Check if a vault has a deposit limit enabled * @param vaultAddress The address of the vault * @returns True if the vault has a deposit limit */ isDepositLimitEnabled(vaultAddress: string): Promise<boolean>; /** * Set the deposit limit for a vault * @param vaultAddress The address of the vault * @param limit The new deposit limit * @returns Transaction response */ setVaultDepositLimit(vaultAddress: string, limit: bigint): Promise<TransactionResponse>; /** * Enable or disable deposit limits for a vault * @param vaultAddress The address of the vault * @param enabled Whether deposit limits should be enabled * @returns Transaction response */ setDepositLimitStatus(vaultAddress: string, enabled: boolean): Promise<TransactionResponse>; /** * Get the metadata of a vault * @param vaultAddress The address of the vault * @returns The metadata object * * @example * // Get vault metadata * const metadata = await byzantineClient.getVaultMetadata("0x123..."); * console.log(metadata.name); // "My Vault" * console.log(metadata.description); // "This is a description of my vault" * console.log(metadata.image); // "https://example.com/image.png" */ getVaultMetadata(vaultAddress: string): Promise<Metadata>; /** * Update the metadata of a vault * @param vaultAddress The address of the vault * @param metadata The new metadata object, or URI * @returns Transaction response * * @example * // Update vault metadata * const metadata = { * name: "My Vault", * description: "An updated description of my vault", * image_url: "https://example.com/new-image.png", * social_twitter: "https://x.com/byzantine_fi", * social_discord: "https://discord.gg/byzantine", * social_telegram: "https://t.me/byzantine", * social_website: "https://byzantine.fi", * social_github: "https://github.com/Byzantine-Finance/", * }; * * * const tx = await byzantineClient.updateVaultMetadata("0x123...", metadata); * await tx.wait(); */ updateVaultMetadata(vaultAddress: string, metadata: Metadata | string): Promise<TransactionResponse>; /** * Get the curator fee of a vault * @param vaultAddress The address of the vault * @returns The curator fee in basis points, e.g. 1.4% = 140 */ getCuratorFee(vaultAddress: string): Promise<bigint>; /** * Get the unclaimed fees of a vault * @param vaultAddress The address of the vault * @returns The unclaimed fees */ getUnclaimedFees(vaultAddress: string): Promise<bigint>; /** * Set the curator fee for a vault. Max is 10_000 (100%) * @param vaultAddress The address of the vault * @param newFee The new curator fee in basis points, e.g. 1.4% = 140 * @returns Transaction response */ setCuratorFee(vaultAddress: string, newFee: bigint): Promise<TransactionResponse>; /** * Claim the fees from a vault * @param vaultAddress The address of the vault * @returns Transaction response */ claimVaultFees(vaultAddress: string): Promise<TransactionResponse>; /** * Get the distribution ratio of a supervault * @param supervaultAddress The address of the supervault * @returns The distribution ratio */ getDistributionRatio(supervaultAddress: string): Promise<bigint>; /** * Get the underlying vaults of a supervault * @param supervaultAddress The address of the supervault * @returns The underlying vault addresses */ getUnderlyingVaults(supervaultAddress: string): Promise<string[]>; /** * Update the distribution ratio of a supervault * @param supervaultAddress The address of the supervault * @param ratio The new distribution ratio * @returns Transaction response */ updateDistributionRatio(supervaultAddress: string, ratio: bigint): Promise<TransactionResponse>; /** * Force a rebalance of a supervault * @param supervaultAddress The address of the supervault * @returns Transaction response */ forceRebalance(supervaultAddress: string): Promise<TransactionResponse>; /** * Check if the vault's shares are tokenized * @param vaultAddress The address of the vault * @returns True if shares can be transferred like ERC20 tokens */ isSharesTokenized(vaultAddress: string): Promise<boolean>; /** * Get the name of the vault share token * @param vaultAddress The address of the vault * @returns The name of the share token */ getSharesName(vaultAddress: string): Promise<string>; /** * Get the symbol of the vault share token * @param vaultAddress The address of the vault * @returns The symbol of the share token */ getSharesSymbol(vaultAddress: string): Promise<string>; /** * Get the total supply of vault shares * @param vaultAddress The address of the vault * @returns The total supply of shares */ getTotalShares(vaultAddress: string): Promise<bigint>; /** * Get the balance of shares for a specific address * @param vaultAddress The address of the vault * @param userAddress The address to check balance for * @returns The balance of shares for the address */ getSharesBalance(vaultAddress: string, userAddress: string): Promise<bigint>; /** * Convert a given amount of assets to shares * @param vaultAddress The address of the vault * @param assets The amount of assets to convert * @returns The equivalent amount of shares */ convertToShares(vaultAddress: string, assets: bigint): Promise<bigint>; /** * Convert a given amount of shares to assets * @param vaultAddress The address of the vault * @param shares The amount of shares to convert * @returns The equivalent amount of assets */ convertToAssets(vaultAddress: string, shares: bigint): Promise<bigint>; /** * Get the asset address of a vault * @param vaultAddress The address of the vault * @returns The asset address */ getVaultAsset(vaultAddress: string): Promise<string>; /** * Get the balance of assets in a user's wallet * @param assetAddress The address of the asset * @param userAddress The address of the user * @returns The user's wallet balance */ getUserWalletBalance(assetAddress: string, userAddress: string): Promise<bigint>; /** * Get the balance of a user in a vault * @param vaultAddress The address of the vault * @param userAddress The address of the user * @returns The user's vault balance */ getUserVaultBalance(vaultAddress: string, userAddress: string): Promise<bigint>; /** * Get the total value locked in a vault * @param vaultAddress The address of the vault * @returns The total value locked */ getVaultTVL(vaultAddress: string): Promise<bigint>; /** * Get the allowance of a user for a vault * @param assetAddress The address of the asset * @param userAddress The address of the user * @param vaultAddress The address of the vault * @returns The user's allowance */ getUserAllowance(assetAddress: string, userAddress: string, vaultAddress: string): Promise<bigint>; /** * Approve a vault to spend user's tokens * @param assetAddress The address of the asset * @param vaultAddress The address of the vault * @param amount The amount to approve * @returns Transaction response */ approveVault(assetAddress: string, vaultAddress: string, amount: bigint): Promise<TransactionResponse>; /** * Deposit assets into a vault * @param vaultAddress The address of the vault * @param amount The amount to deposit * @param autoApprove Whether to automatically approve if needed, false by default * @returns Transaction response */ depositToVault(vaultAddress: string, amount: bigint, autoApprove?: boolean): Promise<TransactionResponse>; /** * Withdraw assets from a vault * @param vaultAddress The address of the vault * @param amount The amount of assets to withdraw * @returns Transaction response */ withdrawFromVault(vaultAddress: string, amount: bigint): Promise<TransactionResponse>; /** * Redeem shares from a vault * @param vaultAddress The address of the vault * @param shares The amount of shares to redeem * @returns Transaction response */ redeemSharesFromVault(vaultAddress: string, shares: bigint): Promise<TransactionResponse>; /** * Check if a withdrawal request is claimable * @param vaultAddress The address of the vault * @param requestId The ID of the withdrawal request * @returns True if the request is claimable */ isClaimable(vaultAddress: string, requestId: string): Promise<boolean>; /** * Complete a withdrawal request * @param vaultAddress The address of the vault * @param requestId The ID of the withdrawal request * @returns Transaction response */ completeWithdrawal(vaultAddress: string, requestId: string): Promise<TransactionResponse>; /** * Get a withdrawal request * @param vaultAddress The address of the vault * @param requestId The ID of the withdrawal request * @returns Transaction response */ getWithdrawalRequest(vaultAddress: string, requestId: string): Promise<ethers.TransactionResponse>; /** * Get the Eigen Operator of a vault * @param vaultAddress The address of the vault * @returns The Eigen Operator */ getEigenOperator(vaultAddress: string): Promise<string>; /** * Set the Eigen Operator of a vault * @param vaultAddress The address of the vault * @param operator The new Eigen Operator * @param approverSignatureAndExpiry The signature and expiry for the approver * @param approverSalt The salt for the approver * @param options Optional transaction parameters like gas limit, gas price, etc. * @returns Transaction response */ setEigenOperator(vaultAddress: string, operator: string, approverSignatureAndExpiry: { signature: string; expiry: number; }, approverSalt: string, options?: Partial<ethers.TransactionRequest>): Promise<TransactionResponse>; /** * Get the epoch at a specific timestamp for a Symbiotic vault * @param vaultAddress The address of the vault * @param timestamp The timestamp to check * @returns The epoch number */ getEpochAt(vaultAddress: string, timestamp: number): Promise<number>; /** * Get the epoch duration for a Symbiotic vault * @param vaultAddress The address of the vault * @returns The epoch duration */ getEpochDuration(vaultAddress: string): Promise<number>; /** * Get the current epoch for a Symbiotic vault * @param vaultAddress The address of the vault * @returns The current epoch number */ getCurrentEpoch(vaultAddress: string): Promise<number>; /** * Get the start timestamp of the current epoch for a Symbiotic vault * @param vaultAddress The address of the vault * @returns The start timestamp of the current epoch */ getCurrentEpochStart(vaultAddress: string): Promise<number>; /** * Get the start timestamp of the previous epoch for a Symbiotic vault * @param vaultAddress The address of the vault * @returns The start timestamp of the previous epoch */ getPreviousEpochStart(vaultAddress: string): Promise<number>; /** * Get the start timestamp of the next epoch for a Symbiotic vault * @param vaultAddress The address of the vault * @returns The start timestamp of the next epoch */ getNextEpochStart(vaultAddress: string): Promise<number>; /** * Get the sym vault address of a Symbiotic vault * @param vaultAddress The address of the vault * @returns The sym vault address */ getSymVaultAddress(vaultAddress: string): Promise<string>; /** * Get the delegator address of a Symbiotic vault * @param vaultAddress The address of the vault * @returns The delegator address */ getDelegatorAddress(vaultAddress: string): Promise<string>; /** * Get the slasher address of a Symbiotic vault * @param vaultAddress The address of the vault * @returns The slasher address */ getSlasherAddress(vaultAddress: string): Promise<string>; /** * Get the burner address of a Symbiotic vault * @param vaultAddress The address of the vault * @returns The burner address */ getBurnerAddress(vaultAddress: string): Promise<string>; /** * Get the delegator operator for a vault * @param vaultAddress The address of the vault * @returns The delegator operator */ getDelegatorOperator(vaultAddress: string): Promise<string>; /** * Get the delegator network for a vault * @param vaultAddress The address of the vault * @returns The delegator network */ getDelegatorNetwork(vaultAddress: string): Promise<string>; /** * Get the delegator type of a Symbiotic vault * @param vaultAddress The address of the vault * @returns The delegator type */ getDelegatorType(vaultAddress: string): Promise<DelegatorType>; /** * Check if a vault is a Symbiotic vault * @param vaultAddress The address of the vault to check * @returns True if the vault is a Symbiotic vault, false otherwise */ isSymbioticVault(vaultAddress: string): Promise<boolean>; /** * Check if a vault is an EigenLayer vault * @param vaultAddress The address of the vault to check * @returns True if the vault is an EigenLayer vault, false otherwise */ isEigenVault(vaultAddress: string): Promise<boolean>; /** * Check if a vault is a SuperVault * @param vaultAddress The address of the vault to check * @returns True if the vault is a SuperVault, false otherwise */ isSupervault(vaultAddress: string): Promise<boolean>; /** * Get the type of vault * @param vaultAddress The address of the vault to check * @returns The type of the vault (Symbiotic, EigenLayer, Supervault), or undefined if unknown */ getVaultType(vaultAddress: string): Promise<RestakingProtocol | undefined>; /** * Check if a user has a specific role * @param vaultAddress The address of the vault * @param roleType The role type * @param address The address of the user to check * @returns True if the user has the role, false otherwise */ isManager(vaultAddress: string, roleType: RoleType, address: string): Promise<boolean>; /** * Set a manager for a vault * @param vaultAddress The address of the vault * @param roleType The role type * @param address The address of the user to set the role for * @param enable True to grant the role, false to revoke it * @returns Transaction response */ setManager(vaultAddress: string, roleType: RoleType, address: string, enable: boolean): Promise<TransactionResponse>; /** * Check if a user has the default admin role * @param vaultAddress The address of the vault to check * @param userAddress The address of the user to check * @returns True if the user has the default admin role */ isRoleManager(vaultAddress: string, userAddress: string): Promise<boolean>; /** * Grant or revoke the role manager role for a user * @param vaultAddress The address of the vault to modify * @param userAddress The address of the user to grant/revoke the role for * @param enable True to grant the role, false to revoke it * @returns Transaction response from the blockchain */ setRoleManager(vaultAddress: string, userAddress: string, enable: boolean): Promise<TransactionResponse>; /** * Check if a user has the validators manager role * @param vaultAddress The address of the vault to check * @param userAddress The address of the user to check * @returns True if the user has the validators manager role */ isValidatorsManager(vaultAddress: string, userAddress: string): Promise<boolean>; /** * Grant or revoke the validators manager role for a user * @param vaultAddress The address of the vault to modify * @param userAddress The address of the user to grant/revoke the role for * @param enable True to grant the role, false to revoke it * @returns Transaction response from the blockchain */ setValidatorsManager(vaultAddress: string, userAddress: string, enable: boolean): Promise<TransactionResponse>; /** * Check if a user has the version manager role * @param vaultAddress The address of the vault to check * @param userAddress The address of the user to check * @returns True if the user has the version manager role */ isVersionManager(vaultAddress: string, userAddress: string): Promise<boolean>; /** * Grant or revoke the version manager role for a user * @param vaultAddress The address of the vault to modify * @param userAddress The address of the user to grant/revoke the role for * @param enable True to grant the role, false to revoke it * @returns Transaction response from the blockchain */ setVersionManager(vaultAddress: string, userAddress: string, enable: boolean): Promise<TransactionResponse>; /** * Check if a user has the whitelist manager role * @param vaultAddress The address of the vault to check * @param userAddress The address of the user to check * @returns True if the user has the whitelist manager role */ isWhitelistManager(vaultAddress: string, userAddress: string): Promise<boolean>; /** * Grant or revoke the whitelist manager role for a user * @param vaultAddress The address of the vault to modify * @param userAddress The address of the user to grant/revoke the role for * @param enable True to grant the role, false to revoke it * @returns Transaction response from the blockchain */ setWhitelistManager(vaultAddress: string, userAddress: string, enable: boolean): Promise<TransactionResponse>; /** * Check if a user has the limit manager role * @param vaultAddress The address of the vault to check * @param userAddress The address of the user to check * @returns True if the user has the limit manager role */ isLimitManager(vaultAddress: string, userAddress: string): Promise<boolean>; /** * Grant or revoke the limit manager role for a user * @param vaultAddress The address of the vault to modify * @param userAddress The address of the user to grant/revoke the role for * @param enable True to grant the role, false to revoke it * @returns Transaction response from the blockchain */ setLimitManager(vaultAddress: string, userAddress: string, enable: boolean): Promise<TransactionResponse>; /** * Check if a user has the delegation manager role * @param vaultAddress The address of the vault to check * @param userAddress The address of the user to check * @returns True if the user has the delegation manager role */ isDelegationManager(vaultAddress: string, userAddress: string): Promise<boolean>; /** * Grant or revoke the delegation manager role for a user * @param vaultAddress The address of the vault to modify * @param userAddress The address of the user to grant/revoke the role for * @param enable True to grant the role, false to revoke it * @returns Transaction response from the blockchain */ setDelegationManager(vaultAddress: string, userAddress: string, enable: boolean): Promise<TransactionResponse>; /** * Check if a user has the operator network shares manager role * @param vaultAddress The address of the vault to check * @param userAddress The address of the user to check * @returns True if the user has the operator network shares manager role */ isOperatorNetworkSharesManager(vaultAddress: string, userAddress: string): Promise<boolean>; /** * Grant or revoke the operator network shares manager role for a user * @param vaultAddress The address of the vault to modify * @param userAddress The address of the user to grant/revoke the role for * @param enable True to grant the role, false to revoke it * @returns Transaction response from the blockchain */ setOperatorNetworkSharesManager(vaultAddress: string, userAddress: string, enable: boolean): Promise<TransactionResponse>; /** * Check if a user has the operator network limit manager role * @param vaultAddress The address of the vault to check * @param userAddress The address of the user to check * @returns True if the user has the operator network limit manager role */ isOperatorNetworkLimitManager(vaultAddress: string, userAddress: string): Promise<boolean>; /** * Grant or revoke the operator network limit manager role for a user * @param vaultAddress The address of the vault to modify * @param userAddress The address of the user to grant/revoke the role for * @param enable True to grant the role, false to revoke it * @returns Transaction response from the blockchain */ setOperatorNetworkLimitManager(vaultAddress: string, userAddress: string, enable: boolean): Promise<TransactionResponse>; /** * Check if a user has the network limit manager role * @param vaultAddress The address of the vault to check * @param userAddress The address of the user to check * @returns True if the user has the network limit manager role */ isNetworkLimitManager(vaultAddress: string, userAddress: string): Promise<boolean>; /** * Grant or revoke the network limit manager role for a user * @param vaultAddress The address of the vault to modify * @param userAddress The address of the user to grant/revoke the role for * @param enable True to grant the role, false to revoke it * @returns Transaction response from the blockchain */ setNetworkLimitManager(vaultAddress: string, userAddress: string, enable: boolean): Promise<TransactionResponse>; /** * Check if a user has the curator role * @param vaultAddress The address of the vault to check * @param userAddress The address of the user to check * @returns True if the user has the curator role */ isCurator(vaultAddress: string, userAddress: string): Promise<boolean>; /** * Grant or revoke the curator role for a user * @param vaultAddress The address of the vault to modify * @param userAddress The address of the user to grant/revoke the role for * @param enable True to grant the role, false to revoke it * @returns Transaction response from the blockchain */ setCurator(vaultAddress: string, userAddress: string, enable: boolean): Promise<TransactionResponse>; /** * Check if a user has the curator fee claimer role * @param vaultAddress The address of the vault to check * @param userAddress The address of the user to check * @returns True if the user has the curator fee claimer role */ isCuratorFeeClaimer(vaultAddress: string, userAddress: string): Promise<boolean>; /** * Grant or revoke the curator fee claimer role for a user * @param vaultAddress The address of the vault to modify * @param userAddress The address of the user to grant/revoke the role for * @param enable True to grant the role, false to revoke it * @returns Transaction response from the blockchain */ setCuratorFeeClaimer(vaultAddress: string, userAddress: string, enable: boolean): Promise<TransactionResponse>; /** * Check if a user has the curator fee claimer admin role * @param vaultAddress The address of the vault to check * @param userAddress The address of the user to check * @returns True if the user has the curator fee claimer admin role */ isCuratorFeeClaimerAdmin(vaultAddress: string, userAddress: string): Promise<boolean>; /** * Grant or revoke the curator fee claimer admin role for a user * @param vaultAddress The address of the vault to modify * @param userAddress The address of the user to grant/revoke the role for * @param enable True to grant the role, false to revoke it * @returns Transaction response from the blockchain */ setCuratorFeeClaimerAdmin(vaultAddress: string, userAddress: string, enable: boolean): Promise<TransactionResponse>; /** * Check if a user has the owner burner role * @param vaultAddress The address of the vault to check * @param userAddress The address of the user to check * @returns True if the user has the owner burner role */ isOwnerBurner(vaultAddress: string, userAddress: string): Promise<boolean>; /** * Grant or revoke the owner burner role for a user * @param vaultAddress The address of the vault to modify * @param userAddress The address of the user to grant/revoke the role for * @param enable True to grant the role, false to revoke it * @returns Transaction response from the blockchain */ setOwnerBurner(vaultAddress: string, userAddress: string, enable: boolean): Promise<TransactionResponse>; }