feat: add deprecate_key and redeem for holder buybacks - #839
Merged
Chucks1093 merged 1 commit intoSep 5, 2026
Merged
Conversation
|
@DammyAji 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! 🚀 |
Contributor
Author
|
hi @Chucks1093 please kindly review and merge. Thank you. |
Member
❌ CI Failed —
|
Contributor
Author
hi @Chucks1093 The verify ci failure is pre existing on main and not on this PR. |
Member
|
It has been resolved Rebase and Fix MC |
Member
|
Fix CI and MC |
DammyAji
force-pushed
the
feat/834-key-deprecation-buyback
branch
from
September 4, 2026 23:02
f4ac1ab to
fb907ec
Compare
Member
|
MC |
…g#834) - Add ContractError::KeyDeprecated (54) and InsufficientEscrow (55) - Add DataKey::DeprecatedKey(Address) and DeprecationEscrow(Address) - Guard buy_key_with_referrer to reject with KeyDeprecated on deprecated keys - Add deprecate_key: creator-only, escrows supply*price, marks key deprecated - Add redeem: holder exchanges all keys for buyback_price_per_key * quantity - Emit KeyDeprecatedEvent on deprecate_key, KeysRedeemedEvent on redeem - Add integration tests covering all five acceptance criteria Closes accesslayerorg#834
DammyAji
force-pushed
the
feat/834-key-deprecation-buyback
branch
from
September 5, 2026 08:03
afdc155 to
305635f
Compare
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
Closes #834
This PR implements an on-chain key deprecation mechanism that allows creators to sunset a key in an orderly way. When a creator calls
deprecate_key, the key is permanently marked as deprecated, a fixed buyback price is set, and the total required payout (circulating_supply x buyback_price_per_key) is escrowed up-front. Holders can then callredeemat any time to exchange their entire balance for the fixed price.Problem
Creators who wanted to wind down a key had no on-chain mechanism to do so gracefully. Once keys were minted, there was no supported path to disable further purchases or guarantee that holders could exit at a fair price.
Changes
creator-keys/src/lib.rs
New error variants (appended, never reordered per enum stability contract):
ContractError::KeyDeprecated = 54- buy attempted on deprecated keyContractError::InsufficientEscrow = 55- creator underfunded the escrowNew DataKey variants (appended):
DeprecatedKey(Address)- marks key deprecated, stores buyback priceDeprecationEscrow(Address)- running escrow balance for redemptionsGuard in
buy_key_with_referrer(covers both buy entrypoints):Checks for
DeprecatedKeyimmediately after pause/blacklist guards and returnsKeyDeprecatedbefore any price math.deprecate_key(creator, caller, buyback_price_per_key, escrow_payment)creator(Unauthorized otherwise)buyback_price_per_key > 0;NotRegisteredif creator absentescrow_payment >= circulating_supply * buyback_price_per_key(InsufficientEscrow)DeprecatedKeyandDeprecationEscrowto persistent storageKeyDeprecatedEventredeem(creator, holder)NotRegisteredif key not deprecatedInsufficientBalanceif holder has no keysKeysRedeemedEvent; returns payout amountcreator-keys/src/events.rs
KeyDeprecatedEventwith topics(key_dep, creator); fields: creator, buyback_price_per_key, circulating_supply, total_escrow, ledgerKeysRedeemedEventwith topics(key_rdm, creator, holder); fields: creator, holder, quantity, payout, new_supply, ledgercreator-keys/tests/key_deprecation.rs
14 integration tests covering all five acceptance criteria:
Plus edge cases: double deprecation, multi-holder independent redemption, zero balance redeem, negative price guard, unregistered creator guard, referral path guard.
Checklist