⚖️ Rebalancing
Rebalancing is the automated process that ensures a basket stays true to its original investment strategy.
🤔 Why is Rebalancing Necessary?
Let's say a basket is designed to be 50% SOL and 50% JUP. If the price of SOL goes up significantly while JUP stays flat, the basket's actual composition might drift to being 65% SOL and 35% JUP.
If left alone, the basket would no longer represent its intended 50/50 strategy. Rebalancing corrects this by selling the overweight asset (SOL) and using the proceeds to buy the underweight asset (JUP), returning the basket to its target weights.
So if an asset runs and becomes overweight for example, the mechanism will sell it gradually and distribute it into other assets until it's back to its target weight - essentially "locking" profits into the basket.
⚙️ How Rebalancing Works
The Baskets Protocol uses a dual approach to rebalancing:
1. Transactional Rebalancing (Passive)
Every time a user deposits USDC into a basket, the smart contract intelligently allocates the funds. Instead of buying assets according to the target weights, it prioritizes buying the assets that are most underweight.
This means that user investment activity naturally and constantly pushes the basket's composition back towards its target, reducing the need for active intervention. This accounts for almost all rebalancing needed.
2. Keeper-Driven Rebalancing (Active)
If a basket has low trading volume and its weights drift significantly due to market volatility, an automated Keeper Bot will intervene.
- The keeper for each basket runs on a daily schedule.
- It checks the basket's current weights against its target weights.
- If the deviation exceeds a certain threshold (which is dynamic based on the basket's TVL), the keeper will initiate a rebalancing session.
- During this session, the keeper executes the necessary swaps to bring the basket back into alignment.