|
| 1 | +# Run Your Own Agent |
| 2 | + |
| 3 | +This guide will help you set up and run your own agent, either **Optimus** or **BabyDegen**. Follow the steps below to get started. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Table of Contents |
| 8 | + |
| 9 | +1. [Get the Code](#1-get-the-code) |
| 10 | +2. [Set Up the Virtual Environment](#2-set-up-the-virtual-environment) |
| 11 | +3. [Synchronize Packages](#3-synchronize-packages) |
| 12 | +4. [Prepare the Data](#4-prepare-the-data) |
| 13 | +5. [Configure for Optimus](#5-configure-for-optimus) |
| 14 | +6. [Configure for BabyDegen](#6-configure-for-babydegen) |
| 15 | +7. [Run the Agent](#7-run-the-agent) |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## 1. Get the Code |
| 20 | + |
| 21 | +Clone the repository from GitHub: |
| 22 | + |
| 23 | +```bash |
| 24 | +git clone https://github.com/valory-xyz/optimus.git |
| 25 | +``` |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +## 2. Set Up the Virtual Environment |
| 30 | + |
| 31 | +Navigate to the project directory and install the required dependencies using `poetry`: |
| 32 | + |
| 33 | +```bash |
| 34 | +cd optimus |
| 35 | +poetry install |
| 36 | +poetry shell |
| 37 | +``` |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +## 3. Synchronize Packages |
| 42 | + |
| 43 | +Synchronize the necessary packages: |
| 44 | + |
| 45 | +```bash |
| 46 | +autonomy packages sync --update-packages |
| 47 | +``` |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## 4. Prepare the Data |
| 52 | + |
| 53 | +### Generate Wallet Keys |
| 54 | + |
| 55 | +Create a `keys.json` file containing wallet addresses and private keys for four agents: |
| 56 | + |
| 57 | +```bash |
| 58 | +autonomy generate-key ethereum -n 1 |
| 59 | +``` |
| 60 | + |
| 61 | +### Create Ethereum Private Key File |
| 62 | + |
| 63 | +Extract one of the private keys from `keys.json` and save it in a file named `ethereum_private_key.txt`. Ensure there's **no newline at the end of the file**. |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## 5. Configure for Optimus |
| 68 | + |
| 69 | +If you want to run the **Optimus** agent, follow these steps: |
| 70 | + |
| 71 | +### a. Deploy Safe Contracts |
| 72 | + |
| 73 | +Deploy [Safe](https://safe.global/) contracts on the following networks: |
| 74 | + |
| 75 | +- Ethereum Mainnet |
| 76 | +- Optimism |
| 77 | +- Base |
| 78 | + |
| 79 | +### b. Fund Your Safe and Agent Addresses |
| 80 | + |
| 81 | +- **Safe Addresses**: |
| 82 | + - Deposit **ETH** and **USDC** into your Safe address on **Ethereum Mainnet**. |
| 83 | +- **Agent Addresses**: |
| 84 | + - Deposit **ETH** into your agent addresses on all networks (Ethereum Mainnet, Optimism, Base) to cover gas fees. |
| 85 | + |
| 86 | +### c. Obtain API Keys |
| 87 | + |
| 88 | +- **Tenderly**: |
| 89 | + - Access Key |
| 90 | + - Account Slug |
| 91 | + - Project Slug |
| 92 | + - Get them from your [Tenderly Dashboard](https://dashboard.tenderly.co/) under **Settings**. |
| 93 | +- **CoinGecko**: |
| 94 | + - API Key |
| 95 | + - Obtain it from your account's [Developer Dashboard](https://www.coingecko.com/account/dashboard). |
| 96 | + |
| 97 | +### d. Create a `.env` File |
| 98 | + |
| 99 | +Instead of exporting environment variables, create a `.env` file in your project directory and add the following configurations. Replace placeholder values with your actual data: |
| 100 | + |
| 101 | +```dotenv |
| 102 | +PYTHONWARNINGS="ignore" |
| 103 | +ALL_PARTICIPANTS=["YOUR_AGENT_ADDRESS"] |
| 104 | +SAFE_CONTRACT_ADDRESSES='{ |
| 105 | + "ethereum": "YOUR_SAFE_ADDRESS_ON_ETHEREUM", |
| 106 | + "optimism": "YOUR_SAFE_ADDRESS_ON_OPTIMISM", |
| 107 | + "base": "YOUR_SAFE_ADDRESS_ON_BASE" |
| 108 | +}' |
| 109 | +ETHEREUM_LEDGER_RPC=YOUR_ETHEREUM_RPC_URL |
| 110 | +OPTIMISM_LEDGER_RPC=YOUR_OPTIMISM_RPC_URL |
| 111 | +BASE_LEDGER_RPC=YOUR_BASE_RPC_URL |
| 112 | +MODE_LEDGER_RPC= |
| 113 | +SLIPPAGE_FOR_SWAP=0.09 |
| 114 | +TENDERLY_ACCESS_KEY=YOUR_TENDERLY_ACCESS_KEY |
| 115 | +TENDERLY_ACCOUNT_SLUG=YOUR_TENDERLY_ACCOUNT_SLUG |
| 116 | +TENDERLY_PROJECT_SLUG=YOUR_TENDERLY_PROJECT_SLUG |
| 117 | +COINGECKO_API_KEY=YOUR_COINGECKO_API_KEY |
| 118 | +ALLOWED_CHAINS=["optimism","base"] |
| 119 | +``` |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +## 6. Configure for BabyDegen |
| 124 | + |
| 125 | +If you prefer to run the **BabyDegen** agent, follow these additional steps: |
| 126 | + |
| 127 | +### a. Set the AGENT_TRANSITION Flag |
| 128 | + |
| 129 | +Set the `AGENT_TRANSITION` flag to `true` in your `.env` file: |
| 130 | + |
| 131 | +```dotenv |
| 132 | +AGENT_TRANSITION=true |
| 133 | +``` |
| 134 | + |
| 135 | +### b. Update Safe Address and Participants |
| 136 | + |
| 137 | +Replace placeholders with your actual Safe address and agent address: |
| 138 | + |
| 139 | +```dotenv |
| 140 | +SAFE_ADDRESS="YOUR_SAFE_ADDRESS" |
| 141 | +ALL_PARTICIPANTS=["YOUR_AGENT_ADDRESS"] |
| 142 | +``` |
| 143 | + |
| 144 | +### c. Fund the Safe Account |
| 145 | + |
| 146 | +Deposit the following tokens into your Safe account, depending on the network: |
| 147 | + |
| 148 | +```python |
| 149 | +LEDGER_TO_TOKEN_LIST = { |
| 150 | + SupportedLedgers.ETHEREUM: [ |
| 151 | + "0x0001a500a6b18995b03f44bb040a5ffc28e45cb0", # Token A on Ethereum |
| 152 | + "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", # USDC on Ethereum |
| 153 | + "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", # WETH on Ethereum |
| 154 | + ], |
| 155 | + SupportedLedgers.OPTIMISM: [ |
| 156 | + "0x4200000000000000000000000000000000000006", # WETH on Optimism |
| 157 | + "0x0b2c639c533813f4aa9d7837caf62653d097ff85", # Token B on Optimism |
| 158 | + "0xda10009cbd5d07dd0cecc66161fc93d7c9000da1", # DAI on Optimism |
| 159 | + ], |
| 160 | + SupportedLedgers.BASE: [ |
| 161 | + "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca", # Token C on Base |
| 162 | + "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", # Token D on Base |
| 163 | + ], |
| 164 | +} |
| 165 | +``` |
| 166 | + |
| 167 | +### d. Fund the Agent Address |
| 168 | + |
| 169 | +Ensure your agent address has enough native tokens to cover gas fees on your chosen network. |
| 170 | + |
| 171 | +--- |
| 172 | + |
| 173 | +## 7. Run the Agent |
| 174 | + |
| 175 | +After completing the setup for either **Optimus** or **BabyDegen**, run the agent using the provided script: |
| 176 | + |
| 177 | +```bash |
| 178 | +bash run_agent.sh |
| 179 | +``` |
0 commit comments