Skip to content

feat: make MIN_BOND, FILL_WINDOW, INTENT_EXPIRY, PROTOCOL_FEE_BPS admin-configurable - #157

Open
favvy994 wants to merge 1 commit into
stellar-vortex-protocol:mainfrom
favvy994:feature/52-configurable-protocol-params
Open

feat: make MIN_BOND, FILL_WINDOW, INTENT_EXPIRY, PROTOCOL_FEE_BPS admin-configurable#157
favvy994 wants to merge 1 commit into
stellar-vortex-protocol:mainfrom
favvy994:feature/52-configurable-protocol-params

Conversation

@favvy994

Copy link
Copy Markdown

Summary

Moves the four compile-time constants to a ProtocolConfig struct stored in instance storage with an admin-only setter and public getter. Any change no longer requires a contract redeploy. Existing behavior is fully preserved: initialize seeds config with the original default values.

Changes

  • New ProtocolConfig struct: {min_bond, fill_window, intent_expiry, protocol_fee_bps}
  • New DataKey::Config instance-storage key
  • set_config(min_bond, fill_window, intent_expiry, protocol_fee_bps) — admin-only, validated
  • get_config() — public view returning current effective parameters
  • Error::InvalidConfig (22) for out-of-bounds values
  • Private load_config() helper with fallback defaults (upgrade-safe)
  • All runtime usages of the four constants now read from Config

Bounds enforced by set_config

Parameter Rule
protocol_fee_bps 0 – 1000 (≤ 10%)
fill_window ≥ 60 s
intent_expiry ≥ 300 s and > fill_window
min_bond ≥ 10_000_000 (1 token unit)

Validation

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

Closes #52

… admin-configurable

Closes stellar-vortex-protocol#52

Moves the four compile-time constants to a ProtocolConfig struct stored in
instance storage, with an admin-only setter (set_config) and a public getter
(get_config). Existing behavior is unchanged: initialize seeds Config with
the same default values as before.

Changes:
- Added ProtocolConfig struct {min_bond, fill_window, intent_expiry, protocol_fee_bps}
- Added DataKey::Config instance-storage key
- Added set_config(min_bond, fill_window, intent_expiry, protocol_fee_bps) admin fn
  with bounds: fee ≤ 1000 bps, fill_window ≥ 60 s, intent_expiry ≥ 300 s and
  > fill_window, min_bond ≥ 10_000_000 (1 token unit)
- Added get_config() public view fn
- Added Error::InvalidConfig (22)
- Added load_config() private helper (falls back to defaults for upgrade safety)
- All four constants now read from Config at runtime; original constant names
  exported as pub const for test backward-compatibility

Tests: 9 new tests covering defaults, updates, all bound violations,
register_solver respecting new min_bond, and fill_intent using updated fee_bps.
@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.

Make MIN_BOND, FILL_WINDOW, INTENT_EXPIRY, and PROTOCOL_FEE_BPS admin-configurable

1 participant