Skip to content

Commit

Permalink
Merge pull request #294 from valory-xyz/develop
Browse files Browse the repository at this point in the history
[WIP]: Release `v0.16.0`
  • Loading branch information
jmoreira-valory authored Jun 12, 2024
2 parents 51bc78f + b3a6f20 commit 6d35928
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
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__
40 changes: 37 additions & 3 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 @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 6d35928

Please sign in to comment.