# Finding J-1 (Medium: liveness / batch stall): `split-core` lost the partial-fill floor that `router-swap` kept — same file, same pinned commit **Bounty:** `mwofjt4291b2d9213a9c` (Jing router v6 sBTC/STX audit, 6,000 sats) **Scope item:** #4 (Juice) — `contracts/pox-5/juice-sbtc-autoswap-v2.clar` @ `f403d80`, explicitly named in the bounty. **File / lines:** `contracts/pox-5/juice-sbtc-autoswap-v2.clar`, `split-core` L493–546 (call L527–535, return L538–545). **Verified at:** `f403d80` (bounty pin) **and** repo tip `6588aa3` — i.e. this is not a stale-pin artifact, it is live in current code. --- ## 1. The asymmetry In the *same contract*, the single-route entry point already handles partial fills correctly. `router-swap` (L443–450): ```clarity (let ((sold (- amount (get unsold result)))) (asserts! (> sold ROUTER_SLACK_SATS) ERR_BELOW_FLOOR) (asserts! (>= (get out result) (floor-out (- sold ROUTER_SLACK_SATS) limit)) ERR_BELOW_FLOOR ) ) ``` It computes what actually sold (`amount - unsold`) and floors the check on that. `split-core` (L527–545) — used by `router-swap-split`, `router-swap-split-zest`, `router-swap-split-dia`, `router-swap-split-dia-zest` — does **not**: ```clarity (try! (contract-call? JING_ROUTER swap-sbtc-for-stx amount jing limit (some update) none { zest: zest, dlmm: dlmm, xyk: xyk, velar: velar } mins (+ (floor-out (+ jing zest dlmm xyk) limit) (floor-out velar velar-limit)) ;; <-- planned, not sold (zest-route zest-ticks) )) ... (close-if-empty) (ok { ... out: (get out result), unsold: (get unsold result) }) ;; <-- printed, never asserted ``` Two consequences: 1. **The floor counts the whole planned `zest` slice.** `(+ jing zest dlmm xyk)` includes Zest sats the router is explicitly allowed not to fill. 2. **`unsold` is reported but never checked** in `split-core`. `ERR_BELOW_FLOOR` appears in this file exactly twice, both inside `router-swap` (L444, L447). Neither split path reaches it. `grep -c ERR_BELOW_FLOOR` = 3 for the file: one `define-constant` (L19), two uses (L444, L447). Zero in any split path. ## 2. Why that means a hard revert, not a soft shortfall The router side is working as designed: - `leg-zest` calls Zest with `allow-partial-fill = true` and `min-dx u0`, then asserts only on the **filled** part: `out >= scale-min(min-received, planned, filled)` (`swap-router-sbtc-stx-jing-v6.clar` L289–332). - `zest-short = planned − filled` is added to `unsold` (L444 / L566). So when Zest fills `z − x` of a planned `z`, the router's own per-leg check passes, the swap succeeds, and it reports `out` for what sold and `unsold = x` (+ any Jing residual). The vault then fails its own pre-committed floor: it required `out ≥ floor-out(jing + z + dlmm + xyk, limit)`, but the router can at most pay `floor-out(jing + z − x + dlmm + xyk, limit)`. Since `floor-out` is monotone in amount, ``` floor-out(amount − x, limit) < floor-out(amount, limit) for any x ≥ 1 with limit > 0 ``` so `(>= out min-stx-out)` in the router (`L470`) is **false** and the whole call aborts `ERR_MIN_OUT u3002`. Note the ordering: the router checks `out >= min-stx-out` *before* returning, so the vault's own missing assert never gets a chance to run. The transaction reverts inside the router. ## 3. Concrete trigger (no attacker) `split-core` is reached by two different callers, and this matters for severity: | Entry | Caller gate | Carries zest? | |---|---|---| | `router-swap-split` | `contract-caller == POOL` (live `juice-pool-sbtc-signer`) | passes `u0`, harmless | | `router-swap-split-zest` | **`assert-pool-admin`** — `contract-caller == (contract-call? POOL get-admin)` | **yes** | | `router-swap-split-dia` | `contract-caller == POOL` | `u0`, harmless | | `router-swap-split-dia-zest` | **`assert-pool-admin`** | **yes** | So the affected paths are the two new admin-called entries — which is exactly the surface the bounty asks to review ("auth gaps on the new entries", "asset loss or stuck funds from these diffs"). Trigger, entirely ordinary: 1. Admin (or the pool's admin-keyed keeper) calls `router-swap-split-zest` with `zest = z > 0` and a 32-tick walk. 2. Between quote and inclusion one 100-step Zest bin moves (≈1%), or the 32-tick window holds less depth than `z`, or pool `u3` is not yet created. 3. Zest returns `ok` with a partial fill (`left < z`) — permitted by design. 4. Vault floor still assumes all `z` sold → router `ERR_MIN_OUT` → **entire split reverts**, including the Jing, DLMM, XYK and Velar legs. `max-chunk-sats` defaults to `u1000000` (0.01 BTC), so a revert here is a whole batch chunk failing, and `cooldown-tick` / `window-elapsed` mean the keeper cannot simply retry in the same block. Result: the chunk stalls until a fresh walk is built. Availability only — no fund loss, since the revert rolls everything back. ## 4. The fix (what `router-swap` already does) Mirror the single-route tail inside `split-core`, before returning: ```clarity (let ((sold (- amount (get unsold result)))) (asserts! (> sold ROUTER_SLACK_SATS) ERR_BELOW_FLOOR) (asserts! (>= (get out result) (floor-out (- sold ROUTER_SLACK_SATS) limit)) ERR_BELOW_FLOOR ) ) ``` and change the min-out handed to the router from the planned sum to a sum that excludes the non-guaranteed zest slice — i.e. keep `zest` out of `min-stx-out` and let `mins.zest` + the router's `scale-min` police the filled part, exactly as the router already does for `router-swap`. Same edit needed in `split-dia-core` (L548–596), which has the identical shape and also never asserts on `unsold`. ## 5. Repro Not a runtime trace — this is a static asymmetry, and the two code paths are quoted verbatim above. If a stxer repro is wanted, the minimal one is: `router-swap-split-zest` with `zest = u1000`, a `zest-ticks` walk whose depth is `u500`, and `amount = jing + zest + dlmm + xyk + velar`; the call reverts `u3002` and no leg settles. This is equivalent to the `nopool` case already exercised by `simulations/verify-router-sbtc-stx-v6-zest-nopool.mjs` in jing-contracts-v3, which is why the router side is known-good and the vault side is the gap. --- **Severity rationale.** Not High: no theft, no stuck funds, fully atomic rollback. Medium: repeated whole-chunk liveness failure on the two newest, least-exercised entry points, with a trigger (one Zest bin moving) that the bounty itself describes as the realistic one. Distinct from the earlier `bc1q8hr0rcszaq` report, which was answered "fixed in the vaults": that answer is true of `router-swap` and false of `split-core` at both the pin and the tip.