Restructured hedger modules: moved CLP hedger and auto hedger into separate folders, updated data fetchers and main app, removed deprecated files
This commit is contained in:
174
clp_auto_hedger/FEE_COLLECTION_INSTRUCTIONS.md
Normal file
174
clp_auto_hedger/FEE_COLLECTION_INSTRUCTIONS.md
Normal file
@ -0,0 +1,174 @@
|
||||
# Fee Collection & Position Recovery Script
|
||||
|
||||
## Overview
|
||||
This script (`collect_fees_simple.py`) will collect all accumulated fees from your Uniswap V3 positions and handle stuck positions that may be in "CLOSING" status due to timeout transactions.
|
||||
|
||||
## Features
|
||||
✅ **Comprehensive Fee Collection**
|
||||
- Collects fees from ALL positions regardless of status (OPEN, CLOSING, etc.)
|
||||
- Handles positions with zero liquidity (fees only)
|
||||
- Enhanced gas settings for reliability (4x multiplier)
|
||||
- 10-minute timeout for large transactions
|
||||
- Detailed logging and error handling
|
||||
|
||||
✅ **Balance Checking**
|
||||
- Shows current ETH, WETH, and USDC balances
|
||||
- Displays position details before processing
|
||||
- Cross-references on-chain vs local status
|
||||
|
||||
✅ **Safety Features**
|
||||
- Simulates fees first to show expected amounts
|
||||
- User confirmation before executing
|
||||
- Transaction monitoring and retry logic
|
||||
- Comprehensive error reporting
|
||||
|
||||
## Usage
|
||||
|
||||
### Prerequisites
|
||||
```bash
|
||||
# Install required packages (if not already installed)
|
||||
pip install web3 eth-account python-dotenv
|
||||
```
|
||||
|
||||
### Setup
|
||||
1. **Ensure your .env file is configured:**
|
||||
```env
|
||||
MAINNET_RPC_URL=https://arb1.arbitrum.io/rpc
|
||||
MAIN_WALLET_PRIVATE_KEY=0x_your_actual_private_key_here
|
||||
```
|
||||
|
||||
### Run Script
|
||||
```bash
|
||||
python collect_fees_simple.py
|
||||
```
|
||||
|
||||
## What the Script Does
|
||||
|
||||
### 1. **Connection & Setup**
|
||||
- Connects to Arbitrum
|
||||
- Sets up your wallet
|
||||
- Loads contract ABIs
|
||||
|
||||
### 2. **Wallet Balance Check**
|
||||
- Shows current ETH balance
|
||||
- Shows WETH balance (if available)
|
||||
- Shows USDC balance (if available)
|
||||
|
||||
### 3. **Position Analysis**
|
||||
For each position in `hedge_status.json`:
|
||||
- ✅ **Gets on-chain position details**
|
||||
- ✅ **Calculates pending fees** via simulation
|
||||
- ✅ **Shows token pair and liquidity**
|
||||
- ✅ **Displays expected fee amounts**
|
||||
|
||||
### 4. **Fee Collection**
|
||||
For every position with fees to collect:
|
||||
- ✅ **Builds transaction with 4x gas price**
|
||||
- ✅ **Uses 300k gas limit for safety**
|
||||
- ✅ **10-minute timeout for network congestion**
|
||||
- ✅ **Transaction monitoring and confirmation**
|
||||
|
||||
### 5. **Reporting**
|
||||
- Success/failure counts
|
||||
- Transaction hashes
|
||||
- Arbiscan links
|
||||
- Summary statistics
|
||||
|
||||
## Expected Output
|
||||
|
||||
```
|
||||
=== Fee Collection & Position Recovery Script ===
|
||||
[SUCCESS] Connected to Chain ID: 42161
|
||||
Wallet: 0xYourAddress...
|
||||
|
||||
ETH Balance: 1.234567 ETH
|
||||
WETH Balance: 0.181031 WETH
|
||||
USDC Balance: 1640.82 USDC
|
||||
|
||||
Processing X positions for fee collection...
|
||||
|
||||
--- Processing Position 5167004 (CLOSING) ---
|
||||
Token Pair: WETH/USDC
|
||||
On-chain Liquidity: XXXXXX
|
||||
Expected fees: 0.000123 WETH + 123.456789 USDC
|
||||
Collect fees sent: 0xabcdef123...
|
||||
Arbiscan: https://arbiscan.io/tx/0xabcdef123
|
||||
[SUCCESS] Fees collected from position 5167004
|
||||
|
||||
--- Processing Position 123456 (OPEN) ---
|
||||
Token Pair: WETH/USDC
|
||||
On-chain Liquidity: XXXXXX
|
||||
Expected fees: 0.000456 WETH + 456.789012 USDC
|
||||
Collect fees sent: 0xdef456789...
|
||||
Arbiscan: https://arbiscan.io/tx/0xdef456789
|
||||
[SUCCESS] Fees collected from position 123456
|
||||
|
||||
=== Fee Collection Summary ===
|
||||
Total Positions: X
|
||||
Successful: X
|
||||
Failed: 0
|
||||
[SUCCESS] Fee collection completed for X positions!
|
||||
=== Fee Collection Script Complete ===
|
||||
```
|
||||
|
||||
## Benefits for Your Situation
|
||||
|
||||
### **Recover from Timeout Issues**
|
||||
- Position 5167004 is stuck in "CLOSING" status due to timeout
|
||||
- Script will still collect fees even if liquidity decrease failed
|
||||
- Fees are separate from the stuck transaction
|
||||
|
||||
### **Collect All Accumulated Fees**
|
||||
- Get back all fees from all positions
|
||||
- Especially important for profitable positions
|
||||
- Fees are your earned income
|
||||
|
||||
### **Enhanced Reliability**
|
||||
- 4x gas multiplier (vs 2x in original)
|
||||
- Longer timeouts (600s vs 120s)
|
||||
- Higher gas limits (300k vs 100k)
|
||||
- Better error handling
|
||||
|
||||
## Important Notes
|
||||
|
||||
⚠️ **Safety Precautions:**
|
||||
- Script shows expected fees before collecting
|
||||
- User confirmation required before execution
|
||||
- Logs all transactions for verification
|
||||
- Uses safe gas parameters
|
||||
|
||||
⚠️ **Transaction Behavior:**
|
||||
- Some positions may have no fees to collect
|
||||
- Positions with 0 liquidity still hold collectible fees
|
||||
- All transactions are monitored until confirmed
|
||||
|
||||
⚠️ **Stuck Position Handling:**
|
||||
- Can collect fees even if position is stuck
|
||||
- Status corrections for mismatched states
|
||||
- No liquidity decrease (fee collection only)
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### **Script Fails to Start:**
|
||||
- Check .env file contains correct RPC and private key
|
||||
- Ensure private key is valid hex format
|
||||
- Verify internet connection
|
||||
|
||||
### **Transaction Failures:**
|
||||
- Network congestion - retry automatically
|
||||
- Insufficient gas - script uses high gas settings
|
||||
- Contract issues - check logs for specific errors
|
||||
|
||||
### **Balance Issues:**
|
||||
- Check Arbiscan for successful transactions
|
||||
- Verify funds in your wallet
|
||||
- Some delays possible due to finalization
|
||||
|
||||
## After Running
|
||||
|
||||
1. **Check `collect_fees.log`** for detailed operation logs
|
||||
2. **Verify on Arbiscan** using provided transaction links
|
||||
3. **Check wallet balances** should increase by collected fees
|
||||
4. **Update status** if needed (script handles automatically)
|
||||
|
||||
This script is specifically designed to handle your situation where position decrease transactions are timing out but you still want to collect accumulated fees safely.
|
||||
Reference in New Issue
Block a user