Qualify a side by minTwoSidedLiquidity, not minContracts - #18
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
LP-reward programs publish two different thresholds, and
rewards eligibilitycollapsed them into one:
minContractsminTwoSidedLiquiditybid_shares/ask_sharesonly accumulated for orders that had already passedbig_enough(qty >= minContracts), so the stricter bar silently governed thetwo-sided test as well.
The result: any position whose ask sat below
minContractswas reportednot two-sided: one-sided liquidity earns nothingwith 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 faroutside the band contributes zero score yet still establishes the ask side,
which is what lets the bid's score earn.
Band and
minContractscontinue to gate scoring — unchanged.Why it matters
Under-reporting eligibility is expensive in both directions:
minContractson a side thatwas already qualified — inventory that adds no score, bought at the AMM
fee
Tests
earning, while the ask itself reports
scoring: falseorder 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.