import { Logger } from 'pino'; import { type ChainMap, type Token } from '@hyperlane-xyz/sdk'; import { type CollateralDeficitStrategyConfig, RebalancerStrategyOptions } from '../config/types.js'; import type { InflightContext, RawBalances, Route, StrategyRoute } from '../interfaces/IStrategy.js'; import { Metrics } from '../metrics/Metrics.js'; import { type BridgeConfigWithOverride } from '../utils/bridgeUtils.js'; import { BaseStrategy, type Delta } from './BaseStrategy.js'; /** * Strategy that detects collateral deficits (negative effective balances) * and proposes JIT rebalances using fast bridges. * * Logic: * 1. Filter pendingRebalances to only those using this strategy's configured bridges * 2. Simulate filtered pending rebalances to get projected balances * 3. Negative simulated balance = deficit (magnitude + buffer) * 4. Positive simulated balance = potential surplus */ export declare class CollateralDeficitStrategy extends BaseStrategy { readonly name = RebalancerStrategyOptions.CollateralDeficit; private readonly config; protected readonly logger: Logger; constructor(config: CollateralDeficitStrategyConfig, tokensByChainName: ChainMap, logger: Logger, bridgeConfigs: ChainMap, metrics?: Metrics); /** * Categorizes balances into surpluses and deficits. * * 1. Filter pendingRebalances/proposedRebalances by configured bridges * 2. Simulate those rebalances to get projected balances * 3. Negative balance = deficit (magnitude + buffer) * 4. Positive balance = potential surplus */ protected getCategorizedBalances(rawBalances: RawBalances, pendingRebalances?: Route[], proposedRebalances?: StrategyRoute[]): { surpluses: Delta[]; deficits: Delta[]; }; /** * Override to prefer transfer origins when selecting surplus chains. * * When a user transfer creates a deficit, the origin chain of that transfer * is the natural source of funds (user deposited there). This prevents * unnecessarily draining the largest balance (typically ethereum at 70%). */ getRebalancingRoutes(rawBalances: RawBalances, inflightContext?: InflightContext): StrategyRoute[]; /** * Filter pending rebalances to only those using this strategy's configured bridges. * A rebalance matches if: * - Its bridge matches the configured bridge (with overrides) for the route, OR * - It has no bridge (recovered from Explorer, can't verify - include to be safe) */ private filterByConfiguredBridges; /** * Build a map from deficit chains to their transfer origin chains. * This identifies which surplus chains are "natural" sources for each deficit. */ private buildTransferOriginMap; /** * Sort surpluses to prefer transfer origins over largest balances. * * Sorting priority: * 1. Chains that are origins of transfers TO any deficit chain (preferred) * 2. By amount descending (tiebreaker) */ private sortSurplusesWithOriginPreference; protected getTokenByChainName(chainName: string): Token; } //# sourceMappingURL=CollateralDeficitStrategy.d.ts.map