Fix #57: Ensure withdraw_fees provenance — per-market ledger, empty-side principal protection - #128
Open
funds0033-cmyk wants to merge 1 commit into
Conversation
…l out of the withdrawable pot. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Closes #57
Problem
withdraw_feesneeded a hard guarantee that only genuine platform fees can ever be withdrawn — never another market's fees, and never user principal from an empty-side resolution.What landed
place_betcreditsMarketFees(market_id).AccumulatedFeesis now only a cached sum of those entries plus pre-upgradeLegacyFees.cancel_marketdebits only that market's ledger, so cancelling one market can't wipe another market's fees.Payout(net)for each bettor.withdraw_feescan only take the 2% platform fee, never user stake — bettors claim their net stake back separately.request_withdraw_fees→execute_withdraw_feespath. Adminwithdraw_feeskeeps its existing 2-arg ABI so the rest of the suite still compiles.New public API
get_market_fees(market_id)get_legacy_fees()migrate_fee_ledger(admin)— for the upgrade pathTests
Regressions added for: full-drain of principal, cross-market cancel, and arbitrary recipient.
Branch:
fix/issue-57-withdraw-fees-provenance