/** * Rebalancer — Check vault positions and move capital to highest yield * * Flow: * 1. Read vault share balances across all Morpho vaults * 2. Estimate APY for each vault (totalAssets as proxy) * 3. If current vault isn't optimal, redeem → deposit into best vault * 4. All through the private pipeline (redeem is public, deposit uses ZK) */ import { ethers } from 'ethers'; import type { SwapProgress } from '../pipeline'; export interface VaultPosition { name: string; address: string; shares: bigint; assets: bigint; /** Formatted asset amount (human-readable) */ assetsFormatted: string; /** Estimated APY range string */ apyEstimate: string; /** Numeric APY midpoint for comparison */ apyMidpoint: number; } export interface RebalanceResult { positions: VaultPosition[]; currentVault: string | null; bestVault: string; action: 'rebalanced' | 'already-optimal' | 'no-positions'; redeemTxHash?: string; depositTxHash?: string; amountMoved?: string; } import { type VaultMetrics } from '../lend/morpho-api'; export declare function scanVaultPositions(smartWallet: string, provider: ethers.JsonRpcProvider, tokenDecimals?: number, metrics?: Record | null): Promise; export declare function findBestVault(metrics?: Record | null): Promise<{ name: string; midpoint: number; }>; export declare function executeRebalance(config: { privateKey: string; paymasterSignerKey: string; rpcUrl?: string; chainId?: number; minApyDiffPercent?: number; }, progress: SwapProgress): Promise;