Skip to content

feat(intent_settlement): optional on-chain referral fee-share (#281) - #338

Merged
james2177 merged 2 commits into
stellar-vortex-protocol:mainfrom
henrypeters:feature/issue-281
Sep 3, 2026
Merged

feat(intent_settlement): optional on-chain referral fee-share (#281)#338
james2177 merged 2 commits into
stellar-vortex-protocol:mainfrom
henrypeters:feature/issue-281

Conversation

@henrypeters

Copy link
Copy Markdown
Contributor

Summary

Implements an optional on-chain referral fee-share mechanism for the Vortex protocol, closing #281.

  • submit_intent now accepts an optional referrer: Option<Address>.
  • ProtocolConfig gains a referral_share_bps field (default 0 = disabled, backward-compatible).
  • When referral_share_bps > 0 and a referrer is set, the configured slice of each fill's protocol fee is routed to the referrer at fill_intent time; the remainder still goes to FeeRecipient.
  • Referral split accrues proportionally on every partial fill (dust rounds to FeeRecipient, so no fee units are silently dropped).
  • Self-referral (referrer == user) is rejected with the new Error::SelfReferral variant, preventing users from gaming the programme against their own volume.
  • batch_submit_intent tuple type extended to carry the referrer through.
  • All new public items carry rustdoc per CONTRIBUTING.md.
  • Error enum is append-only — SelfReferral = 35 is appended after SrcChainNotSupported = 34, no renumbering.

Motivation

Issue #281 requested a way to credit referrers with a share of protocol fees so that integrators (front-ends, wallets, market makers) can be rewarded for routing volume through Vortex. Until now, the entire protocol fee went to FeeRecipient. This PR makes the split opt-in by an admin via set_config (which now takes a referral_share_bps argument) and a referrer per intent via submit_intent.

Changes

File Change
intent_settlement/src/lib.rs Added MAX_REFERRAL_SHARE_BPS / DEFAULT_REFERRAL_SHARE_BPS constants, referral_share_bps on ProtocolConfig/ProtocolParams/IntentRecord, Error::SelfReferral, referrer param on submit_intent + self-referral guard, referral split in fill_intent with CEI ordering preserved, batch_submit_intent tuple extension, validation in set_config.
intent_settlement/src/test.rs Updated Ctx::submit() helper to pass &None for referrer; added assertion for params.referral_share_bps; appended 5 tests (self-referral rejection, 20% split, multi-partial-fill accrual, zero-share passthrough, no-referrer regression).
CHANGELOG.md Entry under [Unreleased] > Added describing the feature.

Tests

Five new tests in intent_settlement/src/test.rs:

  1. submit_intent_self_referral_rejectedError::SelfReferral returned.
  2. fill_intent_referrer_receives_configured_split — 20% share: referrer gets fee * 2000 / 10_000, FeeRecipient gets the remainder.
  3. partial_fills_accrue_referral_share_across_fills — 100% share, two partial fills: referrer accumulates fee1 + fee2.
  4. zero_referral_share_sends_all_fee_to_fee_recipient — explicit 0 share, referrer named, full fee still goes to FeeRecipient.
  5. fill_intent_no_referrer_unchanged_behavior — non-zero share, no referrer named, full fee still goes to FeeRecipient (regression guard).

Note on cargo: this environment does not have cargo / rustup installed, so the suite could not be run locally. Please run cargo test -p intent_settlement and cargo fmt --check in CI before merge.

Compatibility

  • All new params have defaults (None for the referrer, 0 for the share), so existing integrators calling submit_intent or set_config need to be updated to the new arity but their semantics are unchanged.
  • The config_updated event payload gains a fifth field (referral_share_bps) — strictly additive.
  • Error::SelfReferral is appended at index 35; no renumbering of existing variants.

Closes #281.

…llar-vortex-protocol#281

submit_intent now accepts an optional referrer: Option<Address>. When
ProtocolConfig.referral_share_bps is non-zero and a referrer is set, the
configured slice of each fill's protocol fee is routed to the referrer
at fill_intent time; the remainder still goes to the FeeRecipient.

- referral_share_bps added to ProtocolConfig / ProtocolParams
  (default 0 = disabled, backward-compatible with existing deployments).
- IntentRecord gains a locked referrer field set at submission time.
- Self-referral (referrer == user) rejected with new Error::SelfReferral
  variant (appended per CONTRIBUTING.md's append-only enum rule).
- fill_intent now uses get_tiered_fee_bps + checked_mul/checked_div
  overflow-safety and consolidates CEI ordering; the previous
  misplaced duplicate transfer block has been removed.
- Referral split accrues proportionally on every partial fill; integer
  division dust is absorbed by the FeeRecipient so no fee units are
  silently dropped.
- batch_submit_intent tuple extended with Option<Address> referrer.
- Five new tests: self-referral rejection, 20% split, multi-partial-fill
  accrual, zero-share passthrough, no-referrer regression.
- CHANGELOG entry added under [Unreleased] > Added.

Closes stellar-vortex-protocol#281
@drips-wave

drips-wave Bot commented Sep 2, 2026

Copy link
Copy Markdown

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

@james2177
james2177 merged commit 4b7102a into stellar-vortex-protocol:main Sep 3, 2026
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.

[High] Implement an optional on-chain referral fee-share for submit_intent

2 participants