Skip to content
This repository was archived by the owner on May 29, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.trader_runner*
.operate*
trader
*.DS_Store
__pycache__
34 changes: 32 additions & 2 deletions run_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -465,6 +486,7 @@ create_storage() {

# Prompt use staking
prompt_use_staking
prompt_subgraph_api_key
verify_staking_slots

mkdir "../$store"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1067,6 +1096,7 @@ 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 OMEN_SUBGRAPH_URL="https://gateway.thegraph.com/api/$SUBGRAPH_API_KEY/subgraphs/id/9V1aHHwkK4uPWgBH6ZLzwqFEkoHTHPS7XHKyjZWe8tEf"
Copy link
Collaborator

@Adamantios Adamantios Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to set all the subgraphs:

  • NETWORK_SUBGRAPH_URL (gnosis blocks)
  • OMEN_SUBGRAPH_URL
  • TRADES_SUBGRAPH_URL (omen)
  • REALITIO_SUBGRAPH_URL

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Adamantios missing from your list the subgraph for conditonal tokens IMO

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct! This is the CONDITIONAL_TOKENS_SUBGRAPH_URL.


service_dir="trader_service"
build_dir="abci_build"
Expand Down