# Configuration

The market maker uses two configuration layers:

* TOML file for trading parameters
* environment variables for secrets

### TOML Configuration

Create a .toml file in the config/ directory with the following fields:

<pre class="language-sh"><code class="lang-sh">## Network Settings
network_name - Network identifier: "ethereum", "base", or "unichain"
chain_id - Network chain ID (1 for Ethereum, 8453 for Base, etc.)
rpc_url - HTTP RPC endpoint for blockchain connection
explorer_url - Block explorer URL (e.g., "https://etherscan.io/")
tycho_api - Tycho API endpoint (e.g., "tycho-beta.propellerheads.xyz")
<strong>
</strong><strong>## Token Configuration
</strong>base_token - Base token symbol (e.g., "ETH")
base_token_address - Base token contract address (0x...)
quote_token - Quote token symbol (e.g., "USDC")
quote_token_address - Quote token contract address (0x...)
pair_tag - Optional emoji/tag for logging (e.g., "⚪️")

## Wallet
wallet_public_key - Your wallet address that will execute trades

## Gas Configuration
gas_token_symbol - Address of the token used to pay gas (usually WETH)
gas_token_chainlink_price_feed - Chainlink oracle address for gas token price
tx_gas_limit - Maximum gas limit per transaction (e.g., 300000)
max_gas_multiplier - Maximum gas price multiplier allowed; skips transactions when gas exceeds 'gas price at launch' × multiplier


## Trading Parameters
min_watch_spread_bps - Minimum spread in basis points to watch a pool (e.g., 5.0 = 0.05%)
min_executable_spread_bps - Minimum spread to execute a trade, can be negative (e.g., -10.0 = -0.1%)
max_slippage_pct - Maximum acceptable slippage as percentage (e.g., 0.0005 = 0.05%)
max_inventory_ratio - Maximum inventory to use per trade as ratio (e.g., 0.99 = 99%)
min_reference_price_move_bps - Minimum reference price movement in basis points required to process trading logic

## Execution Settings
poll_interval_ms - Milliseconds between each pool query (e.g., 6000 = 6 seconds)
block_offset - Block number offset for transaction inclusion (default: 1)
inclusion_block_delay - Blocks to wait before considering transaction failed (default: 1)
permit2_address - Permit2 contract address for approvals
tycho_router_address - Tycho router contract address

## Behavior Flags
publish_events - Enable Redis event publishing (true/false)
skip_simulation - Skip Tycho simulation, required on mainnet (true/false)
infinite_approval - Use infinite token approvals instead of per-trade (true/false)
min_publish_timeframe_ms - Minimum time between event publishes in ms (≥ 30000)

## Price Feed Configuration
[price_feed_config] - Price feed settings block
type - Feed type: "binance" or "chainlink"
source - API URL for Binance or oracle address for Chainlink
reverse - Whether to invert the price (true/false)
</code></pre>

### **Example TOML**

```toml
## For a mainnet ETH/USDC strategy

pair_tag = "⚪️"
base_token = "ETH"
base_token_address = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
quote_token = "USDC"
quote_token_address = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
network_name = "ethereum"
chain_id = 1
wallet_public_key = "0x..."
gas_token_symbol = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
gas_token_chainlink_price_feed = "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419"
rpc_url = "https://eth-mainnet..."
explorer_url = "https://etherscan.io/"
tycho_api = "tycho-beta.propellerheads.xyz"

min_watch_spread_bps = 5.0
min_executable_spread_bps = 5.0
max_slippage_pct = 0.0005
max_inventory_ratio = 0.99
min_reference_price_move_bps = 1.0
max_gas_multiplier = 100.0

tx_gas_limit = 300000
block_offset = 1
inclusion_block_delay = 1
permit2_address = "0x000000000022D473030F116dDEE9F6B43aC78BA3"
tycho_router_address = "0xfD0b31d2E955fA55e3fa641Fe90e08b677188d35"

poll_interval_ms = 6000
publish_events = true
skip_simulation = true
infinite_approval = true
min_publish_timeframe_ms = 60000

[price_feed_config]
type = "binance"
source = "https://api.binance.com/api/v3"
reverse = false

```

### Environment Variables

Create a .env file in config/secrets/ with sensitive data.

```sh
## Maker Binary
CONFIG_PATH - Path to your TOML config file (e.g., "config/mainnet.eth-usdc.toml")
TESTING - Enable testing mode: "true" or "false"
HEARTBEAT - Optional heartbeat URL for monitoring
WALLET_PRIVATE_KEY - Private key for your trading wallet (required)
TYCHO_API_KEY - API key for Tycho Protocol access (required)

## Monitor Binary
TESTING - Enable testing mode: "true" or "false"
HEARTBEAT - Optional heartbeat URL for monitoring
DATABASE_URL - PostgreSQL connection string (required)
DATABASE_NAME - Database name (required)
```

### **Example**

```sh
## Maker Binary
CONFIG_PATH="config/mainnet.eth-usdc.toml"
TESTING=false
HEARTBEAT="https://..."
WALLET_PRIVATE_KEY="0x..."
TYCHO_API_KEY="your_api_key_here"

## Monitor Binary
TESTING=false
HEARTBEAT="https://..."
DATABASE_URL="postgresql://user:pass@host/db"
DATABASE_NAME="neondb"
```

### Validation Rules

The config validator enforces these constraints:

* Spreads: min\_watch\_spread\_bps ≤ 10000 BPS, min\_executable\_spread\_bps ≥ -50 BPS
* Slippage: max\_slippage\_pct ≤ 1.0 (100%)
* Inventory: max\_inventory\_ratio between 0.0 and 1.0
* Gas limit: tx\_gas\_limit ≤ 1,000,000
* Publish interval: min\_publish\_timeframe\_ms ≥ 30,000 ms
* All addresses must be valid Ethereum addresses (0x + 40 hex characters)
* Base and quote token addresses must be different
* On mainnet: skip\_simulation must be true (Flashbots bundles)
* On Base with preconf RPC: skip\_simulation must be true

### Important Notes

* **Negative Spreads**: setting negative min\_executable\_spread\_bps will execute unprofitable trades and drain your inventory. Use with extreme caution.
* **Infinite Approvals** : when infinite\_approval = true, the wallet will approve unlimited token spending for the router. This saves gas but increases security risk if the router is compromised.
* **Skip Simulation**: simulations can be skipped, because it's not possible or for latency reasons
