Repository navigation
feat(referral): implement referral tier upgrade contract for volume-based reward increases (#1034) - #1063
Merged
Chucks1093 merged 1 commit intoOct 18, 2026
Conversation
…rd rate increases (accesslayerorg#1034) - Extend ReferralContract with Bronze, Silver, and Gold tiers and configurable reward rate bps - Compute referral tiers dynamically from cumulative referred trade volume - Enforce ratchet-only tier upgrades so referrers never downgrade regardless of volume drops - Emit ReferralTierUpgraded event on tier upgrade with old tier, new tier, volume, and bps - Implement get_referral_tier returning current tier, cumulative volume, and next threshold - Add reward accrual applying tier-specific reward rates and claim_referral_rewards - Add unit and integration tests covering tier computation, upgrades, events, ratcheting, and accrual - Document tier upgrade event in docs/contract-event-conventions.md Closes accesslayerorg#1034
|
@Sensei-Victor 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! 🚀 |
5 tasks
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
Extends the referral contract with a tier system that increases referral reward rates as a referrer's cumulative referred trade volume crosses configured thresholds.
Resolves #1034
Scope & Implementation Details
Referral Tiers (
ReferralTier):Bronze(0): default baseline tier, 500 bps (5.00%) reward rate, threshold: 0Silver(1): 1,000 bps (10.00%) reward rate, threshold: 100,000Gold(2): 1,500 bps (15.00%) reward rate, threshold: 1,000,000set_tier_configby authorized admin, with canonical fallback defaults.Cumulative Referred Trade Volume & Tier Calculation:
record_trade/record_trade_volume: increments a referrer's cumulative referred volume and checks for threshold crossing.compute_tier_from_volume: dynamically resolves the tier based on cumulative volume and configured thresholds.Ratchet-Only Guarantee:
adjust_volume).View Function (
get_referral_tier):ReferralTierInfo { tier, volume, next_threshold }.Some(silver_threshold)for Bronze,Some(gold_threshold)for Silver,Nonefor Gold).Reward Accrual (
accrue_reward/accrue_referral_reward):(fee_amount * reward_rate_bps) / 10_000.claim_referral_rewards.Event Emission:
ReferralTierUpgradedevent on topic(Symbol("tier_upg"), referrer)containingreferrer,old_tier,new_tier,volume, andreward_rate_bps.creator-keys/src/events.rsand documented indocs/contract-event-conventions.md.Acceptance Criteria Validation
Testing Performed
All 13 unit and integration tests in
referral-contractpass cleanly:Quality and formatting checks:
cargo fmt --all -- --checkpassedcargo clippy -p referral-contract -p creator-keys --lib -- -D warningspassed (0 warnings)cargo check --workspacepassed