atom-001
Trading Bots for Automated Uniswap v4 Swaps
What it is
What it is
atom-001 is an onchain automation project that executes token swaps on Uniswap v4 without requiring a human intervention. It is built around Chainlink CRE workflows, strategy scripts, execution contracts, and a small web control panel that lets an operator monitor balances, start or stop strategies, and inspect recent trading activity.
How it works
The system continuously reads market and treasury state, runs a trading algorithm against that data, and decides whether to buy, sell, or hold. When the strategy returns a trade decision, the workflow routes that decision into the appropriate Uniswap v4 swap flow, signs and broadcasts the transaction, and records the result for monitoring. The surrounding UI acts as a control surface for selecting algorithms, observing portfolio allocation, and reviewing executed events.
What problem it solves
It solves the operational gap between having a trading strategy and reliably executing it onchain. Instead of manually watching prices, calculating position changes, and submitting swaps one by one, the bot automates monitoring, decisioning, and execution. That makes rebalancing faster, more consistent, and easier to run continuously, while reducing missed opportunities and manual execution overhead.
How it Works
It’s built as four layers:
- Chainlink CRE workflows: The buy and sell flows are separate CRE handlers that accept an HTTP trigger, validate amountIn, encode Uniswap v4 swap parameters, generate a signed CRE report, and submit that report onchain through EVMClient.writeReport() to the treasury consumer contract. See apps/workflows/buy-v4/main.ts and apps/workflows/sell-v4/main.ts.
- Onchain execution contract: The Solidity contract apps/workflows/contracts/src/TreasuryV4SwapConsumer.sol is the onchain executor. It receives the CRE report, decodes swap params, calls Uniswap v4 PoolManager.unlock(), performs the swap in unlockCallback, settles ETH or USDC depending on direction, and stores swap history and events.
- Data and orchestration layer in Bun: The Bun CLI reads the latest market and treasury telemetry from SQLite, runs a pluggable algorithm script, converts the decision into a trade payload, records an event, and launches bunx cre workflow simulate ... --broadcast to fire the matching workflow. That logic lives in apps/web/cli.ts. Two observer workflows feed the state: (1) apps/workflows/data-stream-observer/main.ts reads Chainlink price feeds. (2) apps/workflows/treasury-observer/main.ts reads ETH and USDC balances. Both send telemetry back into the Bun server API.
- Web control plane: The server is a Bun app using Bun.serve() and bun:sqlite. It ingests telemetry, stores audit events, exposes APIs for algorithms and portfolio state, and manages the active CLI process. See apps/web/server.ts. The frontend is a React app with TanStack Start that shows balances, algorithm controls, and the audit log in apps/web/src/routes/index.tsx.
In practice, observers collect state, Bun stores it, an algorithm decides whether to trade, CRE signs and routes the action, and the Solidity consumer executes the Uniswap v4 swap onchain.
Links
Created by
- Luis Tapia
- Alen Ramírez