Autonomous agent that rebalances USDC treasury across chains using Circle CCTP and Uniswap v4
RebalanceX is an autonomous CLI agent that monitors USDC balances across multiple blockchains (Arc, Sepolia, Polygon Amoy, Arbitrum Sepolia) and automatically rebalances treasury allocations when they drift beyond a configurable threshold.
The agent uses Circle's CCTP (Cross-Chain Transfer Protocol) to perform trustless cross-chain USDC transfers via burn-and-mint, with built-in retry logic, gas estimation, and attestation polling. It also integrates Uniswap v4's Universal Router for on-chain token swaps when needed.
Key features: threshold-based rebalancing algorithm, multi-chain balance monitoring, dry-run mode for simulation, structured logging, and comprehensive test coverage (52 tests). Built with TypeScript, ethers.js v6, and designed for treasury automation without requiring a frontend.
Built with TypeScript and ethers.js v6, RebalanceX connects directly to Circle's CCTP smart contracts (TokenMessenger and MessageTransmitter) to perform cross-chain USDC transfers via the burn-and-mint mechanism. The agent polls Circle's attestation API to wait for message verification before completing transfers on the destination chain.
For Uniswap v4 integration, I use the Universal Router with Permit2 approvals for secure token swaps. The rebalancing engine implements a threshold-based algorithm that calculates deviations from target allocations and generates optimal transfer actions to minimize the number of cross-chain operations.
Notable technical choices: exponential backoff retry logic for network resilience, gas estimation with configurable buffers, structured Winston logging for auditability, and Jest test coverage. The CLI is built with Commander.js for a clean developer experience.

