Add additional project structure, config, Docker support, and more prompt files
This commit is contained in:
68
internal/config/config.go
Normal file
68
internal/config/config.go
Normal file
@@ -0,0 +1,68 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// Config represents the application configuration
|
||||
type Config struct {
|
||||
Arbitrum ArbitrumConfig `yaml:"arbitrum"`
|
||||
Bot BotConfig `yaml:"bot"`
|
||||
Uniswap UniswapConfig `yaml:"uniswap"`
|
||||
Log LogConfig `yaml:"log"`
|
||||
Database DatabaseConfig `yaml:"database"`
|
||||
}
|
||||
|
||||
// ArbitrumConfig represents the Arbitrum node configuration
|
||||
type ArbitrumConfig struct {
|
||||
RPCEndpoint string `yaml:"rpc_endpoint"`
|
||||
WSEndpoint string `yaml:"ws_endpoint"`
|
||||
ChainID int64 `yaml:"chain_id"`
|
||||
}
|
||||
|
||||
// BotConfig represents the bot configuration
|
||||
type BotConfig struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
PollingInterval int `yaml:"polling_interval"`
|
||||
MinProfitThreshold float64 `yaml:"min_profit_threshold"`
|
||||
GasPriceMultiplier float64 `yaml:"gas_price_multiplier"`
|
||||
}
|
||||
|
||||
// UniswapConfig represents the Uniswap configuration
|
||||
type UniswapConfig struct {
|
||||
FactoryAddress string `yaml:"factory_address"`
|
||||
PositionManagerAddress string `yaml:"position_manager_address"`
|
||||
FeeTiers []int64 `yaml:"fee_tiers"`
|
||||
}
|
||||
|
||||
// LogConfig represents the logging configuration
|
||||
type LogConfig struct {
|
||||
Level string `yaml:"level"`
|
||||
Format string `yaml:"format"`
|
||||
File string `yaml:"file"`
|
||||
}
|
||||
|
||||
// DatabaseConfig represents the database configuration
|
||||
type DatabaseConfig struct {
|
||||
File string `yaml:"file"`
|
||||
}
|
||||
|
||||
// Load loads the configuration from a file
|
||||
func Load(filename string) (*Config, error) {
|
||||
// Read the config file
|
||||
data, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read config file: %w", err)
|
||||
}
|
||||
|
||||
// Parse the YAML
|
||||
var config Config
|
||||
if err := yaml.Unmarshal(data, &config); err != nil {
|
||||
return nil, fmt.Errorf("failed to parse config file: %w", err)
|
||||
}
|
||||
|
||||
return &config, nil
|
||||
}
|
||||
Reference in New Issue
Block a user