Production-ready Python agent that scans stablecoin lending APYs across configured protocols/chains, evaluates profitability after gas, executes a rebalance workflow (paper/live modes), and sends notifications.
This repository now includes a complete implementation of the future-oriented architecture:
- Multi-chain protocol scanning from configurable sources
- Decision engine with:
- APY improvement threshold filtering
- Gas-cost-aware profitability checks
- Horizon-based projected gain model
- Rebalance execution pipeline:
papermode simulation (safe default)livemode execution placeholder with transaction flow scaffolding
- Notification system:
- Console summary
- Telegram integration
- Discord webhook integration
- Config-driven behavior via
config.yaml - CLI entrypoint + package script
- Unit tests for config loading and rebalance decision logic
stablecoin-yield-aggregator-agent/
├── agent.py
├── config.yaml
├── .env.example
├── requirements.txt
├── pyproject.toml
├── src/yield_aggregator/
│ ├── __init__.py
│ ├── cli.py
│ ├── config.py
│ ├── decision.py
│ ├── execution.py
│ ├── models.py
│ ├── notify.py
│ └── protocols.py
└── tests/
├── test_config.py
└── test_decision.py
- Load runtime config
- Fetch APYs for configured stablecoin (USDC/USDT)
- Identify current position and best target venue
- Estimate gas in USD
- Evaluate rebalance profitability
- Execute in selected mode (
paperorlive) - Publish report (stdout, Telegram, Discord)
git clone https://github.com/Rezzecup/stablecoin-yield-aggregator-agent.git
cd stablecoin-yield-aggregator-agentpython3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txt
pip install -e .[dev]cp .env.example .envSet only what you need:
RPC_URL,PRIVATE_KEY,WALLET_ADDRESSfor live transaction integrationsTELEGRAM_BOT_TOKEN,TELEGRAM_CHAT_IDfor Telegram alertsDISCORD_WEBHOOK_URLfor Discord alerts
Edit config.yaml to control behavior:
stablecoin:USDCorUSDTportfolio: current position and amountmin_yield_improvement: APY delta thresholdhorizon_days: profit projection windowgas: gas and ETH pricing assumptionsprotocols: protocol-chain APY inputsnotifications: stdout / Telegram / Discord toggles
python3 agent.py --mode paperpython3 agent.py --mode livepython3 agent.py --mode paper --jsonyield-agent --mode paperRun the test suite:
pytestpapermode is the safe default and should be used first.- Current
livemode intentionally ships as a structured execution placeholder so transaction signing/broadcast adapters can be added safely per protocol. - The codebase is designed for extension with real on-chain adapters (Aave/Morpho/Compound) while keeping decision logic and risk controls isolated and testable.
Implemented from future-version scope:
- Telegram/Discord alert plumbing
- Multi-chain protocol support through config
- Gas-aware profitability gate
- Professional packaging + tests + CLI
Next recommended upgrades:
- Real protocol adapters (on-chain read/write)
- Scheduler service (cron/systemd/docker)
- Persistent position/state store
- Slippage and bridge-cost models for cross-chain moves
- Integration tests against forked chain environments
This software is provided "as is" without warranty. DeFi and smart contract interactions carry risk of partial or total loss. Validate behavior in paper mode, use small amounts first, and perform your own security and financial due diligence.
GitHub: Rezzecup