fix(market): enforce the minimum net stake - #41
Conversation
|
@payfoxX 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 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
Description
I moved the minimum-bet validation to the post-fee stake amount. The contract now derives
netonce 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
amounttoMIN_BETeven though only the fee-adjustednetvalue was added to the market totals. A gross bet exactly at the advertised minimum therefore created a sub-minimum position. I now validatenet < 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 --checkpassed.cargois not installed in the execution environment.