feat(intent_settlement): optional on-chain referral fee-share (#281) - #338
Merged
james2177 merged 2 commits intoSep 3, 2026
Merged
Conversation
…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
|
@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! 🚀 |
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.
Summary
Implements an optional on-chain referral fee-share mechanism for the Vortex protocol, closing #281.
submit_intentnow accepts an optionalreferrer: Option<Address>.ProtocolConfiggains areferral_share_bpsfield (default0= disabled, backward-compatible).referral_share_bps > 0and a referrer is set, the configured slice of each fill's protocol fee is routed to the referrer atfill_intenttime; the remainder still goes toFeeRecipient.FeeRecipient, so no fee units are silently dropped).referrer == user) is rejected with the newError::SelfReferralvariant, preventing users from gaming the programme against their own volume.batch_submit_intenttuple type extended to carry the referrer through.CONTRIBUTING.md.SelfReferral = 35is appended afterSrcChainNotSupported = 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 viaset_config(which now takes areferral_share_bpsargument) and a referrer per intent viasubmit_intent.Changes
intent_settlement/src/lib.rsMAX_REFERRAL_SHARE_BPS/DEFAULT_REFERRAL_SHARE_BPSconstants,referral_share_bpsonProtocolConfig/ProtocolParams/IntentRecord,Error::SelfReferral,referrerparam onsubmit_intent+ self-referral guard, referral split infill_intentwith CEI ordering preserved,batch_submit_intenttuple extension, validation inset_config.intent_settlement/src/test.rsCtx::submit()helper to pass&Nonefor referrer; added assertion forparams.referral_share_bps; appended 5 tests (self-referral rejection, 20% split, multi-partial-fill accrual, zero-share passthrough, no-referrer regression).CHANGELOG.md[Unreleased] > Addeddescribing the feature.Tests
Five new tests in
intent_settlement/src/test.rs:submit_intent_self_referral_rejected—Error::SelfReferralreturned.fill_intent_referrer_receives_configured_split— 20% share: referrer getsfee * 2000 / 10_000, FeeRecipient gets the remainder.partial_fills_accrue_referral_share_across_fills— 100% share, two partial fills: referrer accumulatesfee1 + fee2.zero_referral_share_sends_all_fee_to_fee_recipient— explicit 0 share, referrer named, full fee still goes to FeeRecipient.fill_intent_no_referrer_unchanged_behavior— non-zero share, no referrer named, full fee still goes to FeeRecipient (regression guard).Compatibility
Nonefor the referrer,0for the share), so existing integrators callingsubmit_intentorset_configneed to be updated to the new arity but their semantics are unchanged.config_updatedevent payload gains a fifth field (referral_share_bps) — strictly additive.Error::SelfReferralis appended at index 35; no renumbering of existing variants.Closes #281.