feat(contract): market creation anti-spam bond (#1327) - #1493
Merged
Olowodarey merged 1 commit intoJul 29, 2026
Merged
Conversation
Require a governance-configurable refundable bond from market creators to deter spam and low-quality markets: - Config: add bond_amount field (i128, default 0 = disabled); expose set_bond_amount and update_bond_amount_from_governance setters with negative-value guard and bnd/upd event. - Escrow: add deposit_market_bond, refund_market_bond, forfeit_market_bond, get_market_bond. Storage uses raw (Symbol, u64) tuple key 'MktBond' to avoid the DataKey 50-variant XDR cap. Events: bnd/deposit, bnd/refund, bnd/forfeit. - Market: create_market pulls the bond via transfer_from allowance after persisting the market (transaction atomicity guarantees rollback on failure); cancel_market forfeits bond to treasury; resolve_market refunds bond to creator. - Errors: reuse InsufficientFunds (allowance too small) and NotAParticipant (double-deposit guard); both reuse documented in errors.rs comments. No new variants added (enum at 50-case XDR cap). - Tests (bond_tests.rs, 16 tests): set_bond_amount auth/validation, creation with and without bond, revert on missing/insufficient allowance, refund on resolution, forfeiture on cancellation, treasury accumulation, disabled-bond no-ops, get_market_bond lifecycle. All 16 new tests pass; full suite (600+ tests) green.
|
@nattyakos07-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! 🚀 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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 #1327
Require a governance-configurable refundable bond from market creators to deter spam and low-quality markets:
Config: add bond_amount field (i128, default 0 = disabled); expose set_bond_amount and update_bond_amount_from_governance setters with negative-value guard and bnd/upd event.
Escrow: add deposit_market_bond, refund_market_bond, forfeit_market_bond, get_market_bond. Storage uses raw (Symbol, u64) tuple key 'MktBond' to avoid the DataKey 50-variant XDR cap. Events: bnd/deposit, bnd/refund, bnd/forfeit.
Market: create_market pulls the bond via transfer_from allowance after persisting the market (transaction atomicity guarantees rollback on failure); cancel_market forfeits bond to treasury; resolve_market refunds bond to creator.
Errors: reuse InsufficientFunds (allowance too small) and NotAParticipant (double-deposit guard); both reuse documented in errors.rs comments. No new variants added (enum at 50-case XDR cap).
Tests (bond_tests.rs, 16 tests): set_bond_amount auth/validation, creation with and without bond, revert on missing/insufficient allowance, refund on resolution, forfeiture on cancellation, treasury accumulation, disabled-bond no-ops, get_market_bond lifecycle.
All 16 new tests pass; full suite (600+ tests) green.