Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds support for mode #24

Open
wants to merge 54 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
5adf48c
feat: add support for mode
Divya-Solulab Oct 16, 2024
6e6315b
fix: add mode rpc url
Divya-Solulab Oct 16, 2024
ca39eac
fix: update packages
Divya-Solulab Oct 16, 2024
968006a
fix: run formatters
Divya-Solulab Oct 16, 2024
2c09f00
chore: update Readme and Security
Divya-Solulab Oct 23, 2024
8dff01b
fix: update README
Divya-Solulab Oct 23, 2024
c7212ef
fix: update HISTORY
Divya-Solulab Oct 23, 2024
6fee773
fix: update readme
Divya-Solulab Oct 23, 2024
208eac9
fix: override gas strategy params for mode
Divya-Solulab Oct 23, 2024
c902241
fix: update merkl params
Divya-Solulab Oct 24, 2024
1964ab6
chore: update packages
Divya-Solulab Oct 24, 2024
eb13be7
chore: bump to [email protected]
gauravlochab Oct 30, 2024
6eeab47
fix: update third party packages hash
Divya-Solulab Oct 30, 2024
2eade8d
fix: add allowed chains in service config
Divya-Solulab Nov 5, 2024
b13251c
fix: add params
Divya-Solulab Nov 5, 2024
e0fde34
fix: add checks for step transaction data
Divya-Solulab Nov 6, 2024
0db5ffd
fix: update packages hash
Divya-Solulab Nov 6, 2024
c64d592
fix: add checks for routes
Divya-Solulab Nov 6, 2024
7f301d6
fix: add default priority fee
Divya-Solulab Nov 6, 2024
7482356
fix: use staking chain
Divya-Solulab Nov 12, 2024
c564613
fix: add initial assets param
Divya-Solulab Nov 12, 2024
9cd63f5
fix: add check for staking chain
Divya-Solulab Nov 15, 2024
81b1807
fix: update user-oriented messages
Divya-Solulab Nov 19, 2024
70f1bad
chore: bump to [email protected]
Divya-Solulab Nov 19, 2024
e6510ea
fix: uodate error message
Divya-Solulab Nov 19, 2024
9f1b893
fix: remove default priority fee override
Divya-Solulab Nov 19, 2024
841617b
fix: remove unused params
Divya-Solulab Nov 21, 2024
ad2162e
chore: add workflow for pushing docker images
Divya-Solulab Nov 21, 2024
2f8d869
fix: update staking chain param
Divya-Solulab Nov 21, 2024
a8b85ca
fix: add gas overrides
Divya-Solulab Nov 22, 2024
717bdeb
fix: remove gas price override
Divya-Solulab Nov 22, 2024
2726b51
fix: remove gas price override from config
Divya-Solulab Nov 22, 2024
53c708d
fix: remove gas override from service config
Divya-Solulab Nov 22, 2024
abc579e
chore: build strategy component
Divya-Solulab Nov 27, 2024
ac28cdf
chore: add hyper strategy selection
Divya-Solulab Nov 27, 2024
c207fd5
fix: minor fixes in strategies
Divya-Solulab Nov 28, 2024
426d0b3
chore: add balancer strategy
Divya-Solulab Nov 28, 2024
b40ccdc
fix: fix return type in strategy
Divya-Solulab Nov 28, 2024
c23e719
fix: add apr threshold
Divya-Solulab Nov 28, 2024
d34ac5d
fix: add apr in balancer strategy
Divya-Solulab Nov 28, 2024
a58db44
fix: add logging statement
Divya-Solulab Nov 28, 2024
39c6b6a
fix: resolve strategies list issue
Divya-Solulab Nov 29, 2024
4174b77
fix: update strategy names
Divya-Solulab Nov 29, 2024
163b5a5
fix: remove worfklow
Divya-Solulab Nov 29, 2024
f3faf05
fix: resolve CI issues
Divya-Solulab Nov 29, 2024
f22e4e0
fix: add deps
Divya-Solulab Nov 29, 2024
62bdc4f
chore: update packages
Divya-Solulab Nov 29, 2024
9fa30bc
fix: update gitleaks ignore
Divya-Solulab Nov 29, 2024
d33dff1
fix: update copyright
Divya-Solulab Nov 29, 2024
d5eddd9
Merge pull request #35 from valory-xyz/feat/strategy-abstraction
Divya-Solulab Nov 29, 2024
0ac107d
Merge remote-tracking branch 'origin/main' into feat/integrate-mode
Divya-Solulab Nov 29, 2024
94da7d2
chore: update packages hash
Divya-Solulab Nov 29, 2024
d1853bd
fix: run formatters
Divya-Solulab Nov 29, 2024
00fd60d
fix: add temporary workflow for pushing docker images
Divya-Solulab Nov 29, 2024
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
104 changes: 104 additions & 0 deletions .github/workflows/push_docker_images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Temporary Push Docker Images

on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to build from'
required: true
default: 'main'
push:
tags:
- 'dev.*'
pull_request:
branches:
- main

jobs:
publish-packages:
name: Push Packages
runs-on: ubuntu-20.04
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.10"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-versions }}
- uses: addnab/docker-run-action@v3
with:
image: valory/open-autonomy-user:latest
options: -v ${{ github.workspace }}:/work
run: |
echo "Pushing Packages"
cd /work
export AUTHOR=$(grep 'service' packages/packages.json | awk -F/ '{print $2}' | head -1)
autonomy init --reset --author $AUTHOR --ipfs --remote
autonomy push-all
publish-images:
name: Publish Docker Images
runs-on: ubuntu-20.04
needs:
- "publish-packages"
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.10"]
env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up tag and vars
uses: addnab/docker-run-action@v3
with:
image: valory/open-autonomy-user:latest
options: -v ${{ github.workspace }}:/work
run: |
echo "Setting Tag Images"
cd /work
apt-get update && apt-get install git -y || exit 1
git config --global --add safe.directory /work
export TAG=$(git describe --exact-match --tags $(git rev-parse HEAD)) || exit 1
if [ $? -eq 0 ]; then
export TAG=`echo $TAG | sed 's/^v//'`
else
echo "You are not on a tagged branch"
exit 1
fi
echo VERSION=$TAG> env.sh
echo AUTHOR=$(grep 'service/' packages/packages.json | awk -F/ '{print $2}' | head -1) >> env.sh
echo SERVICE=$(grep 'service/' packages/packages.json | awk -F/ '{print $3}' | head -1) >> env.sh
echo AGENT=$(grep 'agent/' packages/packages.json | awk -F/ '{print $3}' | head -1) >> env.sh
echo DEFAULT_IMAGE_TAG=$(cat packages/packages.json | grep agent/ | awk -F: '{print $2}' | tr -d '", ' | head -n 1) >> env.sh
cat env.sh
- uses: addnab/docker-run-action@v3
name: Build Images
with:
image: valory/open-autonomy-user:latest
options: -v ${{ github.workspace }}:/work
shell: bash
run: |
echo "Building Docker Images"
cd /work
source env.sh || exit 1
echo "Building images for $AUTHOR for service $SERVICE"
autonomy init --reset --author $AUTHOR --ipfs --remote
autonomy fetch $AUTHOR/$SERVICE --service --local || exit 1
cd $SERVICE || exit 1
autonomy build-image || exit 1
autonomy build-image --version $VERSION || exit 1
- name: Docker login
run: |
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USER --password-stdin
- name: Docker Push
run: |
source env.sh
echo "Pushing $DOCKER_USER/oar-$AGENT:$VERSION"
echo "Pushing $DOCKER_USER/oar-$AGENT:$DEFAULT_IMAGE_TAG"
docker push $DOCKER_USER/oar-$AGENT:$VERSION
docker push $DOCKER_USER/oar-$AGENT:$DEFAULT_IMAGE_TAG
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ packages/open_aea
optimus
assets.json
current_pool.json
gas_costs.json
Pipfile.lock

