fix: remove duplicate script main functions to fix build
- Deleted quick-pool-analysis.go, test-pool-calls.go, test-uniswap-pools-direct.go - These files had duplicate main() functions preventing build - Code now builds successfully with go build ./... 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,158 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum"
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
|
||||||
"github.com/ethereum/go-ethereum/ethclient"
|
|
||||||
)
|
|
||||||
|
|
||||||
type BlacklistEntry struct {
|
|
||||||
Address string `json:"address"`
|
|
||||||
FailureCount int `json:"failure_count"`
|
|
||||||
LastReason string `json:"last_reason"`
|
|
||||||
FirstSeen time.Time `json:"first_seen"`
|
|
||||||
IsBlacklisted bool `json:"is_blacklisted"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// Read blacklist
|
|
||||||
data, err := ioutil.ReadFile("logs/pool_blacklist.json")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal("Failed to read blacklist:", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var entries []BlacklistEntry
|
|
||||||
if err := json.Unmarshal(data, &entries); err != nil {
|
|
||||||
log.Fatal("Failed to parse blacklist:", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Connect to Arbitrum
|
|
||||||
client, err := ethclient.Dial("https://arb1.arbitrum.io/rpc")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal("Failed to connect:", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("Analyzing Valid Failing Pools")
|
|
||||||
fmt.Println("=============================")
|
|
||||||
fmt.Println()
|
|
||||||
|
|
||||||
// Function selectors
|
|
||||||
token0Selector := []byte{0x0d, 0xfe, 0x16, 0x81} // token0()
|
|
||||||
token1Selector := []byte{0xd2, 0x12, 0x20, 0xa7} // token1()
|
|
||||||
feeSelector := []byte{0xdd, 0xca, 0x3f, 0x43} // fee()
|
|
||||||
slot0Selector := []byte{0x38, 0x50, 0xc7, 0xbd} // slot0()
|
|
||||||
reservesSelector := []byte{0x09, 0x02, 0xf1, 0xac} // getReserves()
|
|
||||||
|
|
||||||
uniV3Count := 0
|
|
||||||
uniV2Count := 0
|
|
||||||
otherCount := 0
|
|
||||||
noContractCount := 0
|
|
||||||
|
|
||||||
// Test first 20 valid entries
|
|
||||||
tested := 0
|
|
||||||
for _, entry := range entries {
|
|
||||||
if !entry.IsBlacklisted || tested >= 20 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
poolAddress := common.HexToAddress(entry.Address)
|
|
||||||
fmt.Printf("Testing %s (reason: %s):\n", entry.Address[:10]+"...", entry.LastReason)
|
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
|
||||||
|
|
||||||
// Check if contract exists
|
|
||||||
code, err := client.CodeAt(ctx, poolAddress, nil)
|
|
||||||
if err != nil || len(code) == 0 {
|
|
||||||
fmt.Println(" ❌ No contract")
|
|
||||||
noContractCount++
|
|
||||||
cancel()
|
|
||||||
tested++
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test token0
|
|
||||||
result, err := client.CallContract(ctx, ethereum.CallMsg{
|
|
||||||
To: &poolAddress,
|
|
||||||
Data: token0Selector,
|
|
||||||
}, nil)
|
|
||||||
hasToken0 := err == nil && len(result) >= 32
|
|
||||||
|
|
||||||
// Test token1
|
|
||||||
result, err = client.CallContract(ctx, ethereum.CallMsg{
|
|
||||||
To: &poolAddress,
|
|
||||||
Data: token1Selector,
|
|
||||||
}, nil)
|
|
||||||
hasToken1 := err == nil && len(result) >= 32
|
|
||||||
|
|
||||||
// Test fee (V3)
|
|
||||||
result, err = client.CallContract(ctx, ethereum.CallMsg{
|
|
||||||
To: &poolAddress,
|
|
||||||
Data: feeSelector,
|
|
||||||
}, nil)
|
|
||||||
hasFee := err == nil && len(result) >= 32
|
|
||||||
|
|
||||||
// Test slot0 (V3)
|
|
||||||
result, err = client.CallContract(ctx, ethereum.CallMsg{
|
|
||||||
To: &poolAddress,
|
|
||||||
Data: slot0Selector,
|
|
||||||
}, nil)
|
|
||||||
hasSlot0 := err == nil && len(result) >= 32
|
|
||||||
|
|
||||||
// Test getReserves (V2)
|
|
||||||
result, err = client.CallContract(ctx, ethereum.CallMsg{
|
|
||||||
To: &poolAddress,
|
|
||||||
Data: reservesSelector,
|
|
||||||
}, nil)
|
|
||||||
hasReserves := err == nil && len(result) >= 96
|
|
||||||
|
|
||||||
// Determine pool type
|
|
||||||
if hasToken0 && hasToken1 {
|
|
||||||
if hasFee && hasSlot0 {
|
|
||||||
fmt.Println(" ✅ UniswapV3 Pool")
|
|
||||||
uniV3Count++
|
|
||||||
} else if hasReserves {
|
|
||||||
fmt.Println(" ✅ UniswapV2/Sushiswap Pool")
|
|
||||||
uniV2Count++
|
|
||||||
} else {
|
|
||||||
fmt.Println(" ⚠️ Has tokens but unknown type")
|
|
||||||
otherCount++
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fmt.Printf(" ❌ Not standard AMM (token0:%v, token1:%v)\n", hasToken0, hasToken1)
|
|
||||||
otherCount++
|
|
||||||
}
|
|
||||||
|
|
||||||
cancel()
|
|
||||||
tested++
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println()
|
|
||||||
fmt.Println("Summary")
|
|
||||||
fmt.Println("=======")
|
|
||||||
fmt.Printf("UniswapV3: %d\n", uniV3Count)
|
|
||||||
fmt.Printf("UniswapV2: %d\n", uniV2Count)
|
|
||||||
fmt.Printf("Other/Unknown: %d\n", otherCount)
|
|
||||||
fmt.Printf("No Contract: %d\n", noContractCount)
|
|
||||||
fmt.Println()
|
|
||||||
|
|
||||||
// Analyze failure reasons
|
|
||||||
reasonCounts := make(map[string]int)
|
|
||||||
for _, entry := range entries {
|
|
||||||
if entry.IsBlacklisted {
|
|
||||||
reasonCounts[entry.LastReason]++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("Failure Reasons")
|
|
||||||
fmt.Println("===============")
|
|
||||||
for reason, count := range reasonCounts {
|
|
||||||
fmt.Printf("%s: %d\n", reason, count)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum"
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
|
||||||
"github.com/ethereum/go-ethereum/ethclient"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// Connect to Arbitrum
|
|
||||||
client, err := ethclient.Dial("https://arb1.arbitrum.io/rpc")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal("Failed to connect:", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test pools that were "failing"
|
|
||||||
pools := []string{
|
|
||||||
"0x6f38e884725a116C9C7fBF208e79FE8828a2595F",
|
|
||||||
"0x2f5e87C9312fa29aed5c179E456625D79015299c",
|
|
||||||
"0xB1026b8e7276e7AC75410F1fcbbe21796e8f7526",
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function selectors
|
|
||||||
token0Selector := []byte{0x0d, 0xfe, 0x16, 0x81} // token0()
|
|
||||||
token1Selector := []byte{0xd2, 0x1c, 0xec, 0xd4} // token1() - NOTE: Different from what's in the code!
|
|
||||||
|
|
||||||
for _, poolHex := range pools {
|
|
||||||
poolAddress := common.HexToAddress(poolHex)
|
|
||||||
fmt.Printf("\nTesting pool: %s\n", poolHex)
|
|
||||||
fmt.Println("=" + "=" + "=" + "=" + "=" + "=" + "=" + "=" + "=")
|
|
||||||
|
|
||||||
// Create timeout context
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
||||||
|
|
||||||
// Test token0()
|
|
||||||
token0Data, err := client.CallContract(ctx, ethereum.CallMsg{
|
|
||||||
To: &poolAddress,
|
|
||||||
Data: token0Selector,
|
|
||||||
}, nil)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf(" token0() ERROR: %v\n", err)
|
|
||||||
} else {
|
|
||||||
if len(token0Data) >= 32 {
|
|
||||||
token0 := common.BytesToAddress(token0Data[12:32])
|
|
||||||
fmt.Printf(" token0() SUCCESS: %s\n", token0.Hex())
|
|
||||||
} else {
|
|
||||||
fmt.Printf(" token0() INVALID DATA: %x\n", token0Data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test token1()
|
|
||||||
token1Data, err := client.CallContract(ctx, ethereum.CallMsg{
|
|
||||||
To: &poolAddress,
|
|
||||||
Data: token1Selector,
|
|
||||||
}, nil)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf(" token1() ERROR: %v\n", err)
|
|
||||||
} else {
|
|
||||||
if len(token1Data) >= 32 {
|
|
||||||
token1 := common.BytesToAddress(token1Data[12:32])
|
|
||||||
fmt.Printf(" token1() SUCCESS: %s\n", token1.Hex())
|
|
||||||
} else {
|
|
||||||
fmt.Printf(" token1() INVALID DATA: %x\n", token1Data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cancel()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now let's check what selector is actually being used in the error messages
|
|
||||||
fmt.Println("\nChecking token1() selector:")
|
|
||||||
fmt.Printf(" Correct V3 selector: 0xd21220a7\n")
|
|
||||||
fmt.Printf(" Our code selector: 0x%x\n", token1Selector)
|
|
||||||
}
|
|
||||||
@@ -1,172 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"math/big"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum"
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
|
||||||
"github.com/ethereum/go-ethereum/ethclient"
|
|
||||||
)
|
|
||||||
|
|
||||||
const uniswapV3PoolABI = `[
|
|
||||||
{"name":"token0","type":"function","inputs":[],"outputs":[{"name":"","type":"address"}]},
|
|
||||||
{"name":"token1","type":"function","inputs":[],"outputs":[{"name":"","type":"address"}]},
|
|
||||||
{"name":"fee","type":"function","inputs":[],"outputs":[{"name":"","type":"uint24"}]},
|
|
||||||
{"name":"liquidity","type":"function","inputs":[],"outputs":[{"name":"","type":"uint128"}]},
|
|
||||||
{"name":"slot0","type":"function","inputs":[],"outputs":[{"name":"sqrtPriceX96","type":"uint160"},{"name":"tick","type":"int24"},{"name":"observationIndex","type":"uint16"},{"name":"observationCardinality","type":"uint16"},{"name":"observationCardinalityNext","type":"uint16"},{"name":"feeProtocol","type":"uint8"},{"name":"unlocked","type":"bool"}]}
|
|
||||||
]`
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// Connect to Arbitrum
|
|
||||||
client, err := ethclient.Dial("https://arb1.arbitrum.io/rpc")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal("Failed to connect:", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the ABI
|
|
||||||
poolABI, err := abi.JSON(strings.NewReader(uniswapV3PoolABI))
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal("Failed to parse ABI:", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("Testing UniswapV3 Pool Calls")
|
|
||||||
fmt.Println("============================")
|
|
||||||
fmt.Println()
|
|
||||||
|
|
||||||
// Test known good pools
|
|
||||||
goodPools := []struct {
|
|
||||||
address string
|
|
||||||
name string
|
|
||||||
}{
|
|
||||||
{"0xC31E54c7a869B9FcBEcc14363CF510d1c41fa443", "WETH/USDC.e 0.05%"},
|
|
||||||
{"0x641C00A822e8b671738d32a431a4Fb6074E5c79d", "USDT/WETH 0.05%"},
|
|
||||||
{"0x2f5e87C9312fa29aed5c179E456625D79015299c", "WBTC/WETH 0.05%"},
|
|
||||||
{"0x6f38e884725a116C9C7fBF208e79FE8828a2595F", "WETH/USDC 0.05%"},
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("Testing Known Good UniswapV3 Pools:")
|
|
||||||
fmt.Println("-----------------------------------")
|
|
||||||
for _, pool := range goodPools {
|
|
||||||
testPool(client, poolABI, pool.address, pool.name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test problematic pools from blacklist
|
|
||||||
blacklistedPools := []string{
|
|
||||||
"0x7760cfd39f8fc36239c7299851d8b334cc5acbed",
|
|
||||||
"0xe0571fecab07216cae82a0af3f44e7ea7aff8426",
|
|
||||||
"0x8d17b1ce5132b327981dcea21cb183b9a3e1c177",
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("\nTesting Blacklisted Pools:")
|
|
||||||
fmt.Println("--------------------------")
|
|
||||||
for _, pool := range blacklistedPools {
|
|
||||||
testPool(client, poolABI, pool, "Blacklisted")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func testPool(client *ethclient.Client, poolABI abi.ABI, poolHex string, name string) {
|
|
||||||
poolAddress := common.HexToAddress(poolHex)
|
|
||||||
fmt.Printf("\nPool: %s (%s)\n", poolHex[:10]+"...", name)
|
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
// Check if contract exists
|
|
||||||
code, err := client.CodeAt(ctx, poolAddress, nil)
|
|
||||||
if err != nil || len(code) == 0 {
|
|
||||||
fmt.Println(" ❌ No contract at this address")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Printf(" ✅ Contract exists (%d bytes)\n", len(code))
|
|
||||||
|
|
||||||
// Test token0()
|
|
||||||
token0Data, err := poolABI.Pack("token0")
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf(" ❌ Failed to pack token0: %v\n", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := client.CallContract(ctx, ethereum.CallMsg{
|
|
||||||
To: &poolAddress,
|
|
||||||
Data: token0Data,
|
|
||||||
}, nil)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf(" ❌ token0() failed: %v\n", err)
|
|
||||||
} else {
|
|
||||||
var token0 common.Address
|
|
||||||
err = poolABI.UnpackIntoInterface(&token0, "token0", result)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf(" ❌ Failed to unpack token0: %v\n", err)
|
|
||||||
} else {
|
|
||||||
fmt.Printf(" ✅ token0: %s\n", token0.Hex())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test token1()
|
|
||||||
token1Data, err := poolABI.Pack("token1")
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf(" ❌ Failed to pack token1: %v\n", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err = client.CallContract(ctx, ethereum.CallMsg{
|
|
||||||
To: &poolAddress,
|
|
||||||
Data: token1Data,
|
|
||||||
}, nil)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf(" ❌ token1() failed: %v\n", err)
|
|
||||||
} else {
|
|
||||||
var token1 common.Address
|
|
||||||
err = poolABI.UnpackIntoInterface(&token1, "token1", result)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf(" ❌ Failed to unpack token1: %v\n", err)
|
|
||||||
} else {
|
|
||||||
fmt.Printf(" ✅ token1: %s\n", token1.Hex())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test fee()
|
|
||||||
feeData, err := poolABI.Pack("fee")
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf(" ❌ Failed to pack fee: %v\n", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err = client.CallContract(ctx, ethereum.CallMsg{
|
|
||||||
To: &poolAddress,
|
|
||||||
Data: feeData,
|
|
||||||
}, nil)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf(" ❌ fee() failed: %v\n", err)
|
|
||||||
} else {
|
|
||||||
var fee *big.Int
|
|
||||||
err = poolABI.UnpackIntoInterface(&fee, "fee", result)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf(" ❌ Failed to unpack fee: %v\n", err)
|
|
||||||
} else {
|
|
||||||
fmt.Printf(" ✅ fee: %d (%.2f%%)\n", fee, float64(fee.Int64())/10000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test using raw selectors
|
|
||||||
fmt.Println(" Testing with raw selectors:")
|
|
||||||
token0Selector := []byte{0x0d, 0xfe, 0x16, 0x81}
|
|
||||||
result, err = client.CallContract(ctx, ethereum.CallMsg{
|
|
||||||
To: &poolAddress,
|
|
||||||
Data: token0Selector,
|
|
||||||
}, nil)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf(" ❌ Raw token0() failed: %v\n", err)
|
|
||||||
} else if len(result) >= 32 {
|
|
||||||
fmt.Printf(" ✅ Raw token0(): 0x%x\n", result[12:32])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user