Skip to content

feat: get_claimable_funding_amount view for active position holders #275

Description

@abayomicornelius

Summary

Position holders cannot currently see how much funding they owe or are owed without simulating a position update. Add a read-only view that returns the pending funding amount for a given position.

Proposed API

// reader contract
pub fn get_claimable_funding_amount(
    env: Env,
    data_store: Address,
    oracle: Address,
    position_key: Bytes,
) -> FundingAmountResult
pub struct FundingAmountResult {
    pub long_token_amount: i128,  // positive = owed to holder, negative = holder owes
    pub short_token_amount: i128,
    pub at_ledger: u64,
}

Acceptance Criteria

  • View computes pending funding from current funding_amount_per_size minus position's last-settled index
  • Returns signed values: positive = receive, negative = pay
  • Does not modify any state
  • Unit test: verify returned amount matches what is deducted during actual position decrease
  • Frontend integration note: call before showing 'close position' confirmation

Affected Contracts

reader, position_utils

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    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