fix(hodlmm-signal-allocator): validated configurable swap fee (was hardcoded 5000 µSTX)#411
Conversation
…rdcoded 5000 uSTX) Same F-14 pattern as aibtcdev#410, flagged there by review: 5000 uSTX is 10-50x below peer skill defaults and an underpriced fee strands the head nonce. ALLOCATOR_FEE_USTX (env), strictly validated (^\d+$, > 0, 1 STX cap) so empty/malformed values error loudly instead of broadcasting zero-fee. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
arc0btc
left a comment
There was a problem hiding this comment.
Follows up on the F-14 finding from #410 (flagged there as an unfixed FYI in this same file) — closes the last hardcoded-fee gap. Good, focused fix.
What works well:
- Validation matches the corrected pattern from #410, not the original buggy version: strict
^\d+$regex catches empty/malformed input beforeBigInt()runs, so this avoids the silent-zero-fee bug biwasxyz caught in #410's first pass (BigInt("")===0n→ a real broadcast-a-zero-fee-tx risk). Explicit> 0and 1 STX sanity-cap checks are both present. - Default bumped 5000 → 50000 µSTX, consistent with the peer-skill survey from #410's review (deposit/withdraw 50k, zest/swap-aggregator 70k, limit-order 100k).
- Small diff (19/-1), single responsibility, no unrelated changes.
Checked for the precheck-mismatch bug from #410: that PR's DCA fix initially left a hardcoded + 5000 balance reserve out of sync with the new configurable fee. This file doesn't have that problem — MIN_STX_RESERVE_USTX (line 56) is a flat 10 STX reserve, two orders of magnitude above either the old or new fee value, so the reserve check at line 691 stays correct regardless of ALLOCATOR_FEE_USTX.
[nit] Neither AGENT.md nor SKILL.md for this skill currently document any env vars (not even existing ones like wallet password), so this isn't a regression of an established convention — but since #410's review flagged the equivalent gap for DCA_FEE_USTX, worth a follow-up doc pass across both files if that becomes the norm.
Code quality notes: No simplification opportunities — resolveAllocatorFeeUstx() is minimal and mirrors the validated helper shape already used in bitflow-swap-aggregator.ts.
Operational note: We don't run this allocator against live positions yet, but the stuck-head-nonce failure mode this guards against is real — we've hit it before from underpriced fees elsewhere in the stack.
Follow-up to #410, where review (biwasxyz) flagged this file's identical
fee: 5000n— the same F-14 underpriced-fee pattern: 10–50× below peer skill defaults (deposit/withdraw 50k, zest/swap-aggregator 70k, limit-order 100k, move-liquidity 250k), and an underpriced fee strands the signer's head nonce.Same validated pattern as the revised #410:
ALLOCATOR_FEE_USTX(env), strict^\d+$parse with labeled errors (empty env ≠ silentBigInt("") = 0nzero-fee broadcast; decimals error loudly), default 50000 µSTX, 1 STX sanity cap.🤖 Generated with Claude Code