Rebalance and Allocation Lifecycle
Allocation changes do not activate immediately.
Allocation Update Flow
- Curator calls
update_allocationwithtimelock_secs. - Program stores
pending_allocations+pending_allocations_activation_ts. - Depositors can review changes and exit during timelock window.
- On next eligible
rebalance, if timelock is expired:- pending allocations are promoted to active allocations,
- pending state is cleared,
AllocationUpdateAppliedis emitted.
apply_allocation_update validates pending/timelock state and returns a clear error that activation happens on rebalance.
Orphan Guard
When allocations are removed, update_allocation requires the corresponding VaultReservePosition.shares == 0. This prevents orphaned reserve positions with stranded funds.
Rebalance Paths
Same-mint rebalance
move_vault_reserve_liquidity moves capital between reserve classes of the same mint (e.g. USDC-idle to USDC-Kamino).
Cross-mint rebalance
Uses a two-phase swap pattern:
rebalance_swap_begin— locks the vault, validates pre-conditions, marks swap in progress.- Keeper executes the swap via router (Jupiter/Titan).
rebalance_swap_end— validates post-conditions, updates reserve positions, unlocks vault.
Sequence Diagram
Why This Matters
- Clear and enforceable depositor exit window.
- No surprise strategy switch outside rebalance path.
- Single operational point for activation and drift correction.
- Orphan guard prevents funds getting stuck in removed allocations.