Skip to content

feat: add enrollment_cutoff to the bond schedule - #2713

Merged
rafa-stacks merged 1 commit into
mainfrom
claude/enrollment-cutoff-bond-schedule-eb2f6d
Oct 8, 2026
Merged

rafa-stacks merged 1 commit into
mainfrom
claude/enrollment-cutoff-bond-schedule-eb2f6d

Conversation

@rafa-stacks

@rafa-stacks rafa-stacks commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Adds schedule.enrollment_cutoff to 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 cycle first_reward_cycle - 1. Enrollment is open strictly before this height. On mainnet that's 100 blocks before activation.

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
          }
        }
      }
    }
  ]
}

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread src/api/routes/v3/staking-bonds.ts Resolved
@rafa-stacks
rafa-stacks marked this pull request as ready for review October 8, 2026 18:54
@rafa-stacks
rafa-stacks merged commit 49675a9 into main Oct 8, 2026
27 checks passed
@rafa-stacks
rafa-stacks deleted the claude/enrollment-cutoff-bond-schedule-eb2f6d branch October 8, 2026 19:18

This branch was successfully deployed

1 active deployment
Production — 4ed07898 Deployed Oct 8, 2026 by rafa-stacks via build-publish #3828
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants