Skip to content

Add Pool.getPositionCount() and get_position_count script#270

Draft
vishalchangrani wants to merge 1 commit intov0from
vishal/get-position-count
Draft

Add Pool.getPositionCount() and get_position_count script#270
vishalchangrani wants to merge 1 commit intov0from
vishal/get-position-count

Conversation

@vishalchangrani
Copy link
Contributor

Summary

  • Adds getPositionCount() : Int as a public view function on the Pool resource in FlowALPv0.cdc, returning self.positions.length
  • Adds cadence/scripts/flow-alp/get_position_count.cdc — a Cadence script that resolves the Pool from the protocol account and returns the count
  • Adds cadence/tests/get_position_count_test.cdc covering: zero count on a fresh pool, and correct increment as positions are opened

Context

This is needed for the FCM Observer to be able to query the total number of active positions in the Pool without requiring any off-chain event indexing or privileged access.

Test plan

  • test_position_count_is_zero_initially — asserts count is 0 before any positions are opened
  • test_position_count_reflects_open_positions — opens 2 positions across 2 users, asserts count increments correctly to 1 then 2

🤖 Generated with Claude Code

Expose the total number of active positions in the FlowALPv0 Pool via a
new public view getter on the Pool resource, and a corresponding Cadence
script for off-chain querying.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant