Repository navigation
feat: add enrollment_cutoff to the bond schedule - #2713
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Fresh non-mainnet readonly deployments can publish incorrect mainnet-derived enrollment cutoffs.
1 open finding
What changed in this PR
Adds a derived bond enrollment cutoff to PoX-5 bond schedules across API resources and events.
Changes:
- Computes cutoff from PoX constants.
- Extends bond schemas and serializers.
- Adds endpoint and arithmetic tests.
| File | Description |
|---|---|
src/datastore/pox-constants.ts |
Adds cutoff calculation. |
src/api/serializers/v3/bonds.ts |
Serializes cutoff fields. |
src/api/schemas/v3/entities/bonds.ts |
Extends schedule schema. |
src/api/routes/v3/staking-bonds.ts |
Loads PoX constants for bond endpoints. |
tests/api/pox5/pox-constants.test.ts |
Tests cutoff arithmetic. |
tests/api/pox5/bonds.test.ts |
Tests list and detail responses. |
tests/api/pox5/bond-events.test.ts |
Tests setup-event schedules. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
rafa-stacks
marked this pull request as ready for review
October 8, 2026 18:54
bgridley-stacks
approved these changes
Oct 8, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds
schedule.enrollment_cutoffto bonds, so the BD team can see the last point at which stakers can enroll in a bond.It's the first Bitcoin height at which pox-5 rejects
register-for-bond. That's the start of the prepare phase in the cycle before the bond activates:bond_start_height - prepare_phase_block_length, in cyclefirst_reward_cycle - 1. Enrollment is open strictly before this height. On mainnet that's 100 blocks beforeactivation.GET /extended/v3/staking/bonds?limit=1{ "total": 1, "limit": 1, "cursor": { "next": null, "previous": null, "current": "0" }, "results": [ { "index": 0, "pox_version": "pox5", "status": "unlocked", "parameters": { "target_rate_bps": 300, "stx_value_ratio": 10000000, "minimum_stx_ratio": 1000, "btc_capacity": "105000000" }, "registrations": { "allowed_count": 2, "registered_count": 1 }, "schedule": { "enrollment_cutoff": { "bitcoin_height": 155, "pox_cycle": 7 }, "activation": { "bitcoin_height": 160, "pox_cycle": 8 }, "unlock": { "bitcoin_height": 410, "pox_cycle": 20 } }, "balances": { "locked": { "btc": "1000", "stx": "10000000" }, "rewards": { "btc": { "distributed": "0", "accrued": "0", "claimed": "0" } }, "paid_out": { "btc": "0" } } } ] }GET /extended/v3/staking/bonds/0{ "index": 0, "pox_version": "pox5", "status": "unlocked", "parameters": { "target_rate_bps": 300, "stx_value_ratio": 10000000, "minimum_stx_ratio": 1000, "btc_capacity": "105000000" }, "registrations": { "allowed_count": 2, "registered_count": 1 }, "schedule": { "enrollment_cutoff": { "bitcoin_height": 155, "pox_cycle": 7 }, "activation": { "bitcoin_height": 160, "pox_cycle": 8 }, "unlock": { "bitcoin_height": 410, "pox_cycle": 20 } }, "balances": { "locked": { "btc": "1000", "stx": "10000000" }, "rewards": { "btc": { "distributed": "0", "accrued": "0", "claimed": "0" } }, "paid_out": { "btc": "0" } }, "transaction": { "tx_id": "0x1111111111111111111111111111111111111111111111111111111111111111", "block": { "height": 1, "hash": "0x123456", "index_hash": "0xb1", "time": 94869287, "tx_index": 0 }, "bitcoin_block": { "height": 713000, "time": 94869286 } } }GET /extended/v3/staking/bonds/0/events?limit=50(setup-bond entry only){ "total": 4, "limit": 50, "cursor": { "next": null, "previous": null, "current": "1:0:1:0" }, "results": [ { "name": "setup-bond", "bond_index": 0, "transaction": { "tx_id": "0x1111111111111111111111111111111111111111111111111111111111111111", "event_index": 0 }, "block": { "height": 1, "hash": "0x123456", "index_hash": "0xb1", "time": 94869287, "tx_index": 0 }, "bitcoin_block": { "height": 1, "time": 94869286 }, "data": { "parameters": { "target_rate_bps": 300, "stx_value_ratio": 10000000, "minimum_stx_ratio": 1000 }, "early_unlock_bytes": "", "schedule": { "enrollment_cutoff": { "bitcoin_height": 155, "pox_cycle": 7 }, "activation": { "bitcoin_height": 160, "pox_cycle": 8 }, "unlock": { "bitcoin_height": 410, "pox_cycle": 20 } } } } ] }