Repository navigation
feat: build holder reward for distribution key holder - #1162
Merged
Chucks1093 merged 4 commits intoOct 20, 2026
Conversation
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.
Add holder-rewards contract for airdrop distributions to key holders
Summary
Implements a new
holder-rewardsSoroban contract that lets a key's creator or theprotocol admin fund token airdrops distributed pro-rata to all current key holders,
based on a balance snapshot taken at airdrop creation.
Motivation
Creators and the protocol need a way to reward existing key holders with arbitrary
SEP-41 tokens. The existing
airdrop_keysin creator-keys mints new keys; thiscontract covers the complementary flow — distributing external reward tokens to the
holder base without touching key balances or the bonding curve.
Changes
New crate:
holder-rewards/src/lib.rs—HolderRewardsContractcreate_airdrop(key_id, caller, reward_token, total_amount) -> airdrop_idcallermust be the key creator (key_id, matching the creator-keysconvention) or the protocol admin; otherwise reverts with
Unauthorized.creator-keys contract's
get_holder_registry/get_key_balanceviews via a#[contractclient]trait (CreatorKeysReader). The creator-keys address isstored at
init.total_snapshot_supplyin the airdrop record, so later balance changes cannotshift any allocation.
total_amountofreward_tokenfrom the funder into the contract.MAX_AIRDROP_HOLDERS = 100non-zero holders, mirroring the boundscreator-keys applies to
take_snapshot/airdrop_keys.claim_airdrop(airdrop_id, caller) -> amounttotal_amount * snapshot_balance / total_snapshot_supply, marks thewallet claimed, transfers the reward tokens, and reverts with
AlreadyClaimedon a double claim.NoAllocationfor wallets that held nothing at the snapshot.get_airdrop_allocation(airdrop_id, wallet) -> AirdropAllocation { claimable, claimed }independent of current key balances.
get_airdrop(airdrop_id)view returning the full record incl. snapshot metadata.init(admin, creator_keys_contract)(once-only) andset_admin.AlreadyClaimed = 6per the issue).src/events.rsAirdropCreated— topics(Symbol, key_id); payload: airdrop id, key id,funder, reward token, total amount, snapshot supply, snapshot ledger.
AirdropClaimed— topics(Symbol, key_id, wallet); payload: airdrop id,key id, wallet, amount.
src/test.rs— 16 testsMock creator-keys contract + real Stellar Asset Contract reward token. Covers
every acceptance criterion:
test_pro_rata_allocation_computed_from_snapshot_balancestest_double_claim_reverts_with_already_claimedclaim_airdropreverts on double claim withAlreadyClaimedtest_post_snapshot_balance_changes_do_not_affect_allocationtest_get_airdrop_allocation_tracks_claimed_amountget_airdrop_allocationreturns accurate claimable/claimed before and after claimtest_get_airdrop_allocation_returns_zero_for_unknown_wallettest_airdrop_created_event_emitted_with_correct_dataAirdropCreatedemitted with correct airdrop datatest_airdrop_claimed_event_emitted_with_correct_dataAirdropClaimedemitted with correct amount dataNotPositiveAmount,NoHolders,HolderLimitExceeded, independent multi-airdrop idsRoot
Cargo.tomlholder-rewardsto workspace members.Acceptance Criteria Verification
holder split of a 1_000-token airdrop claims 300/700.
claim_airdropreverts on double claim withAlreadyClaimed— assertedvia
try_claim_airdroperror match.in creator-keys after creation; frozen allocations and claims unchanged.
get_airdrop_allocationreturns accurate amounts for any wallet —verified before/after claim and for non-holders.
decoded and field-checked in dedicated event tests.
CI Pre-Checks
All local CI checks pass:
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspace— all tests pass (16 new)Closes #1096