Files
mev-beta/orig/scripts/load-pools.go
Administrator c54c569f30 refactor: move all remaining files to orig/ directory
Completed clean root directory structure:
- Root now contains only: .git, .env, docs/, orig/
- Moved all remaining files and directories to orig/:
  - Config files (.claude, .dockerignore, .drone.yml, etc.)
  - All .env variants (except active .env)
  - Git config (.gitconfig, .github, .gitignore, etc.)
  - Tool configs (.golangci.yml, .revive.toml, etc.)
  - Documentation (*.md files, @prompts)
  - Build files (Dockerfiles, Makefile, go.mod, go.sum)
  - Docker compose files
  - All source directories (scripts, tests, tools, etc.)
  - Runtime directories (logs, monitoring, reports)
  - Dependency files (node_modules, lib, cache)
  - Special files (--delete)

- Removed empty runtime directories (bin/, data/)

V2 structure is now clean:
- docs/planning/ - V2 planning documents
- orig/ - Complete V1 codebase preserved
- .env - Active environment config (not in git)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 10:53:05 +01:00

138 lines
3.4 KiB
Go

//go:build tools
// +build tools
package main
import (
"encoding/json"
"fmt"
"os"
"time"
)
type PoolSeed struct {
Address string `json:"address"`
Token0 string `json:"token0"`
Token1 string `json:"token1"`
Fee uint32 `json:"fee"`
Protocol string `json:"protocol"`
Factory string `json:"factory"`
Name string `json:"name"`
Description string `json:"description"`
}
type TokenInfo struct {
Symbol string `json:"symbol"`
Name string `json:"name"`
Decimals uint8 `json:"decimals"`
}
type SeedData struct {
Pools []PoolSeed `json:"pools"`
Tokens map[string]TokenInfo `json:"tokens"`
Metadata map[string]interface{} `json:"metadata"`
}
type Pool struct {
Address string `json:"address"`
Token0 string `json:"token0"`
Token1 string `json:"token1"`
Fee uint32 `json:"fee"`
Protocol string `json:"protocol"`
Factory string `json:"factory"`
LastUpdated time.Time `json:"lastUpdated"`
TotalVolume string `json:"totalVolume"`
SwapCount uint64 `json:"swapCount"`
CreatedAt time.Time `json:"createdAt"`
BlockNumber uint64 `json:"blockNumber"`
}
func main() {
// Read seed data
seedData, err := os.ReadFile("data/pools_seed.json")
if err != nil {
fmt.Printf("Error reading seed data: %v\n", err)
os.Exit(1)
}
var seed SeedData
if err := json.Unmarshal(seedData, &seed); err != nil {
fmt.Printf("Error parsing seed data: %v\n", err)
os.Exit(1)
}
// Convert to pool format
pools := make(map[string]Pool)
now := time.Now()
for _, poolSeed := range seed.Pools {
pools[poolSeed.Address] = Pool{
Address: poolSeed.Address,
Token0: poolSeed.Token0,
Token1: poolSeed.Token1,
Fee: poolSeed.Fee,
Protocol: poolSeed.Protocol,
Factory: poolSeed.Factory,
LastUpdated: now,
TotalVolume: "0",
SwapCount: 0,
CreatedAt: now,
BlockNumber: 0,
}
}
// Write to pools.json
poolsJSON, err := json.MarshalIndent(pools, "", " ")
if err != nil {
fmt.Printf("Error marshaling pools: %v\n", err)
os.Exit(1)
}
if err := os.WriteFile("data/pools.json", poolsJSON, 0644); err != nil {
fmt.Printf("Error writing pools.json: %v\n", err)
os.Exit(1)
}
// Write tokens.json
type TokenMetadata struct {
Address string `json:"address"`
Symbol string `json:"symbol"`
Name string `json:"name"`
Decimals uint8 `json:"decimals"`
Verified bool `json:"verified"`
FirstSeen time.Time `json:"firstSeen"`
LastSeen time.Time `json:"lastSeen"`
SeenCount uint64 `json:"seenCount"`
}
tokens := make([]TokenMetadata, 0, len(seed.Tokens))
for address, info := range seed.Tokens {
tokens = append(tokens, TokenMetadata{
Address: address,
Symbol: info.Symbol,
Name: info.Name,
Decimals: info.Decimals,
Verified: true,
FirstSeen: now,
LastSeen: now,
SeenCount: 1,
})
}
tokensJSON, err := json.MarshalIndent(tokens, "", " ")
if err != nil {
fmt.Printf("Error marshaling tokens: %v\n", err)
os.Exit(1)
}
if err := os.WriteFile("data/tokens.json", tokensJSON, 0644); err != nil {
fmt.Printf("Error writing tokens.json: %v\n", err)
os.Exit(1)
}
fmt.Printf("✅ Loaded %d pools and %d tokens successfully!\n", len(pools), len(tokens))
fmt.Printf("📁 Files created:\n")
fmt.Printf(" - data/pools.json (%d pools)\n", len(pools))
fmt.Printf(" - data/tokens.json (%d tokens)\n", len(tokens))
}