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

Migrate from ape to boa #14

Merged
merged 19 commits into from
Dec 12, 2023
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
78 changes: 78 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Git
.gitignore
.gitattributes


# CI
.codeclimate.yml
.travis.yml
.taskcluster.yml

# Docker
docker-compose.yml
Dockerfile
.docker
.dockerignore

# Byte-compiled / optimized / DLL files
**/__pycache__/
**/*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# PyBuilder
target/

# Virtual environment
.env
.venv/
venv/

# PyCharm
.idea

# Python mode for VIM
.ropeproject
**/.ropeproject

# Vim swap files
**/*.swp

# VS Code
.vscode/
15 changes: 11 additions & 4 deletions .github/workflows/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
name: pre-commit

on: [pull_request, push]
on: [push]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Pre-commit checks
uses: pre-commit/[email protected]
35 changes: 11 additions & 24 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,29 @@
name: unitary

on: ["push", "pull_request"]

env:
ETHERSCAN_TOKEN: ${{ secrets.ETHERSKEM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WEB3_INFURA_PROJECT_ID: ${{ secrets.INFURA_TOKEN }}
WEB3_ALCHEMY_PROJECT_ID: ${{secrets.ALCHEMY_API_KEY}}
on: ["push"]

jobs:
unitary:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Cache Compiler Installations
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.vvm
path: ~/.vvm
key: compiler-cache

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 16

- name: Install Hardhat
run: npm ci

- name: Setup Python 3.8
uses: actions/setup-python@v2
- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.11.6

- name: Install Requirements
run: pip install -r requirements.txt
run: pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt

- name: Run Tests
run: ape test
run: pytest -n 16
env:
RPC_ETHEREUM: ${{ secrets.RPC_ETHEREUM }}
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ build/
.python-version
.idea
.pytest_cache
node_modules/
__pycache__/
.DS_Store
venv/
brownie-venv/
bvenv/
.env
11 changes: 4 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.11.0
hooks:
- id: black
args: [--line-length=79]
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
rev: 6.1.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", --line-length=79]

default_language_version:
python: python3.10.4
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.11-slim as base

WORKDIR /usr/app
RUN pip cache purge
COPY requirements.txt ./
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt

FROM base as pre-commit
RUN apt-get update && apt-get install -y git
COPY . .
CMD git add . && pre-commit run --all-files

FROM base as test
COPY . .
CMD pytest
59 changes: 15 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Mainnet:

1. Curve Stable Registry: A registry of custom pool implementations deployed by Curve Core.
2. Curve Stable Factory: A permissionless [StableSwap](https://curve.fi/files/stableswap-paper.pdf) pool factory, which also acts as a registry for pools that its users create.
3. Curve Crypto Registry: A registry of custom CryptoSwap pool implementaions deployed by Curve Core.
3. Curve Crypto Registry: A registry of custom CryptoSwap pool implementations deployed by Curve Core.
4. Curve Crypto Factory: A permissionless [CryptoSwap](https://curve.fi/files/crypto-pools-paper.pdf) pool factory, which also acts as a registry for pools that its users create.

Each of the child registries are accompanied by a RegistryHandler, which is a contract that wraps around the child registry and enforces the abi implemented in the MetaRegistry. These registry handlers are then added to the MetaRegistry using the `MetaRegistry.add_registry_handler` method.
Expand Down Expand Up @@ -67,9 +67,9 @@ Out[1]: '3pool'

#### `MetaRegistry.is_meta`

Metapools are pools that pair a coin to a base pool comprising of multiple coins.
Meta-pools are pools that pair a coin to a base pool comprising multiple coins.

An example is the [`LUSD-3CRV`](https://etherscan.io/address/0xed279fdd11ca84beef15af5d39bb4d4bee23f0ca) pool which pairs [Liquity's](https://www.liquity.org/) [`LUSD`](https://etherscan.io/address/0x5f98805a4e8be255a32880fdec7f6728c6568ba0) against [`3CRV`](https://etherscan.io/address/0x6c3f90f043a72fa612cbac8115ee7e52bde6e490), where `3CRV` is a liquidity pool token that represents a share of a pool containing `DAI`, `USDC` and `USDT`:
An example is the [`LUSD-3CRV`](https://etherscan.io/address/0xed279fdd11ca84beef15af5d39bb4d4bee23f0ca) pool which pairs [Liquidity's](https://www.liquity.org/) [`LUSD`](https://etherscan.io/address/0x5f98805a4e8be255a32880fdec7f6728c6568ba0) against [`3CRV`](https://etherscan.io/address/0x6c3f90f043a72fa612cbac8115ee7e52bde6e490), where `3CRV` is a liquidity pool token that represents a share of a pool containing `DAI`, `USDC` and `USDT`:

```
In [1]: metaregistry.is_meta("0xed279fdd11ca84beef15af5d39bb4d4bee23f0ca")
Expand Down Expand Up @@ -294,7 +294,7 @@ For CryptoSwap, the getter returns:
4. Allowed extra profit
5. Fee gamma
6. Adjustment step
7. MA (moving average) half time
7. MA (moving average) half-time

```

Expand Down Expand Up @@ -387,34 +387,13 @@ Set up the python environment using the following steps:
```

> python -m venv venv
> source ./venv/bin/active
> pip install --upgrade pip
> source ./venv/bin/activate
> python -m pip install --upgrade pip
> pip install -r ./requirements.txt

```

This project uses `eth-ape >= 0.4.0` developed at [Apeworx](https://apeworx.io). The various plugins used are:

1. [`ape-vyper`](https://github.com/ApeWorX/ape-vyper)
2. [`ape-hardhat`](https://github.com/ApeWorX/ape-hardhat)
3. [`ape-alchemy`](https://github.com/ApeWorX/ape-alchemy)
4. [`ape-ledger`](https://github.com/ApeWorX/ape-ledger)
5. [`ape-etherscan`](https://github.com/ApeWorX/ape-etherscan)

To install these, please follow instructions laid out in their respective Github repositories (by clicking on the links above).

Note: If you choose to run tests using `Alchemy` as the upstream provider, please set up an alchemy api key into an environment variable labelled `WEB3_ALCHEMY_PROJECT_ID` or `WEB3_ALCHEMY_API_KEY`. If you choose to use a local node (`geth` or `erigon`) please change the hardhat upstream provider for mainnet-fork to `geth` in [ape-config.yaml](ape-config.yaml):

```

hardhat:
port: auto
fork:
ethereum:
mainnet:
upstream_provider: geth
# upstream_provider: alchemy
```
This project uses [`titanoboa`](https://github.com/vyperlang/titanoboa) for deployment and testing.

### Testing

Expand Down Expand Up @@ -462,22 +441,14 @@ The following command simulates metaregistry setup. For Prod transactions, set n
#### Deployments

Ethereum Mainnet:


`base_pool_registry`: [0xDE3eAD9B2145bBA2EB74007e58ED07308716B725](https://etherscan.io/address/0xDE3eAD9B2145bBA2EB74007e58ED07308716B725#code)

`crypto_registry`: [0x9a32aF1A11D9c937aEa61A3790C2983257eA8Bc0](https://etherscan.io/address/0x9a32aF1A11D9c937aEa61A3790C2983257eA8Bc0#code)

`stable_registry_handler`: [0x46a8a9CF4Fc8e99EC3A14558ACABC1D93A27de68](https://etherscan.io/address/0x46a8a9CF4Fc8e99EC3A14558ACABC1D93A27de68#code)

`stable_factory_handler`: [0x127db66E7F0b16470Bec194d0f496F9Fa065d0A9](https://etherscan.io/address/0x127db66E7F0b16470Bec194d0f496F9Fa065d0A9#code)

`crypto_registry_handler`: [0x22ceb131d3170f9f2FeA6b4b1dE1B45fcfC86E56](https://etherscan.io/address/0x22ceb131d3170f9f2FeA6b4b1dE1B45fcfC86E56#code)

`crypto_factory_handler`: [0xC4F389020002396143B863F6325aA6ae481D19CE](https://etherscan.io/address/0xC4F389020002396143B863F6325aA6ae481D19CE#code)

`metaregistry`: [0xF98B45FA17DE75FB1aD0e7aFD971b0ca00e379fC](https://etherscan.io/address/0xF98B45FA17DE75FB1aD0e7aFD971b0ca00e379fC#code)
- `base_pool_registry`: [0xDE3eAD9B2145bBA2EB74007e58ED07308716B725](https://etherscan.io/address/0xDE3eAD9B2145bBA2EB74007e58ED07308716B725#code)
- `crypto_registry`: [0x9a32aF1A11D9c937aEa61A3790C2983257eA8Bc0](https://etherscan.io/address/0x9a32aF1A11D9c937aEa61A3790C2983257eA8Bc0#code)
- `stable_registry_handler`: [0x46a8a9CF4Fc8e99EC3A14558ACABC1D93A27de68](https://etherscan.io/address/0x46a8a9CF4Fc8e99EC3A14558ACABC1D93A27de68#code)
- `stable_factory_handler`: [0x127db66E7F0b16470Bec194d0f496F9Fa065d0A9](https://etherscan.io/address/0x127db66E7F0b16470Bec194d0f496F9Fa065d0A9#code)
- `crypto_registry_handler`: [0x22ceb131d3170f9f2FeA6b4b1dE1B45fcfC86E56](https://etherscan.io/address/0x22ceb131d3170f9f2FeA6b4b1dE1B45fcfC86E56#code)
- `crypto_factory_handler`: [0xC4F389020002396143B863F6325aA6ae481D19CE](https://etherscan.io/address/0xC4F389020002396143B863F6325aA6ae481D19CE#code)
- `metaregistry`: [0xF98B45FA17DE75FB1aD0e7aFD971b0ca00e379fC](https://etherscan.io/address/0xF98B45FA17DE75FB1aD0e7aFD971b0ca00e379fC#code)

### License

(c) Curve.Fi, 2022 - [All rights reserved](LICENSE).
(c) Curve.Fi, 2023 - [All rights reserved](LICENSE).
29 changes: 0 additions & 29 deletions ape-config.yaml

This file was deleted.

Loading