Skip to content

feat: add dividend distribution and claim functionality#412

Open
syed-ghufran-hassan wants to merge 5 commits into
accesslayerorg:mainfrom
syed-ghufran-hassan:patch-1
Open

feat: add dividend distribution and claim functionality#412
syed-ghufran-hassan wants to merge 5 commits into
accesslayerorg:mainfrom
syed-ghufran-hassan:patch-1

Conversation

@syed-ghufran-hassan

@syed-ghufran-hassan syed-ghufran-hassan commented Jun 24, 2026

Copy link
Copy Markdown

Summary

  • Implement distribute_dividend to allow anyone to deposit XLM and split it proportionally among current key holders of a creator, after deducting a protocol fee.

  • Implement claim_dividend for holders to withdraw their accrued dividends; resets claimable balance to zero.

  • Add get_claimable_dividend view function to read unclaimed dividend balances.

  • Maintain a holders list per creator, updated on key buys and sells, to efficiently iterate over current holders during distribution.

  • Add new storage keys HoldersList and DividendClaimable to persist holder sets and claimable amounts.

  • Extend ContractError with ZeroClaimable, NoHolders, DividendAmountZero (appended at the end).

  • Add event structures and helpers (DividendDistributedEvent, DividendClaimedEvent) and publish events on distribution/claim.

  • Reuse existing protocol fee configuration to deduct fees from distribution amounts.

  • Update buy_key and sell_key to add/remove holders from the list.

Testing

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace

Checklist

  • Linked issue or backlog item
  • Added or updated creator-keys unit/integration tests for every changed contract behavior, including failure paths for new or reachable ContractError variants
  • Ran cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, and cargo test --workspace, or explained exactly why a command was not run
  • Reviewed persistent storage changes against docs/storage-key-invariants.md; any storage layout change includes a migration/backward-compatibility note
  • Confirmed event names, topic order, payload field order, and field meanings remain compatible with docs/contract-event-conventions.md, or documented the breaking change and versioning plan
  • Updated docs for any changed public contract interface, read-only method, event schema, storage behavior, fee logic, or deployment workflow
  • Scope stays limited to one contract concern and does not include unrelated formatting, lockfile, generated artifact, or dependency changes

- Implement distribute_dividend to allow anyone to deposit XLM and split it proportionally among current key holders of a creator, after deducting a protocol fee.

- Implement claim_dividend for holders to withdraw their accrued dividends; resets claimable balance to zero.

- Add get_claimable_dividend view function to read unclaimed dividend balances.

- Maintain a holders list per creator, updated on key buys and sells, to efficiently iterate over current holders during distribution.

- Add new storage keys HoldersList and DividendClaimable to persist holder sets and claimable amounts.

- Extend ContractError with ZeroClaimable, NoHolders, DividendAmountZero (appended at the end).

- Add event structures and helpers (DividendDistributedEvent, DividendClaimedEvent) and publish events on distribution/claim.

- Reuse existing protocol fee configuration to deduct fees from distribution amounts.

- Update buy_key and sell_key to add/remove holders from the list.

@syed-ghufran-hassan syed-ghufran-hassan left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review as incorporated comment

@syed-ghufran-hassan syed-ghufran-hassan left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed incorporated

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.

1 participant