Skip to content

Add hlz builder code to all outgoing orders#1

Open
dzmbs wants to merge 1 commit intomainfrom
sym-8/add-builder-code
Open

Add hlz builder code to all outgoing orders#1
dzmbs wants to merge 1 commit intomainfrom
sym-8/add-builder-code

Conversation

@dzmbs
Copy link
Copy Markdown
Owner

@dzmbs dzmbs commented Mar 14, 2026

Summary

Adds builder fee support to all outgoing orders placed through hlz CLI and hlz-terminal.

Resolves: SYM-8

Changes

SDK (types.zig, client.zig)

  • Builder type: New Builder struct with address: [20]u8 and fee: u16 (tenths of basis points)
  • BatchOrder: Added optional builder: ?Builder = null field (backward compatible)
  • Constants: HLZ_BUILDER_ADDRESS (placeholder 0x0...0), HLZ_BUILDER_FEE (5 = 0.5bp), HLZ_BUILDER
  • msgpack packing: packActionOrder and packBatchOrder emit builder map when present (map size 4 vs 3)
  • JSON serialization: writeActionJson includes "builder":{"b":"0x...","f":5} when builder is set
  • Helper: addressToHex utility for formatting builder address in hex

CLI (commands.zig)

  • All order paths set .builder = types.HLZ_BUILDER:
    • placeOrder (buy/sell)
    • twap slices
    • batchCmd
  • Dry-run output includes builder info (both JSON and TTY formats)
  • Onboarding hint: checkBuilderApproval() queries maxBuilderFee and prints one-time hint if user hasn't approved the hlz builder fee

Terminal (trade.zig)

  • Order placement and close position paths include .builder = types.HLZ_BUILDER

Tests

  • packActionOrder with builder: verifies map size 4, builder/address in output
  • packActionOrder without builder: verifies byte-exact match with original test vector
  • writeActionJson with builder: verifies JSON contains builder field
  • writeActionJson without builder: verifies no builder field present
  • addressToHex: zero and non-zero address formatting

Validation

  • zig build test — all tests pass (existing + new)
  • zig build hlz — CLI builds
  • zig build hlz-terminal — terminal builds
  • Backward compatible: BatchOrder without builder produces identical msgpack/JSON

- Add Builder type with address/fee fields and HLZ_BUILDER constants in types.zig
- Add optional builder field to BatchOrder (defaults to null for backward compat)
- Update packActionOrder/packBatchOrder msgpack packing to include builder map when present
- Update writeActionJson JSON serialization to include builder field
- Wire HLZ_BUILDER into all order placement paths:
  - placeOrder (buy/sell) in commands.zig
  - twap slices in commands.zig
  - batchCmd in commands.zig
  - terminal order placement and close position in trade.zig
- Add builder info to dry-run output (both JSON and TTY)
- Add checkBuilderApproval hint: queries maxBuilderFee and prints approval hint if needed
- Add unit tests for packActionOrder with/without builder, writeActionJson with/without builder
- Add addressToHex utility tests
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hlz Ready Ready Preview, Comment Mar 14, 2026 7:30pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant