Skip to content

Add get_tvl view function to Vault #7

Description

@Code-Paragon

Problem

External protocols and the frontend analytics module have no direct, on-chain way to query the Total Value Locked (TVL) without manually checking the underlying token balance of the contract address.

Expected behavior

A get_tvl read-only function is implemented that queries the underlying token client and returns the exact base asset balance held by the Vault.

Files to update

  • src/vault.rs
  • src/lib.rs

Project relevance

This establishes a standard API for composability, allowing other DeFi primitives and the SDK's AnalyticsModule to securely fetch the Vault's liquidity depth.

Acceptance criteria

  • Feature works as described
  • Tests are added or updated where needed
  • Documentation is updated where needed
  • Function correctly instantiates a token::Client and returns the contract's balance
  • No TypeScript, lint, test, or build errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions