Skip to content
Open
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ substreams/ethereum-template-factory/Cargo.lock
tycho-indexer
substreams/my_substream
testing/tycho-client/build/*
testing/tycho-client/*.egg-info
testing/tycho-client/*.egg-info
11 changes: 10 additions & 1 deletion evm/test/EtherfiAdapter.t.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.13;

import "./AdapterTest.sol";
import "forge-std/Test.sol";
import "openzeppelin-contracts/contracts/interfaces/IERC20.sol";
import "src/interfaces/ISwapAdapterTypes.sol";
import "src/libraries/FractionMath.sol";
import "src/etherfi/EtherfiAdapter.sol";

contract EtherfiAdapterTest is Test, ISwapAdapterTypes {
contract EtherfiAdapterTest is Test, ISwapAdapterTypes, AdapterTest {
using FractionMath for Fraction;

EtherfiAdapter adapter;
Expand Down Expand Up @@ -407,4 +408,12 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes {

assertEq(limits.length, 2);
}

// This test is currently broken due to a bug in runPoolBehaviour
// with constant price pools.
// function testPoolBehaviourEtherfi() public {
// bytes32[] memory poolIds = new bytes32[](1);
// poolIds[0] = bytes32(0);
// runPoolBehaviourTest(adapter, poolIds);
// }
Comment on lines +412 to +418
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we fix this please?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you updated AdapterTest.sol runPoolBehaviourTest function so that it can manage constant prices?

}
33 changes: 33 additions & 0 deletions substreams/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions substreams/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"ethereum-template-factory",
"ethereum-template-singleton",
"ethereum-uniswap-v4",
"ethereum-etherfi",
]
resolver = "2"

Expand Down
38 changes: 38 additions & 0 deletions substreams/ethereum-etherfi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "ethereum-etherfi"
version = "0.0.1"
edition = "2021"

[lib]
name = "ethereum_etherfi"
crate-type = ["cdylib"]

[dependencies]
ethabi = "18.0.0"
hex-literal = "0.4.1"
num-bigint = "0.4.4"
num-traits = "0.2.15"
prost = "0.12.3"
prost-types = "0.12.3"
substreams = "0.5.22"
substreams-ethereum = "0.9.9"
substreams-database-change = "1"
substreams-entity-change = "1.3"
anyhow = "1.0.75"
tycho-substreams = { git = "https://github.com/propeller-heads/tycho-protocol-sdk.git", rev = "3c08359" }
hex = "0.4.3"
itertools = "0.13.0"

# Required so that ethabi > ethereum-types build correctly under wasm32-unknown-unknown
[target.wasm32-unknown-unknown.dependencies]
getrandom = { version = "0.2", features = ["custom"] }

[build-dependencies]
anyhow = "1.0.75"
substreams-ethereum = "0.9.9"
regex = "1.8"

[profile.release]
lto = true
opt-level = 's'
strip = "debuginfo"
26 changes: 26 additions & 0 deletions substreams/ethereum-etherfi/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
CARGO_VERSION := $(shell cargo version 2>/dev/null)

.PHONY: build
build:
ifdef CARGO_VERSION
cargo build --target wasm32-unknown-unknown --release
else
@echo "Building substreams target using Docker. To speed up this step, install a Rust development environment."
docker run --rm -ti --init -v ${PWD}:/usr/src --workdir /usr/src/ rust:bullseye cargo build --target wasm32-unknown-unknown --release
endif

.PHONY: run
run: build
substreams run substreams.yaml $(if $(MODULE),$(MODULE),map_events) $(if $(START_BLOCK),-s $(START_BLOCK)) $(if $(STOP_BLOCK),-t $(STOP_BLOCK))

.PHONY: gui
gui: build
substreams gui substreams.yaml $(if $(MODULE),$(MODULE),map_events) $(if $(START_BLOCK),-s $(START_BLOCK)) $(if $(STOP_BLOCK),-t $(STOP_BLOCK))

.PHONY: protogen
protogen:
substreams protogen ./substreams.yaml --exclude-paths="sf/substreams,google"

.PHONY: pack
pack: build
substreams pack substreams.yaml
188 changes: 188 additions & 0 deletions substreams/ethereum-etherfi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
# ethereum-etherfi substream tests

**Liquidity Pool Proxy**

- Address: 0x308861A430be4cce5502d0A12724771Fc6DaF216
- Deployment tx hash: 0x491b823bc15ced4c54f0ed5a235d39e478f8aae3ad02eb553924b40ad9859e10
- Deployment block: 17664317
- Standard: EIP-1967 Transparent Proxy
- First Deposit tx hash: 0x2e92d04a5da978f13e55c73fe95cfecb4e4124f95c88ce82972665a4145ff769
- First Deposit block: 19891386
- Difference Deposit block - Deployment block: 2227069

**Liquidity Pool Implementation**

- Address: 0xa8A8Be862BA6301E5949ABDE93b1D892C14FfB1F
- Deployment tx hash: 0x95c2e5081af5a591d4899689fa385b550a49775cc705cf1eb0b40bd14974568b
- Deployment block: 20832727

**weETH Proxy**

- Address: 0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee
- Deployment tx hash: 0xa034bdf7ec3b407125fcfbb786d908b0bcfd9976f2fbaf489776ba58b9db61ac
- Deployment block: 17664336
- Standard: EIP-1967 Transparent Proxy
- First Wrap tx hash: 0x8ea192ac34be87bc004f83db69f62e2b92bc41937799b43feeac9a148bc66f62
- First Wrap block: 20287009

**weETH Implementation**

- Address: 0xe629ee84C1Bd9Ea9c677d2D5391919fCf5E7d5D9
- Deployment tx hash: 0x455235ddb3d8c00f4cb805ae76f6c11d017bf71f32940459fce6269530b0c011
- Deployment block: 18517517

**eETH Proxy**

- Address: 0x35fA164735182de50811E8e2E824cFb9B6118ac2
- Deployment tx hash: 0xf6763c707b90b260bba114fce9a141aa4a923327539ded9d4d4ae4395b2200ff
- Deployment block: 17664324
- Standard: EIP-1967 Transparent Proxy

**eETH Implementation**

- Address: 0x1B47A665364bC15C28B05f449B53354d0CefF72f
- Deployment tx hash: 0x13b30c3b456189b04b2049d2c94285443f881497f3221a509a7d98facc06a5f7
- Deployment block: 18549702

## Integration_test.tycho.yaml using constructor()

Since in `ethereum-sfraxeth` we had issues when casting addresses into interface, I'll try to rerun the integration test by first modifying the adapter so that the weeth address is hardcoded and does not need to be passaed

**EtherfiAdapter.sol** changes

```
constructor() {
weEth = IWeEth(address(0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee));
eEth = weEth.eETH();
liquidityPool = eEth.liquidityPool();
}
```

**Integration_test.tycho.yaml**

```
# Name of the substreams config file in your substreams module. Usually "./substreams.yaml"
substreams_yaml_path: ./substreams.yaml

# Name of the adapter contract, usually: ProtocolSwapAdapter
adapter_contract: "EtherfiAdapter"

# Constructor signature of the Adapter contract
adapter_build_signature: "constructor()"

# A comma separated list of args to be passed to the constructor of the Adapter contract
adapter_build_args:

# Whether or not the testing script should skip checking balances of the protocol components.
skip_balance_check: false

# A list of accounts that need to be indexed to run the tests properly.
# Usually used when there is a global component required by all pools and created before the tested range of blocks.
initialized_accounts:
- "0x308861A430be4cce5502d0A12724771Fc6DaF216" # Liquidity pool component for initialization

# A list of protocol types names created by your Substreams module.
protocol_type_names:
- "etherfi_liquidity_pool"
- "etherfi_weeth_pool"

# A list of tests.
tests:
# Test for Etherfi Liquidity Pool creation
- name: test_liquidity_pool_creation
# Indexed block range
start_block: 17664317
stop_block: 17664500
expected_components:
- id: "0x308861A430be4cce5502d0A12724771Fc6DaF216" # Liquidity Pool Address
tokens:
- "0x35fA164735182de50811E8e2E824cFb9B6118ac2" # eETH
- "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" # ETH
creation_tx: "0x491b823bc15ced4c54f0ed5a235d39e478f8aae3ad02eb553924b40ad9859e10"
skip_simulation: false

# Test for WeETH pool creation
- name: test_weeth_pool_creation
start_block: 17664317
stop_block: 17664500
expected_components:
- id: "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee" # WeETH Address
tokens:
- "0x35fA164735182de50811E8e2E824cFb9B6118ac2" # eETH
- "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee" # WeETH
creation_tx: "0xa034bdf7ec3b407125fcfbb786d908b0bcfd9976f2fbaf489776ba58b9db61ac"
skip_simulation: false

```

### Test results

`python ./testing/src/runner/cli.py --package "ethereum-etherfi" --vm-traces`

❗️ test_liquidity_pool_creation failed: '0x308861a430be4cce5502d0a12724771fc6daf216' not found in protocol components.

❗️ test_weeth_pool_creation failed: '0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee' not found in protocol components.

## Integration_test.tycho.yaml using implementation addresses instead of proxyes

```
# Name of the substreams config file in your substreams module. Usually "./substreams.yaml"
substreams_yaml_path: ./substreams.yaml

# Name of the adapter contract, usually: ProtocolSwapAdapter
adapter_contract: "EtherfiAdapter"

# Constructor signature of the Adapter contract
adapter_build_signature: "constructor()"

# A comma separated list of args to be passed to the constructor of the Adapter contract
adapter_build_args:

# Whether or not the testing script should skip checking balances of the protocol components.
skip_balance_check: false

# A list of accounts that need to be indexed to run the tests properly.
# Usually used when there is a global component required by all pools and created before the tested range of blocks.
initialized_accounts:
- "0x308861A430be4cce5502d0A12724771Fc6DaF216" # Liquidity pool component for initialization

# A list of protocol types names created by your Substreams module.
protocol_type_names:
- "etherfi_liquidity_pool"
- "etherfi_weeth_pool"

# A list of tests.
tests:
# Test for Etherfi Liquidity Pool creation
- name: test_liquidity_pool_creation
# Indexed block range
start_block: 20832700 # Actual deployment block: 20832727
stop_block: 20832800
expected_components:
- id: "0xa8A8Be862BA6301E5949ABDE93b1D892C14FfB1F" # Liquidity Pool Implementation Address
tokens:
- "0x35fA164735182de50811E8e2E824cFb9B6118ac2" # eETH
- "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" # ETH
creation_tx: "0x95c2e5081af5a591d4899689fa385b550a49775cc705cf1eb0b40bd14974568b"
skip_simulation: false

# Test for WeETH pool creation
- name: test_weeth_pool_creation
start_block: 18517500 # Actual deployment block: 18517517
stop_block: 18517600
expected_components:
- id: "0xe629ee84C1Bd9Ea9c677d2D5391919fCf5E7d5D9" # WeETH Implementation Address
tokens:
- "0x35fA164735182de50811E8e2E824cFb9B6118ac2" # eETH
- "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee" # WeETH
creation_tx: "0x455235ddb3d8c00f4cb805ae76f6c11d017bf71f32940459fce6269530b0c011"
skip_simulation: false

```
### Test results

`python ./testing/src/runner/cli.py --package "ethereum-etherfi" --vm-traces`

❗️ test_liquidity_pool_creation failed: '0x308861a430be4cce5502d0a12724771fc6daf216' not found in protocol components.

❗️ test_weeth_pool_creation failed: '0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee' not found in protocol components.
Loading
Loading