Skip to content

fix(markets): add min_bet field to enforce minimum bet threshold - #331

Merged
dultimateade merged 1 commit into
dultimateade:mainfrom
jebprince1-web:fix/markets-min-bet-dust-protection
Oct 22, 2026
Merged

dultimateade merged 1 commit into
dultimateade:mainfrom
jebprince1-web:fix/markets-min-bet-dust-protection

Conversation

@jebprince1-web

Copy link
Copy Markdown
Contributor

closes #199 closes #196
Dust bets (1–100 stroops) incur full transaction fees but carry no economic weight. An attacker could place thousands of them to bloat on-chain storage at minimal cost and distort pool statistics.

Changes

  • Add min_bet: i128 field to MarketData (persisted on-chain).
  • Add min_bet parameter to create_market and create_market_with_curve; validate min_bet >= 1 at creation time (panics with InvalidConfig on zero or negative values).
  • Tighten the place_bet guard from amount <= 0 to amount <= 0 || amount < market.min_bet (panics with StakeTooSmall).

Test coverage (issues_007_012_014_022.rs)

  • test_create_market_rejects_zero_min_bet
  • test_create_market_rejects_negative_min_bet
  • test_place_bet_rejects_dust_below_min_bet
  • test_place_bet_accepts_amount_at_min_bet
  • test_place_bet_accepts_amount_above_min_bet
  • test_place_bet_still_rejects_zero_even_with_min_bet_one
  • test_get_market_exposes_min_bet

All existing call-sites in tests/ and benches/ updated to supply the new min_bet argument.

Dust bets (1–100 stroops) incur full transaction fees but carry no
economic weight. An attacker could place thousands of them to bloat
on-chain storage at minimal cost and distort pool statistics.

Changes
-------
* Add `min_bet: i128` field to `MarketData` (persisted on-chain).
* Add `min_bet` parameter to `create_market` and
  `create_market_with_curve`; validate `min_bet >= 1` at creation
  time (panics with `InvalidConfig` on zero or negative values).
* Tighten the `place_bet` guard from `amount <= 0` to
  `amount <= 0 || amount < market.min_bet` (panics with
  `StakeTooSmall`).

Test coverage (issues_007_012_014_022.rs)
-----------------------------------------
* test_create_market_rejects_zero_min_bet
* test_create_market_rejects_negative_min_bet
* test_place_bet_rejects_dust_below_min_bet
* test_place_bet_accepts_amount_at_min_bet
* test_place_bet_accepts_amount_above_min_bet
* test_place_bet_still_rejects_zero_even_with_min_bet_one
* test_get_market_exposes_min_bet

All existing call-sites in tests/ and benches/ updated to supply the
new `min_bet` argument.
@drips-wave

drips-wave Bot commented Oct 21, 2026

Copy link
Copy Markdown

@jebprince1-web Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@dultimateade
dultimateade merged commit fae3747 into dultimateade:main Oct 22, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants