Skip to content

fix(market): enforce the minimum net stake - #41

Open
payfoxX wants to merge 2 commits into
SPulse-Org:mainfrom
payfoxX:fix/issue-#15-net-minimum-bet
Open

fix(market): enforce the minimum net stake#41
payfoxX wants to merge 2 commits into
SPulse-Org:mainfrom
payfoxX:fix/issue-#15-net-minimum-bet

Conversation

@payfoxX

@payfoxX payfoxX commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Closes #15

Description

I moved the minimum-bet validation to the post-fee stake amount. The contract now derives net once before the early validation and rejects any gross amount that would leave less than the one-XLM minimum stake after fees.

Problem Before and Solution After the Problem Fix

Before this change, the contract compared amount to MIN_BET even though only the fee-adjusted net value was added to the market totals. A gross bet exactly at the advertised minimum therefore created a sub-minimum position. I now validate net < MIN_BET, retain the same net calculation for the later bet-entry update, and added a regression test for a gross amount equal to the old threshold.

Files Changed

  • prediction_market/src/lib.rs — calculate the net stake before validation and enforce the minimum against that value.
  • prediction_market/src/tests.rs — verify that the old gross threshold is rejected when its net stake is too small.

Checks

  • git diff --check passed.
  • Rust tests could not be run because cargo is not installed in the execution environment.

@Muyideen-js

Copy link
Copy Markdown
Contributor

@payfoxX
Thanks for the contribution, moving the minimum-bet validation from gross amount to the post-fee net amount correctly fixes the immediate bug where a bet at MIN_BET could create a sub-minimum effective stake.

However, I don't think this fully resolves #15 as currently written.

The issue identifies the deeper root cause as the fee/minimum values being fragmented across MIN_BET, gross amount, net amount, and the fee constants. This PR fixes the validation condition, but those values are still independently defined and coupled implicitly.

Could you please also address that part by making the minimum/fee calculation derive from a clear single source of truth, or explain if the intended scope of #15 has been narrowed to only the gross-vs-net validation bug?

Also, since the Rust tests weren't run locally, please make sure CI confirms the new regression test and existing suite pass before this is considered complete.

Once the fee/minimum relationship is made explicit and the tests are verified, Closes #15 would be appropriate.

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.

[LOW] MIN_BET is checked on gross, but the staked amount is net — fee-dependent minimum stake inconsistency

2 participants