Skip to content

Conversation

@sisyphusSmiling
Copy link
Contributor

@sisyphusSmiling sisyphusSmiling commented Dec 18, 2025

Description

  • Adds scheduled rebalancing support with individualized RebalanceHandlers wired into a central per-Pool Registry
  • Support for per-Position recurring configuration as an extensible path
  • Adds support in FCM Pool for Position ID visibility to ensure non-existent pids are not registered
  • Tests passing, but I wasn't able to add tests specific to this new setup

Lifecycle

Creation

  1. Position is created
  2. Pool registers the PID in its associated Registry in account storage, optionally passing a PID-specific recurring config
  3. Registry stores the PID in its registry
  4. Registry initializes a RebalanceHandler in storage with paths derived from the Pool UUID & the Position ID
  5. Registry schedules the first scheduled rebalance based on either the custom or default recurring config

Updating Default Recurring Config

  1. Run the set_default_rebalance_recurring_config.cdc transaction with the desired values
  2. Registry stores the updated config as default
  3. Any successive RebalanceHandler scheduled executions are scheduled using the default (unless they have a custom config stored)

Steps to Initialize from Current State

  1. Update FCM contract
  2. Deploy FCMRegistry contract to FMC account (see contract init for starting default config values) - Registry is initialized in account storage
  3. Run backfill_positions.cdc transaction (--compute-limit 9999) which will register all existing PIDs in the Registry. This should spin up RebalanceHandlers for all existing Positions
  • If you run into computation limits (possible on Testnet especially)
    1. Get all Position IDs (see get_position_ids.cdc script)
    2. Pass in segments of the returned ID array in to backfill_specific_positions.cdc transaction to backfill in partitions. Again, the transaction will fail if one of the provided IDs does not exist in the Pool as a failsafe.

For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the standards mentioned here.
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels
  • Go WTF 💚

@sisyphusSmiling sisyphusSmiling changed the title Gio/scheduled rebalance Add scheduled rebalancing Dec 18, 2025
@sisyphusSmiling sisyphusSmiling marked this pull request as ready for review December 19, 2025 01:27
@sisyphusSmiling sisyphusSmiling requested a review from a team as a code owner December 19, 2025 01:27
@sisyphusSmiling sisyphusSmiling self-assigned this Dec 19, 2025
@sisyphusSmiling sisyphusSmiling added the enhancement New feature or request label Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants