Add automatic rebalancing contracts #131
Draft
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.
Closes: #90
After reviewing PR #80, it became clear that the approach had some problems.
This PR aims to provide a cleaner and more maintainable solution.
Updated Rebalance Architecture
The core philosophy is decoupling: each component operates independently with the least privilege necessary.
The Supervisor is currently in the design phase (not yet implemented).
Key Principles
rebalancefunction.fixReschedule()call is idempotent and permissionless, ensuring the system can recover without complex auth.Rebalancer variants
There are two rebalancer types; they behave the same for triggering rebalances.
The paid rebalancer is otherwise the same: it holds a rebalance capability and runs on the same schedule/trigger model; only who pays and who controls config differ.
creating a position
sequenceDiagram actor anyone participant FCMHelper as FCM<br/>Helper participant FCM participant AB as Rebalancer participant Supervisor anyone->>FCMHelper: createPosition() FCMHelper->>FCM: createPosition() FCMHelper->>AB: createRebalancer(rebalanceCapability) FCMHelper->>Supervisor: supervise(publicCapability)while running
sequenceDiagram participant AB1 as AutoRebalancer1 participant FCM participant AB2 as AutoRebalancer2 participant SUP as Supervisor loop every x min AB1->>FCM: rebalance() end loop every y min AB2->>FCM: rebalance() end loop every z min SUP->>AB2: fixReschedule() SUP->>AB1: fixReschedule() end