Skip to content

feat: market token NAV price view — USD value per GM token #276

Description

@abayomicornelius

Summary

LPs and the frontend need to know the current USD price per market (GM) token to display portfolio value and compute withdrawal amounts. Add a dedicated view to reader.

Proposed API

pub fn get_market_token_price(
    env: Env,
    data_store: Address,
    oracle: Address,
    market: Address,
    maximize: bool,     // use max oracle price (for minting) or min (for burning)
) -> u128              // USD price per 1 market token, FLOAT_PRECISION scaled

Implementation Notes

  • nav = get_pool_value(market, maximize) / market_token.total_supply()
  • Handle zero-supply edge case (no market tokens outstanding) — return a seed price
  • maximize = true uses oracle max prices (conservative for minting)
  • maximize = false uses oracle min prices (conservative for burning)

Acceptance Criteria

  • Returns correct NAV for a single-asset pool
  • Returns correct NAV for a multi-asset imbalanced pool
  • Zero-supply case returns configured seed price without panic
  • Unit test: deposit 10,000 USD, supply = 10,000 GM, price = 1.00 USD
  • Unit test: after 200 USD in fees, price = 1.02 USD

Affected Contracts

reader, market_utils

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions