Skip to content

Commit

Permalink
Merge pull request #300 from valory-xyz/develop
Browse files Browse the repository at this point in the history
Release `v0.16.1`
  • Loading branch information
Adamantios authored Jun 14, 2024
2 parents 13affc0 + 34bf3a7 commit b1dc675
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 31 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Ensure your machine satisfies the requirements:

- You need xDAI on Gnosis Chain in one of your wallets.
- You need an RPC for your agent instance. We recommend [Nodies RPC](https://www.nodies.app/).
- (From release v0.16.0 onwards) You need a Subgraph API key that can be obtained at [The Graph](https://thegraph.com/studio/apikeys/).
- (From release v0.16.0 onwards) You need a Subgraph API key that can be obtained at [The Graph](https://thegraph.com/studio/apikeys/).

## Run the Service

Expand Down Expand Up @@ -67,7 +67,7 @@ Find below a diagram of the possible status a service can be in the **Alpine sta

![Alpine staking FSM](images/alpine_staking_fsm.svg)

Services can become staked by invoking the `stake()` contract method, where service parameters and deposit amounts are verified. Staked services can call the `checkpoint()` method at regular intervals, ensuring liveness checks and calculating staking incentives. In case a service remains inactive beyond the specified `maxAllowedInactivity` time, it faces eviction from the staking program, ceasing to accrue additional rewards. Staked or evicted services can unstaked by calling the `unstake()` contract method. They can do so after `minStakingDuration` has passed or if no more staking rewards are available.
Services can become staked by invoking the `stake()` contract method, where service parameters and deposit amounts are verified. Staked services can call the `checkpoint()` method at regular intervals, ensuring liveness checks and calculating staking incentives. In case a service remains inactive beyond the specified `maxAllowedInactivity` time, it faces eviction from the staking program, ceasing to accrue additional rewards. Staked or evicted services can unstaked by calling the `unstake()` contract method. They can do so after `minStakingDuration` has passed or if no more staking rewards are available.

__Notes__:

Expand Down Expand Up @@ -199,6 +199,7 @@ Execute the following steps in a PowerShell terminal:
```bash
winget install Python.Python.3.10
```
3. Close and re-open the PowerShell terminal.
4. Install [Poetry](https://python-poetry.org/docs/):
Expand Down Expand Up @@ -235,17 +236,17 @@ This chapter is for advanced users who want to further customize the trader agen
##### Policy weights
This script automatically sets some default weights to the agent's policy as a warm start
to help convergence and improve tool selection.
These data were obtained after many days of running the service and are set
This script automatically sets some default weights to the agent's policy as a warm start.
to help convergence and improve tool selection.
These data were obtained after many days of running the service and are set
[here](https://github.com/valory-xyz/trader-quickstart/blob/0f093ebbf0857b8484a017912c3992f00fbe1a29/run_service.sh#L133-L137).
As a result, the current weights are always deleted and replaced by this strategy
As a result, the current weights are always deleted and replaced by this strategy
which is considered to boost the initial performance of the service.

However, you may have found better performing policy weights and would like to remove this logic.
It can easily be done, by removing this method call,
[here](https://github.com/valory-xyz/trader-quickstart/blob/0f093ebbf0857b8484a017912c3992f00fbe1a29/run_service.sh#L698),
in order to set your own custom warm start.
However, you may have found better performing policy weights and would like to remove this logic.
It can easily be done, by removing this method call,
[here](https://github.com/valory-xyz/trader-quickstart/blob/0f093ebbf0857b8484a017912c3992f00fbe1a29/run_service.sh#L698),
in order to set your own custom warm start.
Setting your own custom weights can be done by editing the corresponding files in `.trader_runner`.
Moreover, you may store your current policy as a backup before editing those files, using the following set of commands:

Expand All @@ -259,12 +260,12 @@ cp ".trader_runner/utilized_tools.json" ".trader_runner/utilized_tools_$(date +"

Sometimes, a mech tool might temporarily return invalid results.
As a result, the service would end up performing mech calls without being able to use the response.
Assuming that this tool has a large reward rate in the policy weights,
the service might end up spending a considerable amount of xDAI before adjusting the tool's reward rate,
Assuming that this tool has a large reward rate in the policy weights,
the service might end up spending a considerable amount of xDAI before adjusting the tool's reward rate,
without making any progress.
If a tool is temporarily misbehaving, you could use an environment variable in order to exclude it.
This environment variable is defined
[here](https://github.com/valory-xyz/trader/blob/v0.8.0/packages/valory/services/trader/service.yaml#L109-L112)
This environment variable is defined
[here](https://github.com/valory-xyz/trader/blob/v0.8.0/packages/valory/services/trader/service.yaml#L109-L112)
and can be overriden by setting it anywhere in the `run_service.sh` script with a new value, e.g.:
```shell
Expand Down Expand Up @@ -317,4 +318,3 @@ Error: Service deployment failed with following error; ChainTimeoutError(Timed o
Error: Service terminatation failed with following error; ChainInteractionError({'code': -32010, 'message': 'AlreadyKnown'})
```
36 changes: 20 additions & 16 deletions run_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -400,14 +400,15 @@ prompt_use_staking() {

# 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
echo "Please provide a Subgraph API key"
echo "---------------------------------"
echo "Since June 12, 2024, you need a Subgraph API key that can be obtained at The Graph https://thegraph.com/studio/apikeys/"
echo ""
echo "If you set your Subgraph API key to blank, the script will use the deprecated Subgraph endpoints (hosted services)."
echo "These deprecated endpoints might stop working, and you will need to manually edit the .trader_runner/.env file to provide your API key."
echo ""
read -rsp "Enter a Subgraph API key [hidden input]: " SUBGRAPH_API_KEY
echo ""
}

# Verify if there are enough slots for staking this service
Expand Down Expand Up @@ -573,7 +574,7 @@ try_read_storage() {
fi

# INFO: This is a fix to avoid corrupting already-created stores
if [ -z "$SUBGRAPH_API_KEY" ]; then
if [ -z "${SUBGRAPH_API_KEY+x}" ]; then
prompt_subgraph_api_key
dotenv_set_key "$env_file_path" "SUBGRAPH_API_KEY" "$SUBGRAPH_API_KEY" true
fi
Expand Down Expand Up @@ -610,7 +611,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.16.0"
service_version="v0.16.1"

# Define constants for on-chain interaction
gnosis_chain_id=100
Expand Down Expand Up @@ -1086,7 +1087,7 @@ export ALL_PARTICIPANTS='["'$agent_address'"]'
export OMEN_CREATORS='["0x89c5cc945dd550BcFfb72Fe42BfF002429F46Fec"]'
# 10 cents minimum bet amount. Also, the bet will not be placed if expected returns - bet_threshold <= 0
export BET_THRESHOLD=100000000000000000
export TRADING_STRATEGY=kelly_criterion
export TRADING_STRATEGY=kelly_criterion_no_conf
export STRATEGIES_KWARGS='[["bet_kelly_fraction",1.5],["floor_balance",500000000000000000],["bet_amount_per_threshold",{"0.0":0,"0.1":0,"0.2":0,"0.3":0,"0.4":0,"0.5":0,"0.6":60000000000000000,"0.7":80000000000000000,"0.8":160000000000000000,"0.9":1000000000000000000,"1.0":1000000000000000000}]]'
export PROMPT_TEMPLATE="Please take over the role of a Data Scientist to evaluate the given question. With the given question \"@{question}\" and the \`yes\` option represented by \`@{yes}\` and the \`no\` option represented by \`@{no}\`, what are the respective probabilities of \`p_yes\` and \`p_no\` occurring?"
export IRRELEVANT_TOOLS='["native-transfer","prediction-online-lite","claude-prediction-online-lite","prediction-online-sme-lite","prediction-request-reasoning-lite","prediction-request-reasoning-claude-lite","prediction-request-rag","prediction-request-reasoning-claude","prediction-url-cot-claude","claude-prediction-offline","claude-prediction-online","prediction-offline-sme","deepmind-optimization", "deepmind-optimization-strong", "openai-gpt-3.5-turbo", "openai-gpt-3.5-turbo-instruct", "openai-gpt-4", "openai-text-davinci-002", "openai-text-davinci-003", "prediction-online-sum-url-content", "prediction-online-summarized-info", "stabilityai-stable-diffusion-512-v2-1", "stabilityai-stable-diffusion-768-v2-1", "stabilityai-stable-diffusion-v1-5", "stabilityai-stable-diffusion-xl-beta-v2-2-2"]'
Expand All @@ -1096,11 +1097,14 @@ 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"

if [ -n "$SUBGRAPH_API_KEY" ]; then
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"
fi

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

0 comments on commit b1dc675

Please sign in to comment.