packages/valory/agents/*
Expand Down
4 changes: 3 additions & 1 deletion .gitleaksignore
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ f162f6e9ce964277d59ff703f905ce4d7e514339:packages/valory/contracts/staking_token
293094bdd1180c1f29da321ab6ffc9f661e00d17:packages/valory/contracts/staking_token/contract.yaml:generic-api-key:10
d82b489e8772df10d476d6ebb3fb6527e525e1cf:packages/valory/contracts/staking_token/contract.yaml:generic-api-key:10
c44680132c9ee15749aa0e9b78e68de64c8012a6:packages/valory/skills/liquidity_trader_abci/behaviours.py:generic-api-key:2921
70f1bad61ecef39d2004e54b7ca396ebaaaa5531:packages/valory/contracts/staking_token/contract.yaml:generic-api-key:10
34591764415f2fbc959e41feb4b7aaef733285aa:packages/valory/services/optimus_pearl/service.yaml:generic-api-key:44
c1df2c40d616f55da657d42be6aaeb9d5569772d:packages/valory/agents/optimus/aea-config.yaml:generic-api-key:146
c022bdff65530d1dc6a037b3d173e3989a51daec:packages/valory/skills/abstract_round_abci/tests/data/dummy_abci/skill.yaml:generic-api-key:73
c022bdff65530d1dc6a037b3d173e3989a51daec:packages/valory/skills/market_data_fetcher_abci/skill.yaml:generic-api-key:78
Expand All @@ -267,4 +269,4 @@ c022bdff65530d1dc6a037b3d173e3989a51daec:packages/valory/skills/reset_pause_abci
c022bdff65530d1dc6a037b3d173e3989a51daec:packages/valory/skills/strategy_evaluator_abci/skill.yaml:generic-api-key:101
c022bdff65530d1dc6a037b3d173e3989a51daec:packages/valory/skills/trader_decision_maker_abci/skill.yaml:generic-api-key:76
c022bdff65530d1dc6a037b3d173e3989a51daec:packages/valory/skills/transaction_settlement_abci/skill.yaml:generic-api-key:93
34591764415f2fbc959e41feb4b7aaef733285aa:packages/valory/services/optimus_pearl/service.yaml:generic-api-key:44
62bdc4f7ebebea4695e415915e773fd680baeb26:packages/valory/contracts/staking_token/contract.yaml:generic-api-key:10
23 changes: 23 additions & 0 deletions .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,26 @@ uniswap
v0.1.0
v0.2.0
optimus-agent
Optimus
Ethereum-Mainnet
Ethereum
SLIPPAGE_FOR_SWAP
LiFi
Merkl
DEXs
KPIs
url
tx
uppercase
v0.2.1
v0.2.2
v0.2.3
v0.2.4
v0.2.5
v0.2.6
v0.2.7
v0.2.8
v0.2.9
relayer
release.yaml

55 changes: 49 additions & 6 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,54 @@

## v0.1.0 - [Release Date: 2024-09-06]

- **feat/uniswap**: Added support for Uniswap integration.
- **feat/claim reward**: Introduced the feature for claiming rewards.
- **v0.1.0 release**: Initial version of the project.
- **fix: claim rewards**: Fixed an issue with claiming rewards.
- Feat/uniswap
- Feat/claim reward
- fix: claim rewards

## v0.2.0 - [Release Date: 2024-09-09]

- Fix/unlocking staking rewards

## v0.2.1 - [Release Date: 2024-09-18]

- Fix/staking
- Fix/include all campaigns

## v0.2.2 - [Release Date: 2024-09-20]

- Fix/vanity tx

## v0.2.3

- fix: resolve CI failures
- chore: add release.yaml

## v0.2.4

- chore: bump to [email protected]
- fix: remove gas overrides

## v0.2.5

- Fix/swap profitability
- Implements logic in the Optimus agent to proceed with a bridge or swap transaction only if the relayer fee is less than 2% of the amount being bridged or swapped, and the gas fees are less than 25% of the amount being traded.

## v0.2.6

- Fix/route selection
- fix: update url
- fix: add check for zero address
- fix: remove retries for status check
- Enhanced the reliability and efficiency of token swaps and bridges.
- Introduced fallback mechanisms for failed routes and cost-efficiency checks to control gas and swap/bridge fees.
- Optimized route selection to reduce complexity and retries, improving transaction success and cost-effectiveness.

## v0.2.7

- adds gas cost tracker

## v0.2.8

- fix: make allowed chains configurable

## v0.2.0 - [Release Date: 2024-09-06]

- **Unlocking Staking Rewards**: Added logic to unlock staking rewards based on meeting a daily minimum transaction threshold on the Optimism network
125 changes: 124 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,124 @@
# optimus-agent
## Optimus service

**Supported Chains:**
The Optimus service currently operates on the following chains:
- Optimism
- Base
- Ethereum
- Mode

**Supported DEXs:**
The Optimus service trades on the following decentralized exchanges (DEXs):
- Balancer
- Uniswap

**Operational Process:**
Within a typical epoch of 24 hours, the Optimus service performs the following tasks:

1. **Opportunity Identification:** It identifies trading opportunities through campaigns advertised on the Merkl platform across the supported DEXs.

2. **Liquidity Pool Investment:** When a suitable liquidity pool is found, the service takes the following actions:
- **First Opportunity:** If this is the first opportunity encountered, the service will add liquidity to the pool if its Annual Percentage Rate (APR) is higher than 5%.
- **Subsequent Opportunities:** If the service has already invested in a liquidity pool, it will consider the next opportunity only if its APR exceeds that of the previously invested pool.

3. **Transaction Tracking:** The service tracks the number of transactions performed on the Optimism chain, which serves as key performance indicators (KPIs) for Olas Staking Rewards.

The Optimus service is an [agent service](https://docs.autonolas.network/open-autonomy/get_started/what_is_an_agent_service/) (or autonomous service) based on the [Open Autonomy framework](https://docs.autonolas.network/open-autonomy/). Below we show you how to prepare your environment, how to prepare the agent keys, and how to configure and run the service.

## Prepare the environment

- System requirements:

- Python `== 3.10`
- [Poetry](https://python-poetry.org/docs/) `>=1.4.0`
- [Docker Engine](https://docs.docker.com/engine/install/)
- [Docker Compose](https://docs.docker.com/compose/install/)

- Clone this repository:

git clone https://github.com/valory-xyz/optimus.git

- Create a development environment:

poetry install && poetry shell

- Configure the Open Autonomy framework:

autonomy init --reset --author valory --remote --ipfs --ipfs-node "/dns/registry.autonolas.tech/tcp/443/https"

- Pull packages required to run the service:

autonomy packages sync --update-packages

## Prepare the keys and the Safe

1. You need a **Gnosis keypair** to run the service.

First, prepare the `keys.json` file with the Gnosis keypair of your agent. (Replace the uppercase placeholders below):

cat > keys.json << EOF
[
{
"address": "YOUR_AGENT_ADDRESS",
"private_key": "YOUR_AGENT_PRIVATE_KEY"
}
]
EOF

2. You need to deploy **[Safes](https://safe.global/) on the following networks - Ethereum-Mainnet, Optimism, Base, Mode**

3. You need to provide some funds ETH and USDC both to your Safe address on Ethereum-Mainnet, and some ETH to your agent across all the chains (Ethereum-Mainnet, Optimism, Base, Mode) to cover for gas fees.

4. You will need your Tenderly Access Key, Tenderly account Slug, and Tenderly Project Slug. Get one at https://dashboard.tenderly.co/ under settings.

5. You will need also need Coingecko API Key. Get one at https://www.coingecko.com/ under My Account -> Developer's Dashboard.

## Configure the service

Set up the following environment variables, to run the service. **Please read their description below**.

```bash
export ETHEREUM_LEDGER_RPC=INSERT_YOUR_ETHEREUM_RPC
export OPTIMISM_LEDGER_RPC=INSERT_YOUR_OPTIMISM_RPC
export BASE_LEDGER_RPC=INSERT_YOUR_BASE_RPC
export MODE_LEDGER_RPC=INSERT_YOUR_MODE_RPC

export ALL_PARTICIPANTS='["YOUR_AGENT_ADDRESS"]'
export SAFE_CONTRACT_ADDRESSES='{ethereum:"YOUR_SAFE_ADDRESS_ON_ETHEREUM","optimism":"YOUR_SAFE_ADDRESS_ON_OPTIMISM","base":"YOUR_SAFE_ADDRESS_ON_BASE","mode":"YOUR_SAFE_ADDRESS_ON_MODE"}'

export SLIPPAGE_FOR_SWAP=0.09
export TENDERLY_ACCESS_KEY=YOUR_TENDERLY_ACCESS_KEY
export TENDERLY_ACCOUNT_SLUG=YOUR_TENDERLY_ACCOUNT_SLUG
export TENDERLY_PROJECT_SLUG=YOUR_TENDERLY_PROJECT_SLUG
export COINGECKO_API_KEY=YOUR_COINGECKO_API_KEY
```

Note - We provide default value for SLIPPAGE_FOR_SWAP, but feel free to experiment with different values. It indicates the allowed slippage when bridging/swapping assets using LiFi.

## Run the service
Once you have configured (exported) the environment variables, you are in position to run the service.

- Fetch the service:

```bash
autonomy fetch --local --service valory/optimus && cd optimus
```

- Build the Docker image:

```bash
autonomy build-image
```

- Copy your `keys.json` file prepared [in the previous section](#prepare-the-keys-and-the-safe) in the same directory:

```bash
cp path/to/keys.json .
```

- Build the deployment with a single agent and run:

```bash
autonomy deploy build --n 1 -ltm
autonomy deploy run --build-dir abci_build/
```
34 changes: 34 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Security Policy

This document outlines security procedures and general policies for the `optimus` project.

## Supported Versions

The following table shows which versions of `optimus` are currently being supported with security updates.

| Version | Supported |
|---------|--------------------|
| `n/a` | :white_check_mark: |
| `n/a` | :x: |

## Reporting a Vulnerability

The `optimus` team and community take all security bugs in `optimus` seriously. Thank you for improving the security of `optimus`. We appreciate your efforts and responsible disclosure and will make every effort to acknowledge your contributions.

Report security bugs by emailing `[email protected]`.

The lead maintainer will acknowledge your email within 48 hours, and will send a more detailed response within 48 hours indicating the next steps in handling your report. After the initial reply to your report, the security team will endeavour to keep you informed of the progress towards a fix and full announcement, and may ask for additional information or guidance.

Report security bugs in third-party modules to the person or team maintaining the module.

## Disclosure Policy

When the security team receives a security bug report, they will assign it to a primary handler. This person will coordinate the fix and release process, involving the following steps:

- Confirm the problem and determine the affected versions.
- Audit code to find any potential similar problems.
- Prepare fixes for all releases still under maintenance. These fixes will be released as fast as possible to PyPI.

## Comments on this Policy

If you have suggestions on how this process could be improved please submit a pull request.
Loading
Loading