feat: add protocol trade fee, holder cap, sell lockup and TTL refresh - #774
Merged
Chucks1093 merged 2 commits intoAug 27, 2026
Merged
Conversation
|
@vjuliaife 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! 🚀 |
Closed
5 tasks
4 tasks
6 tasks
3 tasks
Adejumo-2
added a commit
to Adejumo-2/accesslayer-contracts
that referenced
this pull request
Aug 28, 2026
…and accesslayerorg#795 Two PRs (protocol-fee-holder-cap-lockup-ttl and fix/issues-758-757-756-755) branched from the same base and added items at positions 41-43 in ContractError, plus different DataKey variants, storage helpers, contract methods, and event types. When merged into main, the implementation code was silently dropped while the test files survived, causing compilation failures. Restored: - DataKey variants: RoyaltyConfig, CurveExponent, AuctionConfig, StakeUnlockLedger, TotalStaked, StakingRewardsPool, HolderCapBps, LastBuyTimestamp, ProtocolFeeBps, LockupDurationSecs - ContractError variants: BatchSizeExceeded, RoyaltyExceedsLimit, InvalidExponent, MaxHoldingExceeded, LockupPeriodActive, InvalidHolderCap - Contract methods: batch_buy, set_royalty, get_royalty_config, migrate_curve, get_curve_exponent, refresh_ttl - Event types: FeeCollectedEvent, LockupBlockedEvent - Storage helpers: holder_cap_bps, last_buy_timestamp - AuctionConfig struct - cargo fmt applied to all affected files
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
Adds four protocol-hardening features to the creator-keys contract: a configurable protocol trade fee routed to a treasury address on every buy and sell, a per-creator percentage holding cap enforced during buys, an anti-flash-trade sell lockup window, and systematic persistent-storage TTL maintenance with a new admin refresh entrypoint.
Changes
ProtocolFeeBpsstorage entry (default 100 bps = 1% viaset_protocol_feewithNone), deducted from the trade amount before the creator/seller split is computed; fee is credited to the treasury and afee_collectedevent carries the amount and treasury address. Admin can update both rate and treasury viaset_protocol_fee; 0 bps skips the treasury credit entirely. Addsget_protocol_trade_feeview.set_holder_cap(creator-only, validated 1%-25%, elseInvalidHolderCap). Buys that would push a non-creator wallet above the share of supply revert withMaxHoldingExceeded; the creator wallet is exempt. Addsget_holder_capview.LastBuyTimestamp(creator, holder); once the admin sets a duration viaset_lockup_duration, sells inside the window revert withLockupPeriodActiveand emit alockup_blockedevent. Default duration constant 86400s (24h). Addsget_lockup_durationview.TTL_MIN_EXTENSION_LEDGERS(~30 days) floor withbump_persistent_ttlapplied after hot persistent reads (key price, fee config, referral bps) and full-window extensions after writes across trades, credits, claims, stakes, transfers, withdrawals and admin config setters; new admin-onlyrefresh_ttl(creators)re-extends all known global entries plus each supplied creator's scoped entries in one call.MaxHoldingExceeded,LockupPeriodActive,InvalidHolderCap) and documents them indocs/error-codes.md; documents the four new storage keys indocs/storage-layout.md. All features are dormant until configured, so existing deployments and tests are unaffected.Issues
Resolves #753
Resolves #752
Resolves #751
Resolves #749
Verification
Manual code review completed: full diff inspected against all four issue acceptance criteria, rustfmt passes, and no snapshots or generated files were touched. New integration tests were added under
creator-keys/tests/(protocol_trade_fee.rs,holder_cap.rs,sell_lockup.rs,ttl_refresh.rs) covering buy/sell fee routing, cap enforcement and exemption, lockup rejection/expiry/timestamp refresh, and TTL extension plus refresh.cargo buildandcargo testwere not run.