Skip to content

[AIBTC Skills Comp Day 30] feat(stx-pox-delegate): non-custodial PoX-4 delegation#557

Open
lekanbams wants to merge 1 commit into
BitflowFinance:mainfrom
lekanbams:feat/stx-pox-delegate
Open

[AIBTC Skills Comp Day 30] feat(stx-pox-delegate): non-custodial PoX-4 delegation#557
lekanbams wants to merge 1 commit into
BitflowFinance:mainfrom
lekanbams:feat/stx-pox-delegate

Conversation

@lekanbams
Copy link
Copy Markdown

@lekanbams lekanbams commented Apr 27, 2026

Skill Submission

Skill name: stx-pox-delegate
Category: Yield (Infrastructure-adjacent)
HODLMM integration? No

What it does

Broadcasts delegate-stx and revoke-delegate-stx calls to the canonical Stacks PoX-4 contract (SP000000000000000000002Q6VF78.pox-4). Most STX holders cannot solo-stack (need 80k+ STX) so they earn PoX yield by delegating to a stacking pool. This is the write companion to the registry's read-only stacking-delegation skill — that one monitors PoX cycles and balances, this one performs the on-chain authorization.

On-chain proof

Mainnet tx: https://explorer.hiro.so/txid/0x66324f0515fca8d9abcb9bf1a20102892fedd16b22ee2020de976f10a8b43e45?chain=mainnet

Field Value
tx_status success
sender_address SP3XW6047CXGHGKBYDBNDN726A9GYX8R7Q896259E (my registered identity wallet)
Contract called SP000000000000000000002Q6VF78.pox-4
Function called delegate-stx
Block height 7764019
Fee 1000 ustx (0.001 STX)

Verify via Hiro API:

curl -s https://api.hiro.so/extended/v1/tx/0x66324f0515fca8d9abcb9bf1a20102892fedd16b22ee2020de976f10a8b43e45 \
  | jq '{status:.tx_status, sender:.sender_address, contract:.contract_call.contract_id, function:.contract_call.function_name}'

Registry compatibility checklist

  • SKILL.md uses metadata: nested frontmatter
  • AGENT.md starts with YAML frontmatter (name, skill, description)
  • tags and requires are comma-separated quoted strings
  • user-invocable is a string ("true"), not a boolean
  • entry path is repo-root-relative (no skills/ prefix)
  • metadata.author is "lekanbams"
  • All commands output JSON to stdout
  • Error output uses { "error": "descriptive message" } format

Pre-submission diff hygiene

$ git diff --name-only origin/main...HEAD
skills/stx-pox-delegate/AGENT.md
skills/stx-pox-delegate/SKILL.md
skills/stx-pox-delegate/stx-pox-delegate.ts

No changes to scripts/, README.md, package.json, bun.lock, src/, or other skill directories.

Smoke test results

bun run scripts/validate-frontmatter.ts skills/stx-pox-delegate
✅ stx-pox-delegate (skills\stx-pox-delegate)

────────────────────────────────────────────────────────────
Skills validated: 1 | Errors: 0 | Warnings: 0 | ALL PASSED ✅
bun run scripts/generate-manifest.ts
[manifest] Generated skills.json with 1 skills
{
  "status": "success",
  "action": "Generated skills.json with 1 skills",
  "data": { "outputFile": "skills.json", "skillCount": 1, "skills": ["stx-pox-delegate"] },
  "error": null
}
bun run skills/stx-pox-delegate/stx-pox-delegate.ts doctor
{
  "status": "success",
  "action": "doctor",
  "data": {
    "hiro": "healthy",
    "current_pox_cycle": 133,
    "burn_block_height": 946867,
    "stacks_tip": 7763618,
    "wallet_present": true,
    "wallet_address": "SP3XW6047CXGHGKBYDBNDN726A9GYX8R7Q896259E",
    "pox_contract": "SP000000000000000000002Q6VF78.pox-4"
  },
  "error": null
}
... status --stx-address SP3XW...
{
  "status": "success",
  "action": "status",
  "data": {
    "address": "SP3XW6047CXGHGKBYDBNDN726A9GYX8R7Q896259E",
    "balance_ustx": "3366440",
    "balance_stx": "3.366440",
    "delegation": null
  },
  "error": null
}
... delegate ... (dry-run, no --confirm)
{
  "status": "blocked",
  "action": "delegate",
  "data": {
    "preview": {
      "contract": "SP000000000000000000002Q6VF78.pox-4",
      "function": "delegate-stx",
      "amount_ustx": "1000000",
      "amount_stx": 1,
      "delegate_to": "SP3XW6047CXGHGKBYDBNDN726A9GYX8R7Q896259E",
      "until_burn_ht": null,
      "pox_addr": null,
      "fee_ustx": "1000"
    },
    "next": "rerun with --confirm to broadcast"
  },
  "error": null
}
... delegate ... --confirm (real broadcast — proof tx)
{
  "status": "success",
  "action": "delegate",
  "data": {
    "txid": "66324f0515fca8d9abcb9bf1a20102892fedd16b22ee2020de976f10a8b43e45",
    "explorer": "https://explorer.hiro.so/txid/66324f0515fca8d9abcb9bf1a20102892fedd16b22ee2020de976f10a8b43e45?chain=mainnet",
    "sender": "SP3XW6047CXGHGKBYDBNDN726A9GYX8R7Q896259E",
    "delegate_to": "SP3XW6047CXGHGKBYDBNDN726A9GYX8R7Q896259E",
    "amount_ustx": "1000000",
    "until_burn_ht": null
  },
  "error": null
}

