Skip to content

Qualify a side by minTwoSidedLiquidity, not minContracts - #18

Merged
piekstra merged 2 commits into
mainfrom
fix/two-sided-qualification-threshold
Aug 5, 2026
Merged

Qualify a side by minTwoSidedLiquidity, not minContracts#18
piekstra merged 2 commits into
mainfrom
fix/two-sided-qualification-threshold

Conversation

@piekstra

@piekstra piekstra commented Aug 4, 2026

Copy link
Copy Markdown
Owner

The bug

LP-reward programs publish two different thresholds, and rewards eligibility
collapsed them into one:

field governs
minContracts whether an order accrues score
minTwoSidedLiquidity whether an order qualifies its side

bid_shares / ask_shares only accumulated for orders that had already passed
big_enough (qty >= minContracts), so the stricter bar silently governed the
two-sided test as well.

The result: any position whose ask sat below minContracts was reported
not two-sided: one-sided liquidity earns nothing with no expected reward —
while the program was paying it every hour.

The fix

Qualification requires only that an order be covered and meet
minTwoSidedLiquidity (1 on every program observed). A 1-share ask parked far
outside the band contributes zero score yet still establishes the ask side,
which is what lets the bid's score earn.

Band and minContracts continue to gate scoring — unchanged.

Why it matters

Under-reporting eligibility is expensive in both directions:

  • live income reads as nothing, so a paying property looks idle
  • the natural "fix" is to buy inventory to reach minContracts on a side that
    was already qualified — inventory that adds no score, bought at the AMM
    fee

Tests

  • new: a 4-share in-band bid + a 1-share out-of-band ask is two-sided and
    earning, while the ask itself reports scoring: false
  • corrected: an existing test asserted the conflated rule (that an undersized
    order cannot qualify its side). It now pins the real semantics — qualifies,
    but never scores.

All existing eligibility tests for genuinely one-sided positions (bid-only,
ask-only) still pass unchanged: those earn nothing, and that part was right.

LP-reward programs publish two different thresholds and `rewards eligibility`
collapsed them into one:

  minContracts          an order must be this big to accrue SCORE
  minTwoSidedLiquidity  an order must be this big to QUALIFY its side

`bid_shares`/`ask_shares` only accumulated for orders that had already passed
`big_enough` (qty >= minContracts), so that stricter bar silently governed the
two-sided test as well. Any position whose ask sat below minContracts was
reported "not two-sided: one-sided liquidity earns nothing" and credited with
no expected reward, while the program was in fact paying it every hour.

Qualification only requires that the order be COVERED and meet
minTwoSidedLiquidity, which is 1 on the programs observed. A 1-share ask
parked far outside the band contributes zero score yet still establishes the
ask side, which is what lets the bid's score earn. Band and minContracts
continue to gate scoring, unchanged.

Under-reporting eligibility this way is expensive in both directions: live
income reads as nothing, and the natural "fix" is to buy inventory to reach
minContracts on a side that was already qualified — inventory that adds no
score, bought at the AMM fee.

Adds a regression test for the qualifying-but-not-scoring shape, and corrects
an existing test that asserted the conflated rule.
@piekstra
piekstra merged commit bc0263a into main Aug 5, 2026
2 checks passed
@piekstra
piekstra deleted the fix/two-sided-qualification-threshold branch August 5, 2026 12:34
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.

1 participant