removed the fucking vendor files
This commit is contained in:
@@ -6,17 +6,21 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"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"`
|
||||
Arbitrum ArbitrumConfig `yaml:"arbitrum"`
|
||||
Bot BotConfig `yaml:"bot"`
|
||||
Uniswap UniswapConfig `yaml:"uniswap"`
|
||||
Log LogConfig `yaml:"log"`
|
||||
Database DatabaseConfig `yaml:"database"`
|
||||
Ethereum EthereumConfig `yaml:"ethereum"`
|
||||
Contracts ContractsConfig `yaml:"contracts"`
|
||||
Arbitrage ArbitrageConfig `yaml:"arbitrage"`
|
||||
}
|
||||
|
||||
// ArbitrumConfig represents the Arbitrum node configuration
|
||||
@@ -111,6 +115,28 @@ type DatabaseConfig struct {
|
||||
MaxIdleConnections int `yaml:"max_idle_connections"`
|
||||
}
|
||||
|
||||
// EthereumConfig represents the Ethereum account configuration
|
||||
type EthereumConfig struct {
|
||||
// Private key for transaction signing
|
||||
PrivateKey string `yaml:"private_key"`
|
||||
// Account address
|
||||
AccountAddress string `yaml:"account_address"`
|
||||
// Gas price multiplier (for faster transactions)
|
||||
GasPriceMultiplier float64 `yaml:"gas_price_multiplier"`
|
||||
}
|
||||
|
||||
// ContractsConfig represents the smart contract addresses
|
||||
type ContractsConfig struct {
|
||||
// Arbitrage executor contract address
|
||||
ArbitrageExecutor string `yaml:"arbitrage_executor"`
|
||||
// Flash swapper contract address
|
||||
FlashSwapper string `yaml:"flash_swapper"`
|
||||
// Authorized caller addresses
|
||||
AuthorizedCallers []string `yaml:"authorized_callers"`
|
||||
// Authorized DEX addresses
|
||||
AuthorizedDEXes []string `yaml:"authorized_dexes"`
|
||||
}
|
||||
|
||||
// Load loads the configuration from a file
|
||||
func Load(filename string) (*Config, error) {
|
||||
// Read the config file
|
||||
@@ -173,6 +199,25 @@ func (c *Config) OverrideWithEnv() {
|
||||
c.Arbitrum.WSEndpoint = wsEndpoint
|
||||
}
|
||||
|
||||
// Override fallback endpoints from environment
|
||||
if fallbackEndpoints := os.Getenv("ARBITRUM_FALLBACK_ENDPOINTS"); fallbackEndpoints != "" {
|
||||
endpoints := strings.Split(fallbackEndpoints, ",")
|
||||
c.Arbitrum.FallbackEndpoints = make([]EndpointConfig, 0, len(endpoints))
|
||||
for _, endpoint := range endpoints {
|
||||
endpoint = strings.TrimSpace(endpoint)
|
||||
if endpoint != "" {
|
||||
c.Arbitrum.FallbackEndpoints = append(c.Arbitrum.FallbackEndpoints, EndpointConfig{
|
||||
URL: endpoint,
|
||||
RateLimit: RateLimitConfig{
|
||||
RequestsPerSecond: 100,
|
||||
MaxConcurrent: 10,
|
||||
Burst: 20,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Override rate limit settings
|
||||
if rps := os.Getenv("RPC_REQUESTS_PER_SECOND"); rps != "" {
|
||||
if val, err := strconv.Atoi(rps); err == nil {
|
||||
@@ -198,4 +243,85 @@ func (c *Config) OverrideWithEnv() {
|
||||
c.Bot.ChannelBufferSize = val
|
||||
}
|
||||
}
|
||||
|
||||
// Override Ethereum settings
|
||||
if privateKey := os.Getenv("ETHEREUM_PRIVATE_KEY"); privateKey != "" {
|
||||
c.Ethereum.PrivateKey = privateKey
|
||||
}
|
||||
|
||||
if accountAddress := os.Getenv("ETHEREUM_ACCOUNT_ADDRESS"); accountAddress != "" {
|
||||
c.Ethereum.AccountAddress = accountAddress
|
||||
}
|
||||
|
||||
if gasPriceMultiplier := os.Getenv("ETHEREUM_GAS_PRICE_MULTIPLIER"); gasPriceMultiplier != "" {
|
||||
if val, err := strconv.ParseFloat(gasPriceMultiplier, 64); err == nil {
|
||||
c.Ethereum.GasPriceMultiplier = val
|
||||
}
|
||||
}
|
||||
|
||||
// Override contract addresses
|
||||
if arbitrageExecutor := os.Getenv("CONTRACT_ARBITRAGE_EXECUTOR"); arbitrageExecutor != "" {
|
||||
c.Contracts.ArbitrageExecutor = arbitrageExecutor
|
||||
}
|
||||
|
||||
if flashSwapper := os.Getenv("CONTRACT_FLASH_SWAPPER"); flashSwapper != "" {
|
||||
c.Contracts.FlashSwapper = flashSwapper
|
||||
}
|
||||
}
|
||||
|
||||
// ArbitrageConfig represents the arbitrage service configuration
|
||||
type ArbitrageConfig struct {
|
||||
// Enable or disable arbitrage service
|
||||
Enabled bool `yaml:"enabled"`
|
||||
|
||||
// Contract addresses
|
||||
ArbitrageContractAddress string `yaml:"arbitrage_contract_address"`
|
||||
FlashSwapContractAddress string `yaml:"flash_swap_contract_address"`
|
||||
|
||||
// Profitability settings
|
||||
MinProfitWei int64 `yaml:"min_profit_wei"`
|
||||
MinROIPercent float64 `yaml:"min_roi_percent"`
|
||||
MinSignificantSwapSize int64 `yaml:"min_significant_swap_size"`
|
||||
SlippageTolerance float64 `yaml:"slippage_tolerance"`
|
||||
|
||||
// Scanning configuration
|
||||
MinScanAmountWei int64 `yaml:"min_scan_amount_wei"`
|
||||
MaxScanAmountWei int64 `yaml:"max_scan_amount_wei"`
|
||||
|
||||
// Gas configuration
|
||||
MaxGasPriceWei int64 `yaml:"max_gas_price_wei"`
|
||||
|
||||
// Execution limits
|
||||
MaxConcurrentExecutions int `yaml:"max_concurrent_executions"`
|
||||
MaxOpportunitiesPerEvent int `yaml:"max_opportunities_per_event"`
|
||||
|
||||
// Timing settings
|
||||
OpportunityTTL time.Duration `yaml:"opportunity_ttl"`
|
||||
MaxPathAge time.Duration `yaml:"max_path_age"`
|
||||
StatsUpdateInterval time.Duration `yaml:"stats_update_interval"`
|
||||
|
||||
// Pool discovery configuration
|
||||
PoolDiscoveryConfig PoolDiscoveryConfig `yaml:"pool_discovery"`
|
||||
}
|
||||
|
||||
// PoolDiscoveryConfig represents pool discovery service configuration
|
||||
type PoolDiscoveryConfig struct {
|
||||
// Enable or disable pool discovery
|
||||
Enabled bool `yaml:"enabled"`
|
||||
|
||||
// Block range to scan for new pools
|
||||
BlockRange uint64 `yaml:"block_range"`
|
||||
|
||||
// Polling interval for new pools
|
||||
PollingInterval time.Duration `yaml:"polling_interval"`
|
||||
|
||||
// DEX factory addresses to monitor
|
||||
FactoryAddresses []string `yaml:"factory_addresses"`
|
||||
|
||||
// Minimum liquidity threshold for pools
|
||||
MinLiquidityWei int64 `yaml:"min_liquidity_wei"`
|
||||
|
||||
// Cache configuration
|
||||
CacheSize int `yaml:"cache_size"`
|
||||
CacheTTL time.Duration `yaml:"cache_ttl"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user