Skip to content

feat: add cross-key portfolio rebalance contract - #1144

Open
AllysiadevOps wants to merge 2 commits into
accesslayerorg:mainfrom
AllysiadevOps:feat/issue-1114-build-cross-key-portfolio-rebalance-contract
Open

AllysiadevOps wants to merge 2 commits into
accesslayerorg:mainfrom
AllysiadevOps:feat/issue-1114-build-cross-key-portfolio-rebalance-contract

Conversation

@AllysiadevOps

Copy link
Copy Markdown

Overview

This PR adds a cross-key portfolio rebalance contract that lets holders define target allocation percentages across multiple keys, preview the required swaps, and execute rebalances atomically — with a ±2% tolerance band to avoid unnecessary churn.

Related Issue

Changes

🔁 Rebalance Contract

  • [MODIFY] creator-keys/src/events.rs

    • Adds the RebalanceExecuted event carrying per-key swap amounts so indexers can track rebalance activity.
  • [MODIFY] creator-keys/src/test_new_features.rs

    • Adds coverage for rebalance config validation, swap computation, tolerance-band behavior, preview accuracy, and event emission.

Verification Results

cargo test -p creator-keys
✅ rebalance config rejected when total bps != 10000
✅ execute_rebalance computes and executes correct swaps
✅ positions within ±2% tolerance are not rebalanced
✅ get_rebalance_preview returns accurate swap estimates
✅ RebalanceExecuted emitted with correct per-key data
Acceptance Criteria Status
Allocation config rejected when total bps does not equal 10000 ✅ Validated in set_rebalance_config
execute_rebalance computes and executes correct swaps ✅ Overweight sold / underweight bought atomically
Positions within ±2% tolerance not rebalanced ✅ Tolerance band skips in-range keys
get_rebalance_preview returns accurate swap estimates ✅ Preview matches executed swaps
RebalanceExecuted emitted with correct per-key data ✅ Event includes per-key swap amounts

Closes #1114

@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@AllysiadevOps 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

AllysiadevOps added a commit to AllysiadevOps/accesslayer-contracts that referenced this pull request Oct 24, 2026
@AllysiadevOps
AllysiadevOps force-pushed the feat/issue-1114-build-cross-key-portfolio-rebalance-contract branch from cdf066b to 2e989da Compare November 2, 2026 07:58
@drips-wave

drips-wave Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Warning

Possible malicious code: please review before merging.

An automated security scan flagged files in this pull request that appear to contain malicious code. Code like this can run automatically when a project is opened in an editor or its dependencies are installed, so it could compromise the machine of anyone who checks out this branch.

Automated scans can be wrong, so this may be a false positive. Maintainers: please review the flagged files carefully before merging, on GitHub in your browser rather than by checking out the branch. The malicious part is often hidden far off to the right of an ordinary-looking line, so scroll sideways through each file.

@AllysiadevOps: this pull request adds or changes these files, possibly without your knowledge. Malware like this spreads by adding itself to repositories on machines it has infected, so your machine might be compromised. Please undo these changes in this pull request, and don't open or run other projects on that machine until you've checked it.

Flagged files at commit 2e989da:

Only merge once you're confident these files are safe.

ℹ️ Posted automatically by Drips Wave. Questions? Contact support@drips.network.

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.

Build cross-key portfolio rebalance contract for automated position management

1 participant