feat(integrations): Hummingbot spot connector for CL8Y limit book and hybrid swaps #1581
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
code/cl8y-dex-terraclassic#1581
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Build and maintain an open-source Hummingbot spot connector for CL8Y DEX so strategy bots can market-make on the on-chain limit book and take liquidity through the hybrid route solver without writing chain code. A Hummingbot connector is the lowest-friction, no-marketing distribution channel available to this venue: bots already hunt for discoverable, profitable markets and do not care that the settlement asset is LUNC.
This issues bundles the whole connector deliverable: connector package (market data, balances, orders, fills, fees), the Terra Classic signing/execution layer the connector needs, self-trade and spend guardrails, a LocalTerra-based conformance harness, and the upstream contribution path.
It consumes the DEX read plane from the sibling market-data issue (#1580: cached book snapshot,
/marketsdiscovery, book + per-wallet streams). The connector must still work, degraded but safe, if those streams are unavailable. Gateway-mediated swaps/LP are tracked separately in #1582.Community request (anonymized)
A community request asked whether a Hummingbot connector is worth building for CL8Y DEX, reasoning that bot/strategy flow already reaches major centralized venues, that bots only need a discoverable, tradable and profitable market, and that the connector (open source) would widen reach without marketing spend.
Do not retain or reproduce handles, timestamps, quotations, or any user-identifying information from that request in this issue, code, docs, tests, fixtures, commit messages, or connector logs.
Current codebase
What exists
columbus-5) CosmWasm DEX. Pair contract supports pool swaps, hybrid pool+book swaps, greedy book-first swaps, resting FIFO limit orders (place batch/ladder, cancel batch, reprice, expiry/claim, permissionless clean), router multi-hop execution, community-tax CW20s, and CL8Y fee-discount tiers. Message shapes and invariants:docs/limit-orders.md,docs/integrators.md,smartcontracts/packages/dex-common/src/pair.rs.indexer.dex.cl8y.com(prod) /127.0.0.1:3001(dev). Book via LCD-proxy endpoints; route solving is zero-LCD (local_v1) and returnshops+router_operations+estimated_amount_out_net+snapshot_age_ms. Seedocs/indexer-http.md.GET /api/v1/pairs/{addr}/limit-fills,.../limit-orders/{order_id}/fills,.../limit-placements|limit-cancellations, and trader-scoped equivalents.scripts/bots/swarm.py/swarm_tax.pybuild CW20Send+ pair hook messages and shell out todocker exec … terrad tx …on LocalTerra.packages/localnet-trading-swarmis a TypeScript LocalTerra-only swarm. Neither holds keys safely for mainnet nor implements order lifecycle reconciliation.terra-classic-sdk(PyPI, 3.0.2,>=3.10,<4) supports Terra Classic LCD/key management/signing including the 0.47 chain upgrade.hummingbot/connector/exchange/*; no Terra/Terra Classic connector today. Gateway (the DEX path) supports onlyethereumandsolanachains, so a Gateway route is not available without a new chain implementation (separate sibling issue).hummingbot.org/connectors/): required public REST (active markets, last price, order book snapshot, ping, trading rules), required private REST (balance, order status, open orders, create/cancel), required public book channel with minimum depth 100, required private user order/trade channel, documented rate limits, and an auth class. A connector must live inhummingbot/connector/exchange/<name>/with a matching test folder, docs PR tohummingbot-site, and an HGP for upstream inclusion.docs/runbooks/mainnet-soft-launch.md); place/cancel/reprice/hybrid gas envelopes are derived from signed message shape (skills/AGENTS_HYBRID_LIMIT_GAS.md,skills/AGENTS_TERRACLASSIC_GAS.md).Gaps
Why
pure_market_making,avellaneda_market_making,cross_exchange_market_makingand arbitrage strategies against any connector that passes their standard. A maintained connector makes CL8Y a selectable venue.Constraints and guardrails
0600permissions; refuse to start otherwise. Redact key material, signed bytes, and full tx payloads. No telemetry, no remote signing, no key in env printed by--help/status.columbus-5(and the expected bech32 prefixcosmos); refuse to trade on mismatch. Never sign a tx whosechain_idcame from an unverified source.order_idbinding is explicit. CL8Y assignsorder_idon-chain; it appears only in wasm events (limit_order_placed,order_id) of the placement tx. The connector must bindclient_order_id → order_idby parsing the committed tx response. On ambiguous broadcast (timeout/unknown), look up the placement by tx hash (indexerlimit-placements/ LCD tx events) before re-signing. Blind retry after an ambiguous send is a fund-loss defect.code 32(sequence mismatch) with bounded retries, and halt with a clear error when another process appears to share the key.snapshot_age_msunder a configured bound), refuse degraded quote kinds, and setmin_returnfromestimated_amount_out_netminus configured slippage. Gas comes from the documented message-shape envelopes; no flat 15M default, no query-string gas.reject,cancel_oldest,offset) applied before placement, including against the connector's own open orders and any same-wallet orders found on-chain. Wash trading for tier discounts is explicitly not supported.dry_run/paper mode that never signs. Caps are enforced locally even if a strategy misbehaves.Receive, cancel and claim), factory blacklist (wallet/token/pair), and F6 code-id freeze. Surface typed errors; do not retry a deterministic revert.429Retry-After; no more than one book refresh per pair per configured interval; no per-order full-book walks.decimalsand supported tax semantics; community-tax CW20s need the documentedTaxPreview/extra-debit handling (skills/AGENTS_FRONTEND_EXTRA_DEBIT_SELL.md,skills/AGENTS_LOCAL_QUOTE_COVERAGE.md). Unknown semantics fail closed.docs/supply-chain-security.md.Relevant files
integrations/hummingbot/hummingbot/connector/exchange/cl8y_dex/—cl8y_dex_constants.py,cl8y_dex_auth.py,cl8y_dex_web_utils.py,cl8y_dex_utils.py,cl8y_dex_order_book.py,cl8y_dex_api_order_book_data_source.py,cl8y_dex_api_user_stream_data_source.py,cl8y_dex_exchange.py,dummy.pyx,__init__.pyintegrations/hummingbot/test/hummingbot/exchange/cl8y_dex/— one test module per component, plustest_cl8y_dex_order_lifecycle.pyandtest_cl8y_dex_signing.pyintegrations/cl8y_client/(build/sign/broadcast,OrderStatusreader, tx-log parser, sequence manager)integrations/hummingbot/README.md,integrations/hummingbot/conf/*.yml.example,scripts/qa/hummingbot-localterra.sh,scripts/qa/hummingbot-smoke.sh,Makefiledocs/limit-orders.md,docs/route-solver.md,docs/integrators.md,smartcontracts/packages/dex-common/src/pair.rs,smartcontracts/packages/dex-common/src/limit_placement.rsscripts/bots/swarm.py,scripts/bots/swarm_tax.py,frontend-dapp/src/services/terraclassic/pair.ts,frontend-dapp/src/services/terraclassic/hybridSwapGas.tsskills/AGENTS_HYBRID_LIMIT_GAS.md,skills/AGENTS_TERRACLASSIC_GAS.md,docs/limit-orders.md§ Batch / ladder gas savingsdocs/reference/fee-discount-tiers.md(I13 limit discount),docs/integrators.md§ Limit book feesscripts/setup-cloud-agent-localterra.sh,scripts/e2e-provision-dev-wallet.sh,docs/localterra-sdk53.mddocs/security-model.md,docs/supply-chain-security.md,AGENTS.mdRecommended direction
Phase 0 — package, harness, guardrails
integrations/hummingbot/tree containing the connector plus acl8y_clientexecution layer. Upstream-ready folder layout from day one (constants/auth/web_utils/utils/order_book/data sources/exchange).terra-classic-sdkfor account, CW20/bank balances and signing; indexer REST for markets/book/trades/fills; direct LCD only for broadcast, account state,OrderStatus, and pre-sign simulation.make hummingbot-localterratarget. Connector tests must run in CI without network.Phase 1 — read-only parity
GET /markets(from the sibling issue) → trading pairs, decimals, trading rules (price band, min remainder, rung/step caps, fees, pause/blacklist/frozen).book/snapshot+ book stream with sequence/height handling; resync on gap. Depth ≥100 per pair.pairs/{addr}/statsor best bid/ask; reconcile withtrades.ulunaand CW20 contracts; reportavailableandtotal, fee-aware.Phase 2 — maker path
place_limit_ordervia CW20Send→PlaceLimitOrderBatch(single-rung batch for one order) withmax_adjust_stepsandhint_after_order_idfromlimit-book/insert-hints; optionalexpires_at.cancel(single/batch),cancel_allon shutdown/startup per config,repriceviaUpdateLimitOrderPrice(relink joins the tail of the equal-price run, no new maker fee — L23).ClaimExpiredLimitOrder(s)) with thereasondiscriminator (expired/dust_filled/force_cleaned/blacklisted/unfillable); pause blocks cancel/claim → surface and wait.limit-orders/{order_id}/fillsand trader stream; idempotent trade IDs; no duplicate fills after restart. Reconcile with typedOrderStatus(Active/ParkedRefund/Unknown) —Unknownis not proof of fill.deducted_from_returns/added_to_costcorrectly so Hummingbot P&L is right. Apply the pair's placement discount (limit_discount_bps, tier 1–9) and the taker discount; never invent a discount for an unwired pair (I14).Phase 3 — taker path
GET/POST /api/v1/route/solvewithamount_in: execute the returnedrouter_operationsvia the router, or CW20Send→ pairSwapfor a single hop that carrieshybrid.snapshot_age_ms,quote_kind,optimality_scope; setmin_return/belief_pricefromestimated_amount_out_netminus slippage; size gas from the documented envelopes (hybrid formula, pool-only 840k, unknown 15M fallback is a refusal, not a default); never reuse a stale quote across a book change.indexer_hybrid_lcd_degraded,book_start_hintvalidity) and community-tax extra-debit quotes (gross offer vs net output;route_local_v1).Phase 4 — safety, observability, packaging
statuscommand for humans.conf/) with acl8y_dexsection: network endpoints, wallet selector, pair allowlist, slippage bounds, caps, strategies' defaults, poll intervals,self_trade_prevention,dry_run.Phase 5 — upstream contribution
hummingbot-site; an HGP draft; a maintenance commitment (CI, release cadence, security contact) stated in the PR.Given / When / Then
Given a funded wallet, a running indexer and a fresh book on a supported pair,
When the operator starts Hummingbot with a
pure_market_makingstrategy oncl8y_dex,Then the connector discovers the pair rules, places a resting order through the on-chain book, binds the returned
order_idto its client order id, reports the maker placement fee in the fee ledger, refreshes the book from snapshots/streams without LCD spam, and cancels its orders on shutdown.Given a placement broadcast whose response is lost (timeout or node error),
When the connector retries,
Then it first locates the tx by hash and the
order_idin the placement records, and only re-signs when no committed placement exists — never producing duplicate resting orders.Given the indexer book snapshot is stale or a market flag is unknown,
When a strategy asks the connector for a price or to place an order,
Then the connector refuses to place, reports the degraded reason, and does not fall back to a chain poll inside the request path.
Given a market (taker) quote older than the configured freshness bound,
When the strategy submits a buy/sell,
Then the connector re-quotes and signs only a fresh route with a positive
min_return, or fails without signing.Acceptance criteria
_auth.py, order book + user stream data sources, anddummy.pyx; imports/instantiation work from a stock Hummingbot install.availableexcludes escrowed/allowance-bound funds; decimal handling correct for 6/18-decimal assets.reason.client_order_id → order_idbinding is derived from committed tx events; ambiguous broadcast resolves by tx hash before any retry; duplicate placements are impossible in tests.OrderStatusreconciliation (Active/ParkedRefund/Unknown—Unknownnever counted as filled), parks and claims reflected in status.min_return, freshness and degraded-quote refusal, message-shape gas envelopes, and explicit failure when gas/quote cannot be established.limit_discount_bpsfor placement) reported through Hummingbot fee accounting without double counting.dry_runthat provably never signs.chain_id.LimitOrderAmountTooSmall), insert-step exhaustion, batch-all-or-nothing revert, and expiry-park races.cross_exchange_market_makingagainstpaper_tradeor a supported CEX connector in dry-run), including cancel-all, restart/recovery, and fill reconciliation.make verify-issue-<n>exists and passes;docs/qa/issue-<n>/README.mdchecklist andskills/AGENTS_HUMMINGBOT_CONNECTOR.md(invariants HB1–HB12) are present.Test plan — all paths
/marketsparsing, decimals 6/18, missing metadata, unknown flagswalk_index), depth truncation, stale flagresync, reconnectRetry-After; stale after boundlimit_discount_bps, taker discount, unregistered, tier 255floor(eff/2)and docscode 32, concurrent signing, second processorder_idper rung; missing ⇒ ambiguous, no false bindingOrderStatus: Active, ParkedRefund (eachreason), UnknownUnknownnever filledmin_returnrespectedpaper_trade(dry-run CEX) 15 minavellaneda_market_making(V2) smokeAdversarial test plan — attack, hack, abuse
HybridSimulation/router sim before signing; bound deviation vs pool reference; refuse on mismatch; pinned HTTPS endpoint + optional cert pinmin_returnfrom fresh quote; bounded size; timing jitter; avoid predictable ladder cadence; document mempool exposure honestlyOrderStatus+ committed tx events; reorg handling on indexed history; never close a position on an uncommitted fillcode 32handling with bounded retries, then halt with a distinct error; single-instance locktoken_info/TaxPreviewchecks; unknown semantics fail closed; never size from nominalremainingchain_idverification, sequence, and nonce semantics; signed payload never reusedVerification criteria
make verify-issue-<n>: formatting/lint (ruff/black or repo standard), connector unit tests with coverage gate,cl8y_clientunit tests, no-network assertion, and a LocalTerra suite gated likeVERIFY_ISSUE_1329_CHAIN=1(explicitly SKIP when no chain, never silently PASS).docs/qa/issue-<n>/README.mdrecords each AC as PASS/FAIL/SKIP with the exact command, tx hashes, heights and UTC timestamps. Executed failures remain FAIL; unavailable live checks are explicit SKIP and do not close acceptance.code=0,gas_used < gas_wanted, andOrderStatusread-backs for each lifecycle state.limit_order_fillevents.dry_runcan discover markets, read depth ≥100, and refuse to sign; no writes, no funds moved.Out of scope
amm-arbitrage(separate sibling issue).https://bridge.cl8y.com).Deliverables
integrations/hummingbot/connector package +integrations/cl8y_client/execution layer + tests +conf/examples.scripts/qa/hummingbot-localterra.sh,scripts/qa/hummingbot-smoke.sh,make hummingbot-localterra,make verify-issue-<n>.docs/runbooks/hummingbot-connector.md(install, custody, limits, troubleshooting, deviations),docs/integrators.mdbot section,skills/AGENTS_HUMMINGBOT_CONNECTOR.md(HB1–HB12),docs/qa/issue-<n>/README.md.First-pass model recommendation
Recommendation: a high-capability coding model with Python + Cosmos/Terra Classic experience and access to a LocalTerra sandbox. The high-risk parts are order-id binding after ambiguous broadcasts, sequence handling, and fee/gas accounting; those are fund-loss classes of bug, not style issues.