Rebalancing Lit Action
What is the Rebalancing Lit Action?
The Rebalancing Lit Action is like a smart liquidity manager that automatically balances token supplies across different blockchains. Think of it as a financial advisor that constantly monitors and adjusts where money is stored to ensure optimal distribution and availability.
What Does It Do?
The Problem It Solves
When the Genius Protocol operates across multiple blockchains (Ethereum, Base, Solana, etc.), liquidity can become unevenly distributed. For example:
Base might have $10 million in USDC but only $2 million in demand
Solana might have $2 million in USDC but $8 million in demand
This creates inefficiency and poor user experience
The problem is: how do we automatically move liquidity to where it's needed most?
The Solution
The Rebalancing Lit Action solves this with a two-phase approach:
Instructions Phase: Analyzes all vaults and calculates what needs to be moved where
Execution Phase: Actually moves the liquidity using bridges
Architecture: Two-Phase System
Due to Lit Network limitations (HTTP call limits, 30-second timeouts), rebalancing uses a sophisticated two-phase approach:
Phase 1: Instructions (Planning)
Analyze Vaults → Calculate Rebalancing → Sign Instructions → Store Results
What happens:
Fetch vault data from all supported chains
Calculate optimal distribution based on current balances and target ratios
Generate rebalancing actions (what to move where)
Sign the instructions with authorized keys
Return signed instructions for execution
Phase 2: Execution (Action)
Receive Instructions → Validate Signature → Execute Transfers → Confirm Results
What happens:
Receive signed instructions from Phase 1
Validate the signature and timestamp
Execute the transfers using bridges
Confirm successful execution
How Does It Work?
Step 1: Vault Analysis
The system checks all vaults across supported chains:
For EVM chains:
Gets stablecoin balance
Gets available liquidity
Gets top holder balance (for risk assessment)
For Solana:
Gets USDC balance from the pool
Gets available liquidity
Calculates risk metrics
Step 2: Rebalancing Calculation
The algorithm determines what needs to be moved:
Target Distribution:
Equal distribution: Each chain gets the same amount (default)
Custom ratios: Specific percentages per chain (if provided)
Minimum amounts: Only rebalance if amount > $1 (configurable)
Calculation Logic:
// Example: 3 chains with equal distribution
Chain A: $10M available → Target: $4M → Move out: $6M
Chain B: $2M available → Target: $4M → Move in: $2M
Chain C: $0M available → Target: $4M → Move in: $4M
Step 3: Bridge Selection
For each rebalancing action, the system:
Fetches bridge quotes from multiple providers
Selects the best route (lowest fees, fastest)
Prepares transactions for execution
Step 4: Execution
The system executes the transfers:
For EVM chains:
Creates bridge transactions using vault contracts
Handles gas optimization
Manages transaction ordering
For Solana:
Creates multiple transactions (remove liquidity + bridge + add liquidity)
Includes fallback mechanisms
Handles decimal conversions
Technical Implementation
Instructions Phase
Vault Data Structure:
interface VaultData {
network: ChainId; // Which blockchain
stablecoin: string; // Token address
decimals: number; // Token decimals
vaultBalance: bigint; // Total vault balance
availableBalance: bigint; // Available for rebalancing
highestStakedAmount: bigint; // Risk metric
}
Rebalancing Action:
interface RebalanceAction {
sourceNetwork: ChainId; // Where to take from
targetNetwork: ChainId; // Where to send to
amount: string; // How much to move
}
Signed Instructions:
interface RebalancingInstructions {
actions: RebalanceAction[]; // What to do
finalAvailableBalances: { [chainId: string]: string }; // Expected results
timestamp: number; // When created
env: ENVIRONMENT; // Which environment
}
Execution Phase
Signature Validation:
5-minute validity period to prevent replay attacks
Authorized signer verification using
REBALANCING_INSTRUCTIONS_SIGNER
Environment matching to prevent cross-environment attacks
Bridge Integration:
Genius Intents for bridge quote fetching
Multiple bridge support (Across, Stargate, etc.)
Slippage protection (1% default)
Authority delegation for cross-chain transfers
Real-World Example
Let's say the system detects uneven liquidity distribution:
Current State:
Base: $8M USDC available
Optimism: $1M USDC available
Solana: $1M USDC available
Target State (Equal Distribution):
Each chain should have ~$3.33M USDC
Phase 1 - Instructions:
{
actions: [
{
sourceNetwork: ChainId.BASE,
targetNetwork: ChainId.OPTIMISM,
amount: "4667000000" // $4.667M
},
{
sourceNetwork: ChainId.BASE,
targetNetwork: ChainId.SOLANA,
amount: "4667000000" // $4.667M
}
],
timestamp: 1703123456789,
env: ENVIRONMENT.STAGING
}
Phase 2 - Execution:
Base → Optimism: Bridge $4.667M using Across bridge
Base → Solana: Bridge $4.667M using Stargate bridge
Confirm: Verify all transfers completed successfully
Security Features
1. Signature Validation
Authorized signers only: Only specific addresses can create valid instructions
Timestamp validation: Prevents replay attacks with 5-minute window
Environment isolation: Staging and production are completely separate
2. Risk Management
Minimum amounts: Only rebalance if amount > $1 (prevents dust attacks)
Maximum amounts: Respects vault capacity limits
Slippage protection: 1% maximum slippage on bridge transfers
3. Error Handling
Graceful failures: If one transfer fails, others continue
Fallback mechanisms: Alternative execution paths for Solana
Comprehensive logging: All actions are logged for audit
Key Benefits
For Users
Better liquidity: Always have tokens available where you need them
Lower fees: Optimized routing reduces bridge costs
Faster execution: Pre-funded liquidity means instant transfers
For the Protocol
Efficient capital usage: Money is always where it's needed
Risk reduction: Balanced exposure across chains
Scalability: Can handle growing demand across all chains
For Bridge Providers
Predictable volume: Regular rebalancing creates consistent demand
Optimized routes: System finds the best bridges automatically
Reduced congestion: Spreads transfers across multiple providers
Architecture: The Proxy Pattern
Like the Solver, the Rebalancing Lit Action uses a proxy pattern for upgradability:
Proxy Structure
User calls Proxy → Proxy checks on-chain registry → Proxy calls Implementation → Result returned
Environment-Specific Proxies:
rebalancing-execution-proxy-dev.ts
: Development environmentrebalancing-execution-proxy-staging.ts
: Staging environmentrebalancing-execution-proxy-test.ts
: Test environment
Implementation Lookup
// Get current implementation from on-chain registry
const implementationId = await geniusActions.getActionImplementationId(
ActionTypeEnum.REBALANCER,
);
// Call implementation with parameters
const resImpl = await Lit.Actions.call({
ipfsId: implementationId,
params
});
Best Practices
1. Monitoring
Regular execution: Run rebalancing every few hours
Balance thresholds: Trigger when imbalance > 20%
Performance tracking: Monitor execution times and success rates
2. Risk Management
Gradual rebalancing: Don't move everything at once
Bridge diversification: Use multiple bridges for large amounts
Emergency stops: Ability to pause rebalancing if needed
3. Optimization
Batch processing: Execute multiple actions together
Gas optimization: Choose optimal times for EVM transactions
Route selection: Always use the best available bridge
Conclusion
The Rebalancing Lit Action is the backbone of the Genius Protocol's liquidity management system. By automatically maintaining optimal token distribution across all supported chains, it ensures users always have access to the liquidity they need, when they need it.
The two-phase architecture makes it robust and efficient, while the proxy pattern ensures it can evolve and improve over time. This creates a seamless cross-chain experience where users don't need to worry about which chain has liquidity - the system handles it all automatically.