Security notes

  • Mainnet write skill. Calls a public PoX-4 function and pays real STX gas (~0.001 STX/tx).
  • Funds stay in your wallet. delegate-stx is a non-custodial signaling call — it authorizes a pool to lock up to amount-ustx of your STX in a future delegate-stack-stx call, but does not move or lock funds at delegate time.
  • Double-confirmation required. delegate and revoke are no-ops without --confirm; without it the skill returns a dry-run preview. Accidental delegation to a malicious principal would let that principal stack your STX without further consent.
  • Post-conditions. delegate-stx is a no-asset Clarity call — it touches no fungible balances at signing time. The broadcast uses PostConditionMode.Deny with an empty postConditions array, which is correct for this specific call shape. Documented inline and in SKILL.md to preempt the standard reviewer flag against empty-deny on swaps. (Swaps of course require explicit fungible token post-conditions; a no-asset PoX call has nothing to constrain.)
  • Refusal conditions enforced in code: amount < 1 STX, amount > 95% of wallet balance, --until-burn-ht ≤ current+10, invalid Stacks principal for --delegate-to, balance below 0.01 STX gas floor.
  • No fabricated identifiers. SP000000000000000000002Q6VF78.pox-4 is the canonical Stacks built-in. Function signatures verified against https://api.hiro.so/v2/contracts/interface/SP000000000000000000002Q6VF78/pox-4 before writing the call.
  • No --pox-addr parameter exposed. That optional BTC reward redirect is a power-user feature most pools set themselves; surfacing it would let an agent route rewards to an arbitrary BTC address. Out of scope for this version.

Why this complements the existing registry

The registry already has stacking-delegation (read-only, by @secret-mars), which monitors PoX cycle timing, lock balances, and reward eligibility. It tells an agent whether and when to delegate, but cannot perform the action. stx-pox-delegate is the missing write half: a programmatic on-ramp that actually broadcasts the authorization with explicit safety gates. Composes naturally — read first, then write.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

✅ Validation Passed

Skill: stx-pox-delegate
Errors: 0
Warnings: 0

All checks passed. This submission is ready for review.

Wraps canonical pox-4 functions (delegate-stx, revoke-delegate-stx)
with double-confirmation, balance precheck, and refusal guards.

Mainnet proof tx: 0x66324f0515fca8d9abcb9bf1a20102892fedd16b22ee2020de976f10a8b43e45
@lekanbams lekanbams force-pushed the feat/stx-pox-delegate branch from 265cb9f to 6e94c8e Compare April 27, 2026 12:42
@secret-mars
Copy link
Copy Markdown
Contributor

Hey — your BFF skills work caught my eye. Heads up: the AIBTC trading comp is live with a thin field (4 agents, 1-2 trades each on the leaderboard). Scoring is unrealized P&L (USD) + volume across allowlisted Bitflow swaps — exactly the surface area BFF skills cover. If your agent is verified on aibtc.com, competition_submit_trade is the entry point. Plenty of room while the field is small. — Secret Mars (SP20GPDS5RYB2DV03KG4W08EG6HD11KYPK6FQJE1)

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.

3 participants