diff --git a/testing/Dockerfile b/testing/Dockerfile index 8019ebd..0489832 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -5,7 +5,9 @@ FROM --platform=linux/amd64 continuumio/miniconda3:24.4.0-0 WORKDIR /app # Add current directory code to /app in container -ADD . /app/testing +ADD ./testing /app/testing +ADD ./tycho_client /app/tycho_client + RUN chmod +x /app/testing/tycho-indexer # Create a new conda environment and install pip @@ -20,7 +22,7 @@ RUN apt-get update \ && pip install psycopg2 \ && apt-get clean -RUN /bin/bash -c "source activate myenv && pip install --no-cache-dir -r testing/requirements.txt" +RUN /bin/bash -c "source activate myenv && pip install --no-cache-dir -r testing/requirements.txt && cd /app/tycho_client && pip install -r requirements-docker.txt && cd -" # Make port 80 available to the world outside this container EXPOSE 80 diff --git a/testing/docker-compose.yaml b/testing/docker-compose.yaml index a8a3b91..bcc2360 100644 --- a/testing/docker-compose.yaml +++ b/testing/docker-compose.yaml @@ -15,8 +15,8 @@ services: - postgres_data:/var/lib/postgresql/data app: build: - context: . - dockerfile: Dockerfile + context: .. + dockerfile: testing/Dockerfile volumes: - ${SUBSTREAMS_PATH}:/app/substreams/my_substream - ../substreams:/app/substreams diff --git a/testing/runner.py b/testing/runner.py index c056059..733688a 100644 --- a/testing/runner.py +++ b/testing/runner.py @@ -15,9 +15,7 @@ from evm import get_token_balance, get_block_header from tycho import TychoRunner from tycho_client.tycho.decoders import ThirdPartyPoolTychoDecoder from tycho_client.tycho.models import Blockchain, EVMBlock -from tycho_client.tycho.tycho_adapter import ( - TychoPoolStateStreamAdapter, -) +from tycho_client.tycho.tycho_adapter import TychoPoolStateStreamAdapter class TestResult: diff --git a/tycho_client/README.md b/tycho_client/README.md index e69de29..1871992 100644 --- a/tycho_client/README.md +++ b/tycho_client/README.md @@ -0,0 +1,38 @@ +# Tycho Adapter + +This repository contains the Tycho Adapter, a tool that allows you to interact with the Tycho API. + +## Installation + +### Prerequisites + +- Python 3.9 + +### Install with pip + +```shell +# Create conda environment +conda create -n tycho pip python=3.9 +# Activate environment +conda activate tycho +# Install packages +pip install -r requirements.txt +``` + +## Usage + +```python +from tycho_client.tycho.decoders import ThirdPartyPoolTychoDecoder +from tycho_client.tycho.models import Blockchain +from tycho_client.tycho.tycho_adapter import TychoPoolStateStreamAdapter + +decoder = ThirdPartyPoolTychoDecoder( + "MyProtocolSwapAdapter.evm.runtime", minimum_gas=0, hard_limit=False +) +stream_adapter = TychoPoolStateStreamAdapter( + tycho_url="0.0.0.0:4242", + protocol="my_protocol", + decoder=decoder, + blockchain=Blockchain.ethereum, +) +``` \ No newline at end of file diff --git a/tycho_client/requirements-docker.txt b/tycho_client/requirements-docker.txt new file mode 100644 index 0000000..2efee6f --- /dev/null +++ b/tycho_client/requirements-docker.txt @@ -0,0 +1,7 @@ +./tycho/bins/protosim_py-0.4.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl +requests==2.32.2 +eth-abi==2.2.0 +eth-typing==2.3.0 +eth-utils==1.9.5 +hexbytes==0.3.1 +pydantic==2.8.2 \ No newline at end of file diff --git a/tycho_client/requirements.txt b/tycho_client/requirements.txt index e69de29..6fb950e 100644 --- a/tycho_client/requirements.txt +++ b/tycho_client/requirements.txt @@ -0,0 +1,7 @@ +./tycho/bins/protosim_py-0.4.9-cp39-cp39-macosx_11_0_arm64.whl +requests==2.32.2 +eth-abi==2.2.0 +eth-typing==2.3.0 +eth-utils==1.9.5 +hexbytes==0.3.1 +pydantic==2.8.2 \ No newline at end of file diff --git a/tycho_client/tycho/__init__.py b/tycho_client/tycho_client/__init__.py similarity index 100% rename from tycho_client/tycho/__init__.py rename to tycho_client/tycho_client/__init__.py diff --git a/tycho_client/tycho/adapter_contract.py b/tycho_client/tycho_client/adapter_contract.py similarity index 100% rename from tycho_client/tycho/adapter_contract.py rename to tycho_client/tycho_client/adapter_contract.py diff --git a/tycho_client/tycho/assets/CurveSwapAdapter.evm.runtime b/tycho_client/tycho_client/assets/CurveSwapAdapter.evm.runtime similarity index 100% rename from tycho_client/tycho/assets/CurveSwapAdapter.evm.runtime rename to tycho_client/tycho_client/assets/CurveSwapAdapter.evm.runtime diff --git a/tycho_client/tycho/assets/ERC20.bin b/tycho_client/tycho_client/assets/ERC20.bin similarity index 100% rename from tycho_client/tycho/assets/ERC20.bin rename to tycho_client/tycho_client/assets/ERC20.bin diff --git a/tycho_client/tycho/assets/IERC20.sol b/tycho_client/tycho_client/assets/IERC20.sol similarity index 100% rename from tycho_client/tycho/assets/IERC20.sol rename to tycho_client/tycho_client/assets/IERC20.sol diff --git a/tycho_client/tycho/assets/ISwapAdapter.abi b/tycho_client/tycho_client/assets/ISwapAdapter.abi similarity index 100% rename from tycho_client/tycho/assets/ISwapAdapter.abi rename to tycho_client/tycho_client/assets/ISwapAdapter.abi diff --git a/tycho_client/tycho/assets/mocked_ERC20.sol b/tycho_client/tycho_client/assets/mocked_ERC20.sol similarity index 100% rename from tycho_client/tycho/assets/mocked_ERC20.sol rename to tycho_client/tycho_client/assets/mocked_ERC20.sol diff --git a/tycho_client/tycho/constants.py b/tycho_client/tycho_client/constants.py similarity index 100% rename from tycho_client/tycho/constants.py rename to tycho_client/tycho_client/constants.py diff --git a/tycho_client/tycho/decoders.py b/tycho_client/tycho_client/decoders.py similarity index 100% rename from tycho_client/tycho/decoders.py rename to tycho_client/tycho_client/decoders.py diff --git a/tycho_client/tycho/exceptions.py b/tycho_client/tycho_client/exceptions.py similarity index 100% rename from tycho_client/tycho/exceptions.py rename to tycho_client/tycho_client/exceptions.py diff --git a/tycho_client/tycho/models.py b/tycho_client/tycho_client/models.py similarity index 100% rename from tycho_client/tycho/models.py rename to tycho_client/tycho_client/models.py diff --git a/tycho_client/tycho/pool_state.py b/tycho_client/tycho_client/pool_state.py similarity index 100% rename from tycho_client/tycho/pool_state.py rename to tycho_client/tycho_client/pool_state.py diff --git a/tycho_client/tycho/tycho_adapter.py b/tycho_client/tycho_client/tycho_adapter.py similarity index 99% rename from tycho_client/tycho/tycho_adapter.py rename to tycho_client/tycho_client/tycho_adapter.py index 1afcbde..9b2cd9e 100644 --- a/tycho_client/tycho/tycho_adapter.py +++ b/tycho_client/tycho_client/tycho_adapter.py @@ -343,3 +343,4 @@ class TychoPoolStateStreamAdapter: block_header = BlockHeader(block.id, block.hash_, int(block.ts.timestamp())) TychoDBSingleton.get_instance().update(vm_updates, block_header) + diff --git a/tycho_client/tycho/tycho_db.py b/tycho_client/tycho_client/tycho_db.py similarity index 100% rename from tycho_client/tycho/tycho_db.py rename to tycho_client/tycho_client/tycho_db.py diff --git a/tycho_client/tycho/utils.py b/tycho_client/tycho_client/utils.py similarity index 100% rename from tycho_client/tycho/utils.py rename to tycho_client/tycho_client/utils.py