Skip to content
A

AutoDipper

Automated "Buy the Dip" Smart Contract

Created on 28th June 2025

•

A

AutoDipper

Automated "Buy the Dip" Smart Contract

The problem AutoDipper solves

AutoDipper: The Problem & Solution

The Problem
Crypto markets are volatile and move 24/7, but most people can't monitor them constantly. When ETH drops to attractive prices, you're often sleeping, working, or just not watching. This leads to:
Missed Opportunities: ETH drops to $2000 but you're not there to buy.
Emotional Trading: FOMO buying at peaks, panic selling at bottoms.
Time Investment: Hours spent monitoring charts and placing orders.
Inconsistent Strategy: No discipline to stick to "buy the dip" plans.

  • The Solution*
    AutoDipper automatically buys ETH when prices drop to your target levels using Chainlink's real-time price feeds.
// Set it and forget it
createDipOrder(2200, 1000); // Buy $1000 worth when ETH hits $2200
createDipOrder(2000, 1000); // Buy another $1000 when ETH hits $2000

Who Uses It & How
Individual Investors
Busy Professionals: Set price targets, let AutoDipper work while you focus on your job.
New Crypto Users: Simple "buy the dip" strategy without complex trading knowledge.
Long-term Holders: Dollar-cost average into ETH at optimal prices automatically

Small Business Owners.
Treasury Management: Automatically convert excess USDC to ETH when prices are favorable.
Inflation Protection: Hedge against fiat devaluation with automated crypto allocation.

DeFi Users
Yield Farmers: Automatically rebalance portfolios during market dips
Liquidity Providers: Optimize entry points for providing liquidity.

How It Makes Things Easier
Massive Time Savings
Setup: 5 minutes vs. hours of strategy development.
Monitoring: 0 hours vs. 2-3 hours daily watching charts.
Execution: Instant vs. minutes of manual trading.

Accessibility
No Trading Knowledge: Just set price targets.
24/7 Operation: Works while you sleep.
Global Access: Works anywhere with internet.
Any Amount: Works with any USDC balance.

Cost Efficiency
Fees: Only gas costs vs. trading fees + subscriptions.
No Slippage: Perfect execution vs. market delays.
No Missed Trades: Automatic vs. manual timing errors.

AutoDipper transforms the complex task of timing crypto purchases into a simple, automated system that works 24/7 while you focus on what matters most. It's like having a professional trader working for you around the clock, but without the fees, emotions, or time investment.

Challenges I ran into

1. Frontend Error Handling & User Feedback
The Problem
Poor error handling led to confusing user experiences when transactions failed or contracts were unavailable.

The Hurdle
Generic error messages
No loading states
Silent failures

The Solution
Implemented comprehensive error handling with specific messages
Added loading states and progress indicators
Created toast notifications for user feedback
Added transaction status tracking

2. OpenZeppelin Version Conflicts
The Problem
Encountered version conflicts between OpenZeppelin contracts and Chainlink dependencies, causing compilation errors.

The Solution
Standardized on OpenZeppelin 5.0.1 across all dependencies
Updated foundry.toml to use consistent Solidity version (0.8.18)
Manually resolved version conflicts by ensuring all contracts used compatible pragma versions

3. Frontend-Backend Integration with wagmi v2
The Problem
Migrating from wagmi v1 to v2 introduced breaking changes in how contract interactions work, particularly with reading contract data.

The Hurdle

// This no longer worked in wagmi v2
const { data } = useContractRead({
  address: contractAddress,
  abi: contractABI,
  functionName: 'getLatestPrice',
});

The Solution
Updated to use useReadContract hook
Implemented proper error handling for contract reads
Used usePublicClient for manual contract interactions:

const publicClient = usePublicClient();
const data = await publicClient.readContract({
  address: dipSaverAddress,
  abi: DipSaverABI,
  functionName: "getLatestPrice",
});

4. USDC Decimal Mismatch
The Problem
Initially treated USDC as 6 decimals (standard) but deployed MockUSDC with 18 decimals, causing balance display and transaction issues.

The Hurdle

// Frontend expected 6 decimals
const amount = parseUnits("1000", 6); // 1000 USDC
// But contract used 18 decimals
const amount = parseUnits("1000", 18); // 1000 * 10^12 USDC

The Solution
Standardized on 18 decimals for MockUSDC to match ETH
Updated frontend constants and formatting functions
Added clear documentation about decimal handling
Implemented proper conversion utilities

5. Transaction Confirmation & RPC Issues
The Problem
Transactions were being sent but not showing up on Sepolia Etherscan, and frontend wasn't receiving confirmation.

The Hurdle
Transactions appeared to fail silently
No error messages in frontend
RPC timeouts and connection issues

The Solution
Switched to Alchemy RPC for better reliability
Implemented proper transaction waiting with provider.waitForTransaction()
Added comprehensive error handling and logging
Used wagmi's useWaitForTransactionReceipt for better UX

6. Price Feed Integration Testing
The Problem
Difficulty testing Chainlink price feed integration on local networks without real price data.

The Hurdle
Local networks don't have Chainlink price feeds
Hard to verify price-based logic works correctly
Testing required deployment to testnets

The Solution
Created mock price feed contracts for local testing
Implemented comprehensive unit tests with different price scenarios
Used Sepolia testnet for integration testing with real Chainlink feeds
Added price validation and error handling

7. Transaction Confirmation & RPC Issues
The Problem
Transactions were being sent but not showing up on Sepolia Etherscan, and frontend wasn't receiving confirmation.

The Hurdle
Transactions appeared to fail silently
No error messages in frontend
RPC timeouts and connection issues

The Solution
Switched to Alchemy RPC for better reliability
Implemented proper transaction waiting with provider.waitForTransaction()
Added comprehensive error handling and logging
Used wagmi's useWaitForTransactionReceipt for better UX

Tracks Applied (1)

Onchain Finance

AutoDipper: Revolutionizing On-Chain Finance with Automated Trading AutoDipper represents the evolution of on-chain fin...Read More

Discussion

Builders also viewed

See more projects on Devfolio