Skip to content

feat(creator-keys): add dividend reinvestment function (#805) - #811

Merged
Chucks1093 merged 9 commits into
accesslayerorg:mainfrom
Oluwasuyi-Oluwatimilehin-Daniel:issue-805-dividend-reinvestment
Sep 5, 2026
Merged

feat(creator-keys): add dividend reinvestment function (#805)#811
Chucks1093 merged 9 commits into
accesslayerorg:mainfrom
Oluwasuyi-Oluwatimilehin-Daniel:issue-805-dividend-reinvestment

Conversation

@Oluwasuyi-Oluwatimilehin-Daniel

Copy link
Copy Markdown
Contributor

Summary

  • Implemented the reinvest_dividend entry point on CreatorKeysContract allowing key holders to atomically convert their unclaimed dividend balance into additional creator keys via the bonding curve in a single transaction.
  • Computed claimable dividends and iteratively executed whole key purchases at incremental bonding curve prices while remaining >= key_price and supply/wallet caps permit.
  • Automatically refunded/credited any residual dividend balance below the incremental price of 1 key to the caller's balance.
  • Reset the pending unclaimed dividend balance and updated the accumulator checkpoint to the current global value.
  • Reverted with ContractError::NoDividendToClaim when called with zero unclaimed dividend balance.
  • Accrued trading fees, protocol trade fees, royalties, incremented creator supply and holder balance, and updated last_buy_timestamp for anti-flash-trade sell lockups.
  • Emitted a structured DividendReinvestedEvent (div_reinv) containing wallet, key_id, keys_bought, remainder_returned, and ledger.
  • Added comprehensive integration test coverage in creator-keys/tests/dividend_reinvestment.rs covering happy path compounding, remainder returns, zero dividend errors, security guards, and event verification.

Closes #805

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

@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@Oluwasuyi-Oluwatimilehin-Daniel 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

@Chucks1093

Copy link
Copy Markdown
Member

✅ CI Passed — ⚠️ Merge Conflict

CI is green but this PR has a merge conflict with main and cannot be auto-merged.

To fix:

  1. Pull the latest main: git fetch origin && git checkout your-branch && git merge origin/main
  2. Resolve any conflicts in the affected files
  3. Run cargo build and cargo fmt to verify everything still compiles and is formatted
  4. Push the resolved branch — CI will re-run and the PR will be auto-merged once it passes

@Chucks1093

Copy link
Copy Markdown
Member

Fix MC

@Chucks1093

Copy link
Copy Markdown
Member

Merge Conflict

@Chucks1093
Chucks1093 merged commit ba45cee into accesslayerorg:main Sep 5, 2026
1 check passed
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.

Add a dividend reinvestment function allowing holders to automatically buy more keys using their dividend payout

2 participants