Skip to content

feat(contract): market creation anti-spam bond (#1327) - #1493

Merged
Olowodarey merged 1 commit into
Arena1X:mainfrom
nattyakos07-web:feature/1327-market-creation-anti-spam-bond
Jul 29, 2026
Merged

feat(contract): market creation anti-spam bond (#1327)#1493
Olowodarey merged 1 commit into
Arena1X:mainfrom
nattyakos07-web:feature/1327-market-creation-anti-spam-bond

Conversation

@nattyakos07-web

Copy link
Copy Markdown

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.

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.
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
insight-arena-4rll Ready Ready Preview, Comment Jul 29, 2026 12:41pm

@Olowodarey
Olowodarey merged commit 5be93de into Arena1X:main Jul 29, 2026
4 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

Development

Successfully merging this pull request may close these issues.

[Contract] — Market Creation Anti-Spam Bond

2 participants