diff --git a/.gitignore b/.gitignore index 3eb0c675..8b26e8f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .trader_runner* +.operate* trader *.DS_Store __pycache__ \ No newline at end of file diff --git a/run_service.sh b/run_service.sh index 17a8b789..d0e8eef7 100755 --- a/run_service.sh +++ b/run_service.sh @@ -398,6 +398,18 @@ prompt_use_staking() { echo "" } +# Prompt user for subgraph API key +prompt_subgraph_api_key() { + echo "You can get a Subgraph API key at https://thegraph.com/studio/apikeys/" + while [[ -z "$SUBGRAPH_API_KEY" ]]; do + read -rsp "Enter a Subgraph API key [hidden input]: " SUBGRAPH_API_KEY + echo "" + if [[ -z "$SUBGRAPH_API_KEY" ]]; then + echo "API key cannot be blank. Please try again." + fi + done +} + # Verify if there are enough slots for staking this service verify_staking_slots() { if [ "${USE_STAKING}" = true ]; then @@ -416,6 +428,7 @@ dotenv_set_key() { local dotenv_path="$1" local key_to_set="$2" local value_to_set="$3" + local hidden="${4:-false}" # Check if the .env file exists if [ ! -f "$dotenv_path" ]; then @@ -427,11 +440,19 @@ dotenv_set_key() { if grep -q "^$key_to_set=" "$dotenv_path"; then # Variable exists, so update its value using awk awk -v key="$key_to_set" -v val="$value_to_set" '{gsub("^" key "=.*", key "=" val); print}' "$dotenv_path" > temp && mv temp "$dotenv_path" - echo "Updated '$key_to_set=$value_to_set' in $dotenv_path" + if [ "$hidden" = true ]; then + echo "Updated '$key_to_set=*****' in $dotenv_path" + else + echo "Updated '$key_to_set=$value_to_set' in $dotenv_path" + fi else # Variable doesn't exist, so add it to the .env file echo "$key_to_set=$value_to_set" >> "$dotenv_path" - echo "Added '$key_to_set=$value_to_set' to $dotenv_path" + if [ "$hidden" = true ]; then + echo "Added '$key_to_set=*****' to $dotenv_path" + else + echo "Added '$key_to_set=$value_to_set' to $dotenv_path" + fi fi export "$key_to_set=$value_to_set" @@ -465,6 +486,7 @@ create_storage() { # Prompt use staking prompt_use_staking + prompt_subgraph_api_key verify_staking_slots mkdir "../$store" @@ -474,6 +496,7 @@ create_storage() { ' This folder contains crucial configuration information and autogenerated keys for your Trader agent.\n' \ ' Please back up this folder and be cautious if you are modifying or sharing these files to avoid potential asset loss.' > "../$store_readme_path" + dotenv_set_key "$env_file_path" "SUBGRAPH_API_KEY" "$SUBGRAPH_API_KEY" true dotenv_set_key "../$env_file_path" "USE_STAKING" "$USE_STAKING" AGENT_ID=14 @@ -549,6 +572,12 @@ try_read_storage() { service_id=$(cat $service_id_path) fi + # INFO: This is a fix to avoid corrupting already-created stores + if [ -z "$SUBGRAPH_API_KEY" ]; then + prompt_subgraph_api_key + dotenv_set_key "$env_file_path" "SUBGRAPH_API_KEY" "$SUBGRAPH_API_KEY" true + fi + # INFO: This is a fix to avoid corrupting already-created stores if [ -z "$USE_STAKING" ]; then prompt_use_staking @@ -581,7 +610,7 @@ directory="trader" service_repo=https://github.com/$org_name/$directory.git # This is a tested version that works well. # Feel free to replace this with a different version of the repo, but be careful as there might be breaking changes -service_version="v0.15.2" +service_version="v0.16.0" # Define constants for on-chain interaction gnosis_chain_id=100 @@ -1067,6 +1096,11 @@ export STOP_TRADING_IF_STAKING_KPI_MET=true export RESET_PAUSE_DURATION=45 export MECH_WRAPPED_NATIVE_TOKEN_ADDRESS=$WXDAI_ADDRESS export MECH_CHAIN_ID=ethereum +export CONDITIONAL_TOKENS_SUBGRAPH_URL="https://gateway-arbitrum.network.thegraph.com/api/$SUBGRAPH_API_KEY/subgraphs/id/7s9rGBffUTL8kDZuxvvpuc46v44iuDarbrADBFw5uVp2" +export NETWORK_SUBGRAPH_URL="https://gateway-arbitrum.network.thegraph.com/api/$SUBGRAPH_API_KEY/subgraphs/id/FxV6YUix58SpYmLBwc9gEHkwjfkqwe1X5FJQjn8nKPyA" +export OMEN_SUBGRAPH_URL="https://gateway-arbitrum.network.thegraph.com/api/$SUBGRAPH_API_KEY/subgraphs/id/9fUVQpFwzpdWS9bq5WkAnmKbNNcoBwatMR4yZq81pbbz" +export REALITIO_SUBGRAPH_URL="https://gateway-arbitrum.network.thegraph.com/api/$SUBGRAPH_API_KEY/subgraphs/id/E7ymrCnNcQdAAgLbdFWzGE5mvr5" +export TRADES_SUBGRAPH_URL="https://gateway-arbitrum.network.thegraph.com/api/$SUBGRAPH_API_KEY/subgraphs/id/9fUVQpFwzpdWS9bq5WkAnmKbNNcoBwatMR4yZq81pbbz" service_dir="trader_service" build_dir="abci_build"