Auto Rebalancing
Automate yield optimization for multiple predefined strategies .
Objective
The Auto Rebalancing Strategy automates yield optimization across multiple predefined strategies — each representing a specific capital deployment method such as lending, LP farming, leveraged looping, or vault aggregation.
It continuously:
Activates pending deposits into the most profitable strategy.
Rebalances or deactivates positions when better yields are found or performance declines.
Processes withdrawals safely by prioritizing liquidity sources to minimize friction.
1. Automation Overview
Trigger
Frequency: Every 1 hour (Cron)
Data fetched:
Current and historical APYs per strategy
TVL and liquidity
Historical volatility metrics
Transaction costs (gas, slippage)
2. Opportunity Discovery
Each strategy is a predefined configuration (asset pair, protocol, or vault). The rebalancing process evaluates all strategies to find the best net yield after accounting for risks and costs.
For each strategy:
Fetch performance metrics:
supplyAPY,borrowAPY(if relevant)TVL,liquidity,volatility,fees
Compute Net APY:
Store opportunities with all metadata for guard evaluation.
3. Independent Guard Checks
Each candidate opportunity passes through independent guard checks before being eligible for activation or rebalancing.
Each guard can be toggled or weighted differently depending on strategy type.
Minimum Pending Amount Avoid activating small deposits. Example:
pendingAssets ≥ 5000APY Improvement Ensure yield gain exceeds the threshold. Example:
ΔAPY ≥ 0.2%APY Stability Avoid pools or vaults with volatile APYs. Example:
volatility ≤ 0.5%Profit vs Gas Rebalance only if expected profit exceeds gas costs. Example:
(ΔAPY × balance × freqEst) > gasCostSlippage Profitability Require at least 10 days of additional yield to offset slippage. Example:
10-day profit > slippageCostTVL Capacity Limit exposure to small or illiquid pools. Example:
strategyTVL × maxShare = vaultLimitTVL Stability Ensure liquidity is stable and not fluctuating excessively. Example:
stdev(TVL)/mean(TVL) < 0.1
4. Decision Engine
The automation evaluates all eligible opportunities and selects the one with the highest net APY that passes all guards.
best_opportunity = None
for opp in opportunities:
if not check_apy_boost(opp.apy, currentAPY): continue
if not check_apy_stability(opp.historicalAPY): continue
if not check_profit_vs_gas(opp.apy, currentAPY, balance, freqEst, gasCost): continue
if not check_slippage(opp.apy, currentAPY, balance, opp.slippageCost): continue
if not check_tvl_capacity(opp.totalSupply, opp.poolTVL): continue
if not check_tvl_stability(opp.historicalTVL): continue
if not best_opportunity or opp.apy > best_opportunity.apy:
best_opportunity = opp5. Execution Logic
Better strategy found
IStrategy.rebalance() into target strategy
No better yield & current APY < 0
IStrategy.deactivate() or shift to a safe asset
Pending deposits ≥ MIN_ACTIVATION
IStrategy.activate() (enter current or best strategy)
Otherwise
No action (wait for next cycle)
6. Strategy Interface
Every strategy integrates with the Automation Controller via a unified interface. This allows the rebalancer to manage any strategy type through standardized calls.
interface IStrategy {
function activate(bytes calldata params) external;
function deactivate(bytes calldata params) external;
function rebalance(bytes calldata oldParams, bytes calldata newParams) external;
function getCurrentYield() external view returns (uint256);
function getExpectedYield(bytes calldata params) external view returns (uint256);
function getTVL() external view returns (uint256);
}Implementations of
IStrategymay wrap looping, LP vaults, money markets, or any structured yield product.
7. Withdrawal Automation
Withdrawals follow a prioritized flow to minimize capital movement:
Pending Deposits First Serve withdrawal requests from unactivated deposits (instant runtime match).
Idle Liquidity Second If insufficient, use liquidity already in the redeemVault.
Deactivation (Last Resort) If the above sources can’t satisfy withdrawals, call
IStrategy.deactivate()to unwind positions and release liquidity.
This creates a natural netting effect between new deposits and redemptions.
8. Risk Framework
Yield improvement threshold (≥0.2%)
APY stability filters
Gas and slippage profitability guards
TVL capacity and liquidity stability
Minimum activation size
Auto deactivation if APY < 0
All checks operate independently and can be updated without redeploying strategy contracts.
9. Yield Comparison Model
To compare yields across heterogeneous strategies, normalize all metrics to a net annualized APY:
A rebalance is triggered when:
10. Rebalance Flow
Detect better opportunity (ΔAPY > threshold).
Validate all guard checks.
Execute:
IStrategy.rebalance(oldParams, newParams);Rebalance transaction redistributes capital from the underperforming strategy to the target one.
Updated positions are stored in the Automation Controller state.
Key Takeaway
The Auto Rebalancing Strategy acts as a universal yield optimizer for any ERC-4626 or ERC-7540-compatible vault, using Ditto’s secure automation to maximize returns while maintaining safety and composability.
It provides a unified framework for automated capital deployment, rebalancing, and withdrawals — built for reliability, modularity, and cross-protocol interoperability.
Last updated

