Skip to content

feat: add competitive multi-solver acceptance window - #156

Open
favvy994 wants to merge 1 commit into
stellar-vortex-protocol:mainfrom
favvy994:feature/51-competitive-acceptance-window
Open

feat: add competitive multi-solver acceptance window#156
favvy994 wants to merge 1 commit into
stellar-vortex-protocol:mainfrom
favvy994:feature/51-competitive-acceptance-window

Conversation

@favvy994

Copy link
Copy Markdown

Summary

Adds a competitive bid-window mode behind an admin-controlled flag (off by default), so solvers can compete on quoted price before one is assigned exclusive fill rights. The existing first-accept-wins path is fully preserved when the flag is off.

Design

Problem: accept_intent is first-write-wins — the first solver to submit a valid transaction claims exclusive fill rights. This may not produce the best execution for users, especially for large intents.

Solution: Admin enables set_bid_window_enabled(true). New intents open in Bidding state for BID_WINDOW (120 s). Solvers call bid_intent(quoted_dst_amount) to compete on price. After the window, anyone calls settle_bids permissionlessly — the solver who quoted the highest dst_amount wins and the intent transitions to Accepted with a fresh fill window.

Backward compatibility: All existing intents in Open state continue to use accept_intent (first-accept-wins). The new path only applies to intents submitted while BidWindowEnabled = true.

Changes

  • New IntentState::Bidding variant
  • New BestBidRecord struct and DataKey::BestBid storage key
  • set_bid_window_enabled / is_bid_window_enabled admin controls
  • bid_intent — solver submits a quote during the window
  • settle_bids — permissionless; picks highest bidder, transitions to Accepted
  • BID_WINDOW = 120 constant
  • New errors: BidWindowNotOpen, BidWindowStillOpen, NoBidsSubmitted

Validation

  • 63 tests pass (cargo test)
  • cargo fmt and cargo clippy -- -D warnings clean

Closes #51

…st-accept-wins

Closes stellar-vortex-protocol#51

Implements an optional bid-window mode (off by default) so solvers can
compete on price before one is assigned exclusive fill rights.

When disabled (default): existing first-accept-wins behavior is fully
preserved via accept_intent, with no change to the happy-path lifecycle.

When enabled (admin toggles set_bid_window_enabled):
- submit_intent opens a BID_WINDOW (120 s) collection period
  (IntentState::Bidding) instead of Open
- Solvers call bid_intent(solver, intent_id, quoted_dst_amount) to
  submit competing quotes; only the highest quote is retained
- After the window closes, anyone calls settle_bids permissionlessly:
  the highest bidder is assigned and the intent transitions to Accepted
  with a fresh FILL_WINDOW; fill_intent and slash_solver are unchanged

New storage: BestBid(intent_id) -> BestBidRecord{solver, quoted_dst_amount}
New errors: BidWindowNotOpen(22), BidWindowStillOpen(23), NoBidsSubmitted(24)
New constant: BID_WINDOW = 120 s

Tests: 8 new tests covering happy path, no-bids, window-still-open,
lower-bid-rejected, and backward-compatibility of first-accept-wins mode.
@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@favvy994 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

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.

Add a competitive multi-solver acceptance window instead of first-accept-wins

1 participant